Having a related issue. I am able to convert the date fine when I know it is a date. My issue is identifying the cell as a date when it has a custom date format. There is not an apparent way for me to know whether the cell is a date value to convert or an actual number as none of the cell attributes tells me it is a date.
Excel cell has a custom number/date format of "mm/dd/yyyy" and a value of "07/20/2014".
Code below shows my issue:
my ( $cell, $col, $k, $row, $sheet );
my $workbook = Spreadsheet::XLSX->new( "test.xlsx" );
foreach $sheet ( @{ $workbook->{Worksheet} } ) {
$sheet->{MaxRow} ||= 0; #$sheet->{MinRow};
$sheet->{MaxCol} ||= 0; #$sheet->{MinCol};
next if ( $sheet->{MaxRow} == 0 and $sheet->{MaxCol} == 0 );
foreach $row ( $sheet->{MinRow} .. $sheet->{MaxRow} ) {
foreach $col ( $sheet->{MinCol} .. $sheet->{MaxCol} ) {
$cell = $sheet->{Cells}[$row][$col];
if ($cell) {
foreach $k ( keys %{$cell} ) {
print "cell{$k}=$cell->{$k}\n";
}
}
}
}
}
Results:
cell{Type}=Numeric
cell{Val}=41840
cell{_Value}=41840
cell{Format}=
In the original Spreadsheet::ParseExcel the $cell{Type} attribute above returns "Date".
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.