Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aspose-com-kb/dc1bfcfe578bb91b0b256828cc8deb99 to your computer and use it in GitHub Desktop.
Save aspose-com-kb/dc1bfcfe578bb91b0b256828cc8deb99 to your computer and use it in GitHub Desktop.
This sample code converts Excel chart to JPG in C#. For more details, refer to https://kb.aspose.com/cells/net/how-to-convert-excel-chart-to-jpg-in-csharp-without-interop/
using Aspose.Cells;
using Aspose.Cells.Charts;
using Aspose.Cells.Rendering;
namespace ConvertExcelChartToJPGInCSharp
{
class Program
{
static void Main(string[] args)
{
// Initialize license object
License license = new License();
// Set license by providing path to license file
license.SetLicense("Aspose.Cells.lic");
//Load the workbook containing the chart
Workbook ChartToImageWorkbook = new Workbook("ExcelChartFile.xlsx");
//Access chart object that is to be rendered to image
Chart chart = ChartToImageWorkbook.Worksheets[0].Charts[0];
//Set image type options using ImageOrPrintOptions
ImageOrPrintOptions imageOrPrintOptions = new ImageOrPrintOptions();
imageOrPrintOptions.ImageType = Aspose.Cells.Drawing.ImageType.Jpeg;
//Save chart as JPEG image
chart.ToImage("ExcelChartToJPG.jpg", imageOrPrintOptions);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment