summaryrefslogtreecommitdiffstats
path: root/lib/Spreadsheet/Template/Generator/Parser/Excel.pm
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-05-01 12:25:42 -0500
committerJesse Luehrs <doy@tozt.net>2013-05-01 12:30:20 -0500
commit9cf7419380a812d1bbacb74018c111a7e77cb5ac (patch)
tree8bba295fd364c81a5f8cd0b30cbba483877d3adf /lib/Spreadsheet/Template/Generator/Parser/Excel.pm
parent9824fd56633cc3cf4b65aa5c1585805e6fc447f3 (diff)
downloadspreadsheet-template-9cf7419380a812d1bbacb74018c111a7e77cb5ac.tar.gz
spreadsheet-template-9cf7419380a812d1bbacb74018c111a7e77cb5ac.zip
handle types a bit better
Diffstat (limited to 'lib/Spreadsheet/Template/Generator/Parser/Excel.pm')
-rw-r--r--lib/Spreadsheet/Template/Generator/Parser/Excel.pm30
1 files changed, 28 insertions, 2 deletions
diff --git a/lib/Spreadsheet/Template/Generator/Parser/Excel.pm b/lib/Spreadsheet/Template/Generator/Parser/Excel.pm
index 4638a8b..1aed4a8 100644
--- a/lib/Spreadsheet/Template/Generator/Parser/Excel.pm
+++ b/lib/Spreadsheet/Template/Generator/Parser/Excel.pm
@@ -72,10 +72,36 @@ sub _parse_cell {
my $self = shift;
my ($cell) = @_;
+ my %types = (
+ 'Numeric' => 'number',
+ 'Text' => 'string',
+ 'Date' => 'date_time',
+ );
+
+ my $contents = $cell->unformatted;
+ my $type = $cell->type;
+
+ if ($type eq 'Numeric') {
+ $type = 'number';
+ }
+ elsif ($type eq 'Text') {
+ if ($contents =~ /^=/) {
+ $type = 'formula';
+ }
+ else {
+ $type = 'string';
+ }
+ }
+ elsif ($type eq 'Date') {
+ $type = 'date_time';
+ }
+ else {
+ die "unknown type $type";
+ }
my $data = {
- contents => $self->_filter_cell_contents($cell->unformatted),
- type => $cell->type,
+ contents => $self->_filter_cell_contents($contents, $type),
+ type => $type,
};
return $data;