Query | Solution |
While exporting to excel I need to exclude some of columns from Child table | By default, GroupingGridExcelConverterControl do not have the support to hide the column while exporting. But you can achieve your scenario using GridGroupingExcelConverterControl using ExcludeColumns property in QueryExportNestedTable event. Please refer to the below code example, Code example GridGroupingExcelConverterControl converter = new GridGroupingExcelConverterControl(); converter.QueryExportNestedTable += converter_QueryExportNestedTable; private void converter_QueryExportNestedTable(object sender, Syncfusion.GroupingGridExcelConverter.ExportNestedTableEventArgs e) { List<String> hidecolumn = new List<string>(); hidecolumn.Add("Field2"); hidecolumn.Add("Field3"); e.ExportingOptions.ExcludeColumns = hidecolumn; } |
need to export child table row which contains GridControl | In order to export the child table which contains the GridControl. You can use the Cancel property in QueryExportRowRange event. Please refer to the below code example, Code example GridGroupingExcelConverterControl converter = new GridGroupingExcelConverterControl(); converter.QueryExportRowRange += converter_QueryExportRowRange; private void converter_QueryExportRowRange(object sender, Syncfusion.GroupingGridExcelConverter.QueryExportRowRangeEventArgs e) { Record record = e.Element.GetRecord(); if (record != null && record.ParentTable.Info.Contains("Child")) { int colindex = this.gridGroupingControl1.GetTableModel("Child").NameToColIndex("Control"); GridTableCellStyleInfo style = this.gridGroupingControl1.Table.GetTableCellStyle(e.Element, "Control"); if (!(style.Control is GridControl)) e.Cancel = true; } } Please let us know if we misunderstood your query. |
if
(e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record)
{
if
(e.TableCellIdentity.DisplayElement.ChildTableGroupLevel == 1)
{
Record
parentRecord =
e.TableCellIdentity.Table.TableModel.FilteredChildTable.ParentDisplayElement.ParentRecord;
// My
Coode
}
}
GroupingGridExcelConverterControl converter = new GroupingGridExcelConverterControl(); converter.ExportStyle = true; converter.GroupingGridToExcel(this.gridGroupingControl1, "SampleOutput.xls",
ConverterOptions.Default); |
If I am using this converter, below property having values. |
GridGroupingExcelConverterControl converter = new GridGroupingExcelConverterControl(); converter.ExportStyle = true; converter.ExportToExcel(this.gridGroupingControl1, "Output.Xls",
new ExcelExportingOptions()); |
If I am using this converter, below property having null values. e.TableCellIdentity.Table.TableModel.FilteredChildTableHow to get the Parent record if using GridGroupingExcelConverterControl converter? |
- Kevin
Query | Solution |
I would like to export the Grid control which is inside the nested table cell. Also, Is there any options available to exclude column from Grid control(not GridGrouping) on export? | By default, we do not have the support to export the GridControl which is inside the nested table cell. But you can export the GridControl in another sheet and add that sheet reference in that GridControl loaded cell using HyperLinks property and you can hide the column using ColumnWidth property while exporting the GridControl to excel. Please refer to the below code example, Code example converter.QueryExportCellRange += converter_QueryExportCellRange; void converter_QueryExportCellRange(object sender, Syncfusion.GroupingGridExcelConverter.QueryExportCellRangeEventArgs e) { if (e.GridCell.Control is GridControl) { GridControl control = e.GridCell.Control as GridControl; if (control != null && e.GridCell.CellType == "Control") { GridExcelConverterControl converter = new GridExcelConverterControl(); workbook.Worksheets.Create("Child" + i.ToString()); //Export the each grid separately to the worksheets converter.GridToExcel(control, workbook.Worksheets["child" + i.ToString()], ConverterOptions.ColumnHeaders); //Date column has hided. workbook.Worksheets["Child" + i.ToString()].Columns[1].ColumnWidth = 0; //refer the exported sheet for GridCotrol IHyperLink hyperlink4 = e.ExcelCell.Worksheet.HyperLinks.Add(workbook.Worksheets["child" + i.ToString()].Range[e.ExcelCell.AddressLocal]); hyperlink4.Type = ExcelHyperLinkType.Workbook; hyperlink4.Address = "child" + i.ToString() + "!A1"; hyperlink4.TextToDisplay = "child" + i.ToString(); //To hide the colum in GridControl while exporting. if (e.GridCell.CellIdentity.ColIndex == 2) e.ExcelCell.ColumnWidth = 0; } i++; } } |
If I am using this converter, below property having null values. e.TableCellIdentity.Table.TableModel.FilteredChildTable How to get the Parent record if using GridGroupingExcelConverterControl converter? | We have tested your scenario using below attached sample. But we are unable to reproduce your scenario at our end. The GridGroupingExcelConverterControl not affect the FilteredChildTable property in QueryCellStyleInfo. So, please provide the following details, · Let us know, have you got the null value for FilteredChildTable while exporting. · Please provide the your Syncfusion product version details. If we missed anything in our attached sample, please modify the sample to reproduce your scenario. It will be helpful to provide the solution at the earliest. |