Hi Monks, I'm trying to plot a chart in perl from the excel sheet that I also create in the program. Below is the actual code. If I understood it correctly, the $A and $B etc under "values" in add_series function are the excel column number. I'm facing a problem where it would plot data only if I put $A in it. No other column(tried $B, $CJ). I'll appreciate help with these questions: 1. Why is nothing being plotted if I try any column other than $A? 2. I need to automate it to pick the last column of any sheet. I couldn't figure a syntax to do that. 3. How do I automate the worksheet name “sim_*” to as many sheets I have?

#!/usr/intel/pkgs/perl/5.14.1/bin/perl use Spreadsheet::WriteExcel; $num_files = @ARGV[0]; print "Help - Syntax: ./process_xyz.pl <number_of_csv_files> <all_csv_files>\n"; print " The output file is: xyz_stat.xls \n"; my $workbook = Spreadsheet::WriteExcel->new('xyz_stat.x +ls') or die $!; my $worksheet_chart = $workbook->add_worksheet('chart'); my $chart = $workbook->add_chart(type => 'line', emb +edded => 1); for ($k = 1; $k <= $num_files; $k++) { $stat_file[$k] = @ARGV[$k]; open (_file, "$stat_file[$k]") or die "cannot open $stat_file[$k]"; $frm_num = 0; $frm_start = 2; $frm_end = 3; $tmp_var = "sim_$k"; $worksheet[$k] = $workbook->add_worksheet($tmp_var); while ($line = <_file>) { @frame_stats = split(/,/,$line); my $col = 0; foreach $el(@frame_stats) { $worksheet[$k]->write($frm_num, $col, $el); $col ++; } $frm_num++; } } $chart->add_series( # categories => '=test1!$A$2:$A$10', values => '=sim_1!$B$2:$B$361', # values => '=sim_1!$A$2:$A$361', name => 'sim1', ); $chart->add_series( # categories => '=test1!$A$2:$A$10', values => '=sim_2!$CU$2:$CU$361', name => 'sim2', ); $worksheet_chart->insert_chart('E2', $chart, 15, 10);

In reply to Plot a chart by wizsc

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.