A chart is a visual representation of data, in which the data is represented by symbols such as bars in a bar chart or lines in a line chart. The Syncfusion .NET Excel (XlsIO) library supports creating and modifying 80+ chart types including Excel 2016 charts.
Here is an example of how to create a chart in Excel using C#
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
FileStream inputStream = new FileStream(“Sample.xlsx”, FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream);
IWorksheet worksheet = workbook.Worksheets[0];
//Create a Chart
IChartShape chart = worksheet.Charts.Add();
//Set the Chart Type
chart.ChartType = ExcelChartType.Column_Clustered;
//Set data range in the worksheet
chart.DataRange = worksheet.Range["A1:E5"];
//Save the document into a stream
using (MemoryStream outputStream = new MemoryStream())
{
workbook.Save(outputStream);
}
}
Formatting chart area, plot area, data labels, chart series, chart axes, legend, chart and chart axes titles, border, etc., comes under chart appearance settings.
Explore appearance and customization for more information.
Greatness—it’s one thing to say you have it, but it means more when others recognize it. Syncfusion is proud to hold the following industry awards.