Skip to content

Commit 882bd73

Browse files
author
Theo Ephraim
committed
docs: docs cleanup and improvements
1 parent c306dc0 commit 882bd73

File tree

4 files changed

+26
-23
lines changed

4 files changed

+26
-23
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ _the following examples are meant to give you an idea of just some of the things
3535
### The Basics
3636
```js
3737
import { GoogleSpreadsheet } from 'google-spreadsheet';
38-
import { JWT } from 'google-auth-library'
38+
import { JWT } from 'google-auth-library';
3939

4040

4141
// Initialize auth - see https://theoephraim.github.io/node-google-spreadsheet/#/guides/authentication

docs/classes/google-spreadsheet-worksheet.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ You do not initialize worksheets directly. Instead you can load the sheets from
1414

1515
```javascript
1616
const doc = new GoogleSpreadsheet('<YOUR-DOC-ID>', auth);
17-
await doc.loadInfo(); // loads sheets
17+
await doc.loadInfo(); // loads sheets and other document metadata
1818

1919
const firstSheet = doc.sheetsByIndex[0]; // in the order they appear on the sheets UI
20-
const otherSheet = doc.sheetsById[123]; // accessible via ID if you already know it
20+
const sheet123 = doc.sheetsById[123]; // accessible via ID if you already know it
2121

2222
const newSheet = await doc.addSheet(); // adds a new sheet
2323
```
@@ -333,16 +333,16 @@ Param|Type|Required|Description
333333

334334
?> The authentication method being used must have write access to the destination document as well
335335

336-
### Export
336+
### Exports
337337

338-
Several export methods are available, which are the same as using the `File > Download` menu in the Google Sheets UI. The formats listed below export only a single sheet. See [GoogleSpreadsheet > Export](classes/google-spreadsheet?id=export) formats which include the entire document.
338+
See [Exports guide](guides/exports) for more info.
339339

340340
#### `downloadAsCSV(returnStreamInsteadOfBuffer)` (async) :id=fn-downloadAsCSV
341341
> Export worksheet in CSV format
342342
343343
Param|Type|Required|Description
344344
---|---|---|---
345-
`returnStreamInsteadOfBuffer`|Boolean|-|Set to true to return a stream instead of a Buffer
345+
`returnStreamInsteadOfBuffer`|Boolean|-|Set to true to return a stream instead of a Buffer<br/>_See [Exports guide](guides/exports) for more details_
346346

347347
- ↩️ **Returns** - Buffer (or stream) containing CSV data
348348

@@ -352,7 +352,7 @@ Param|Type|Required|Description
352352
353353
Param|Type|Required|Description
354354
---|---|---|---
355-
`returnStreamInsteadOfBuffer`|Boolean|-|Set to true to return a stream instead of a Buffer
355+
`returnStreamInsteadOfBuffer`|Boolean|-|Set to true to return a stream instead of a Buffer<br/>_See [Exports guide](guides/exports) for more details_
356356

357357
- ↩️ **Returns** - Buffer (or stream) containing TSV data
358358

@@ -362,7 +362,7 @@ Param|Type|Required|Description
362362
363363
Param|Type|Required|Description
364364
---|---|---|---
365-
`returnStreamInsteadOfBuffer`|Boolean|-|Set to true to return a stream instead of a Buffer
365+
`returnStreamInsteadOfBuffer`|Boolean|-|Set to true to return a stream instead of a Buffer<br/>_See [Exports guide](guides/exports) for more details_
366366

367367
- ↩️ **Returns** - Buffer (or stream) containing PDF data
368368

docs/classes/google-spreadsheet.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,14 @@ Param|Type|Required|Description
164164

165165
### Exports
166166

167-
Several export methods are available, which are the same as using the `File > Download` menu in the Google Sheets UI. The formats listed below export all sheets in the document. See [GoogleSpreadsheetWorksheet > Export](classes/google-spreadsheet-worksheet?id=export) formats which export only a single sheet.
167+
See [Exports guide](guides/exports) for more info.
168168

169169
#### `downloadAsHTML(returnStreamInsteadOfBuffer)` (async) :id=fn-downloadAsHTML
170170
> Export entire document in HTML format (zip file)
171171
172172
Param|Type|Required|Description
173173
---|---|---|---
174-
`returnStreamInsteadOfBuffer`|Boolean|-|Set to true to return a stream instead of a Buffer
174+
`returnStreamInsteadOfBuffer`|Boolean|-|Set to true to return a stream instead of a Buffer<br/>_See [Exports guide](guides/exports) for more details_
175175

176176
- ↩️ **Returns** - Buffer (or stream) containing HTML data (in a zip file)
177177

@@ -181,7 +181,7 @@ Param|Type|Required|Description
181181
182182
Param|Type|Required|Description
183183
---|---|---|---
184-
`returnStreamInsteadOfBuffer`|Boolean|-|Set to true to return a stream instead of a Buffer
184+
`returnStreamInsteadOfBuffer`|Boolean|-|Set to true to return a stream instead of a Buffer<br/>_See [Exports guide](guides/exports) for more details_
185185

186186
- ↩️ **Returns** - Buffer (or stream) containing XLSX data
187187

@@ -191,7 +191,7 @@ Param|Type|Required|Description
191191
192192
Param|Type|Required|Description
193193
---|---|---|---
194-
`returnStreamInsteadOfBuffer`|Boolean|-|Set to true to return a stream instead of a Buffer
194+
`returnStreamInsteadOfBuffer`|Boolean|-|Set to true to return a stream instead of a Buffer<br/>_See [Exports guide](guides/exports) for more details_
195195

196196
- ↩️ **Returns** - Buffer (or stream) containing ODS data
197197

docs/guides/exports.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,22 @@ Some of these formats export the entire document, while others are only a single
66

77
These are the available formats:
88

9-
File Type|File Extension|Full Document|Method|Notes
10-
---|---|---|---|---
11-
Web Page | zip | ✅ | [`doc.downloadAsHTML()`](classes/google-spreadsheet?id=fn-downloadAsHTML) | _unzips to folder containing html file(s)_
12-
Microsoft Excel | xlsx | | [`doc.downloadAsXLSX()`](classes/google-spreadsheet?id=fn-downloadAsXLSX) |
13-
OpenDocument | ods | | [`doc.downloadAsODS()`](classes/google-spreadsheet?id=fn-downloadAsODS) |
14-
Comma Separated Values | csv | | [`sheet.downloadAsCSV()`](classes/google-spreadsheet-worksheet?id=fn-downloadAsCSV) |
15-
Tab Separated Values | tsv | | [`sheet.downloadAsTSV()`](classes/google-spreadsheet-worksheet?id=fn-downloadAsTSV) |
16-
PDF | pdf | | [`sheet.downloadAsPDF()`](/classes/google-spreadsheet-worksheet?id=fn-downloadAsPDF) |
9+
File Type|File Extension|Contents|Method
10+
---|---|---|---
11+
Web Page | zip > html+css | document | [`doc.downloadAsHTML()`](classes/google-spreadsheet?id=fn-downloadAsHTML)
12+
Microsoft Excel | xlsx | document | [`doc.downloadAsXLSX()`](classes/google-spreadsheet?id=fn-downloadAsXLSX)
13+
OpenDocument | ods | document | [`doc.downloadAsODS()`](classes/google-spreadsheet?id=fn-downloadAsODS)
14+
Comma Separated Values | csv | worksheet | [`sheet.downloadAsCSV()`](classes/google-spreadsheet-worksheet?id=fn-downloadAsCSV)
15+
Tab Separated Values | tsv | worksheet | [`sheet.downloadAsTSV()`](classes/google-spreadsheet-worksheet?id=fn-downloadAsTSV)
16+
PDF | pdf | worksheet | [`sheet.downloadAsPDF()`](/classes/google-spreadsheet-worksheet?id=fn-downloadAsPDF)
1717

1818

1919
All of these methods by default fetch an ArrayBuffer, but can be passed an optional parameter to return a stream instead.
2020

2121
## ArrayBuffer mode (default)
22+
23+
This means you are dealing with the entire document at once. Usually you'd want to write this to a file, for example:
24+
2225
```javascript
2326
const doc = new GoogleSpreadsheet('<YOUR-DOC-ID>', auth);
2427

@@ -28,14 +31,14 @@ All of these methods by default fetch an ArrayBuffer, but can be passed an optio
2831

2932
## Stream mode
3033

31-
Dealing with streams can be useful to do things like upload the file directly to somewhere else, or to handle a large CSV.
34+
Dealing with [streams](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API) means you are dealing with a stream of data rather than the entire file at once. This can be useful to do things like upload the file to somewhere else without saving it locally first, or to handle a large CSV when you want to do something else with each entry.
3235

33-
This example doesn't get into the details, but this simple example should at least get you started.
36+
This example doesn't get into the details of using streams, but this simple example should at least get you started:
3437

3538
```javascript
3639
const doc = new GoogleSpreadsheet('<YOUR-DOC-ID>', auth);
3740

38-
const csvStream = await doc.downloadAsCSV(true);
41+
const csvStream = await doc.downloadAsCSV(true); // this `true` arg toggles to stream mode
3942
const writableStream = fs.createWriteStream('./my-export-stream.csv');
4043

4144
writableStream.on('finish', () => {

0 commit comments

Comments
 (0)