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.

XlsIO MVC - File Generation Issue - Unreadable content

Thread ID:

Created:

Updated:

Platform:

Replies:

97990 Jan 24,2011 05:29 AM Jan 25,2011 07:43 AM ASP.NET Web Forms (Classic) 2
loading
Tags: XlsIO
Andrea Batazzi
Asked On January 24, 2011 05:29 AM

Hello,
I am generating an excel file in a MVC controller.
Everything works wonderfully when on my dev machine (Win 7 64bit). Once I move the app to our development server ( windows 2008 - IIS 7.5), the file gets generated, but once it is downloaded, I get the following warning : "Excel found unreadable content in 'xxx'. Do you want to recover...." .
I did a binary comparison of the generated files ( my dev machine vs dev server ) and noticed that the file is different, although the actual Excel content is the same.

Strangely enough genrating in Excel 97/2003 format does not lead up to this error.

Any clues ?
Thank you.



Andrea Batazzi
Replied On January 24, 2011 05:36 AM

Snippet ( I am using the extensions provided in the product samples ExcelResult.cs and XlsIOExtension.cs) :

ExcelEngine excelEngine = new ExcelEngine();
IWorkbook workbook = null;
if (Excel == "97")
{
workbook = excelEngine.Excel.Workbooks.Open(ResolveApplicationDataPath(string.Format("Standard_B_{0}.xls", IDBrand)), ExcelOpenType.Automatic, ExcelVersion.Excel97to2003);
}
else if (Excel == "2007")
{
workbook = excelEngine.Excel.Workbooks.Open(ResolveApplicationDataPath(string.Format("Standard_B_{0}.xlsx", IDBrand)), ExcelOpenType.Automatic, ExcelVersion.Excel2007);
}

IWorksheet sheet = workbook.Worksheets[0];
ITemplateMarkersProcessor marker = sheet.CreateTemplateMarkersProcessor();
marker.AddVariable("Report", dt);
marker.ApplyMarkers();
sheet.Visibility = WorksheetVisibility.StrongHidden;
try
{
//Saving the workbook to disk. This spreadsheet is the result of opening and modifying
//an existing spreadsheet and then saving the result to a new workbook.

if (Excel == "97")
{

return excelEngine.SaveAsActionResult(workbook, IDBrand == 1 ? "CRMStandardB.xls" : "ReportNominativi.xls", HttpContext.ApplicationInstance.Response, ExcelDownloadType.Open, ExcelHttpContentType.Excel2000);
}
else if (Excel == "2007")
{
workbook.Version = ExcelVersion.Excel2007;
//EVEN IF SAVE TO FS AND OPENED VIA FS I GET THE SAME ISSUE workbook.SaveAs(ResolveApplicationDataPath(string.Format("0000.xls")),ExcelSaveType.SaveAsXLS);
return excelEngine.SaveAsActionResult(workbook, IDBrand == 1 ? "CRMStandardB.xlsx" : "ReportNominativi.xlsx", HttpContext.ApplicationInstance.Response, ExcelDownloadType.Open, ExcelHttpContentType.Excel2007);
}





John Bowlin Bosco K [Syncfusion]
Replied On January 25, 2011 07:43 AM

Hi Andrea,

Thank you very much for using Syncfusion Products.

Currently we are setting up an environment to reproduce the issue at our side. So we will get back to you with more details in two business days (i.e., 27th Jan 2011). We deeply regret for the inconvenience caused.

Please let us know if you have any concerns.

Thanks,
Pauline Bosco.



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.

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.

;