I have attached screen shots of the Excel with the chart in it and the image created by Chart.ToImage(). I have also cut and pasted the code that I am using to pull the images from the Excel file loaded in Aspose.Cells object. If you compare the chart in the Excel to the one in the word file that I attached you will see the x-axis is not correct.
public void AsposeExportChart(string sWorksheetName, string outputChartName, string chartTitle)
{
ECells.Charts.ChartCollection oChartCollection = wb.Worksheets[sWorksheetName].Charts;
foreach (ECells.Charts.Chart oChart in oChartCollection)
{
if (oChart.Title != null && oChart.Title.Text != null)
{
if (chartTitle.Replace(".", string.Empty).Replace(",", string.Empty).Replace("'", string.Empty).Replace("\\", string.Empty).Replace("/", string.Empty).Replace("&", string.Empty).Replace("'", string.Empty).Replace(" ", string.Empty) == oChart.Title.Text.Replace(".", string.Empty).Replace(",", string.Empty).Replace("'", string.Empty).Replace("\\", string.Empty).Replace("/", string.Empty).Replace("&", string.Empty).Replace("'", string.Empty).Replace(" ", string.Empty))
{
try
{
oChart.ToImage(outputChartName, System.Drawing.Imaging.ImageFormat.Png);
}
catch (Exception ee)
{
Trace.WriteLine(ee.Message);
Trace.WriteLine(ee.StackTrace);
}
}
}
}
}
Is there a problem with converting to PNG format or is there a better way to get the chart out of Excel into Word?
Thanks,
Bryan