2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
Excel exportBy default, GridGroupingControl does not have Grid-like support for exporting the Sparkline cells to Excel. But Sparkline cells also can be exported by the following customization. The Sparkline column or cells in the GridGroupingControl can be exported to Excel by defining the Sparkline Groups in the Excel sheet while exporting. ISparklineGroups interface is used for defining the Sparkline group in the Excel sheet. ISparklineGroups interface caches the SparklineGroup that needs to be added to the Excel sheet. The Sparklines appears once you select the Data range and the Location range. Data range and Reference range for the Sparkline in Excel can be determined and assigned in QueryImportExportCellInfo event. C# void converter_QueryImportExportCellInfo(object sender, GridImportExportCellInfoEventArgs e) { if (e.Action == GridConverterAction.Export) { GridTableCellStyleInfoIdentity id = e.GridCell.CellIdentity as GridTableCellStyleInfoIdentity; if (id != null && id.Column != null && id.DisplayElement.IsRecord() && e.GridCell.CellType == GridCellTypeName.Control && e.GridCell.Control is SparkLine) { ISparklineGroup sparklineGroup = e.ExcelCell.Worksheet.SparklineGroups.Add(); sparklineGroup.SparklineType = SparklineType.Line; ISparklines sparklines = sparklineGroup.Add(); //Specify your needed Column index for starting range string startRange = GridRangeInfo.GetAlphaLabel(e.ExcelCell.Column - 3) + e.ExcelCell.Row.ToString(); //Specify your needed Column index for end range string endRange = GridRangeInfo.GetAlphaLabel(e.ExcelCell.Column - 1) + e.ExcelCell.Row.ToString(); IRange dataRange = e.ExcelCell.Worksheet.Range[startRange + ":" + endRange]; IRange referenceRange = e.ExcelCell; //Adding Sparkline in excel sheet range sparklines.Add(dataRange, referenceRange); e.Handled = true; } } } VB Private Sub converter_QueryImportExportCellInfo(ByVal sender As Object, GridImportExportCellIn- ByVal e As foEventArgs) If e.Action = GridConverterAction.Export Then Dim id As GridTableCellStyleInfoIdentity = TryCast(e.GridCell.CellIdentity, GridTableCellStyleInfoI)-dentity If id IsNot Nothing AndAlso id.Column IsNot Nothing AndAlso id.DisplayElement.IsRecord() AndAlso e.GridCell.CellType Is GridCellTypeName.Control AndAlso TypeOf e.GridCell.Control Is SparkLine Then Dim sparklineGroup As ISparklineGroup = e.ExcelCell.Worksheet.SparklineGroups.Add() sparklineGroup.SparklineType = SparklineType.Line Dim sparklines As ISparklines = sparklineGroup.Add() 'Specify your needed Column index for starting range Dim startRange As String = GridRangeInfo.GetAlphaLabel(e.ExcelCell.Column - 3) + e.ExcelCell.Row.ToString() 'Specify your needed Column index for end range Dim endRange As String = GridRangeInfo.GetAlphaLabel(e.ExcelCell.Column - 1) + e.ExcelCell.Row.ToString() Dim dataRange As IRange = e.ExcelCell.Worksheet.Range(startRange & ":" & endRange) Dim referenceRange As IRange = e.ExcelCell 'Adding Sparkline in excel sheet range sparklines.Add(dataRange, referenceRange) e.Handled = True End If End If End Sub Screenshots: Figure 1: Sparkline in GridGroupingControl
Figure 2: Sparkline in ExcelSheet (Exported) Samples: Reference link: https://help.syncfusion.com/windowsforms/classic/gridgroupingcontrol/exporting |
2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.