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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.