Convert Chart to Images
Aspose.Cells - Convert Chart to Images
Charts are visually appealing and make it easy for users to see comparisons, patterns, and trends in data. The Chart class toImage method converts the chart to an image file, that can be saved to disk or stream.
// Instantiating a Workbook object Workbook workbook = new Workbook(); // Obtaining the reference of the first worksheet WorksheetCollection worksheets = workbook.Worksheets; Worksheet sheet = worksheets; // Adding some sample value to cells Cells cells = sheet.Cells; Cell cell = cells["A1"]; cell.Value = 50; cell = cells["A2"]; cell.Value = 100; cell = cells["A3"]; cell.Value = 150; cell = cells["B1"]; cell.Value = 4; cell = cells["B2"]; cell.Value = 20; cell = cells["B3"]; cell.Value = 50; ChartCollection charts = sheet.Charts; // Adding a chart to the worksheet int chartIndex = charts.Add(ChartType.Pyramid, 5, 0, 15, 5); Chart chart = charts[chartIndex]; //Save the chart image file. chart.ToImage("AsposeChartImage.png", ImageFormat.Png);
Download Running Code
Download Convert Chart to Images form any of the below mentioned social coding sites: