Hello
Could you please help me with some sample where I can export from XamDataGrid into excel?
Only condition I have is - I have couple of grouping columns and I want those grouping remain as it is.
Cheers
Sagar
Hello Sagar,
Thank you for your post. I am attaching a sample for you showing how to achieve exporting of the xamDataGrid’s content in MS Excel format. If you group the data by some field before the exporting and later press the export button the exported data will contains grouping too.
Here is a link which contains additional information regarding Excel exporting:
http://help.infragistics.com/doc/WPF?page=xamDataGrid_Exporting_to_Excel.html
Please do not hesitate to let me know if you have any further questions on this matter.
Sincerely,
Radko Kolev
Infragistics Inc.
www.infragistics.com/support
Hello Radko,
Your sample does work for me in some extent. However, few formatting of cells not retain from grid to excel.
1. In some of the cells, I display values using prefix with tab character /t. This tab space is not remains in excel.
2. there is one blank row appears in between grouping.
3. Going forward, I will be using foreground and background colour for specific cells. How do I make sure this is maintain after excel export.
1. The tab character ‘\t’ is exported by the IG Excel exporter, however it is not rendered by MS Excel – I believe this is some kind of MS Excel limitation. To verify this you can attach events handlers to the “CellExporting” and “CellExported” events of the DataPresenterExcelExporter object from my previous example and check the “Value” property of the event argument object.
2. To remove the empty lines around grouped records you can set the ExportOptions object’s “ChildRecordCollectionSpacing” property to “None”. Here is how to modify the export procedure in my previous sample:
exporter.Export(this.xamDataGrid1, fileName, WorkbookFormat.Excel2007,
new ExportOptions() { ChildRecordCollectionSpacing = ChildRecordCollectionSpacing.None }
);
3. You can set different foreground and background colors when exporting using the "CellExporting" event of the "DataPresenterExcelExporter" object. This kind of procedure is discussed in this thread:
http://www.infragistics.com/community/forums/t/63992.aspx
and also in this topic:
http://help.infragistics.com/doc/WPF?page=xamDataPresenter_Handle_Exporting_Events.html
Hi Radko
This happens for normal spacing as well. I added 4-5 spaces before text inside cell and exported to excel and spaces were trim from cell value.
How do I retain spaces? Any alternative for this?
Hi Sagar,
I am attaching you a sample which contains a lot of cells with spaces before their values. All these spaces are exported and visible in MS Excel. Please look at the sample and if possible send me an example showing your issue or modify my example to show the exporting issue.
Thanks