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
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."
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'm having the same issue -- CLR 35, version 11.1 -- always tacks .XLS onto the file name. Is there a workaround?
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 believe you will need to change your references to Infragistics3 for both the Excel and the Wingrid Exporter assembly. Take a look at this forum thread:
http://ko.infragistics.com/community/forums/p/50867/266761.aspx#266761
I am using Infragistics2.UltraGrid.Excel.v10.2 CLR 2x for WINFORMs. So need IpackageFactory implementation for this version.
Hello Renuka,
Thank you for the update. Please see the following documentation:
http://help.infragistics.com/NetAdvantage/WinForms/Current/CLR4.0/?page=Infragistics4.Win.UltraWinGrid.ExcelExport.v12.2~Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter~Export(UltraGrid,String,WorkbookFormat).html
As you can see the export on the Windows Form exporter has an overload that allows you to set the WorkbookFormat.
Please let me know if you have any further questions concerning this matter.
Sincerely,Mike P.Developer Support Engineer IIInfragistics, Inc.www.infragistics.com
I am using Windows form. Can you please provide solution according.
Hello,
Thank you for your patience. The WebExcelExporter has a property called WorkbookForm that you can set to tell it what format to export in. If you set it to Excel2007 it will export as an xlsx. For example:
<ig:WebExcelExporter ID="WebExcelExporter1" runat="server" WorkbookFormat="Excel2007"> </ig:WebExcelExporter>
<ig:WebExcelExporter ID="WebExcelExporter1" runat="server"
WorkbookFormat="Excel2007">
</ig:WebExcelExporter>
Please let me know if you have any questions concerning this matter.