2004-09-10 12:10:07 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
set_time_limit(10);
|
|
|
|
|
|
|
|
|
|
require_once "class.writeexcel_workbook.inc.php";
|
|
|
|
|
require_once "class.writeexcel_worksheet.inc.php";
|
|
|
|
|
|
2006-01-27 21:52:08 +01:00
|
|
|
$fname = tempnam("/tmp", "simple.xls");
|
2004-09-10 12:10:07 +02:00
|
|
|
$workbook = &new writeexcel_workbook($fname);
|
|
|
|
|
$worksheet = &$workbook->addworksheet();
|
|
|
|
|
|
|
|
|
|
# The general syntax is write($row, $column, $token). Note that row and
|
|
|
|
|
# column are zero indexed
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
# Write some text
|
|
|
|
|
$worksheet->write(0, 0, "Hi Excel!");
|
|
|
|
|
|
|
|
|
|
# Write some numbers
|
|
|
|
|
$worksheet->write(2, 0, 3); # Writes 3
|
|
|
|
|
$worksheet->write(3, 0, 3.00000); # Writes 3
|
|
|
|
|
$worksheet->write(4, 0, 3.00001); # Writes 3.00001
|
|
|
|
|
$worksheet->write(5, 0, 3.14159); # TeX revision no.?
|
|
|
|
|
|
2006-01-27 21:52:08 +01:00
|
|
|
# Write two formulas
|
|
|
|
|
$worksheet->write(7, 0, '=A3 + A6');
|
|
|
|
|
$worksheet->write(8, 0, '=IF(A5>3,"Yes", "No")');
|
2004-09-10 12:10:07 +02:00
|
|
|
|
|
|
|
|
# Write a hyperlink
|
2006-01-27 21:52:08 +01:00
|
|
|
$worksheet->write(10, 0, 'http://www.php.net/');
|
2004-09-10 12:10:07 +02:00
|
|
|
|
|
|
|
|
$workbook->close();
|
|
|
|
|
|
2006-01-27 21:52:08 +01:00
|
|
|
header("Content-Type: application/x-msexcel; name=\"example-simple.xls\"");
|
|
|
|
|
header("Content-Disposition: inline; filename=\"example-simple.xls\"");
|
2004-09-10 12:10:07 +02:00
|
|
|
$fh=fopen($fname, "rb");
|
|
|
|
|
fpassthru($fh);
|
|
|
|
|
unlink($fname);
|
|
|
|
|
|
|
|
|
|
?>
|