Free Support Forum - aspose.com

Error bars in Excel chart

Hi,

I have used the following code to copy a chart from an excel sheet and save it as an image.

Workbook wb1 = new Workbook();

Chart chart;

System.Drawing.Bitmap bmp;

wb1.Open(@"C:\Test.xls");

chart = wb1.Worksheets[1].Charts[0];

chart.NSeries[2].HasUpDownBars = true;

bmp = chart.ToImage();

bmp.Save(@"C:\Test.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

But the image seems to be dropping the the excel bars.

I have attached the excel sheet and the image file for your reference.

I need to get around this problem ASAP.

Please Help.

Thanks

Swapna

Hi Swapna,

Thanks for the files,

We will figure out the issue soon.

Thank you.

Hi,

I am in a deadline situation, so I need to know if it is possible ASAP.

Thanks in advance

Swapna

Hi Swapna,

Please try this fix.

By the way ASeries.HasUpDownBars only applies for line chart. So

"chart.NSeries[2].HasUpDownBars = true;" does not effect.

Hi Warren,

Thanks for the DLL.

I am still having a problem with the way the images are converted.

I used the same code but removed the line for the error bars.

Workbook wb1 = new Workbook();

Chart chart;

System.Drawing.Bitmap bmp;

wb1.Open(@"C:\Sample codes\TestAspose\Test.xls");

chart = wb1.Worksheets[0].Charts[0];

bmp = chart.ToImage();

bmp.Save(@"C:\Sample codes\TestAspose\Test.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

When I did that, the Image file generated is attached as Test1.jpg.

I them opened the excel file to check some contents and closed it, it prompted me with a dialog box that read as follows

"Do you wan to save the changes to "...."

Excel calculates the formulas while opening....."

I clicked on YES and closed the excel.

I then ran the code mentioed above and got the Image file that is attached as Test.jpg.

Why is this happening?

Also if you see in the Excel file I have some Images near the Yaxis.

They are not being copied over to the Image file. Why ?

Hi,

Now we will force Excel to re-calculate the formula when the file is opened by Ms Excel .So when you open the file with Excel, you will get such message box. Please call calculating formula before you convert chart to image.

Workbook wb1 = new Workbook();

Chart chart;

System.Drawing.Bitmap bmp;

wb1.Open(@"C:\Sample codes\TestAspose\Test.xls");

wb1.CalculateFormula();

chart = wb1.Worksheets[0].Charts[0];

bmp = chart.ToImage();

bmp.Save(@"C:\Sample codes\TestAspose\Test.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

By the way, the xls file in the attached zip package is opened and saved by MS Excel. So we could not get the test1.jpg. But we think it must be caused by not calculating formulas before coveting.

Now we do not support convet the shapes in the chart to image. We will look into it soon.

Hi Warren,

Just attaching the original excel file which did not have the formulas calculated.

I tried the code that you had given with this file, it still did not work. I have also attached the Image that I got from the Excel file.

Thanks

Hi,

Please try this fix.

Hi,

Thanks for the fix.

I have the following two queries

1) The code works fine, if the graph has values. But if the graph is empty like shown in the attachment, it produces an image as attached.Why is this happening ?

2) When will you start supporting convet shapes in the chart to image functionality.

Thank you for all your help.

Swapna

Hi,

1, Please try this fix.

2.We are still working on it.