Skip Menu |
 
rt.cpan.org will be shut down on March 1st, 2021.

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

Report information
The Basics
Id: 23600
Status: new
Priority: 0/
Queue: Spreadsheet-ParseExcel-Simple

People
Owner: Nobody in particular
Requestors: chagglund [...] shrinkingplanet.ca
Cc:
AdminCc:

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



Subject: Spreadsheet::ParseExcel::Simple mod allowing for obtaining unformatted values from the next_row
Date: Fri, 24 Nov 2006 11:08:21 -0500
To: bug-Spreadsheet-ParseExcel-Simple [...] rt.cpan.org
From: Chris Hagglund <chagglund [...] shrinkingplanet.ca>
Download (untitled) / with headers
text/plain 1.5k
Just passing this along in case you or your users are interested. I made this mod b/c our client likes to send us xls files to load into the db but with all kind of stupid formatting applied that makes us need to access unformatted values for some fields. Since I was using your module already I figured I could just modify it to allow for that. The changes seem to work properly, though it might blow up if the new arguments are specified incorrectly. Meh, works for me :) though maybe it moves things slightly out of the realm of "Simple". - Chris. Your original: sub next_row { map { $_ ? $_->Value : "" } @{$_[0]->{sheet}->{Cells}[$_[0]->{row}++]}; } My modification: sub next_row { my $cc = 0; #cellcount map { $cc++; $_ ? ((defined($_[1]) && (($_[1]->{Val} && $_[1]->{Val}->{$cc-1}) || $_[1]->{AllAsVal})) ? $_->{Val} : $_->Value) : "" } @{$_[0]->{sheet}->{Cells}[$_[0]->{row}++]}; } With added documentation: Now with the ability to get the next_row but with base values instead of formatted values. By default, it will still obtain all formatted values. But now you can pass a hashref as an argument to next_row and depending what you ask for either get certain cells back unformatted, or get all the cells back unformatted. For regular old behavior, nothing changes and you call it like: my @data = $sheet->next_row(); To ask for just cells 3 and 7 to be unformatted (counting from 0), calling it like this will do the job: my @data = $sheet->next_row({Val=>{3=>1,7=>1}}); To ask for all of the cells to be unformatted: my @data = $sheet->next_row({AllAsVal=>1});


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.