Hi,
I have an ultrawebgrid with hierarchial data. I am exporting that data to excel.
I have the data in the following format.
Jan 09 Q01 09 Q02 09
ItemDescription Act Part Act Part Act Part like this...
I have three bands. When i export to excel i want the data to be in flat indentation. But it is getting exported in hierarchial indentation. How can i achive that. I tried setting the properties in export click event. But it doesn't seem to work....
Please help me out..
Hello,
The grid excel exporter exports the grid as it is bound - so if it is hierarchical, it exports it in hierarchical mode. In order to export it in a flat mode, you just need to rebind it just before exporting to a flat datasource.
In essence, what you need to do is to have a method which makes a flat datasource (say, ADO.NET DataTable) from your H\hierarchical datasource - e.g. if you have a DataSet with relations you can just enumerate all DataTables and create one big flat DataTable based on that, then rebind.
Thanks. Enumerate all DataTables in the sense?
To prevent the Child Band Indentation when exporting a Hierarchical WebGrid to EXCEL, check for the Child Band Key in the UltraWebGridExcelExporter HeaderRowExporting and RowExporting events and set the CurrentColumnIndex to 0.
The following code example demonstrates how:
protected
void UltraWebGridExcelExporter1_HeaderRowExporting(object sender, Infragistics.WebUI.UltraWebGrid.ExcelExport.HeaderRowExportingEventArgs e){ // Check for the Child Band Key from the Band // to set CurrentColumnIndex Indentation to 0 if (e.Band.Key == "[Child Band Key]") { e.CurrentColumnIndex = 0; }}
void UltraWebGridExcelExporter1_RowExporting(object sender, Infragistics.WebUI.UltraWebGrid.ExcelExport.RowExportingEventArgs e){ // Check for the Child Band Key from the GridRow // to set CurrentColumnIndex Indentation to 0 if (e.GridRow.Band.Key == "[Child Band Key]") { e.CurrentColumnIndex = 0; }}
Please let me know if this helps or if you have any questions.Sincerely,Mike D.Developer Support EngineerInfragistics, Inc.
I have the same problem: Exporting hierarchical data of the ultrawebgrid in flat format. I understand your logic, could you please give me a sample. I am using WebHierarchicalDataSource and two sqldatasource controls which bind to separate table. Thanks.
Yes, if you are binding to DataSet, it contains a number of DataTables in a relation, so you need to just construct one big DataTable prior to exporting on bind the grid to it.
Still, this really depends on the structure of the data you are binding to (e.g. do you have the same schema for all tables, etc)