# A1 notation

[GAS](https://lochiwei.gitbook.io/web/appendix/gas) ⟩ [Classes](https://lochiwei.gitbook.io/web/appendix/gas/classes) ⟩ [Range](https://lochiwei.gitbook.io/web/appendix/gas/classes/range) ⟩ A1 notation

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="info" %}
試算表的「欄位編號」採用一種很特殊的「數字系統」：

* A = 1, B = 2, ... , Z = 26。
* 沒有「0」這個符號，也無法表示 0 這個數字。

例如：26 只能用 Z 表示，不能用 A0 表示。
{% endhint %}

```javascript
ABC = 1*26^2 + 2*26 + 3    // 轉換為 10 進位
Z + A = AA                 // = 26 + 1 = AA
ZZ + A = AAA               // = 26² + 26 + 1 = AAA
```

{% endtab %}

{% tab title="💈範例" %}

```excel-formula
Sheet1!A1:B2    # first two cells in top two rows of `Sheet1`
Sheet1!A:A      # first column of `Sheet1`
Sheet1!1:2      # first two rows of `Sheet1`
Sheet1!A5:A     # first column (from row 5 onward)
A1:B2           # first two cells in top two rows
Sheet1          # all the cells in `Sheet1`
'My Custom Sheet'!A:A     # first column of sheet named "My Custom Sheet" 
'My Custom Sheet'         # all the cells in "My Custom Sheet"
```

{% hint style="warning" %}
:bulb:Tip:&#x20;

* where possible, use distinct names for the objects within your spreadsheets. For example, A1 refers to the cell A1 in the first visible sheet, whereas 'A1' refers to all the cells in a sheet named A1. Similarly, Sheet1 refers to all the cells in Sheet1. However, if there’s a named range titled "Sheet1", then Sheet1 refers to the named range and 'Sheet1' refers to the sheet.
* <mark style="color:yellow;">**single quotes**</mark> are required for <mark style="color:orange;">**sheet names**</mark> with **spaces**, **special characters**, or an **alphanumeric** combination.
  {% endhint %}
  {% endtab %}

{% tab title="🛠 工具" %}

* [columnname](https://lochiwei.gitbook.io/web/appendix/gas/classes/range/a1-notation/columnname "mention") - column index to column name.
* [a1notation](https://lochiwei.gitbook.io/web/appendix/gas/classes/range/a1-notation/a1notation "mention") - <mark style="color:blue;">`(row, col)`</mark> to A1 Notation.
* [a1notationtorowcolumn](https://lochiwei.gitbook.io/web/appendix/gas/classes/range/a1-notation/a1notationtorowcolumn "mention") - A1 notation to <mark style="color:blue;">`{ row, col }`</mark>.
  {% endtab %}

{% tab title="📘 手冊" %}

* [Google Sheets API Overview](https://developers.google.com/sheets/api/guides/concepts) ⟩ Cell ⟩ A1 notation
* [Cells](https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/cells) - internal data structure of a cell
* [Range](https://developers.google.com/apps-script/reference/spreadsheet/range) ⟩
  * [getA1Notation()](https://developers.google.com/apps-script/reference/spreadsheet/range#geta1notation) - 回傳類似 <mark style="color:yellow;">`"A1:E2"`</mark> 的字串。
  * Sheet ⟩ [getRangeList(a1Notations)](https://developers.google.com/apps-script/reference/spreadsheet/sheet#getrangelista1notations)

相關試算表指令：

* [=ADDRESS()](https://support.google.com/docs/answer/3093308?hl=en) - <mark style="color:yellow;">**row/col number**</mark> to <mark style="color:orange;">**A1/R1C1**</mark> notation.
* [=ROW()](https://support.google.com/docs/answer/3093316?hl=en\&ref_topic=3105472) - <mark style="color:yellow;">**row number**</mark> of a cell.
* [=COLUMN()](https://support.google.com/docs/answer/3093373?hl=en\&ref_topic=3105472) - <mark style="color:yellow;">**column number**</mark> of a cell.
  {% endtab %}

{% tab title="📗 參考" %}

* [x] [How to Convert Column Number (e.g. 28) to Column Letter (e.g. AB) in Google Sheets](https://www.labnol.org/convert-column-a1-notation-210601/) ⭐️ - row/column number ⇄ A1 notation
  {% endtab %}
  {% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lochiwei.gitbook.io/web/appendix/gas/classes/range/a1-notation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
