dongwuge6201 2015-01-24 11:20
浏览 57

使用PHPExcelReader进行Excel文件解析问题

I am facing a peculiar problem in parsing an excel file (.xls) using PHPExcelReader which actually Spreadsheet_Excel_Reader class. I have used it so many times in different applications and every time I was fine. I am working for an app where there is a ftp folder and an excel file is remotely put there every day. I have a scheduler task that runs every day and read the excel file and update the database.

It was working very fine for couple of months. Now they are adding some new columns in the files and the Spreadsheet_Excel_Reader is unable to read the numeric and date values. But if I just open the file and hit CTRL+S without doing anything, svn says that the file has been modified although I don't see anything changed from 'SVN: Diff with previous version'. However it is doing the magic as I see that the saved file is parsed correctly. Bellow is the result I see when I try to run the script without touching the file. Please look at index 5 to 9. Parsed result with the untouched excel file

Now look at the parse result when I run the script after opening the file and hit CTRL+S. Now entirely sure what is happening. I contacted to them and they said they are not doing anything new. Parse result after hitting CTRL+S which is correct

Any idea about this problem? Sharing the idea here is much appreciated.

  • 写回答

1条回答 默认 最新

  • dtysql0586 2015-01-25 17:37
    关注

    How are you looping through and grabbing the cell values? Have you tried using $cell->val(12,6)? An alternative could be (Thanks to Mark Baker):

    $range = 'F'.$row.':'.'J'.$row; # assuming F-J cols are your numeric cols
    $objPHPExcel->getActiveSheet()
        ->getStyle($range)
        ->getNumberFormat()
        ->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大