0

我使用 PhpExcelReader——
包括 'excel_reader.php';// 包含类

// creates an object instance of the class, and read the excel file data
$excel = new PhpExcelReader;

数据读取和函数调用——

$excel->read('test.xls');
sheetData($excel->sheets[0]);

功能码--

function sheetData($sheet) 
{
    while($x <= $sheet['numRows']) 
    {
        if(@$sheet['cells'][$x][1])
        {
            while($y <= $sheet['numCols']) 
            {
                $cell = isset($sheet['cells'][$x][$y]) ? $sheet['cells'][$x][$y] : '';
                echo $cell = @date($cell)."<br/>";
            }
         }
     }
}

它只显示像 36400 这样的数字
然后我尝试了

echo $cell = @date("Y-m-d",$cell)."<br/>";

但它显示默认值,如 1970-01-01
但我的数据 2004-05-12

4

2 回答 2

0

The Date field in Excel is "Number of days since Jan 0 1900", where as the time in PHP is "Number of Seconds since Jan 01 1970 00:00". Conversion should be pretty easy from there.

于 2015-01-19T13:25:50.687 回答
0

使用此处详细介绍的此功能https://phpexcel.codeplex.com/discussions/219301

$PHPDate = PHPExcel_Shared_Date::ExcelToPHP($cell);
echo date("Y-m-d", $PHPDate);
于 2015-01-19T13:31:19.913 回答