When I run the program shown here:
#!C:\strawberry\perl\bin\perl.exe
use strict;
use warnings;
use Spreadsheet::ParseExcel;
use Spreadsheet::ParseExcel::SaveParser;
# Specify cell H2’s row and col
my $row = 1;
my $col = 7;
my $worksheet_num = 0;
# Create a parser that can read/write/display cells in an existing Exc
+el spreadsheet
my $parser = Spreadsheet::ParseExcel::SaveParser->new();
if ($parser) {
print "parser is defined\n";
} else {
print "parser is NOT defined\n";
}
# Parse the ‘Build_Scheduler.xlsx’ spreadsheet
my $template = $parser->Parse('Build_Scheduler.xlsx');
if ($template) {
print "template is defined\n";
} else {
print "template is NOT defined\n";
}
# Specify leftmost tab (“0”) as the worksheet to be modified
my $worksheet = $template->worksheet(0) || die("$@$!");
# Overwrite the AsOf string value in tab = “Monday”, cell H2. (05/05/2
+016 2:00PM is replaced by 05/05/2016 2:00PM)
$worksheet->AddCell( $row, $col, '05/12/2016 2:00PM' );
I find the the call to my $template $parser->Parse('Build_Scheduler.xlsx') fails and returns "undefined", causing the later call my $worksheet = $template->worksheet(0) to fail.
My Perl version is Strawberry 5.18.1001
Can someone let me know why my
$template = $parser->Parse('Build_Scheduler.xlsx'); is failing?
Currently I see no syntax or logic errors in the above program.
I am following the CPAN examples for the relevant modules exactly.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.