From 9cf7419380a812d1bbacb74018c111a7e77cb5ac Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 1 May 2013 12:25:42 -0500 Subject: handle types a bit better --- lib/Spreadsheet/Template/Generator/Parser/Excel.pm | 30 ++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'lib/Spreadsheet/Template/Generator/Parser/Excel.pm') 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; -- cgit v1.2.3-54-g00ecf