Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Excel chart enumeration and editing

by poj (Abbot)
on Jun 27, 2014 at 15:34 UTC ( [id://1091485]=note: print w/replies, xml ) Need Help??


in reply to Excel chart enumeration and editing

Try this, it should list the SERIES data for all the charts in the workbook.
If it does then the code I have commented out may be all you need to make the changes.
#!perl use strict; use Win32::OLE::Const 'Microsoft Excel'; Win32::OLE->Option(Warn => 3); my $ex = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); # change filename to suit my $wb = $ex->Workbooks->Open('c:/temp/testchart.xls') ; for my $ws ( $wb->Sheets->in){ print "\nSheet = ".$ws->Name."\n"; for my $obj ( $ws->ChartObjects->in ){ my $cht = $obj->Chart; print "Name = ".$cht->Name."\n"; print "Title = ".$cht->ChartTitle->text."\n" if $cht->hasTitle; for my $ser ($cht->SeriesCollection->in){ my $SERIES = $ser->{'FormulaR1C1'}; print $ser->Name.' ['.$SERIES."]\n"; # make changes as appropriate #my $NEWSERIES = $SERIES; #if ($NEWSERIES =~ s/Sheet1/Sheet2/g){; # $ser->{'FormulaR1C1'} = $NEWSERIES; # print "--> Changed to [$NEWSERIES]\n"; #}; } } } # save and exit $wb->SaveAs( 'c:\\temp\\changed.xls' ); undef $wb; undef $ex;
poj

Replies are listed 'Best First'.
Re^2: Excel chart enumeration and editing
by italdesign (Novice) on Jun 30, 2014 at 18:58 UTC
    The code worked perfectly. Thanks for setting me on the right path!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1091485]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-23 22:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found