Skip Menu |

This queue is for tickets about the Spreadsheet-Read CPAN distribution.

Report information
The Basics
Id: 80409
Status: resolved
Priority: 0/
Queue: Spreadsheet-Read

People
Owner: Nobody in particular
Requestors: cpan [...] ch.pkts.ca
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: (no value)
Fixed in: 0.48



Subject: Date format problem
Date: Thu, 25 Oct 2012 23:08:26 -0700
To: bug-Spreadsheet-Read [...] rt.cpan.org
From: ch <cpan [...] ch.pkts.ca>
Hello! I'm enjoying the flexibility of Spreadsheet::Read! Now I don't have to care what file format I'm given, it just works! 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. 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. :-) Thanks again for a great module!
Subject: Re: [rt.cpan.org #80409] Date format problem
Date: Fri, 26 Oct 2012 08:39:24 +0200
To: bug-Spreadsheet-Read [...] rt.cpan.org
From: "H.Merijn Brand" <h.m.brand [...] xs4all.nl>
On Fri, 26 Oct 2012 02:08:59 -0400, "ch via RT" <bug-Spreadsheet-Read@rt.cpan.org> wrote: Show quoted text
> 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 Show quoted text
> 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 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)}; And I don't know in what section I would put it, as I already think it was documented enough. Show quoted text
> Thanks again for a great module!
-- H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/ using perl5.00307 .. 5.17 porting perl5 on HP-UX, AIX, and openSUSE http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/
Subject: Re: [rt.cpan.org #80409] Date format problem
Date: Fri, 26 Oct 2012 00:00:21 -0700
To: bug-Spreadsheet-Read [...] rt.cpan.org
From: Charles Howes <ch [...] pkts.ca>
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!
>
Subject: Re: [rt.cpan.org #80409] Date format problem
Date: Fri, 26 Oct 2012 10:16:44 +0200
To: bug-Spreadsheet-Read [...] rt.cpan.org
From: "H.Merijn Brand" <h.m.brand [...] xs4all.nl>
On Fri, 26 Oct 2012 03:00:47 -0400, "Charles Howes via RT" <bug-Spreadsheet-Read@rt.cpan.org> wrote: Show quoted text
> > On Fri, 26 Oct 2012 02:08:59 -0400, "ch via RT" > > <bug-Spreadsheet-Read@rt.cpan.org> wrote: > >
> > > 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 > } > }
my @rows = Spreadsheet::Read::rows ($ref->[1]); is the documented way to do this for unformatted values, I could add a feature to do it formatted. As currently, 'rows ()' is implemented more or less like this: my @rows = map { my $r = $_; [ map { $s->[$_][$r] } 1..$sheet->{maxcol} ]; } 1..$sheet->{maxrow}; changing the inner map to return the formatted values is rather simple Show quoted text
> 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?
I don't know, as the format is not implemented from Spreadsheet::Read's point of view, but in the underlying parser. Might be a bug in the parser you use. You never stated the source format. (FWIW, using a / as date sep char is evil on its own :) I'd choose YYYYMMDD or DD-MM-YYYY). 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];
I can have a look at the examples and choose better names $ref being the top level and $sheet being a singe sheet 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!
-- H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/ using perl5.00307 .. 5.17 porting perl5 on HP-UX, AIX, and openSUSE http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/