1.0.2 • Published 3 years ago
sheet-convert v1.0.2
sheet-convert
Converts a Google Sheet to a JSON array, or vice versa.
Table of contents
Installation
To install the library, run:
$ npm install sheet-convertor with JSDelivr:
<script src="https://cdn.jsdelivr.net/npm/sheet-convert@latest/file"></script>Importing
With require:
const { Sheet, from } = require("sheet-convert");With import:
import { Sheet, from } from "sheet-convert";Usage
Generating JSON from a Sheet
import Parser from "sheet-convert";
const sheet = new Parser.Sheet([id]); // If getting the main spreadsheet page
const sheet = new Parser.Sheet([id], [subsheet]) // If getting a specific sheet
const info = await sheet.fetch() // Array of JSON objectsGenerating a Sheet from JSON
import Parser from "sheet-convert";
const sheet = Parser.from([{a: 1, b: 2}, {b: 3, c: 4}]) // Full JSON
const sheet = Parser.from([{a: 1, b: 2}, {b: 3, c: 4}], ['c']) // JSON excluding "c"Output
Full JSON
| a | b | c |
|---|---|---|
| 1 | 2 | |
| 3 | 4 |
Excluding "c"
| a | b |
|---|---|
| 1 | 2 |
| 3 |