Following example shows how to export charts to Excel files by using only GemBox.Spreadsheet .NET component.
GemBox.Spreadsheet is a C# / VB.NET component which provides simple and efficient way to read, write, convert and print native Microsoft Excel (XLSX, XLS) and other spreadsheet (ODS, CSV) formats and various document formats (HTML, PDF, XPS) from .NET applications without the need for Microsoft Excel on either the developer or client machines.
GemBox.Spreadsheet Free is free of charge while GemBox.Spreadsheet Professional is a commercial version licensed per developer.
For more information, see GemBox.Spreadsheet features and why GemBox.Spreadsheet outperforms Excel automation.
Inserting charts is not supported directly, so template file (with empty chart dataset) is used. Example reads template Excel file (in XLSX format), fills it with chart data and writes the new file:
C# code:
// Load template Excel file that contains chart on the empty dataset.
var workbook = ExcelFile.Load("TemplateChart.xlsx");
// Select the first worksheet.
var worksheet = workbook.Worksheets[0];
// Fill the data used to create chart.
worksheet.Cells[0, 0].Value = "John Doe";
worksheet.Cells[0, 1].Value = 8;
worksheet.Cells[1, 0].Value = "Hans Meier";
worksheet.Cells[1, 1].Value = 9;
worksheet.Cells[2, 0].Value = "Jean Dupont";
worksheet.Cells[2, 1].Value = 12;
// Save the Excel file.
workbook.Save("NewChart.xlsx");
Visual Basic .NET code:
' Load template Excel file that contains chart on the empty dataset.
Dim workbook = ExcelFile.Load("TemplateChart.xlsx")
' Select the first worksheet.
Dim worksheet = workbook.Worksheets(0)
' Fill the data used to create chart.
worksheet.Cells(0, 0).Value = "John Doe"
worksheet.Cells(0, 1).Value = 8
worksheet.Cells(1, 0).Value = "Hans Meier"
worksheet.Cells(1, 1).Value = 9
worksheet.Cells(2, 0).Value = "Jean Dupont"
worksheet.Cells(2, 1).Value = 12
' Save the Excel file.
workbook.Save("NewChart.xlsx")
For a more detailed example, see Charts sample from GemBox.Spreadsheet Sample Explorer.
Template file had no chart data and looked like this:

New file was created by using the code above and looks like this:

