PHPOffice / PHPExcel

ARCHIVED
Other
11.46k stars 4.2k forks source link

unalbe to get date type correctly while exporting Numbers to excel #1241

Open weidacat opened 7 years ago

weidacat commented 7 years ago

Hi

On my Mac Os, I exported Numbers to Excel, In which sheet, I had a date type column. But when I use "load" function in Classes/PHPExcle/Reader/Excel2007.php, I found a mistake.

this is the styles.xml when I unzip my excel from Numbers '\<numFmt numFmtId="59" formatCode="yyyy-mm-dd"\/>'

this is the styles.xml when I unzip my excel from google excel '\<numFmt numFmtId="164" formatCode="yyyy-mm-dd"\/>'

this is the code of my phpexcel:1.8.0, in Classes/PHPExcle/Reader/Excel2007.php. if ($xf["numFmtId"]) { if (isset($numFmts)) { $tmpNumFmt = self::array_item($numFmts->xpath("sml:numFmt[@numFmtId=$xf[numFmtId]]"));

    if (isset($tmpNumFmt["formatCode"])) {
        $numFmt = (string) $tmpNumFmt["formatCode"];
    }
}

if ((int)$xf["numFmtId"] < 164) {
    $numFmt = PHPExcel_Style_NumberFormat::builtInFormatCode((int)$xf["numFmtId"]);
}

}

From the code, we can see, using the 'formatCode', I can get the '$numFmt' correctly, But the 'numFmtId' in the styles.xml from Numbers is '59', so I get the result of '$numFmt' is 't0', but not ''yyyy-mm-dd. And when I using the 'rangeToArray' function in Classes/PHPExcle/Reader/Excel2007.php, I can't get the date type correctly.