We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Zip exception.Unable to read value at the specified position - end of stream was reached.

I have file input control and it allows user to upload xlsx files. I have to validate the content of file as in how many records the file does contains.
When i am trying to read the file using syncfusion xlsio lib.. it show the error message "Zip exception.Unable to read value at the specified position - end of stream was reached."
My code lines are below :

   using (Stream fileStream = file.InputStream)
    {

                    ExcelEngine engine = new ExcelEngine();
                   var wb= engine.Excel.Workbooks.Open(fileStream, ExcelOpenType.Automatic, ExcelParseOptions.Default);
                    var count = wb.ActiveSheet.Rows.Count();
}

Please help, if anybody has solution for this.

15 Replies

MR Mahajothi R Syncfusion Team June 22, 2012 05:06 AM UTC

Hi Gurpreet,

 

Thank you for your interest in Syncfusion products.

 

We are not able to reproduce the reported exception at our side. We have created test sample and placed in the following link for your reference. Could you please update us with your input template and modified test sample, which will helps us to further investigate on this.

 

Sample : ZipException.zip

 

The reported exception may occur due to stream end position. Please try the below code.

 

Code snippet [C#]:

 

using (Stream fileStream = file.InputStream)

{

     ExcelEngine engine = new ExcelEngine();

     // set the stream position to zero

     fileStream.Position = 0;

     var wb = engine.Excel.Workbooks.Open(fileStream, ExcelOpenType.Automatic, ExcelParseOptions.Default);

     var count = wb.ActiveSheet.Rows.Count();

}

 

 

Please let us know if you need any clarifications.

 

 

Regards,

Mahajothi R.



RS R SURYA PRAKASH November 4, 2021 08:11 PM UTC

Hi,

I have tried the same, still, I am getting the same exception.

Please help.

Thanks,

Surya prakash R



KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team November 8, 2021 07:14 AM UTC

Hi Surya Prakash, 

Greetings from Syncfusion. 

The above shared code snippet do resolve the exception if any. If you still face the issue even after using the above code snippet, we request you to share the issue reproducing sample and confirm the Syncfusion XlsIO version you are using at your end, which will be helpful for us in investigating the query and provide prompt solution at the earliest. 
  
Regards, 
Keerthi.


RF Ryoichi Fukushima November 25, 2021 08:16 AM UTC

Hi, 

I have been getting the same exception since last Monday.
And it's occurring on a specific PC.
So I displayed StackTrace etc. and it looks like the image below.

using (ExcelEngine excelEngine = new ExcelEngine())
{
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2016;
    try
    {
        IWorkbook workbook = application.Workbooks.Open(file);
    }
    catch (Exception ex)
    {
        ShowMessage(this, String.Format("Message:{0}StackTrace:{1}Source:{2}", ex.Message, ex.StackTrace, ex.Source), MessageBoxIcon.Exclamation);
    }
}

ExceptionMessages.png


I am using Ver. 19.1450.0.54, and Excel files are downloaded from Microsoft Forms.
Since those files contain personal information, I cannot upload here.

I'm working on a different PC now, so I don't get the exception, but is there any hint to avoid this exception on my previous PC?
If you need the file, please show me a safety way for sending it.

Thank you,
Ryoichi.



KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team November 29, 2021 03:18 AM UTC

Hi Ryoichi, 

It would be helpful for us if you could share the file, to reproduce the issue. Kindly mail your file to support@syncfusion.com , mentioning the forum ID. Regarding safety, we just you the file for reproducing the issue and testing. This file will not be shared anywhere.  

Regards, 
Keerthi. 



RF Ryoichi Fukushima November 29, 2021 05:47 AM UTC

Hi  Keerthi,

Thank you for your reply.
I'll send support staff a file soon.

Thank you,
Ryoichi.



KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team November 29, 2021 12:02 PM UTC

Hi Ryoichi, 

We have received the file and created a new support ticket under your account. We request you to follow that for further updates regarding the issue. 

Regards, 
Keerthi. 



RS Rishabh Sharma December 2, 2021 10:21 AM UTC

Any resolution found? I too am receiving the same error on opening an Excel (.xlsx) file.



KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team December 3, 2021 09:38 AM UTC

Hi Rishabh, 

Greetings from Syncfusion. 

This reported end of stream was reached exception will be thrown while the stream position is at end of the stream and it is loaded into IWorkbook. This exception can be resolved by setting the stream position to 0, before loading the stream into IWorkbook. 

If the issue still persist, kindly share us the issue reproducing sample along with the Excel document you are using at your end and confirm the Syncfusion XlsIO, which will be helpful for us in investigating the query. 

Regards, 
Keerthi. 



RF Ryoichi Fukushima December 5, 2021 09:20 PM UTC

Hi  Sharma,


I finally got it!
If you have gotten same exception, you should check file size or open the file by Excel.
It's just 0 byte or can't open.

I wish your resolve.


Thanks,
Ryoichi



KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team December 6, 2021 10:45 AM UTC

Hi Ryoichi, 

Thanks for sharing your suggestion. 

Regards, 
Keerthi. 



NI Nivas June 27, 2022 07:14 AM UTC

Hi Ryoichi, 

How can I resolve this 0 byte Excel issue?




RS Ramya Sivakumar Syncfusion Team June 28, 2022 01:35 PM UTC

Hi Nivas,


As mentioned earlier, even Microsoft Excel cannot open the file with size 0. Please check if this the same case at your end. If Microsoft Excel opens your file correctly, kindly share that Excel document to investigate from our side further.


Regards,

Ramya.



CD Chetan Deore May 12, 2023 01:18 PM UTC

can we send the excel file in .net webapi in chunks and merge this chunks on client side if posssible so please share the implementation in api



MC Mohan Chandran Syncfusion Team replied to Chetan Deore October 31, 2023 11:31 AM UTC

Hi Chetan,

It is not possible to send the Excel document as chunks using XlsIO. This is not feasible in XlsIO.

Regards,

Mohan.


Loader.
Live Chat Icon For mobile
Up arrow icon