I'm working with a XLS spreadsheet that is rendered from a third-party software. If I open the file in a text editor it's obvious that it's HTML saved as an XLS file. It appears that MS used to allow this pattern and has recently stopped in Excel per a couple of articles I found:
- Office Forum: XLS file will not open in Excel 2016, only gray view
- UserVoice: HTML formatted files (with an XLS extension) no longer opened – Welcome to Excel’s Suggestion Box!
So, now to the actual tech question. If I send the file (as a stream) directly into the ExcelDataReader using the CreateReader
method it throws this error:
"Invalid file signature."
IExcelDataReader excelReader;
excelReader = ExcelReaderFactory.CreateReader(stream);
If on the other hand, I open it in Excel and do a "Save As" and save the XLS as an XLSX, then send it into my code; it imports fine.
My preference would be to not force my user to do the "Save As" step. And getting the third-party to change their format is not a realistic option (as we all know).
Any recommendations or maybe tricks to make this work with the ExcelDataReader?
Here's a screen shot of what I see if I open the XLS in Notepad++ (notice the xls extension):