in reply to Excel chart enumeration and editing
poj#!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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Excel chart enumeration and editing
by italdesign (Novice) on Jun 30, 2014 at 18:58 UTC |