doxd96148 2015-04-13 20:24
浏览 41


I have an XLSX file with some cells that has a date value like: 13/04/2015 when I convert my XLSX to CSV the date value in my CSV becomes its value as: 42107

I need that the value be the same in both files like in XLSX (13/04/2015)

Here's my convert script

include ('./PHPExcel/Classes/PHPExcel.php');
$FilePath= "./assets/uploads/files/prf.xlsx";
$objReader = PHPExcel_IOFactory::createReader($TypeFile);
$objExcel = $objReader->load($FilePath);
$objCSV = PHPExcel_IOFactory::createWriter($objExcel, 'CSV');
  • 写回答

1条回答 默认 最新

  • douduiwei2831 2015-04-13 20:29

    Yes, it will

    A date in MS Excel is a number value like 42107, that represents a number of days since 1st January 1900, and the only thing that tells MS Excel (or PHPExcel) that it should be treated as a date is the number format mask that's applied to that cell.

    When you use


    you're telling PHPExcel to read the raw data values from the cells, and ignore any number format masks (or indeed any styling) for cells, so that's what you're getting.

    If you want PHPExcel to treat the value as a date, then don't use $objReader->setReadDataOnly(true);

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!