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.