How do I use Spreadsheet::WriteExcel to create a chart from numeric log data?

Posted by yaohung on Stack Overflow See other posts from Stack Overflow or by yaohung
Published on 2010-04-23T04:15:14Z Indexed on 2010/04/23 10:03 UTC
Read the original article Hit count: 220

I used csv2xls.pl to convert a text log into .xls format, and then I create a chart as in the following:

my $chart3 = $workbook->add_chart( type => 'line' , embedded => 1);

# Configure the series.
$chart3->add_series(
    categories => '=Sheet1!$B$2:$B$64',
    values     => '=Sheet1!$C$2:$C$64',
    name       => 'Test data series 1',
);

# Add some labels.
$chart3->set_title( name => 'Bridge Rate Analysis' );
$chart3->set_x_axis( name => 'Packet Size ' );
$chart3->set_y_axis( name => 'BVI Rate' );

# Insert the chart into the main worksheet.
$worksheet->insert_chart( 'G2', $chart3 );

I can see the chart in the .xls file. However, all the data are in text format, not numeric, so the chart looks wrong.

How do I convert text into number before applying this create-chart function?

Also, how do I sort the .xls file before creating the chart?

© Stack Overflow or respective owner

Related posts about perl

Related posts about spreadsheet-writeexcel