Articles in this section
Category / Section

How to set gap width to chart series in WinForm Excel?

2 mins read

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.

C:\Users\sridhar.sukumar\AppData\Local\Microsoft\Windows\INetCache\Content.Word\Gapwidth_0.png

 

 

Gap width is 200.

C:\Users\sridhar.sukumar\AppData\Local\Microsoft\Windows\INetCache\Content.Word\Gapwidth_200.png

 

 

Gap width is 500.

C:\Users\sridhar.sukumar\AppData\Local\Microsoft\Windows\INetCache\Content.Word\Gapwidth_500.png

 


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 forumsDirect-Trac, or feedback portal. We are always happy to assist you!


Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied