Prevent extra rows/columns when adding data into xlsx sheet using ExcelJS

Hi all,

I'm looking for ways to add data into multiple sheets within a single workbook and download the xlsx file. I found this thread is super useful. However, I found the downloaded xlsx file contains extra empty columns/rows.
Below is the image of downloaded xlsx using aturiot's solution. Does anybody know how to prevent getting the additional rows/columns so that the table size can match to the exact number of rows/columns added?

Thank you so much for the help!!!

Hi @doris.l! Thanks for reaching out. It looks like you're using Numbers in order to open and visualize the file - is that right? I tried using a few other programs (Excel, GSheets, etc.) and the format of the output isn't consistent, which suggests to me that the extra cells you're seeing are essentially an artifact added by Numbers. For what it's worth, it adds far fewer cells than either Excel or GSheets.

I don't think it will be an issue if your real dataset is even slightly larger, as Numbers wouldn't need to create as much artificial white space. It might leave a one row/column buffer around your data, at most.

The first "fix" that comes to mind is to hide the grid lines, as I've shown below.


Would that satisfy your use case? It almost certainly depends on how you plan to utilize the download. I hope that helps but don't hesitate to follow up here!