Hi,
How the following code line works?
ExcelFile ef = new ExcelFile();
ef.LoadXls(strPath);
Since the Microsoft uses the same file as storage container for storing embedded data of excel file for .xls file.
Now when we change the extension of .txt file to .xls file, it get modified but still when we try to open same in Office Excel it show modal dialog box stating as,
"The file you are trying to open, 'Document.xls', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?" Yes || No || Help
So that implies that while we have changed the extension, still the file is not complete .xls file because it is missing the Ole2Compound file.
And in same manner, internally, Gembox tries to extract storage information from Ole2Compound file associated with .xls file. Then convert plain text information of .xls file to temporary memory and save or load it as plain .xls. Now when we try the .txt converted to .xls file it expects the Ole2Compound file but that's not there and hence error.
Solution: You would need to convert the .txt document into .xls file in proper way. Merely changing extension doesn't set all internal things.
Hope it helps.