node-google-spreadsheet icon indicating copy to clipboard operation
node-google-spreadsheet copied to clipboard

insert row at specific index

Open pravinfullstack opened this issue 2 years ago • 2 comments

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)
    ```

pravinfullstack avatar Mar 19 '23 23:03 pravinfullstack

await sheet.insertDimension('COLUMNS', {
      startIndex: currentCol,
      endIndex: headers.length,
    });

You can you this. If you want to insert ROWS, just replace 'COLUMNS' by 'ROWS'

fuongduyuid avatar Jun 06 '23 08:06 fuongduyuid

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.

theoephraim avatar Jun 26 '23 18:06 theoephraim