Free Support Forum - aspose.com

Converting Excel chart to image

Hi

Could you please let me know whether there is any option to convert chart in excel to image.

I hope that we are having option like the one below:
Bitmap imgChart = wb.Worksheets[chartSheetIndex].Charts[0].ToImage();

Apart from this, is there any option to save it as an image format and render it in html

--
Thanks
Sridevi

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;}

<![endif]–>

Hi,

Thank you for considering Aspose.

Well, I think you can save a workbook with a Chart Sheet to HTML. Please see the following sample code in this regard:

Workbook workbook = new Workbook();

Cells cells = workbook.Worksheets[0].Cells;

//Put a string into a cell

cells["A1"].PutValue("Region");

cells["A2"].PutValue("France");

cells["A3"].PutValue("Germany");

cells["A4"].PutValue("England");

cells["B1"].PutValue("Marketing Costs");

cells["B2"].PutValue(7000000);

cells["B3"].PutValue(5500000);

cells["B4"].PutValue(3000000);

Worksheet sheet = workbook.Worksheets[workbook.Worksheets.Add()];

//Set the name of the worksheet

sheet.Name = "Clustered Column";

sheet.IsGridlinesVisible = false;

//Create chart

int chartIndex = sheet.Charts.Add(ChartType.Column, 5, 1, 29, 10);

Chart chart = sheet.Charts[chartIndex];

//Add the nseries collection to a chart

chart.NSeries.Add("Sheet1!B2:B4", true);

//Get or set the range of category axis values

chart.NSeries.CategoryData = "Sheet1!A2:A4";

chart.NSeries.IsColorVaried = true;

//Set the legend position type

chart.Legend.Position = LegendPositionType.Top;

//Set properties of chart title

chart.Title.Text = "Marketing Costs by Region";

chart.Title.TextFont.IsBold = true;

chart.Title.TextFont.Color = Color.Black;

chart.Title.TextFont.Size = 12;

workbook.Worksheets.ActiveSheetIndex = 1;

workbook.Worksheets[0].IsVisible = false;

workbook.Save("C:\\Chart.html",FileFormatType.Html);

Also, for chart2Image feature, you may check the following user documentation link with details and sample code:

http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/converting-chart-to-image.html

Thank You & Best Regards,