We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Syncfusion Feedback


Trusted by the world’s leading companies

Overview

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.

Learn about Charts

Explore more features of Charts

.NET Charts


How to create a chart in Excel using C#

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); 
  }
}

Chart Appearance Settings

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.



References



Awards

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.

Scroll up icon