We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

EndOfStreamException: Unable to read beyond the end of the stream [18.9.0]


we get an Excel file from customers which is actually a CSV file. This file seems to be saved as .xls only.

I would have thought that there would be a CellsException that says the file is invalid.

Unfortunately the following message appears:

System.IO.EndOfStreamException: Über das Ende des Datenstroms hinaus kann nicht gelesen werden.
   bei System.IO.BinaryReader.FillBuffer(Int32 numBytes)
   bei System.IO.BinaryReader.ReadInt64()
   bei    ..ctor(BinaryReader )
   bei    .(Stream )
   bei Aspose.Cells.Workbook.(String , LoadOptions )
   bei Aspose.Cells.Workbook..ctor(String file, LoadOptions loadOptions)

The file to reproduce can be created as follows:

  1. Create a text file with the content “ö” or something like that
  2. Changes the file extension to .xls

Now try to open it with Aspose.Cells.


Thanks for the details.

Please attach your template .xls file (which is actually a CSV file), we will check it soon. You may zip the file prior attaching here.

Here you go.

Crash.zip (155 Bytes)


Thanks for the template file.

Since your so called XLS file is actually a Tab Delimited (text) file, so you have to use the following line of code to open the file with respect to correct loading options, see the following sample code which works fine as I tested:
Sample code:

Aspose.Cells.TxtLoadOptions lOptions = new Aspose.Cells.TxtLoadOptions(Aspose.Cells.LoadFormat.TabDelimited);
Aspose.Cells.Workbook Excel = new Aspose.Cells.Workbook("e:\\test2\\Crash.xls", lOptions);

Hope, this helps a bit.

Unfortunately it doesn’t help us because we needed LoadFormat.Auto explicitly and can’t restrict it to text.

Since LoadFormat.TabDelimited works, couldn’t you enhance the check (LoadFormat.Auto) to detect such cases?


I am not sure if this can be accomplished. Actually your underlying file is simply a text file and does not follow any specific standard file format type (the file format is simply detected as “Unknown” type), so you have to load it with the concerned loading options. Even when you try to open the file into MS Excel, MS Excel prompts you the error.

Yeah, that makes sense. Okay, thank you very much, we need to look at this for ourselves, how we implement it.


You are welcome and feel free to contact us if you have any other query.