The File is Corrupted Error on Text File Open


When I try to open a text file to a xlsx format from Aspose.Cells with this code:

Excel.Workbook workbook = new Excel.Workbook(filePath, new Excel.TxtLoadOptions(Excel.LoadFormat.Xlsx) { SeparatorString = " " });

it crashes with the exception being “The file is corrupted”. This is only happening since yesterday.

I feel like nothing changed that could possibly affect the Aspose.Cells library from functionning correctly.

I have searched quite a bit online, but nothing really relates to a file being corrupted when opening a text file.

I thought at first that the text files were the issue, but I tried creating a new text file with the text: "test test1 test2"

Even with this new file it is still telling me it is corrupted. Also, by removing the parameter
new Excel.TxtLoadOptions(Excel.LoadFormat.Xlsx) { SeparatorString = " " }

It works, but the text only gets put into one cell instead of splitting it between multiple cells.

Any ideas what the issue could be?

Thank you for your help.



If you are loading a text, CSV or Tab delimited file, why you are forcing/using LoadFormat.Xlsx? You cannot load a text file as an XLSX file via Aspose.Cells object model. You should give relevant LoadFormat enum member for it. For example, if you are loading a CSV file, you may change your code segment like following:

Excel.Workbook workbook = new Excel.Workbook(filePath, new Excel.TxtLoadOptions(Excel.LoadFormat.CSV) { SeparatorString = " " });

Let us know if you still find any issue.


It is strange that it worked in the past and all of sudden it stopped working.

However, I did try your solution and it worked as it did before!

Thank you for your help!



Good to know that your issue is sorted out by the suggested code segment. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.