PERL excell scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting PERL excell scripting
# 1  
Old 11-15-2012
PERL excell scripting

Hi,
At the minute I am using a script to gather weekly SAR stats and put them into an excel scpreadsheet using perl.
I then get that spreadsheet and manually add in a chart on a new worksheet, Can i add this step into the script?
and if so how?

here is the part of my script that creates the spreadsheet
Code:
#
# Generate Excel Spreadsheet
#
my $workbook = Spreadsheet::WriteExcel->new("$filename");
my $worksheet = $workbook->add_worksheet('cpu_stats');
# Write header into worksheet
my @header = ('00:00:00','%usr','%sys','%wio','%idle');
$worksheet->write_row(0,0,\@header);
# Write data into worksheet
$worksheet->write('A2',\@data);
# Close workbook
$workbook->close;

---------- Post updated at 02:03 PM ---------- Previous update was at 02:01 PM ----------

just for reference the chart needs to be a line chart which shows each of the stats with time along the x-axis and % alonf the y-axis

Last edited by Franklin52; 11-16-2012 at 03:45 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 11-15-2012
# 3  
Old 11-15-2012
Cheers, i will have a look and if i have any problems ill let you know
# 4  
Old 11-19-2012
Below is my script at the moment:

Code:
 
#
# Generate Excel Spreadsheet
#
my $workbook = Spreadsheet::WriteExcel->new("$filename");
my $worksheet = $workbook->add_worksheet('cpu_stats');
my $worksheet2 = $workbook->add_worksheet('chart1');
my $chart = $workbook->add_chart(type => 'line', embedded =>1);
# Write header into worksheet
my @header = ('00:00:00','%usr','%sys','%wio','%idle');
$worksheet->write_row(0,0,\@header);
# Write data into worksheet
$worksheet->write('A2',\@data);
# Add worksheet data to the chart
$chart->add_series(
 categories => '=$worksheet!$B$1:$E$1',
 values     => '=$worksheet',
 name       => 'chart1',
);
# Add chart labels
$chart->set_title (name=> '$host Performance Chart for Week Ending $week_ending');
$chart->set_x_axis (name=> 'Time 24(HR)');
$chart->set_y_axis (name=> 'Percentage');
# Insert chart into worksheet2
$worksheet2->insert_chart ('A1', $chart);
# Close workbook
$workbook->close;

I know the issue is "
Code:
values => '=$worksheet

" as i get the following when i try to run the script:
Code:
 
Couldn't parse formula: =$worksheet! at sar_chart.tst line 83

The thing is I need to have 2 worksheets, 1 with all the data and 1 with the chart,
Can anyone help?
# 5  
Old 11-19-2012
Try this:
Code:
 categories => '=cpu_stats!$B$1:$E$1',
 values     => '=cpu_stats',

# 6  
Old 11-19-2012
That worked great, thanks:
Does anyone know if its possible to remove the markers on a line chart using perl?
and secondly my script runs on a number of servers so Im trying to get the script to name the chart with the hostname,
Here is what im doing:
Code:
#Hostname
my $host = hostname;
 
$chart->set_title (name=> print "$host" 'Performance Chart' );
$chart->set_x_axis (name=> 'Time "$(HR)');
$chart->set_y_axis (name=> 'Percentage');

I can't seem to get it to actually print the hostname, it just prints whatever i type after name=>
# 7  
Old 11-19-2012
I don't know what markers you are talking about (maybe post some screenshot). As for the chart name, this should work:
Code:
$chart->set_title (name=> "$host Performance Chart" );

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Trimmean of Excell in awk

Anyone know how we can implement excel trimmean avg in Unix. possible by AWK Sample File scr1 100 scr1 2000 scr2 320 scr1 50 scr1 10 scr2 2 scr2 220 scr1 4234 scr2 2435 scr2 2 scr3 345 scr2 356 expected Output, which was using =trimmean(scr1 values, ignore 50% of values from... (8 Replies)
Discussion started by: mychbears
8 Replies

2. Web Development

Perl scripting or shell scripting?

i am going to study any one of the scripting languages mentioned above(shell 0r perl scripting) . Which is having more scope for a fresher? (1 Reply)
Discussion started by: Anna Hussie
1 Replies

3. What is on Your Mind?

Shell Scripting vs Perl scripting

Gents, I have been working in a Solaris/Unix environment for about 9 months. I took some linux classses online before getting the job. But, I am not very good at scripting. I want to learn how to script. Do you think that I should start with Shell scripting or Perl? I wanted to continue with... (2 Replies)
Discussion started by: Pouchie1
2 Replies

4. What is on Your Mind?

Shell scripting vs Perl scripting

Hi all, I would like to start developping some good scripting skills. Do you think it would be best to start with shell scripting or Perl? I already got a fundation, really basics, in perl. but I am wondering what would be best to be good at first. Can you please help me determine which one to... (14 Replies)
Discussion started by: Pouchie1
14 Replies

5. UNIX for Dummies Questions & Answers

Need help configuring Active Perl on Windows Vista.: Perl Scripting on Windows

Hi All, Need help configuring Active Perl on Windows Vista. I am trying to install Active Perl on Windows Vista. The version of Active Perl i am trying to install is : ActivePerl 5.10.1 Build 1006 After installing it through cmd, When i try to run perl -v to check the version, i get the... (2 Replies)
Discussion started by: Vabiosis
2 Replies

6. Shell Programming and Scripting

Call Shell scripting from Perl Scripting.

Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Discussion started by: anupdas
2 Replies

7. UNIX for Dummies Questions & Answers

From Ascii files to Excell

Hi, Is there anyway to copy a certain column from the Ascii file into a column on an Excel sheet? Thanks, (4 Replies)
Discussion started by: cosmologist
4 Replies

8. Shell Programming and Scripting

Perl Scripting

Hi, I want to use the mailx command or sendmail command in perl script. I am trying this one and getting error: system "mailx -s \"Test mail\" $ar1"; Error: The flags you gave are used only when sending mail. (10 Replies)
Discussion started by: vaibhav
10 Replies

9. Shell Programming and Scripting

how to write into an Excell

Hello All, I have a query inside a shell script and it will retun a 1000 rows result set. how can i take the output into an excel file from the script for better viewing the results. Thanks, Sateesh (4 Replies)
Discussion started by: kotasateesh
4 Replies

10. UNIX for Dummies Questions & Answers

Perl scripting

Can anyone help ..... I am prettey new to perl but would like to do the following :- write a script that would open one or more log files and select a few lines from each and create a new file with the selected lines from the logs. Thanx (4 Replies)
Discussion started by: jikyj
4 Replies
Login or Register to Ask a Question