Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use date format detection based on Spreadsheet::XLSX #67

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/Spreadsheet/ParseXLSX.pm
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ sub _parse_sheet {

my $format_idx = $cell->att('s') || 0;
my $format = $sheet->{_Book}{Format}[$format_idx];
my $formatstr = $sheet->{_Book}{FormatStr}{$format->{FmtIdx}};
die "unknown format $format_idx" unless $format;

# see the list of built-in formats below in _parse_styles
Expand All @@ -436,6 +437,10 @@ sub _parse_sheet {
$long_type = 'Date';
}

if ($formatstr =~ /\b(mmm|m|d|yy|h|hh|mm|ss)\b/i) {
$long_type = 'Date';
}

my $formula = $cell->first_child('s:f');
my $cell = Spreadsheet::ParseExcel::Cell->new(
Val => $val,
Expand Down