IRONSOFTWAREHOME

How to Create and Edit Excel Charts in C#

Curtis Chau
Curtis Chau
Updated: August 2, 2026

IronXL enables C# developers to create, edit, and remove Excel charts programmatically using simple API calls. You can generate column, line, pie, and other chart types directly from your data without Excel Interop dependencies.

In Excel, a chart is a graphical representation of data used to display and analyze information visually. Excel provides various chart types, such as bar charts, line charts, and pie charts, each suited for different data and analysis needs. When working with IronXL's comprehensive Excel library, you can programmatically create these visualizations to enhance your reports and dashboards.

Quickstart: Create and Plot a Line Chart in Seconds

With IronXL, you can install, load a workbook, call CreateChart, add your data series, set your title and legend position, and Plot - all in just a few lines. This example shows how to create a chart using native C# methods without Interop overhead.

  1. 1Install IronXL with NuGet Package Manager

    PM > Install-Package IronXL.Excel

  2. 2Copy and run this code snippet.

    // Load workbook and create a line chart, then add a data series
    IChart chart = workSheet.CreateChart(ChartType.Line, 2, 2, 15, 10);
    IChartSeries series = chart.AddSeries("A2:A10", "B2:B10");
    series.Title = workSheet["B1"].StringValue;
    // Set title and legend position, then plot the chart
    chart.SetTitle("Quick Line Chart");
    chart.SetLegendPosition(LegendPosition.Bottom);
    chart.Plot();
    C#
  3. 3Deploy to test on your live environment

    Start using IronXL in your project today with a free trial
    arrow pointer

Get started with IronXL


How Do I Create Charts in Excel?

IronXL supports column, scatter, line, pie, bar, and area charts. To create a chart, specify the following components. This flexibility allows you to create Excel spreadsheets with rich visualizations tailored to your data presentation needs.

  1. Use CreateChart to specify the chart type and worksheet location.
  2. Add series with AddSeries. This method accepts a single column for some chart types. The first parameter is horizontal axis values. The second is vertical axis values.
  3. Optionally specify series name, chart name, and legend position.
  4. Call Plot to render the chart. Multiple calls create multiple charts.

Let's create charts from the data in the chart.xlsx Excel file. A preview of the data is displayed below:

Spreadsheet with sample chart data showing monthly animal counts for giraffes, elephants, and rhinos from Jan-Jun

What's the Process for Creating Column Charts?

Column charts are ideal for comparing values across categories. When you load spreadsheet data, you can visualize it effectively using column charts to highlight differences between data points. The following example demonstrates creating a multi-series column chart with animal population data:

using IronXL;
using IronXL.Drawing.Charts;

WorkBook workBook = WorkBook.Load("chart.xlsx");
WorkSheet workSheet = workBook.DefaultWorkSheet;

// Set the chart type and position
IChart chart = workSheet.CreateChart(ChartType.Column, 5, 5, 20, 10);

string xAxis = "A2:A7";

// Add the series
IChartSeries series = chart.AddSeries(xAxis, "B2:B7");
series.Title = workSheet["B1"].StringValue;

// Add the series
series = chart.AddSeries(xAxis, "C2:C7");
series.Title = workSheet["C1"].StringValue;

// Add the series
series = chart.AddSeries(xAxis, "D2:D7");
series.Title = workSheet["D1"].StringValue;

// Set the chart title
chart.SetTitle("Column Chart");

// Set the legend position
chart.SetLegendPosition(LegendPosition.Bottom);

// Plot the chart
chart.Plot();

workBook.SaveAs("columnChart.xlsx");
Excel spreadsheet showing animal data table and corresponding grouped column chart with monthly counts for giraffes, elephants, and rhinos

How Do I Create Line Charts?

Line charts excel at showing trends over time. Since line charts display the same information as column charts, switching between them requires only changing the chart type. This makes line charts particularly useful when reading XLSX files containing time-series data:

using IronXL;
using IronXL.Drawing.Charts;

WorkBook workBook = WorkBook.Load("chart.xlsx");
WorkSheet workSheet = workBook.DefaultWorkSheet;

// Set the chart type and position
IChart chart = workSheet.CreateChart(ChartType.Line, 5, 5, 20, 10);

string xAxis = "A2:A7";

// Add the series
IChartSeries series = chart.AddSeries(xAxis, "B2:B7");
series.Title = workSheet["B1"].StringValue;

// Add the series
series = chart.AddSeries(xAxis, "C2:C7");
series.Title = workSheet["C1"].StringValue;

// Add the series
series = chart.AddSeries(xAxis, "D2:D7");
series.Title = workSheet["D1"].StringValue;

// Set the chart title
chart.SetTitle("Line Chart");

// Set the legend position
chart.SetLegendPosition(LegendPosition.Bottom);

// Plot the chart
chart.Plot();

workBook.SaveAs("lineChart.xlsx");
C#
Excel spreadsheet showing animal data table and corresponding line chart with three trend lines for giraffes, elephants, and rhinos

When Should I Use Pie Charts?

Pie charts show proportions and percentages of a whole. For pie charts, only one column of data is needed, making them simpler to implement. They're effective when you want to convert spreadsheet data into visual representations of market share, budget allocation, or category distribution:

using IronXL;
using IronXL.Drawing.Charts;

WorkBook workBook = WorkBook.Load("chart.xlsx");
WorkSheet workSheet = workBook.DefaultWorkSheet;

// Set the chart type and position
IChart chart = workSheet.CreateChart(ChartType.Pie, 5, 5, 20, 10);

string xAxis = "A2:A7";

// Add the series
IChartSeries series = chart.AddSeries(xAxis, "B2:B7");
series.Title = workSheet["B1"].StringValue;

// Set the chart title
chart.SetTitle("Pie Chart");

// Set the legend position
chart.SetLegendPosition(LegendPosition.Bottom);

// Plot the chart
chart.Plot();

workBook.SaveAs("pieChart.xlsx");
Spreadsheet with wildlife data and pie chart showing monthly giraffe distribution, April highlighted with 89 giraffes (21%)

How Do I Edit Existing Charts?

When working with existing Excel files, you may need to modify charts already created. IronXL provides straightforward methods to edit existing charts, allowing you to update titles, reposition legends, and refresh data. This is useful when editing Excel files that contain pre-existing visualizations.

You can edit legend position and chart title in existing charts. To edit a chart, first retrieve it by accessing the Charts property and selecting the targeted chart. Then access the chart properties to make your edits:

using IronXL;
using IronXL.Drawing.Charts;

WorkBook workBook = WorkBook.Load("pieChart.xlsx");
WorkSheet workSheet = workBook.DefaultWorkSheet;

// Retrieve the chart
IChart chart = workSheet.Charts[0];

// Edit the legend position
chart.SetLegendPosition(LegendPosition.Top);

// Edit the chart title
chart.SetTitle("Edited Chart");

workBook.SaveAs("editedChart.xlsx");
Pie chart showing monthly data from Jan-Jun with color-coded segments and legend below
Pie chart showing monthly data distribution from January to June with color-coded segments and legend

How Do I Remove Charts from Excel?

Sometimes you need to clean up Excel files by removing outdated or unnecessary charts. This is common when managing worksheets containing multiple visualizations. To remove an existing chart from a spreadsheet, first retrieve the chart from the Charts property. You'll receive a list of charts. Pass the targeted chart object to RemoveChart:

using IronXL;
using IronXL.Drawing.Charts;
using System.Collections.Generic;

WorkBook workBook = WorkBook.Load("pieChart.xlsx");
WorkSheet workSheet = workBook.DefaultWorkSheet;

// Retrieve the chart
List<IChart> chart = workSheet.Charts;

// Remove the chart
workSheet.RemoveChart(chart[0]);

workBook.SaveAs("removedChart.xlsx");

Advanced Chart Customization

Beyond basic chart creation, IronXL supports advanced customization options. When creating complex reports or dashboards, you can combine charts with other Excel features like conditional formatting to create comprehensive data visualizations.

For business applications, charts often need dynamic generation from database queries or real-time data sources. IronXL integrates seamlessly with .NET data structures, allowing you to create charts from DataTables, Lists, or any enumerable collection. This makes it ideal for generating automated reports that include visual elements.

Summary

IronXL provides a complete solution for working with Excel charts in C# applications. Whether creating new visualizations, modifying existing ones, or removing outdated charts, the library offers intuitive methods that don't require Excel Interop. By combining chart functionality with IronXL's other features like data manipulation and formatting, you can build sophisticated Excel automation solutions that enhance data presentation and analysis in your .NET applications.

Frequently Asked Questions

What types of Excel charts can I create using IronXL?

IronXL supports the creation of various Excel charts such as column, line, pie, bar, scatter, and area charts directly within C# applications without requiring Excel Interop.

How do I create a line chart using IronXL?

To create a line chart with IronXL, install the library, load your workbook, use the `CreateChart` method to set the chart type to line, add your data series with `AddSeries`, and then call `Plot` to render the chart.

Can IronXL help in editing existing Excel charts?

Yes, IronXL provides methods to edit existing Excel charts by enabling you to update the chart title, change the legend position, and refresh data with ease.

Is it possible to remove charts from an Excel worksheet using IronXL?

Yes, IronXL allows you to remove charts from an Excel worksheet by accessing the `Charts` property and calling `RemoveChart` on the desired chart.

How can I customize Excel charts further with IronXL?

Beyond basic chart creation, IronXL supports advanced customizations such as dynamic generation from database queries and integration with .NET data structures for comprehensive data visualization.

What is one advantage of using IronXL over Excel Interop for chart creation?

IronXL enables chart creation and editing in C# without relying on Excel Interop, providing a more straightforward and efficient way to handle Excel files programmatically.

How do I create a column chart using IronXL?

To create a column chart, load your workbook using IronXL, set the chart type with `CreateChart`, add data series using `AddSeries`, and call `Plot` to finalize and display the chart.

Can IronXL handle real-time data for chart creation?

Yes, IronXL integrates with .NET data structures like `DataTables` and `Lists`, making it ideal for creating charts from real-time data sources and generating automated reports.

Why should I consider using pie charts with IronXL?

Pie charts are useful for showing proportions and percentages of a whole, and with IronXL, you can easily implement them to visually represent market share, budget allocation, or category distribution.

Can I create Excel charts without Excel installed using IronXL?

Yes, IronXL operates independently of Excel, allowing you to create and manipulate Excel charts programmatically without needing Excel to be installed on your system.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Nuget Downloads 2,237,574Version:2026.9just released

Get your FREE

30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required
bullet_testTest in production
without watermarks
bullet_calendar30 days fully
functional product
bullet_support24/5 technical
support during trial
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronXL.Excel
nuget.org/packages/IronXL.Excel/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronXL"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

  1. Download and unzip IronXL to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronXL.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required