Spreadsheet setArray does not populate all data exceeding row and column count

Posted by: alexei.snisarenko on 16 December 2021, 7:23 pm EST

  • Posted 16 December 2021, 7:23 pm EST

    I used setArray to populate a worksheet. Array I passed as setArray third argument contained around 250 rows (and approx 60 columns). I then exported workbook with that worksheet and it appears that only rows and cells were populated with my array values were those which originally had values in the worksheet.

    I found one workaround for that - namely to populate the very bottom and very right cell with some value. But this was more to prove my guess about rowcount and columncount properties of the worksheet must cover the size of the array I pass to the setArray function.

    What would be better way to deal with column and row counts in this case? Ideally I would imagine that setArray would be capable to auto-increase rows and columns counts in worksheet when applies data passed as setArray’s third argument.

  • Posted 20 December 2021, 11:06 pm EST

    Hey,

    setArray() method won’t auto-increment rows and columns of the sheet. This is the expected behavior (by design). Before calling the setArray method, you need to make sure that the sheet contains the required number of rows and columns.

    However, if you want the auto-increment functionality, you can override the setArray() method.

    Sample: https://jscodemine.grapecity.com/share/hWqhs6JUxka-JmOyu1XdAw/

    Thanks.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels