Free Support Forum - aspose.com

Overflow error when calling chart.ToImage

I have a very simple excel document with a chart, but when I call chart.ToImage() I receive an overflow error (Cells 4.4.0.18)

When running in debug mode, the error is _COMPlusExceptionCode = -532459699, catching that and showing the full stacktrace is:

A first chance exception of type 'System.OverflowException' occurred in System.Drawing.dll

at System.Drawing.Graphics.CheckErrorStatus(Int32 status)

at System.Drawing.Graphics.FillPath(Brush brush, GraphicsPath path)

at Aspose.Charts.ChartHelpers.۱.ܜ(Graphics ә, Ӟ ӕ, ׺ ܗ, PointF[] ּ, Single Վ)

at Aspose.Charts.ChartHelpers.۱.ܖ(Graphics ә, ׺ ܗ, Ӟ ӕ, Single ܐ, Single ܑ, Single ܘ, Single ۳, Single Վ)

at Aspose.Charts.ChartHelpers.۱.܋(Graphics ә, Ӟ ӕ, Double ۴, Int32 ٞ)

at Aspose.Charts.ChartHelpers.ۓ.Ә(Ӟ ӕ)

at Aspose.Charts.ChartHelpers.۩.Render(Ӟ chart)

at Aspose.Charts.Ӟ.Render()

at Aspose.Cells.᪪.᪭(Chart ӕ)

at Aspose.Cells.Chart.ToImage()

Sample attached - the code I use (which works for all my other test files) is

foreach (Worksheet sheet in _workbook.Worksheets)

{

//Charts

foreach (Chart chart in sheet.Charts)

{

try

{

System.Drawing.Bitmap bitmap = chart.ToImage();

Hi,

I don't find the problem/error you have mentioned. It works fine here. Following is my sample code and attached is the output chart image.

Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook();
workbook.Open(@"d:\test\Mappe1.xls");
Aspose.Cells.Chart chart = workbook.Worksheets[0].Charts[0];
Bitmap bitmap = chart.ToImage();
bitmap.Save(@"d:\chart_image.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

Thank you.

Hi,

Could you try the attached version.

Thank you.

Worked with the supplied version - thanks