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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

workbook,SaveAs() downloads corrupt file

Thread ID:

Created:

Updated:

Platform:

Replies:

130986 Jun 14,2017 06:22 PM UTC Jun 15,2017 12:07 PM UTC ASP.NET Core 1
loading
Tags: XlsIO
John Sivilla
Asked On June 14, 2017 06:22 PM UTC

Hi,

I am generating a Excel file and then sending it through a web page to open or download. The file gets generated, but we receive an error with the content(see attachment). The Excel message says that it needs to repair it. When I click Yes, The file opens properly for me. However, our client, gets the same message, but cannot open the file. 

Below is the code that I am using to generate and downlaod the file;

Can you please let me know if I should do anything differently ?

Thanks,
John

ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;

application.DefaultVersion = ExcelVersion.Excel2016;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];

....,.....

HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "report.xlsx"));
HttpContext.Current.Response.AddHeader("Pragma", "no-cache");
HttpContext.Current.Response.ContentType = "application/ms-excel";  
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.CacheControl = "no-cache";
                
workbook.SaveAs("report.xlsx", ExcelSaveType.SaveAsXLS, HttpContext.Current.Response, ExcelDownloadType.Open, ExcelHttpContentType.Excel2016);
workbook.Close();
excelEngine.Dispose();

Attachment: ProblemWithContent_52f77faf.zip

Sridhar Sukumar [Syncfusion]
Replied On June 15, 2017 12:07 PM UTC

Hi John, 
 
Thank you for contacting Syncfusion support. 
 

We are unable to reproduce the issue with shared information. We have shared a simple sample for your reference which can be downloaded from the following location.  

 

Sample link: http://www.syncfusion.com/downloads/support/directtrac/general/ze/XLSIO_ASPNET-159010494.zip 

 

Kindly modify the sample to reproduce the issue and share us the modified issue reproducing sample which will be helpful for us to give you a prompt solution at the earliest. 

  

Regards, 

Sridhar. 

CONFIRMATION

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.

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

;