optilude / xlsx-template

A NodeJS module to generate Excel files in .xlsx format from a template created with Excel itself
MIT License
401 stars 144 forks source link

Resulting file exceeds the maximum number of rows #166

Open Dan-DH opened 2 years ago

Dan-DH commented 2 years ago

I seem to run into this issue only when using ${table:}. The resulting file is around 10x bigger than the template, and I get an error message when I open it:

"Warning loading document xyz.xlsx: The data could not be loaded completely because the maximum number of rows per sheet was exceeded"

The report itself looks fine, however, and if I save the file, it will decrease to a normal size and the error won't reappear.

tx46 commented 1 year ago

Also need help on this.

kant2002 commented 1 year ago

Can somebody share template and small script for this issue?

tx46 commented 1 year ago

I can't because I'm building it from internal company documents.

I found the issue, I think. If I save the template file with LibreOffice, I get this error. If I save it from MS Excel, then the template works fine.

kant2002 commented 1 year ago

I don't need exact template. If you can create small sample that would be fine. Maybe you are using images/checkboxes or other stuff inside template.

tx46 commented 1 year ago

No, just text cells. As soon as I save the file with LibreOffice, the issues occurs.

valentin-puiu commented 1 year ago

Hello,

I have the same problem. Attached is the file template and the data that I pass to the file.

{ "receiptCode": "RCV000000463", "receiptDate": "30-05-2023", "location": "A02-1", "supplier": "new-supplier", "supplierCode": "code", "deliveryNote": "test with uom and price", "data": [ { "part": "FBB-GC1_WT250_700x1000ARE", "description": "folding box board 250g arktika", "um": 4, "quantity": 10857.142857142857, "value": 380000, "price": 35, "umName": "Sheet", "vat": 72200 }, { "part": "FBB-LIN_WT210_964x600MMS", "description": "Folding Box Board Topliner 210g from MM Kolicevo", "um": 4, "quantity": 12345.67901234568, "value": 450000.00000000006, "price": 36.45, "umName": "Sheet", "vat": 85500.00000000001 } ], "partsValue": 830000, "vatValue": 157700, "totalValue": 987700 }

Thank you for your help. template.xlsx

moopmonster commented 1 year ago

Had this issue before, where my templates were modified (from MS) in LibreOffice, and after running it through xlsx-template, people using Microsoft Excel reported that the file was corrupted.

I had to use MS Office 365 (online) to create my templates from scratch, due to finding out that my templates (in LibreOffice) were being detected by the ElementTree parser as having more rows that i intended it to have.

Example, for the above template.xlsx provided by @valentin-puiu, from analysis via etree.tostring(sheet.root), it gives :

<dimension ref="A2:I1048576" /> and <SheetData> ... <row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.8" outlineLevel="0" r="1048575" /> <row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.8" outlineLevel="0" r="1048576" /> </SheetData>

This is indication of phantom rows in the spreadsheet ( 1048576 Rows ??? ), which you can either programmatically clean, or just create new spreadsheet and copy paste the columns you need (A1 to L18) into a brand new spreadsheet.