CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [rnovelo79] Advice on charting data from an existing excel file.: Edit Log



rnovelo79
Novice

Apr 14, 2013, 1:26 PM


Views: 390
Re: [rnovelo79] Advice on charting data from an existing excel file.

Hi guys,
I found this script which works as an example but I'd like to modify it. I intend to use it in a combination of 'if' and 'for' loops but I can't seem to name the worksheets, whenever I try to it corrupts the file and i can't open it. For instance, I'd like to name the first worksheet where the data is as 'ach', then I'd like to have other worksheets by region as 'north', 'south' and 'west' where I will sort through the data my other script generates and start inserting the charts corresponding to my loops. Can someone please help me modify this script?

For this particular script, two worksheets are generated, 'sheet1' and 'chart1'. I'd like to have control of the naming of the worksheets and be able to have control over inserting the chart in a particular worksheet.

I'd like to make mention that this script will be added to my other script.


Code
#!/usr/bin/perl 

use strict;
use warnings;
use Excel::Writer::XLSX;

my $workbook = Excel::Writer::XLSX->new( 'chart.xlsx' );
my $worksheet = $workbook->add_worksheet();

my $chart = $workbook->add_chart( type => 'line' );
$chart->set_legend( position => 'bottom' );

# Configure the chart.
$chart->add_series(
categories => '=Sheet1!$A$2:$A$7',
values => '=Sheet1!$B$2:$B$7',
);

# Add the worksheet data the chart refers to.
my $data = [
[ 'Category', 2, 3, 4, 5, 6, 7 ],
[ 'Value', 1, 4, 5, 2, 1, 5 ],
];

$worksheet->write( 'A1', $data );



(This post was edited by rnovelo79 on Apr 14, 2013, 1:37 PM)


Edit Log:
Post edited by rnovelo79 (Novice) on Apr 14, 2013, 1:30 PM
Post edited by rnovelo79 (Novice) on Apr 14, 2013, 1:32 PM
Post edited by rnovelo79 (Novice) on Apr 14, 2013, 1:34 PM
Post edited by rnovelo79 (Novice) on Apr 14, 2013, 1:37 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives