This problem occurs when Excel is used for import and export in a recent project,
After exporting the data to an Excel file, modify some data and then import the Excel file.
The error message "not an expected format error" is displayed ". After detailed troubleshooting, find the exported Excel File Format
Not a true Microsoft Office Excel file format, but an HTML Excel file,
You can use NotePad to open the Excel file for verification,
If the file is garbled, it indicates the file format of Microsoft Office Excel, which is correct for File Import.
If it is not garbled, you will find some HTML FormatCodeWhen the Excel file is imported, the above error is reported.
Then, check the cause and find that if you use httpcontext. current. response Method, change the contenttype type to output the Excel file, then the exported Excel file format is HTML type Excel file.
If you use the Excel component to export an Excel file, the exported Excel file format is normal and can be imported.
This problem is basically solved, and I hope to help my friends who encounter the same problem!
In addition, if you open the exported Excel file in HTML format and save it as a correct Excel file format, it can also be imported normally.