我使用PhpExcelReader--
include 'excel\_reader.php'; // include the class// 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
发布于 2015-01-19 21:25:51
Excel中的日期字段是“自1900年1月0日以来的天数”,而PHP中的时间是“自1970年1月1日00:00以来的秒数”。从那里转换应该很容易。
发布于 2015-01-19 21:31:20
使用此处详细介绍的此函数https://phpexcel.codeplex.com/discussions/219301
$PHPDate = PHPExcel_Shared_Date::ExcelToPHP($cell);
echo date("Y-m-d", $PHPDate);https://stackoverflow.com/questions/28025543
复制相似问题