summaryrefslogtreecommitdiffstats
path: root/lib/Spreadsheet/Template/Generator/Parser/Excel.pm
diff options
context:
space:
mode:
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;