require_once 'Spreadsheet/Excel/Writer.php';
$workbook = new Spreadsheet_Excel_Writer();
$worksheet =& $workbook->addWorksheet();
// We'll show dates with a three letter month and four digit year format
$date_format =& $workbook->addFormat();
$date_format->setNumFormat('D-MMM-YYYY');
// number of seconds in a day
$seconds_in_a_day = 86400;
// Unix timestamp to Excel date difference in seconds
$ut_to_ed_diff = $seconds_in_a_day * 25569;
// show Excel's day zero date
$worksheet->write(0, 0, "Excel's day zero");
$worksheet->write(0, 1, 0, $date_format);
// show today's date
$now = time();
$worksheet->write(1, 0, "Today's date:");
$worksheet->write(1, 1, ($now + $ut_to_ed_diff) / $seconds_in_a_day, $date_format);
$workbook->send('num_formatting.xls');
$workbook->close(); |