spreadsheet-to-array
v1.0.1
Published
A convenient library to convert google spreadSheet to array
Downloads
4
Maintainers
Readme
spreadsheet-to-array
A library to convert google spreadSheet to array
The result looks like this :
[
[ 'menu.home', 'homepage' ],
[ 'menu.campaign', 'campaignPage' ]
]
Install
npm i --save spreadsheet-to-array
QuickStart
const spreadsheetToArray = require('spreadsheet-to-array')
spreadsheetToArray(
{
credentials: '../credentials.json',
// The following options can refer to https://googleapis.dev/nodejs/googleapis/latest/sheets/interfaces/Params$Resource$Spreadsheets$Values$Get.html#info
spreadsheetId: 'abcdefg',
range: 'CP!C2:D',
},
(res) => {
console.log(res)
}
)
Authentification
The credentials
key should be a file path.
API Key
You can create an API key here : https://console.developers.google.com/apis/credentials
Google service account
Create a credentials.json file for your app here : https://console.developers.google.com/
- create a new project
- enable the Drive API
- in credentials, select create new credentials then service account and save the generated JSON. (privately)
- then give the JSON contents to the
credentials
parameter in theextractSheets
call.
Share the target google spreadsheet with the client_email
from the credentials.json.
License
- MIT : http://opensource.org/licenses/MIT