Last active
October 9, 2021 11:31
-
-
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/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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