
September 8th, 2006, 06:44 PM
|
 |
Contributing User
|
|
Join Date: Apr 2007
Location: Cape Cod
Posts: 1,347
Time spent in forums: 3 h 52 m 2 sec
Reputation Power: 4
|
|
|
RE: Spreadsheet_Excel_Writer
You need to use the formatting feature to specify the number format for a date and then calculate the number of days since 12/30/1899.
php Code:
Original
- php Code |
|
|
|
// set up workbook and a sheet $xls =& new Spreadsheet_Excel_Writer(); $xls->send('example.xls'); $sheet =& $xls->addWorksheet('Sheet1'); // define date format $dateFormat =& $xls->addFormat(); $dateFormat->setNumFormat('M/D/YYYY'); // calculate date and write $date_num = Date_Calc:: dateToDays(date('d'), date('m'), date('Y')) - Date_Calc:: dateToDays(30, 12, 1899); $sheet->write(0, 0, $date_num, $dateFormat);
I'm using PEAR's Date_Calc class to do the calculation.
Note: the single tick in your post is because that is how Excel specifies "treat this number as text."
|