How to Convert Excel Chart to JPG in C# without Interop

In this topic you will get answer to how to convert Excel chart to JPG in C# without Interop. Once you go through this step-by-step tutorial, you will be able to Save Excel chart as JPG in C#. Similar to saving as JPG you can also save chart to any of the other common formats like BMP, PNG, SVG, etc.

Steps to convert Excel chart to JPG in C#

  1. Using NuGet package manager, install Aspose.Cells for .NET
  2. Add using directive for Aspose.Cells, Aspose.Cells.Charts and Aspose.Cells.Rendering namespaces
  3. Set Aspose license using SetLicense method
  4. Load the workbook containing a chart
  5. Get an instance of the chart from the desired worksheet
  6. Finally, save the chart as JPG file

These steps demonstrate the process of converting Excel chart to JPG in C# and saving it in a file however there are other options also like saving the output image to MemoryStream and using it accordingly. The Chart.ToImage() function provides option to select page number also if the chart is too large and comprises of multiple pages.

Code to convert Excel chart to JPG in C#

This conversion neither requires MS Excel to be installed on the system nor interop is used. It is a simple console-based application code that can be used in form-based, ASP.NET, and other web technologies like Azure and many more.

In this example, we learned that how to convert Excel chart to JPG in C#. However using the ImageType option, you can save it as PNG, BMP, PICT, TIFF, SVG, and many other formats. You can convert Excel files to other formats also like XPS as given in the article how to convert Excel to XPS in C#.