sheet-loader
v2.1.6
Published
Google Spreadsheet loader wrapper.
Downloads
22
Readme
sheet-loader
Google Spreadsheet loader wrapper.
install
npm install sheet-loader
usage
initialize
const SheetLoader = require('sheet-loader');
const sheetLoader = new SheetLoader({
sheetKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
keyFilePath: './xxxxxxxx-xxxxxxx.json'
});
load data with column scheme
sheetLoader.loadRecords({
sheetTitle: 'sample sheet',
columns: {
name: '名前',
message: '文章',
year: '年',
month: '月',
date: '日'
}
}).then((records) => {
records.forEach(function (row, index) {
console.log('========================');
console.log('name:\t' + row.name);
console.log('birth day:\t' + [row.year, row.month, row.date].join('.');
});
});
load raw sheet data
sheetLoader.loadRows('sample sheet').then((rows) => {
console.log(rows);
});
export records to json file
sheetLoader.exportRecords('./sample.json', {
sheetTitle: 'sample sheet',
columns: {
name: '名前',
message: '文章',
year: '年',
month: '月',
date: '日'
}
}).then(() => {
console.log('done.');
});
auth with raw credentials
const sheetLoader = new SheetLoader({
sheetKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
credentials: {
client_email: '[email protected]',
private_key: 'XXXXXXXXXXXXXXX'
},
});