Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How do I save a chart from Microsoft Excel as GIF/JPEG/PNG?

chart Excel GIF JPEG Microsoft PNG
0
Posted

How do I save a chart from Microsoft Excel as GIF/JPEG/PNG?

0

You can use the Export method of a chart. If you have a chartobject the code looks like this $ChartObj->Chart->Export({ FileName => “$graphics_filename”, FilterName => ‘GIF’, Interactive => 0}); A complete example that opens an Excel workbook, loops through all the charts and saves them as GIFs and then closes the Excel workbook is here: use strict; use Win32::OLE qw(in with); use Win32::OLE::Const; use Win32::OLE::Const ‘Microsoft Excel’; $Win32::OLE::Warn = 3; # die on errors… my $filename = ‘c:\\documents\\test.xls’; my $filter = ‘GIF’; # can be GIF, JPG, JPEG or PNG my $count = 0; my $Excel = Win32::OLE->GetActiveObject(‘Excel.Application’) || Win32::OLE->new(‘Excel.Application’, ‘Quit’); # use the Excel application if it’s open, otherwise open new my $Book = $Excel->Workbooks->Open( $filename ); # open the file foreach my $Sheet (in $Book->Sheets) { # loop through all sheets foreach my $ChartObj (in $Sheet->ChartObjects) { # loop through all chartobjects in the sheet my $savenam

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123