tags:

views:

41

answers:

1

Hi All , 1)I have been working on fetching data from an excel sheet i can see on a cell written "Oct-10" but when i select it i see "10/31/2000" on fx column right at top ,when i fetch data from the .xls sheet using http://phpexcel.codeplex.com library version number 1.7.3 ,it is returning float("40482") , can any body tell how to convert it to either "10/31/2000"/"Oct-10" all the cells other than this one are reading correctly so there is no error in code.

2)Also Please tell how can i get a better tutorial for this library as one provided on this site is not very helpful or i am using wrong library. thanks in advance

+2  A: 

See answer to this question http://stackoverflow.com/questions/2988201/days-since-1900 or read section 3.2 (and specifically 3.2.3) in the not very helpful "PHPExcel Function Reference Developer Documentation" which describes exactly how to convert between Excel dates and PHP dates (or PHP date/time objects).

The function you're after is:

$PHPdateValue = PHPExcel_Shared_Date::ExcelToPHP($excelDateValue);

or

$PHPdateObject = PHPExcel_Shared_Date::ExcelToPHPObject($excelDateValue);

There are links to a number of tutorials in a variety of languages on the documents section of the PHPExcel website. And in addition to the documentation, there's plenty of code examples in the /Tests subdirectory of the distribution

Example of returning a PHP date/time object: include 'PHPExcel.php';

$excelDateValue = 40482.0;
$dateObj = PHPExcel_Shared_Date::ExcelToPHPObject($excelDateValue);

echo $dateObj->format('Y-m-d H:i:s');

displays

2010-10-31 00:00:00
Mark Baker
Hi ,$PHPdateObject = PHPExcel_Shared_Date::ExcelToPHPObject($excelDateValue); is not working but it did solved my problem the link u have given to me tankyou very very much , thank u mark :)
Extjs Commander
In what way is $PHPdateObject = PHPExcel_Shared_Date::ExcelToPHPObject($excelDateValue); not working?
Mark Baker