Skip to content

Commit d664441

Browse files
committed
Docs Fix: row.set
1 parent a7260d8 commit d664441

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# google-spreadsheet
2+
23
> The most popular [Google Sheets API](https://developers.google.com/sheets/api/guides/concepts) wrapper for javascript / typescript
34
45
[![NPM version](https://img.shields.io/npm/v/google-spreadsheet)](https://www.npmjs.com/package/google-spreadsheet)
@@ -16,37 +17,35 @@
1617
**Docs site -**
1718
Full docs available at [https://theoephraim.github.io/node-google-spreadsheet](https://theoephraim.github.io/node-google-spreadsheet)
1819

19-
-------------
20+
---
2021

2122
> 🌈 **Installation** - `pnpm i google-spreadsheet`<br/>(or `npm i google-spreadsheet --save` or `yarn add google-spreadsheet`)
2223
2324
## Examples
25+
2426
_The following examples are meant to give you an idea of just some of the things you can do_
2527

2628
> **IMPORTANT NOTE** - To keep the examples concise, I'm calling await [at the top level](https://v8.dev/features/top-level-await) which is not allowed by default in most versions of node. If you need to call await in a script at the root level, you must instead wrap it in an async function like so:
2729
2830
```javascript
29-
(async function() {
31+
(async function () {
3032
await someAsyncFunction();
31-
}());
33+
})();
3234
```
3335

34-
3536
### The Basics
37+
3638
```js
3739
import { GoogleSpreadsheet } from 'google-spreadsheet';
3840
import { JWT } from 'google-auth-library';
3941

40-
4142
// Initialize auth - see https://theoephraim.github.io/node-google-spreadsheet/#/guides/authentication
4243
const serviceAccountAuth = new JWT({
4344
// env var values here are copied from service account credentials generated by google
4445
// see "Authentication" section in docs for more info
4546
email: process.env.GOOGLE_SERVICE_ACCOUNT_EMAIL,
4647
key: process.env.GOOGLE_PRIVATE_KEY,
47-
scopes: [
48-
'https://www.googleapis.com/auth/spreadsheets',
49-
],
48+
scopes: ['https://www.googleapis.com/auth/spreadsheets'],
5049
});
5150

5251
const doc = new GoogleSpreadsheet('<the sheet ID from the url>', serviceAccountAuth);
@@ -63,14 +62,15 @@ console.log(sheet.rowCount);
6362
const newSheet = await doc.addSheet({ title: 'another sheet' });
6463
await newSheet.delete();
6564
```
65+
6666
More info:
67+
6768
- [GoogleSpreadsheet](https://theoephraim.github.io/node-google-spreadsheet/#/classes/google-spreadsheet)
6869
- [GoogleSpreadsheetWorksheet](https://theoephraim.github.io/node-google-spreadsheet/#/classes/google-spreadsheet-worksheet)
6970
- [Authentication](https://theoephraim.github.io/node-google-spreadsheet/#/guides/authentication)
7071

71-
72-
7372
### Working with rows
73+
7474
```js
7575
// if creating a new sheet, you can set the header row
7676
const sheet = await doc.addSheet({ headerValues: ['name', 'email'] });
@@ -87,7 +87,7 @@ const rows = await sheet.getRows(); // can pass in { limit, offset }
8787

8888
// read/write row values
8989
console.log(rows[0].get('name')); // 'Larry Page'
90-
rows[1].set('email') = 'sergey@abc.xyz'; // update a value
90+
rows[1].set('email', 'sergey@abc.xyz'); // update a value
9191
rows[2].assign({ name: 'Sundar Pichai', email: 'sundar@google.com' }); // set multiple values
9292
await rows[2].save(); // save updates on a row
9393
await rows[2].delete(); // delete a row
@@ -108,12 +108,12 @@ userRows[0].get('badColumn'); // <- will throw a type error
108108
```
109109

110110
More info:
111+
111112
- [GoogleSpreadsheetWorksheet > Working With Rows](https://theoephraim.github.io/node-google-spreadsheet/#/classes/google-spreadsheet-worksheet#working-with-rows)
112113
- [GoogleSpreadsheetRow](https://theoephraim.github.io/node-google-spreadsheet/#/classes/google-spreadsheet-row)
113114

114-
115-
116115
### Working with cells
116+
117117
```js
118118
await sheet.loadCells('A1:E10'); // loads range of cells into local cache - DOES NOT RETURN THE CELLS
119119
console.log(sheet.cellStats); // total cells, loaded, how many non-empty
@@ -130,11 +130,12 @@ a1.textFormat = { bold: true };
130130
c6.note = 'This is a note!';
131131
await sheet.saveUpdatedCells(); // save all updates in one call
132132
```
133+
133134
More info:
135+
134136
- [GoogleSpreadsheetWorksheet > Working With Cells](https://theoephraim.github.io/node-google-spreadsheet/#/classes/google-spreadsheet-worksheet#working-with-cells)
135137
- [GoogleSpreadsheetCell](https://theoephraim.github.io/node-google-spreadsheet/#/classes/google-spreadsheet-cell)
136138

137-
138139
### Managing docs and sharing
139140

140141
```js
@@ -161,6 +162,7 @@ await newDoc.delete();
161162
```
162163

163164
## Why?
165+
164166
> **This module provides an intuitive wrapper around Google's API to simplify common interactions**
165167
166168
While Google's v4 sheets API is much easier to use than v3 was, the official [googleapis npm module](https://www.npmjs.com/package/googleapis) is a giant autogenerated meta-tool that handles _every Google product_. The module and the API itself are awkward and the docs are pretty terrible, at least to get started.
@@ -169,7 +171,6 @@ While Google's v4 sheets API is much easier to use than v3 was, the official [go
169171
This module makes trade-offs for simplicity of the interface.
170172
Google's API provides a mechanism to make many requests in parallel, so if speed and efficiency are extremely important to your use case, you may want to use their API directly. There are also many lesser-used features of their API that are not implemented here yet.
171173

172-
173174
## Support & Contributions
174175

175176
This module was written and is actively maintained by [Theo Ephraim](https://theoephraim.com).
@@ -189,4 +190,5 @@ The docs site is generated using [docsify](https://docsify.js.org). To preview a
189190
The content lives in markdown files in the docs folder.
190191

191192
## License
193+
192194
This is free and unencumbered public domain software. For more info, see https://unlicense.org.

0 commit comments

Comments
 (0)