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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

MemoryStream Problem

Thread ID:





110049 Jul 17,2013 07:47 AM UTC Feb 26,2015 08:33 AM UTC ASP.NET Web Forms (Classic) 3
Tags: XlsIO
Asked On July 17, 2013 07:47 AM UTC

Hi all,
i have some problems with the memorystream.
1) the program opens a Iworkbook
2) i fill this workbook/sheets
3) i send this workbook to the browser
workbook.SaveAs(sfile, Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel2007);

this works fine...
Save the workbook to the memory stream

    MemoryStream ms = new MemoryStream();
and for testing back to file:
    FileStream file = new FileStream(@"c:\test.xlsx", FileMode.Create, System.IO.FileAccess.Write);
    byte[] bytes = new byte[ms.Length];
    ms.Read(bytes, 0, (int)ms.Length);
    file.Write(bytes, 0, bytes.Length);

doesnt work. The filesize is exactly like the org file. But i cant open it.
if i use this function:

it works.
The point is - i want to save the file into a blob column of my database. My method of saving files/byte into my database works perfect on other projects/files. I think there is problem with the memorystream!?

Can someone help me?



Manikandan M [Syncfusion]
Replied On July 22, 2013 04:21 AM UTC

Hi Markus,


Thanks for using Syncfusion products.


We are able to reproduce the reported issue “XlsIO Saved file does not open in MS Excel” from our side. We suspect that this could be an issue and send to the development team for further analysis. We request you to create a new incident to further follow up on this issue.


Direct-Trac Link: Login


Please let us know if you need any clarifications.



Manikandan M.


Christos Tatitzikidis
Replied On February 25, 2015 02:21 PM UTC

Any luck with this?

Having the exact same problem!

Dilli Babu Nandha Gopal [Syncfusion]
Replied On February 26, 2015 08:33 AM UTC

Hi Christos,

Thank you for Syncfusion products.

The memory issue reported earlier was an usage issue. This issue can be resolved by resetting the memory stream position to zero before copying the memory stream to file stream. Please follow the below code snippet  to resolve the issue.

Code Snippets:

            MemoryStream ms = new MemoryStream();


            //Resetting Memory stream position.

            ms.Position = 0;

            FileStream file = new FileStream(Server.MapPath("App_data/Output.xlsx"),  FileMode.Create, System.IO.FileAccess.Write);

            byte[] bytes = new byte[ms.Length];

            ms.Read(bytes, 0, (int)ms.Length);

            file.Write(bytes, 0, bytes.Length);



If you are unable to resolve the issue, please share us your entire scenario and the code snippet which will be helpful for us to give you a prompt solution.

Please let us know if you have any concerns.


Dilli babu.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon