sheet-convert
v1.0.2
Published
Parses a Google Sheets file into an array of JSON objects
Downloads
7
Readme
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-convert
or 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 objects
Generating 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 |