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

XlsIO MVC - File Generation Issue - Unreadable content

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.



2 Replies

AB Andrea Batazzi January 24, 2011 10:36 AM UTC

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);
}






JB John Bowlin Bosco K Syncfusion Team January 25, 2011 12:43 PM UTC

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.



Loader.
Live Chat Icon For mobile
Up arrow icon