in reply to Spreadsheet::XSLX parsing workbook, but not retrieving values from cells
Hello divyahk, and welcome to the Monastery!
There are two problems with your code as posted:
You have use Spreadsheet::Read; instead of use Spreadsheet::XLSX;.
In various places single- and double-quote characters are non-ASCII and so not recognised by the Perl parser.
With these issues fixed, your code works fine for me:
I created an Excel file called xyz.xlsx, containing one worksheet named Paper.1, and populated that worksheet as follows:
A B 1 Number Name 2 1 Fred 3 15 Barney 4 27 Homer
Running this script:
#! perl use strict; use warnings; use Spreadsheet::XLSX; use Data::Dump; my $excel = Spreadsheet::XLSX->new('xyz.xlsx'); if (!defined $excel) { die "Error: " . $excel->error() . "\n"; } print "Read with Spreadsheet::XSLX\n"; dd $excel;
gives this output:
21:43 >perl 1017_SoPW.pl Read with Spreadsheet::XSLX bless({ Flg1904 => 0, FmtClass => bless({}, "Spreadsheet::XLSX::Fmt2007"), SheetCount => 1, Worksheet => [ bless({ Cells => [ [ bless({ _Value => "Number", For +mat => "", Type => "Text", Val => "Number" }, "Spreadsheet::ParseExce +l::Cell"), bless({ _Value => "Name", Forma +t => "", Type => "Text", Val => "Name" }, "Spreadsheet::ParseExcel::C +ell"), ], [ bless({ _Value => 1, Format => +"", Type => "Numeric", Val => 1 }, "Spreadsheet::ParseExcel::Cell"), bless({ _Value => "Fred", Forma +t => "", Type => "Text", Val => "Fred" }, "Spreadsheet::ParseExcel::C +ell"), ], [ bless({ _Value => 15, Format => + "", Type=> "Numeric", Val => 15 }, "Spreadsheet::ParseExcel::Cell"), bless({ _Value => "Barney", For +mat => "", Type => "Text", Val => "Barney" }, "Spreadsheet::ParseExce +l::Cell"), ], [ bless({ _Value => 27, Format => + "", Type=> "Numeric", Val => 27 }, "Spreadsheet::ParseExcel::Cell"), bless({ _Value => "Homer", Form +at => "",Type => "Text", Val => "Homer" }, "Spreadsheet::ParseExcel:: +Cell"), ], ], DefColWidth => 8.43, MaxCol => 1, MaxRow => 3, MinCol => 0, MinRow => 0, Name => "Paper.1", path => "worksheets/sheet1.xml", }, "Spreadsheet::ParseExcel::Worksheet"), ], }, "Spreadsheet::ParseExcel::Workbook") 21:43 >
— so all the cells are being read correctly.
Perhaps the file being read is actually empty after all?
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Spreadsheet::XSLX parsing workbook, but not retrieving values from cells
by divyahk (Initiate) on Sep 17, 2014 at 12:38 UTC | |
by Tux (Canon) on Sep 17, 2014 at 12:47 UTC | |
by divyahk (Initiate) on Sep 18, 2014 at 10:38 UTC |