Hi,
Actually I use the UltraWebGridExcelExporter (10.3 on ASP.NET 2.0) to export a grid to .xls using the following code:
this.xlsExport.DownloadName = "result.xls"; Infragistics.WebUI.UltraWebGrid.UltraWebGrid resultGrid = this.resGrid.GetGrid(); this.xlsExport.Export(resultGrid);
This works fine, but now I want to allow exporting to Office 2007+ file format .xlsx. If I just pass a DownloadName "result.xlsx", I will get a file "result.xlsx.XLS". :(I've also tried to do the following:
this.xlsExport.DownloadName = "result.xlsx"; Infragistics.WebUI.UltraWebGrid.UltraWebGrid resultGrid = this.resGrid.GetGrid(); Infragistics.Excel.Workbook wb = new Infragistics.Excel.Workbook(); wb.SetCurrentFormat(Infragistics.Excel.WorkbookFormat.Excel2007); this.xlsExport.Export(resultGrid, wb);
But then I get the following error:
Exception of type 'System.Web.HttpUnhandledException' was thrown.Stack Trace:System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.NotSupportedException: packageFactory cannot be null. When saving to Excel2007 workbook format and using the Infragistics2.Excel assembly, you must provide an IPackageFactory to handle the packaging of data. If you are using the DotNet Framework 3.0 or higher, use the Infragistics3.Excel assembly instead, and the packaging will be handled by the WindowsBase class
How to get that working?
Best Regards
I'm also facing same issue of reading .xlsx. Do we have any workaround for this.
In some sites, it was informed to implement ipackagefactory.But there is no implementation for refrence.
Please let me know , if any one has workaround for this issue withour changing Infragistic 2 dll.
I'm having the same issue -- CLR 35, version 11.1 -- always tacks .XLS onto the file name. Is there a workaround?
This is still a problem in 2011.1, The CLR 3 version creates the format well enough but when you go to export it, it always tags .XLS onto the filename reguardless of the workbook format.
Workbook wkbk = new Workbook(WorkbookFormat.Excel2007);
Worksheet sheet = wkbk.worksheets.Add(sheetname + page);
UltraWebGridExcelExporter exporter = new UltraWebGridExcelExporter();exporter.DownlaodName = "mydoc.xlsx";
exporter.Export(grid, sheet, 0, 0);
this will kick a document to the browser that is named "mydoc.xlsx.XLS" when I save it and open it, excel will complain that the doc format is not the same as the extension. If I rename the file and strip the .XLS off it opens as an xslx just fine.
So the UltraWebGridExcelExporter either needs to get smarter by looking at the format that is set in the workbook or get dumber and let us set the extension.
I am not familiar with the web grid exporter, so I don't know if it has a way to provide the package factory directly. But if it doesn't, I'm guessing it would have a way to export to a Workbook instance without actually saving the Workbook. If so, you can use that overload of Export and then save the Workbook yourself, passing along your IPackageFactory implementation.
Hi Mike,
thanks for your reply!
Yes, thats right, as I mentioned, the application is running on ASP.NET 2.0, and CLR 2 assemblies are used. Migrating the application to 3.5/4.0 is not possible in my case. If I would provide a IPackageFactory implementation, how to set it to the WorkBook when using the UltraWebGridExcelExporter.Export(grid, workbook) method for the export and not the WorkBook.Save(file, packageFactory) method?
Andreas