0

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.

Mohaimen
  • 159
  • 1
  • 3
  • 12

1 Answers1

0

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);
NightOwlPrgmr
  • 1,322
  • 3
  • 21
  • 31
  • Thanks a lot @NightOwlPrgmr for your answer. No, I haven't tried your way but this is how I do it: `$fileData = new Spreadsheet_Excel_Reader($productFile, false); $data = $fileData->dumpToArray(true, true); unset($data[0]); echo '
    ';
    print_r($data);
    echo '
    '; for($r=0; $r
    – Mohaimen Jan 26 '15 at 11:46