Important alert: (current site time 7/15/2013 8:45:07 PM EDT)
 

VB icon

Chart in Excel

Email
Submitted on: 4/14/2003 9:02:52 AM
By: Damian myerscough  
Level: Intermediate
User Rating: By 1 Users
Compatibility: 5.0 (all versions), Active Perl specific, 4.0 (all versions), 3.0 (all versions), Pre 3.0
Views: 13421
 
     Makes a chart in Microsoft Excel

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
=**************************************
= Name: Chart in Excel
= Description:Makes a chart in Microsoft Excel
= By: Damian myerscough
=
= Returns:A Chart
=
= Assumes:This code uses Win32::OLE
=
=This code is copyrighted and has= limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=444&lngWId=6=for details.=**************************************

#!/usr/bin/perl
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Excel';
my $Excel = Win32::OLE->new("Excel.Application");
$Excel->{Visible} = 1;
my $Book = $Excel->Workbooks->Add;
my $Sheet = $Book->Worksheets(1);
# Range Length satrts at: A1 and finishes at: H3
my $Range = $Sheet->Range("A1:H3");
 
 # My Value range which was on the survay 
$Range->{Value} =
[['My primary source of Linux help/support/advice',
'My local Linux User Group', 
'IRC channel (Which one - post, please)',
'Web forum (Which one - post, please)', 
'The companys sysadmins handle all that stuff',
'If I get stuck Linus comes to my house and helps me out ',
'I never need help. When Linus gets stuck, I help *him* out',
'RTFM; I use man pages books and other references most of the time',
'Now and then I hop on an email list or newsgroup (Which one? - post, please)'
],
 # My Results off the survay
[328, 301, 368, 33, 400, 346, 2634, 242]];
my $Chart = $Excel->Charts->Add;
 # Select what type of chart you want
$Chart->{ChartType} = xlAreaStacked;
$Chart->SetSourceData({Source => $Range, PlotBy => xlColumns});
$Chart->{HasTitle} = 1; 
 # Give the Chart a Title
$Chart->ChartTitle->{Text} = "This Survay was off Linux.com";


Other 35 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

4/21/2003 3:56:33 PMICode

How about a chart that reads a csv file for it's values? I am new to Perl and have no idea how to read the csv file or parse it for the data. Eventually I will learn how to do this.
(If this comment was disrespectful, please report it.)

 
6/10/2009 5:03:50 AMdinhchung82

thanks for this code !
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.