Hi Team,
I have a problem with several excels files.
<span style=“font-size:10.0pt;font-family:“Arial”,sans-serif;
color:#333333;background:white”>We obtaion “Unexcepted eof.” when execute:
FileStream <span lang=“EN-US” style=“font-size:10.0pt;font-family:“Courier New”;mso-ansi-language:
EN-US”>stream<span lang=“EN-US” style=“font-size:10.0pt;font-family:
“Courier New”;mso-ansi-language:EN-US”> = new
<span style=“font-size:10.0pt;font-family:“Courier New””><a href=“http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://mscorlib:4.0.0.0:b77a5c561934e089/System.IO.FileStream/.ctor(String,System.IO.FileMode)” title="System.IO.FileStream.FileStream(string, FileMode);
CTRL+Click to open in new tab.">FileStream<span lang=“EN-US” style=“font-size:10.0pt;font-family:“Courier New”;mso-ansi-language:
EN-US”>(path, <span style=“font-size:10.0pt;font-family:“Courier New””><a href=“http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://mscorlib:4.0.0.0:b77a5c561934e089/System.IO.FileMode” title="System.IO.FileMode
CTRL+Click to open in new tab.">FileMode<span lang=“EN-US” style=“font-size:10.0pt;font-family:“Courier New”;mso-ansi-language:
EN-US”>.<span style=“font-size:10.0pt;font-family:“Courier New””><a href=“http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://mscorlib:4.0.0.0:b77a5c561934e089/System.IO.FileMode/Open” title="FileMode System.IO.FileMode.Open;
CTRL+Click to open in new tab.">Open);<o:p></o:p>
new http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://Aspose.Cells:8.4.1.0:716fcc553a201e56/Aspose.Cells.Workbook/Save(String,Aspose.Cells.SaveFormat)” title="void Aspose.Cells.Workbook.Save(string, SaveFormat);
CTRL+Click to open in new tab.">Save(str,
<a href=“http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://Aspose.Cells:8.4.1.0:716fcc553a201e56/Aspose.Cells.SaveFormat” title="Aspose.Cells.SaveFormat
CTRL+Click to open in new tab.">SaveFormat.<a href=“http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://Aspose.Cells:8.4.1.0:716fcc553a201e56/Aspose.Cells.SaveFormat/Xlsx 1” title="SaveFormat Aspose.Cells.SaveFormat.Xlsx;
CTRL+Click to open in new tab.">Xlsx);
I have attached one file.
We are using the Aspose.Cells for .NET.
Thanks for your help-
Hi,
Thanks for your posting and using Aspose.Cells.
Probably, it is the problem of stream position. You should set it to 0 and check if it works fine. However, we have tested your exact sample code with your source excel file with the latest version: Aspose.Cells for .NET v8.9.0.9 and it worked fine.
Here is the sample code we used for testing which is same as yours.
C#
FileStream stream = new FileStream(“72907430663.XLS”, FileMode.Open);
new Workbook(stream).Save(“output.xlsx”, SaveFormat.Xlsx);
Please also try the following code by setting the stream position to 0 and check if it works fine with your own Aspose.Cells version.
C#
FileStream stream = new FileStream(“72907430663.XLS”, FileMode.Open);
stream.Position = 0;
new Workbook(stream).Save(“output.xlsx”, SaveFormat.Xlsx);
Thanks for your answer.
I deleted data from excel before sent you and maybe that solve the problem because I try with this file and now works.
Attached complet excel that return error.
Thanks again.
Hi,
Thanks for your posting and using Aspose.Cells.
We are now able to replicate this issue. We tried to load it with other ways but all of them failed. Please note, your file is actually a SpreadsheetML file not XLS file that’s why Microsoft Excel shows warning. However, in the sample code below, we find its format on runtime using the FileFormatUtil.DetectFileFormat() method.
We have logged this issue in our database for investigation. We will look into it and fix this issue. Once the issue is resolved or we have some other update for you, we will let you know asap.
This issue has been logged as
-
CELLSNET-44664 - Unexcepted eof exception occurs on loading excel file
C#//Detect file format of your excel file
//It is actually SpreadsheetML
FileFormatInfo finfo = FileFormatUtil.DetectFileFormat(“72907430663.XLS”);
//Create load options
LoadOptions opts = new LoadOptions(finfo.LoadFormat);
//Open your workbook, however it throws exception
Workbook wb = new Workbook(“72907430663.XLS”, opts);
wb.Save(“output.xlsx”, SaveFormat.Xlsx);
Exception: was unhandled
HResult=-2146232832
Message=Unexcepted eof.
Source=Aspose.Cells
StackTrace:
at . ()
at . ()
at . ( , Workbook )
at . (Stream , Workbook )
at Aspose.Cells.Workbook. (Stream , LoadOptions , Boolean )
at Aspose.Cells.Workbook. (String , LoadOptions )
at Aspose.Cells.Workbook…ctor(String file, LoadOptions loadOptions)
InnerException:
Hi,
Thanks for using Aspose.Cells.
We have looked into this issue further and found that the file is SpreadsheetML and the xml data is invalid.
Please change the data
onaiza mall < al majles st
as
onaiza mall < al majles st
And could you please show us which tool you used to create such file? Have a good day.
Hi;
Thanks for your help.
We test your sugestion and works properly.
We have internal application (in COBOL) that generate this type of files. Our dev team is working for solve the problem.
Thanks again for your support.
Hi,
Thanks for your posting and considering Aspose.Cells.
It is good to know that you were able to figure out this issue after our investigation of this issue. Hopefully, you will be able to fix it at your end in your internal application. We have now closed this issue. Let us know if you encounter any other issue, we will be glad to look into it and help you further.