Hi Monks
My requirement is to insert graphs in multiple sheets in excel. But i am getting Graph with datas from sheet1 in both sheet1 and sheet2.
Attaching my code below
use Win32::OLE; $xlApp = Win32::OLE->new('Excel.Application'); $xlApp->{Visible} = 1; $xlBook = $xlApp->Workbooks->Add; ############################# FIRST CHART [SHEET 1]################### +############## my $Sheet = $xlBook->Worksheets("Sheet1"); $Sheet->{Name} = "SERVER NAME I"; # Get data from a txt file open (STAT, "memorystatus.txt") or die "memorystatus.txt not available +"; @data = <STAT>; $y = 1; foreach $line (@data) { chomp($line); $data[$i] = $line; ($day, $status) = split (/,/, $line); my $aRange = 'a'.$y; my $bRange = 'b'.$y; $Sheet->Range($aRange)->{Value} = $day; $Sheet->Range($bRange)->{Value} = $status; $y++; } $chart = $xlBook->Charts->Add; $chart->SetSourceData($Sheet, 2); $chart->{HasTitle} = 1; $chart->ChartTitle->{Text} = "SERVER NAME I"; $chart->Location(3, "SERVER NAME I"); ############################# SECOND CHART [SHEET 2]################## +############### # Second chart my $Sheet = $xlBook->Worksheets("Sheet2"); $Sheet->{Name} = "SERVER NAME II"; # Get data from a txt file open (STAT, "hourly_status.txt") or die "hourly_status.txt not availab +le"; @data = <STAT>; $y = 1; foreach $line (@data) { chomp($line); $data[$i] = $line; ($day, $status) = split (/,/, $line); my $aRange = 'a'.$y; my $bRange = 'b'.$y; $Sheet->Range($aRange)->{Value} = $day; $Sheet->Range($bRange)->{Value} = $status; $y++; } $chart2 = $xlBook->Charts->Add; $chart2->SetSourceData($Sheet, 2); $chart2->{HasTitle} = 1; $chart2->ChartTitle->{Text} = "SERVER NAME II"; $chart2->{Name} = "SERVER NAME II"; $chart2->Location(3, "SERVER NAME II");
Both the input file will look something like tis
DAY, STATUS SUNDAY, 5.25 MONDAY, 23.00 TUESDAY, 16.25 WEDNESDAY, 5.00 THURSDAY, 31.00 FRIDAY, 2.25 SATURDAY, 2.25
Can anyone help me on this
Thanks in advance
In reply to Adding multiple graphs in Excel by sivaBala
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |