On Fri, 26 Oct 2012 02:39:38 -0400
"h.m.brand@xs4all.nl via RT" <bug-Spreadsheet-Read@rt.cpan.org> wrote:
Show quoted text> <URL:
https://rt.cpan.org/Ticket/Display.html?id=80409 >
>
> On Fri, 26 Oct 2012 02:08:59 -0400, "ch via RT"
> <bug-Spreadsheet-Read@rt.cpan.org> wrote:
>
> > I'm enjoying the flexibility of Spreadsheet::Read! Now I don't
> > have to care what file format I'm given, it just works!
>
> Thanks
>
> > I found a small problem with dates, though: while the date is
> > correct in the 'A1' section, it's just a number in the
> > {'cell'}[0][0] array, Excel's internal format for dates.
>
> That is as it is documented:
>
> The "cell" hash entry contains unformatted data, while the hash
> entries with the traditional labels contain the formatted values
> (if applicable).
>
> See
>
http://search.cpan.org/dist/Spreadsheet-Read/Read.pm#Data_structure
Ah, didn't see that.
I ended up doing this:
my @rows;
for (my $x=1;$x<=$ref->[1]{'maxcol'};$x++) { # A B C D ...
for (my $y=1;$y<=$ref->[1]{'maxrow'};$y++) { # 1 2 3 4 ...
$rows[$y-1][$x-1]=($ref->[1]{cr2cell($x,$y)})||""; # Note x-y swap
}
}
On a related note, in the formatted values, my dates are showing up in
'mm/dd/yy' format (evil format), even though I set 'dtfmt=>'yyyy/mm/dd'.
What am I doing wrong?
Show quoted text> > Also, while it might seem silly, perhaps you could include a short
> > code fragment for accessing the cell data in the documentation? It
> > took me longer than I expected to get it right. :-)
>
> As it took you a while, can you post me what *you* did, as that might
> be the most intuitive way someone else might want to be doing it. This
> would be what I would include to explain what you are/were looking
> for:
>
> $unformatted = $ss->{cell}[4][14];
> $formatted = $ss->{D14};
> $formatted = $ss->{cr2cell (4, 14)};
I briefly looked at the documentation, saw this example:
my $a3 = $ref->[1]{A3}, "\n"; # content of field A3 of sheet 1
and jumped to the conclusion:
my $a3 = $ref->[1][1][3];
although in hindsight hashes and arrays can't be mixed like that, and
[1]{1}[3] would have looked daft. Just put this example in the
synopsis:
my $unformatted_a3 = $ref->[1]{cell}[1][3];
I didn't grasp the distinction between $ss and $ref, mainly because $ss
isn't defined anywhere that I could see:
my $ss = $ref->[1];
Show quoted text> And I don't know in what section I would put it, as I already think it
> was documented enough.
>
> > Thanks again for a great module!
>