How to set gap width to chart series in WinForm Excel?
XlsIO provides support for setting gap width to chart series using ICharFormat.GapWidth property. The following code example illustrates how to set gap width to chart series in XlsIO.
C#
ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; IWorkbook workbook = application.Workbooks.Open("Sample.xlsx"); IWorksheet worksheet = workbook.Worksheets(0); //The first series in the chart is accessed. IChartSerie serie = worksheet.Charts(0).Series(0); //Setting the GapWidth to chart series. serie.SerieFormat.CommonSerieOptions.GapWidth = 25; //Save the workbook. workbook.SaveAs("Output.xlsx"); //Close the workbook and dispose the engine. workbook.Close(); excelEngine.Dispose();
VB
Dim excelEngine As ExcelEngine = New ExcelEngine Dim application As IApplication = excelEngine.Excel Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx") Dim worksheet As IWorksheet = workbook.Worksheets(0) 'The first series in the chart is accessed. Dim serie As IChartSerie = worksheet.Charts(0).Series(0) 'Setting the GapWidth to chart series. serie.SerieFormat.CommonSerieOptions.GapWidth = 25 'Save the workbook. workbook.SaveAs("Output.xlsx") 'Close the workbook and dispose the engine. workbook.Close() excelEngine.Dispose()
The sample which illustrates the above behavior can be downloaded here.
Below are the screen shots with different gap widths applied to chart series.
Gap width is 0.
Gap width is 200.
Gap width is 500.
Conclusion
I hope you enjoyed learning how to set gap width to chart series in WinForm Excel.
You can refer to our WinForms Excel feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms Excel example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!