Skip to content
This repository was archived by the owner on Nov 4, 2025. It is now read-only.

Commit 20c689b

Browse files
authored
Merge pull request #18 from SC5/v4
google sheet API V4 migration
2 parents 777426b + 482f901 commit 20c689b

10 files changed

Lines changed: 599 additions & 309 deletions

README.md

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,30 @@ Fetch info from one sheet
116116
117117
* @param {String} id Sheets document id
118118
* @param {String} sheetId Worksheet id (use getSheets to fetch them)
119-
* @return {Promise} A promise that resolves to a worksheet info containing id, title, rowCount, colCount and latest update info
119+
* @return {Promise} A promise that resolves to a worksheet info containing id, title, rowCount, colCount
120120
121121
122122
### sheets.getRange(id, sheetId, rangeInfo)
123123
124-
Retrieve cells based on given range
125-
126-
**NOTE:** If there are missing cells (no content) this function adds them there (unlike other functions), thus you'll always have full matrix
127-
124+
Retrieve cells data based on given range
125+
126+
**NOTE:**
127+
* * All below ranges are v4 compatible but full matrix are [SUPPORTED] only for few of them:
128+
*
129+
* - [SUPPORTED] "Sheet1!A1:B2" refers to the first two cells in the top two rows of Sheet1.
130+
* - [SUPPORTED] "A3:" refres to all cells starts from 'A' column and 3rd row.
131+
* - "Sheet1!A:A" refers to all the cells in the first column of Sheet1.
132+
* - "Sheet1!1:2" refers to all the cells in the first two rows of Sheet1.
133+
* - "Sheet1!A5:A" refers to all the cells of the first column of Sheet 1, from row 5 onward.
134+
* - [SUPPORTED]"Sheet1" refers to all the cells in Sheet1.
135+
* - "'My Custom Sheet'!A:A" refers to all the cells in a sheet named "My Custom Sheet."
136+
* Single quotes are required for sheet names with spaces, special characters, or an alphanumeric combination.
137+
*
138+
*
128139
* @param {String} id Sheet document id
129140
* @param {String} sheetId Sheet id
130-
* @param {Mixed} rangeInfo Range info as object or string like `A2:D5` or `A2:`
131-
* @return {Array} Rows containing cells, like `[[{A1}, {B1}], [{A2}, {B2}]]`
141+
* @param {Mixed} rangeInfo Range info
142+
* @return {Array} Rows containing cells
132143
133144
134145
### sheets.getCells(id, sheetId)
@@ -139,8 +150,49 @@ Fetch cell contents from one worksheet
139150
* @param {String} sheetId Worksheet id (use getSheets to fetch them)
140151
* @return {Promise} A promise that resolves to a list of rows
141152
153+
### sheets.getRowAndColCount(data)
154+
155+
Get total count of rows and columns in a data array
156+
157+
* @param {Array} data Title, name of the sheet
158+
* @return {Array<number>} Total count of rows and columns
159+
160+
### sheets.paddedEmptyMatrix(data)
161+
162+
Generate a empty matrix from startRow,startCol
163+
164+
* @param {number} totalRow no of total rows in raw v4 data
165+
* @param {number} totalCol no of total cols in raw v4 data
166+
* @param {number} startRow start row number
167+
* @param {number} startCol start col number
168+
* @return {Array<[{row: number, column: string, content: string}]>} A full empty matrix
169+
170+
### sheets.paddedDataMatrix(data, rangePattern)
171+
172+
Creates a full, padded data matrix
173+
174+
* if the range is like 'A3:' or 'B1:C2' and there are missing
175+
* cells (no content) this function adds them there (unlike other functions),
176+
* thus you'll always have full matrix like B1:C2 -->
177+
* [
178+
[
179+
{ row: 1, column: "B", content: "B1" },
180+
{ row: 1, column: "C", content: "C1" },
181+
],
182+
[
183+
{ row: 2, column: "B", content: "" },
184+
{ row: 2, column: "C", content: "C2" },
185+
],
186+
]
187+
* or in either case it will return raw v4 response like, A:B --> [[A1, B1], ['', B2]]
188+
*
189+
* @param {Array} data Sheet document id
190+
* @param {String} rangePattern Range info
191+
* @return {Array<[]>} A full data matrix
192+
142193
## Changelog
143194

195+
- 1.0.0: Google sheet API migration from v3 to v4
144196
- 0.4.3: Fixed JWT auth issue with recent Google API
145197
- 0.4.2: Updated dependencies / fixed vulnerabilities
146198
- 0.4.1: Fixed the double letter range issue, like: `A1:AA5`

0 commit comments

Comments
 (0)