Articles in this section
Category / Section

How to split the series of pie of pie chart using XlsIO?

1 min read

A pie of pie can separate the tiny slices from the main pie chart and display them in an additional pie chart, so that the smaller slices are more visible. The data for the secondary pie can be set through CommonSerieOptions’ in SerieFormat’ class, with the properties ‘SplitType’ and ‘SplitValueas shown in the below code snippet using XlsIO.

C#:

            ExcelEngine excelEngine = new ExcelEngine();
            
            IApplication application = excelEngine.Excel;
 
            application.DefaultVersion = ExcelVersion.Excel2016;
 
            //The workbook is opened.
            workbook = application.Workbooks.Open("Sample.xlsx");
            IWorksheet worksheet = workbook.Worksheets[0];
 
              //Accessing the chart in the worksheet
            IChart chart = worksheet.Charts[0];
            IChartSerie serie = chart.Series[0];
            //Spliting the series of Pieofpie chart by value SplitType.
            serie.SerieFormat.CommonSerieOptions.SplitType = ExcelSplitType.Value;
            serie.SerieFormat.CommonSerieOptions.SplitValue = 13;
            serie.DataPoints.DefaultDataPoint.DataLabels.IsValue = true;                         
             
            //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
 
            application.DefaultVersion = ExcelVersion.Excel2016
 
            'The workbook is Opened.
            Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")
 
            Dim worksheet As IWorksheet = workbook.Worksheets(0)
 
            'Accessing the chart in the worksheet
            Dim chart As IChart = worksheet.Charts(0)
            
             Dim serie As IChartSerie = chart.Series(0)
 
            'Spliting the series of Pieofpie chart by value SplitType.
            serie.SerieFormat.CommonSerieOptions.SplitType = ExcelSplitType.Value
            serie.SerieFormat.CommonSerieOptions.SplitValue = 13
            serie.DataPoints.DefaultDataPoint.DataLabels.IsValue = True
           
           ' 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.

 

Pie of pie chart’s series splitted by Value SplitType

Chart, pie chart

 

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