I have an xlsx doc with headers and it is located in my project path. I want to insert data using OpenXML but I get an exception while opening the file:
using (SpreadsheetDocument myDoc = SpreadsheetDocument.Open(MyxlsFileName, true))
{
// ...
}
The exception:
"The specified package is invalid. The main part is missing"
What is the meaning of the exception and what is wrong?
Thank in advance!
You cannot open XLS files with OpenXml. You must save your Excel file as an XLSX file using Microsoft Excel 2007 or newer. (Assuming you are using the correct file extension here...)
Files with XLS extension are in a proprietary binary format which cannot be processed with OpenXML.
So you have two options:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With