Interface IChartFormat
Provides access to the formatting options for chart elements.
Namespace: Syncfusion.XlsIO
Assembly: Syncfusion.XlsIO.NET.dll
Syntax
public interface IChartFormat
Properties
BubbleScale
Gets or sets the scale factor for bubbles. Can be an integer value from 0 to 300, corresponding to a percentage of the default size.
Declaration
int BubbleScale { get; set; }
Property Value
Type |
---|
System.Int32 |
Examples
The following code illustrates how to set BubbleScale for Bubble chart.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Value = "50";
sheet.Range["B1"].Value = "60";
sheet.Range["C1"].Value = "5";
sheet.Range["A2"].Value = "1";
sheet.Range["B2"].Value = "4";
sheet.Range["C2"].Value = "2";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set chart type
chart.ChartType = ExcelChartType.Bubble_3D;
//Set chart format
IChartFormat format = chart.Series[0].SerieFormat.CommonSerieOptions;
//Set bubble scale
format.BubbleScale = 50;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
Exceptions
Type | Condition |
---|---|
System.NotSupportedException |
DoughnutHoleSize
Gets or sets the size of the hole in a Doughnut chart. The hole size is expressed as a percentage of the chart size, between 10 and 90 percent.
Declaration
int DoughnutHoleSize { get; set; }
Property Value
Type |
---|
System.Int32 |
Examples
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set serie
IChartSerie serie = chart.Series[0];
//Set chart type
chart.ChartType = ExcelChartType.Doughnut;
//Set Doughnut hole size
serie.SerieFormat.CommonSerieOptions.DoughnutHoleSize = 60;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
DropLines
Represents Drop lines of Stock, Line and Area Charts. Read-only.
Declaration
IChartBorder DropLines { get; }
Property Value
Type |
---|
IChartBorder |
Examples
The following code illustrates how to get DropLines for Stock, Line and Area charts.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Value = "Fruits";
sheet.Range["B1"].Value = "Joey";
sheet.Range["C1"].Value = "Mathew";
sheet.Range["D1"].Value = "Peter";
sheet.Range["A2"].Value = "Apples";
sheet.Range["B2"].Value = "5";
sheet.Range["C2"].Value = "3";
sheet.Range["D2"].Value = "2";
sheet.Range["A3"].Value = "Grapes";
sheet.Range["B3"].Value = "4";
sheet.Range["C3"].Value = "5";
sheet.Range["D3"].Value = "2";
sheet.Range["A4"].Value = "Bananas";
sheet.Range["B4"].Value = "4";
sheet.Range["C4"].Value = "4";
sheet.Range["D4"].Value = "3";
sheet.Range["A5"].Value = "Oranges";
sheet.Range["B5"].Value = "2";
sheet.Range["C5"].Value = "1";
sheet.Range["D5"].Value = "5";
sheet.Range["A6"].Value = "Melons";
sheet.Range["B6"].Value = "2";
sheet.Range["C6"].Value = "7";
sheet.Range["D6"].Value = "6";
//Create chart
IChart chart = sheet.Charts.Add();
//Data being charted on the X axis will move to the Y axis and vice versa
chart.IsSeriesInRows = false;
//Set range
chart.DataRange = sheet.Range["A1:D6"];
//Set chart type
chart.ChartType = ExcelChartType.Stock_HighLowClose;
//Set chart format
IChartFormat format = chart.Series[0].SerieFormat.CommonSerieOptions;
//Set drop line style
format.DropLineStyle = ExcelDropLineStyle.Drop;
//Initialize border and set drop lines
IChartBorder border = format.DropLines;
border.LineColor = System.Drawing.Color.Yellow;
border.LinePattern = ExcelChartLinePattern.Dash;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
DropLineStyle
Gets or sets drop lines or hi-low lines or series lines: 0 = drop lines 1 = hi-low lines 2 = series lines (lines used in Pie of Pie and Bar of Pie charts)
Declaration
ExcelDropLineStyle DropLineStyle { get; set; }
Property Value
Type |
---|
ExcelDropLineStyle |
Examples
The following code illustrates how to set DropLineStyle for charts.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Value = "Fruits";
sheet.Range["B1"].Value = "Joey";
sheet.Range["C1"].Value = "Mathew";
sheet.Range["D1"].Value = "Peter";
sheet.Range["A2"].Value = "Apples";
sheet.Range["B2"].Value = "5";
sheet.Range["C2"].Value = "3";
sheet.Range["D2"].Value = "2";
sheet.Range["A3"].Value = "Grapes";
sheet.Range["B3"].Value = "4";
sheet.Range["C3"].Value = "5";
sheet.Range["D3"].Value = "2";
sheet.Range["A4"].Value = "Bananas";
sheet.Range["B4"].Value = "4";
sheet.Range["C4"].Value = "4";
sheet.Range["D4"].Value = "3";
sheet.Range["A5"].Value = "Oranges";
sheet.Range["B5"].Value = "2";
sheet.Range["C5"].Value = "1";
sheet.Range["D5"].Value = "5";
sheet.Range["A6"].Value = "Melons";
sheet.Range["B6"].Value = "2";
sheet.Range["C6"].Value = "7";
sheet.Range["D6"].Value = "6";
//Create chart
IChart chart = sheet.Charts.Add();
//Data being charted on the X axis will move to the Y axis and vice versa
chart.IsSeriesInRows = false;
//Set range
chart.DataRange = sheet.Range["A1:D6"];
//Set chart type
chart.ChartType = ExcelChartType.Stock_HighLowClose;
//Set chart format
IChartFormat format = chart.Series[0].SerieFormat.CommonSerieOptions;
//Set drop line style
format.DropLineStyle = ExcelDropLineStyle.HiLow;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
FirstDropBar
Gets the up bars on the Line chart. Read-only.
Declaration
IChartDropBar FirstDropBar { get; }
Property Value
Type |
---|
IChartDropBar |
Remarks
Up bars connect points on series one with higher values on the last series in the chart group (the lines go up from series one). Only 2-D line groups that contain at least two series can have up bars. This object isn't a collection. Theres no object that represents a single up bar; you either have up bars turned on for all points in a chart group or you have them turned off.
Examples
The following code illustrates how to access FirstDropBar and set Gap for Line chart.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
sheet.Range["A3"].Value = "15";
sheet.Range["B3"].Value = "25";
sheet.Range["C3"].Value = "35";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C3"];
//Set chart type
chart.ChartType = ExcelChartType.Line;
//Set chart drop bar
IChartDropBar dropBar = chart.Series[0].SerieFormat.CommonSerieOptions.FirstDropBar;
//Set gap
dropBar.Gap = 90;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
FirstSliceAngle
Gets or sets the angle of the first pie-chart or dough-nut chart slice, in degrees (clockwise from vertical). Can be a value from 0 through 360.
Declaration
int FirstSliceAngle { get; set; }
Property Value
Type |
---|
System.Int32 |
Remarks
Applies only to pie, 3-D pie, and dough-nut charts.
Examples
The following code illustrates how to set FirstSliceAngle for Pie chart.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set chart type
chart.ChartType = ExcelChartType.Pie;
//Set chart format
IChartFormat format = chart.Series[0].SerieFormat.CommonSerieOptions;
//Set first slice angle
format.FirstSliceAngle = 60;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
GapWidth
Declaration
int GapWidth { get; set; }
Property Value
Type |
---|
System.Int32 |
HasDropLines
True if stock, line or area charts has drop lines
Declaration
bool HasDropLines { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how to set drop lines for Stock, Line and Area charts.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Value = "Fruits";
sheet.Range["B1"].Value = "Joey";
sheet.Range["C1"].Value = "Mathew";
sheet.Range["D1"].Value = "Peter";
sheet.Range["A2"].Value = "Apples";
sheet.Range["B2"].Value = "5";
sheet.Range["C2"].Value = "3";
sheet.Range["D2"].Value = "2";
sheet.Range["A3"].Value = "Grapes";
sheet.Range["B3"].Value = "4";
sheet.Range["C3"].Value = "5";
sheet.Range["D3"].Value = "2";
sheet.Range["A4"].Value = "Bananas";
sheet.Range["B4"].Value = "4";
sheet.Range["C4"].Value = "4";
sheet.Range["D4"].Value = "3";
sheet.Range["A5"].Value = "Oranges";
sheet.Range["B5"].Value = "2";
sheet.Range["C5"].Value = "1";
sheet.Range["D5"].Value = "5";
sheet.Range["A6"].Value = "Melons";
sheet.Range["B6"].Value = "2";
sheet.Range["C6"].Value = "7";
sheet.Range["D6"].Value = "6";
//Create chart
IChart chart = sheet.Charts.Add();
//Data being charted on the X axis will move to the Y axis and vice versa
chart.IsSeriesInRows = false;
//Set range
chart.DataRange = sheet.Range["A1:D6"];
//Set chart type
chart.ChartType = ExcelChartType.Stock_HighLowClose;
//Set chart format
IChartFormat format = chart.Series[0].SerieFormat.CommonSerieOptions;
//Set drop lines
format.HasDropLines = true;
//Initialize border and set drop lines
IChartBorder border = format.DropLines;
border.LineColor = System.Drawing.Color.Yellow;
border.LinePattern = ExcelChartLinePattern.Dash;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
HasHighLowLines
True if stock or line charts has high-low lines
Declaration
bool HasHighLowLines { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how to set high-low lines for Stock and Line charts.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Value = "Fruits";
sheet.Range["B1"].Value = "Joey";
sheet.Range["C1"].Value = "Mathew";
sheet.Range["D1"].Value = "Peter";
sheet.Range["A2"].Value = "Apples";
sheet.Range["B2"].Value = "5";
sheet.Range["C2"].Value = "3";
sheet.Range["D2"].Value = "2";
sheet.Range["A3"].Value = "Grapes";
sheet.Range["B3"].Value = "4";
sheet.Range["C3"].Value = "5";
sheet.Range["D3"].Value = "2";
sheet.Range["A4"].Value = "Bananas";
sheet.Range["B4"].Value = "4";
sheet.Range["C4"].Value = "4";
sheet.Range["D4"].Value = "3";
sheet.Range["A5"].Value = "Oranges";
sheet.Range["B5"].Value = "2";
sheet.Range["C5"].Value = "1";
sheet.Range["D5"].Value = "5";
sheet.Range["A6"].Value = "Melons";
sheet.Range["B6"].Value = "2";
sheet.Range["C6"].Value = "7";
sheet.Range["D6"].Value = "6";
//Create chart
IChart chart = sheet.Charts.Add();
//Data being charted on the X axis will move to the Y axis and vice versa
chart.IsSeriesInRows = false;
//Set range
chart.DataRange = sheet.Range["A1:D6"];
//Set chart type
chart.ChartType = ExcelChartType.Stock_HighLowClose;
//Set chart format
IChartFormat format = chart.Series[0].SerieFormat.CommonSerieOptions;
//Set high-low lines
format.HasHighLowLines = true;
//Initialize border and set high-low lines
IChartBorder border = format.HighLowLines;
border.LineColor = System.Drawing.Color.Yellow;
border.LinePattern = ExcelChartLinePattern.Dash;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
HasRadarAxisLabels
True if a radar chart has axis labels. otherwise False. Applies only to radar charts.
Declaration
bool HasRadarAxisLabels { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how to hide the axis labels of radar charts.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
//Create chart
IChart chart = sheet.Charts.Add();
//Set chart type
chart.ChartType = ExcelChartType.Radar;
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set chart format
IChartFormat format = chart.Series[0].SerieFormat.CommonSerieOptions;
//Set radar label visibility
format.HasRadarAxisLabels = false;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
HasSeriesLines
True if pie of pie or bar of pie charts has series lines
Declaration
bool HasSeriesLines { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illusrates how to set series lines for pie of pie and bar of pie charts.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["D1"].Text = "Apr";
sheet.Range["E1"].Text = "May";
sheet.Range["F1"].Text = "Jun";
sheet.Range["A2"].Value = "5";
sheet.Range["B2"].Value = "21";
sheet.Range["C2"].Value = "15";
sheet.Range["D2"].Value = "12";
sheet.Range["E2"].Value = "28";
sheet.Range["F2"].Value = "9";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:F2"];
//Set chart type
chart.ChartType = ExcelChartType.PieOfPie;
//Set chart format
IChartFormat format = chart.Series[0].SerieFormat.CommonSerieOptions;
//Set series lines
format.HasSeriesLines = true;
//Set pie series line border
IChartBorder border = chart.Series[0].SerieFormat.CommonSerieOptions.PieSeriesLine;
//Set color
border.ColorIndex = ExcelKnownColors.Red;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
HighLowLines
Represents High-low lines of Stock and Line Charts. Read-only.
Declaration
IChartBorder HighLowLines { get; }
Property Value
Type |
---|
IChartBorder |
Examples
The following code illustrates how to get HighLowLines for Stock and Line charts.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Value = "Fruits";
sheet.Range["B1"].Value = "Joey";
sheet.Range["C1"].Value = "Mathew";
sheet.Range["D1"].Value = "Peter";
sheet.Range["A2"].Value = "Apples";
sheet.Range["B2"].Value = "5";
sheet.Range["C2"].Value = "3";
sheet.Range["D2"].Value = "2";
sheet.Range["A3"].Value = "Grapes";
sheet.Range["B3"].Value = "4";
sheet.Range["C3"].Value = "5";
sheet.Range["D3"].Value = "2";
sheet.Range["A4"].Value = "Bananas";
sheet.Range["B4"].Value = "4";
sheet.Range["C4"].Value = "4";
sheet.Range["D4"].Value = "3";
sheet.Range["A5"].Value = "Oranges";
sheet.Range["B5"].Value = "2";
sheet.Range["C5"].Value = "1";
sheet.Range["D5"].Value = "5";
sheet.Range["A6"].Value = "Melons";
sheet.Range["B6"].Value = "2";
sheet.Range["C6"].Value = "7";
sheet.Range["D6"].Value = "6";
//Create chart
IChart chart = sheet.Charts.Add();
//Data being charted on the X axis will move to the Y axis and vice versa
chart.IsSeriesInRows = false;
//Set range
chart.DataRange = sheet.Range["A1:D6"];
//Set chart type
chart.ChartType = ExcelChartType.Stock_HighLowClose;
//Set chart format
IChartFormat format = chart.Series[0].SerieFormat.CommonSerieOptions;
//Set drop line style
format.DropLineStyle = ExcelDropLineStyle.HiLow;
//Initialize border and set high-low lines
IChartBorder border = format.HighLowLines;
border.LineColor = System.Drawing.Color.Yellow;
border.LinePattern = ExcelChartLinePattern.Dash;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
IsVaryColor
Gets or sets a boolean value indicating whether to vary color for each data point.
Declaration
bool IsVaryColor { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how to set IsVaryColor for charts.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set chart format
IChartFormat format = chart.Series[0].SerieFormat.CommonSerieOptions;
//Set vary color
format.IsVaryColor = true;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
IsVeryColor
Gets or sets a boolean value indicating whether to vary color for each data point. [Deprecated]
Declaration
bool IsVeryColor { get; set; }
Property Value
Type |
---|
System.Boolean |
Remarks
Please, use IsVaryColor instead of this property. Sorry for inconvenience.
Overlap
Gets or sets the space between the bars/columns. Can be a value between - 100 and 100.
Declaration
int Overlap { get; set; }
Property Value
Type |
---|
System.Int32 |
Remarks
Applies only to 2-D bar and 2-D column charts.
Examples
The following code illustrates how to set Overlap for charts.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
sheet.Range["A3"].Value = "15";
sheet.Range["B3"].Value = "25";
sheet.Range["C3"].Value = "35";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C3"];
//Set chart type
chart.ChartType = ExcelChartType.Column_Stacked;
//Set chart format
IChartFormat format = chart.Series[0].SerieFormat.CommonSerieOptions;
//Set overlap
format.Overlap = 20;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
PieSecondSize
Gets or sets the size of the secondary section of either a PieOfPie chart or a Pie_Bar chart, as a percentage of the size of the primary pie. ( 5 - 200 ).
Declaration
int PieSecondSize { get; set; }
Property Value
Type |
---|
System.Int32 |
Examples
The following code illustrates how to set PieSecondSize for charts.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["D1"].Text = "Apr";
sheet.Range["E1"].Text = "May";
sheet.Range["F1"].Text = "Jun";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["D2"].Value = "20";
sheet.Range["E2"].Value = "25";
sheet.Range["F2"].Value = "15";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:F2"];
//Set chart type
chart.ChartType = ExcelChartType.PieOfPie;
//Set chart format
IChartFormat format = chart.Series[0].SerieFormat.CommonSerieOptions;
//Set second pie size
format.PieSecondSize = 40;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
PieSeriesLine
Declaration
IChartBorder PieSeriesLine { get; }
Property Value
Type |
---|
IChartBorder |
Examples
The following code illusrates how to set color to ColorIndex property for PieOfPie chart using PieSeriesLine property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["D1"].Text = "Apr";
sheet.Range["E1"].Text = "May";
sheet.Range["F1"].Text = "Jun";
sheet.Range["A2"].Value = "5";
sheet.Range["B2"].Value = "21";
sheet.Range["C2"].Value = "15";
sheet.Range["D2"].Value = "12";
sheet.Range["E2"].Value = "28";
sheet.Range["F2"].Value = "9";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:F2"];
//Set chart type
chart.ChartType = ExcelChartType.PieOfPie;
//Set pie series line border
IChartBorder border = chart.Series[0].SerieFormat.CommonSerieOptions.PieSeriesLine;
//Set color
border.ColorIndex = ExcelKnownColors.Red;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
SecondDropBar
Gets the down bars on the Line chart. Read-only.
Declaration
IChartDropBar SecondDropBar { get; }
Property Value
Type |
---|
IChartDropBar |
Remarks
Down bars connect points on the first series in the chart group with lower values on the last series (the lines go down from the first series). Only 2-D line groups that contain at least two series can have down bars. This object isn't a collection. Theres no object that represents a single down bar; you either have up bars and down bars turned on for all points in a chart group or you have them turned off.
Examples
The following code illustrates how to access SecondDropBar and set Gap for Line chart.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
sheet.Range["A3"].Value = "15";
sheet.Range["B3"].Value = "25";
sheet.Range["C3"].Value = "35";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C3"];
//Set chart type
chart.ChartType = ExcelChartType.Line;
//Set chart first drop bar
IChartDropBar dropBar = chart.Series[0].SerieFormat.CommonSerieOptions.FirstDropBar;
//Set gap
dropBar.Gap = 20;
//Set chart second drop bar
dropBar = chart.Series[0].SerieFormat.CommonSerieOptions.SecondDropBar;
//Set gap
dropBar.Gap = 20;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
ShowNegativeBubbles
True to show negative bubbles on bubble chart. otherwise False.
Declaration
bool ShowNegativeBubbles { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
By default ShowNegativeBubbles is set to "false" so negative values will not be plotted in Bubble charts. Here for example, we load negative values to Bubble chart value axis and set ShowNegativeBubbles to "true".
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Value = "50";
sheet.Range["B1"].Value = "60";
sheet.Range["C1"].Value = "5";
sheet.Range["D1"].Value = "20";
sheet.Range["A2"].Value = "1";
sheet.Range["B2"].Value = "4";
sheet.Range["C2"].Value = "2";
sheet.Range["D2"].Value = "-2";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:D2"];
//Set chart type
chart.ChartType = ExcelChartType.Bubble_3D;
//Set chart format
IChartFormat format = chart.Series[0].SerieFormat.CommonSerieOptions;
//Set negative bubble visibility
format.ShowNegativeBubbles = true;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
SizeRepresents
Gets or sets a value indicating what the bubble size represents on a Bubble chart.
Declaration
ExcelBubbleSize SizeRepresents { get; set; }
Property Value
Type |
---|
ExcelBubbleSize |
Examples
The SizeRepresents property can be set to either Area or Width. By default it is set to Area. Here for example, we set Width to SizeRepresents property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Value = "50";
sheet.Range["B1"].Value = "60";
sheet.Range["C1"].Value = "5";
sheet.Range["A2"].Value = "1";
sheet.Range["B2"].Value = "4";
sheet.Range["C2"].Value = "2";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set chart type
chart.ChartType = ExcelChartType.Bubble_3D;
//Set chart format
IChartFormat format = chart.Series[0].SerieFormat.CommonSerieOptions;
//Set bubble scale and size represents
format.BubbleScale = 50;
format.SizeRepresents = ExcelBubbleSize.Width;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
SplitType
Declaration
ExcelSplitType SplitType { get; set; }
Property Value
Type |
---|
ExcelSplitType |
Examples
By default SplitType is set to Position. Here for example, we set Value to SplitType.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["D1"].Text = "Apr";
sheet.Range["E1"].Text = "May";
sheet.Range["F1"].Text = "Jun";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["D2"].Value = "20";
sheet.Range["E2"].Value = "25";
sheet.Range["F2"].Value = "15";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:F2"];
//Set chart type
chart.ChartType = ExcelChartType.PieOfPie;
//Set chart format
IChartFormat format = chart.Series[0].SerieFormat.CommonSerieOptions;
//Set split type
format.SplitType = ExcelSplitType.Value;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
SplitValue
Gets or sets the threshold value separating the two sections of either a PieOfPie chart or a Pie_Bar chart.
Declaration
int SplitValue { get; set; }
Property Value
Type |
---|
System.Int32 |
Examples
The following code illustrates how to set SplitValue for charts.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["D1"].Text = "Apr";
sheet.Range["E1"].Text = "May";
sheet.Range["F1"].Text = "Jun";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["D2"].Value = "20";
sheet.Range["E2"].Value = "25";
sheet.Range["F2"].Value = "15";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:F2"];
//Set chart type
chart.ChartType = ExcelChartType.PieOfPie;
//Set chart format
IChartFormat format = chart.Series[0].SerieFormat.CommonSerieOptions;
//Set split type
format.SplitType = ExcelSplitType.Value;
//Set split value
format.SplitValue = 20;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}