vog / php-excel-reader2

Automatically exported from code.google.com/p/php-excel-reader2
0 stars 0 forks source link

Dates from OpenOffice #4

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Save an excel file in open office with date formatted columns
2. Read the file with php-excel-reader2
3. Look at the date columns

What is the expected output? What do you see instead?

Expected output is the date in the same format as excel.
Instead it seems to use the format "DD\-MMM\-YY", which when run through 
gmdate on line 78 produces MONMON-MAYMAYMAY-20092009

What version of the product are you using? On what operating system?

Using version 2.22
PHP 5.3

To get around the problem I've just made the default date format 'c', 
meaning gmdate gives me a standard ISO date back.

Surely there could be a fallback for this? Why doesn't the script use 
$dateFormats if they are defined?

Original issue reported on code.google.com by arron.wo...@gmail.com on 10 Mar 2010 at 3:19

GoogleCodeExporter commented 9 years ago
I also have the same problem.

Original comment by Radbi...@gmail.com on 5 Jul 2010 at 4:18

GoogleCodeExporter commented 9 years ago
Fix that worked for me:
function ooodate(&$excel_reader,$row,$col) {
  $date = new DateTime('1904/1/1'); //base date for OpenOffice xls
  $date->modify('+'.$excel_reader->raw($row,$col).' days');
  return $date->format('d-m-Y'); //or whatever format you want.
}

I used it in another file, but it should be similar to include it in the class, 
I just don't have the time at present.

Original comment by EagleG...@gmail.com on 3 Aug 2010 at 7:10