From 940ac69408ea7a98795652b8fcb5c6045528ac2e Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 5 Jun 2013 12:55:18 -0500 Subject: introspect datetime cells from the num format too --- lib/Spreadsheet/ParseXLSX.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/Spreadsheet/ParseXLSX.pm b/lib/Spreadsheet/ParseXLSX.pm index 880d2e0..71af8fe 100644 --- a/lib/Spreadsheet/ParseXLSX.pm +++ b/lib/Spreadsheet/ParseXLSX.pm @@ -132,10 +132,19 @@ sub _parse_sheet { die "unimplemented type $type"; # XXX } + my $format = $sheet->{_Book}{Format}[$cell->att('s') || 0]; + + # see the list of built-in formats below in _parse_styles + # XXX probably should figure this out from the actual format string, + # but that's not entirely trivial + if (grep { $format->{FmtIdx} == $_ } 14..22, 45..47) { + $long_type = 'Date'; + } + $sheet->{Cells}[$row][$col] = Spreadsheet::ParseExcel::Cell->new( Val => $val, Type => $long_type, - Format => $sheet->{_Book}{Format}[$cell->att('s') || 0], + Format => $format, ($cell->first_child('f') ? (Formula => $cell->first_child('f')->text) : ()), -- cgit v1.2.3-54-g00ecf