Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
XLSX export?
posted

 

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

 

  • 44743
    posted

    It sounds like you are using the CLR 2 versions of the assemblies. CLR 2 did not have support for putting files into zip packages, which is required for writing out .xlsx files. That is why it is asking you to supply an IPackageFactory, because the burden of zipping is on the developer with the CLR 2 versions. But if you use the CLR 3 assemblies or later, zipping is done automatically. So if you are using the ASP.NET assemblies, make sure to use those prefaced with "Infragistics35." or "Infragistics4."

  • 45
    posted

    Nobody? :(