node-google-spreadsheet
node-google-spreadsheet copied to clipboard
insert row at specific index
I am using insertDimension to insert row on top on my sheet, but unable to comprehend range in the documentation.
An example would be appreciated. Thanks
This is what I am trying to do
const excel = new GoogleSpreadsheet('17GO6WMRuhdqdVy_vqpBZCkSo5X99eCseTZGJTx3asQnA');
await excel.useServiceAccountAuth(require('../googlesheet.json'));
await excel.loadInfo(); // loads document properties and worksheets
const sheet = excel.sheetsByIndex[0]; // or use doc.sheetsById[id]
const today = new Date();
await sheet.insertDimension('ROWS', {
Name: user.name,
Email: user.email
} , 1, 1)
```
await sheet.insertDimension('COLUMNS', {
startIndex: currentCol,
endIndex: headers.length,
});
You can you this. If you want to insert ROWS, just replace 'COLUMNS' by 'ROWS'
currently insertDimension just inserts empty rows/columns. There is not functionality to insert a row at a specific index like I can see you are trying to do. This would be possible but would take some work.