PNG JPG BMP TIFF XLS
Aspose.Cells  for .NET

Convert Charts to BMP Images in C#

Native and high performance XLS document charts to images conversion using server-side APIs, without the use of any software like Microsoft or Adobe PDF.

How to Convert Charts To BMP Images Using C#

In order to convert XLSX charts, we’ll use

Aspose.Cells for .NET

API which is a feature-rich, powerful and easy to use document manipulation API for C# platform. Open

NuGet

package manager, search for Aspose.Cells and install. You may also use the following command from the Package Manager Console.

Command


PM> Install-Package Aspose.Cells

Steps to Convert Chart to BMP Files in C#

A basic document charting with

Aspose.Cells for .NET

APIs can be done with just few lines of code.

  • Create XLSX file.
  • Get the chart.
  • Convert chart to BMP image.

System Requirements

Our APIs are supported on all major platforms and Operating Systems. Before executing the code below, please make sure that you have the following prerequisites on your system.

  • Microsoft Windows or a compatible OS with .NET Framework, .NET Core, Mono or Xamarin Platforms
  • Development environment like Microsoft Visual Studio
  • Add reference to the Aspose.Cells for .NET DLL in your project - Install from NuGet using the Download button above
 

Convert XLSX Files Chart to BMP image - C#

// Instantiating a Workbook object
Workbook wkb = new Workbook();
// Obtaining the reference of the first worksheet
Worksheet wks = wkb.Worksheets[0];
// Adding sample values to cells
wks.Cells["A2"].PutValue("Category1");
wks.Cells["A3"].PutValue("Category2");
wks.Cells["A4"].PutValue("Category3");
wks.Cells["B1"].PutValue("Column1");
wks.Cells["B2"].PutValue(4);
wks.Cells["B3"].PutValue(20);
wks.Cells["B4"].PutValue(50);
wks.Cells["C1"].PutValue("Column2");
wks.Cells["C2"].PutValue(50);
wks.Cells["C3"].PutValue(100);
wks.Cells["C4"].PutValue(150);
// Adding a chart to the worksheet
int chartIndex = wks.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 5, 0, 15, 5);
// Accessing the instance of the newly added chart
Aspose.Cells.Charts.Chart chart = wks.Charts[chartIndex];
// Setting chart data source as the range "A1:C4"
chart.SetChartDataRange("A1:C4", true);
// Converting to the BMP file
chart.ToImage("output.bmp");