I have been using the code example here for creating-excel-file-using-openxml this is simple enough code and it does work nicely i can send my data and save it as an .xlsx file. However when i open the file it is corrupted and needs to be opend as repaired. when i do open it all the data is there the formatting/styles are nissing but all the data is there.
looking at the log file i see this
any help appreciated. i am new to openXML
Naimish MakwanaPosted Apr 22, 2024, 5:47 AM
I understand that you’re having trouble with an Excel file created using OpenXML. The file appears to be corrupted when opened in Excel, but the data is intact after the file is repaired. The log file indicates issues with the styles and cell information.
This issue might be due to Excel expecting a fully formatted file when using OpenXML1. That means just having a file with a workbook won’t suffice, it has to have the workbook, worksheets, and at least one sheet for it to open properly1.
Another common issue is not creating a new row for each iteration when adding data1. Essentially, you might be creating a single row with multiple rows inside of it1.
Here’s a simplified example of how to create a new row for each iteration:
The most important part to note is the
row = new Row {RowIndex = rowIdex};1.If you’re still facing issues, you might want to try using the Open XML SDK Validator to check for any errors2.
Thanks