Here's the code. Not much to it.
<?php
include("Spreadsheet/Excel/Writer.php");
$xls = new Spreadsheet_Excel_Writer();
$sheet = $xls->addWorksheet('At a Glance');
$colNames = array('Foo', 'Bar');
$sheet->writeRow(0, 0, $colNames, $colHeadingFormat);
for($i=1; $i<=10; $i++)
{
$row = array( "foo $i", "bar $i");
$sheet->writeRow($rowNumber++, 0, $row);
}
header ("Expires: " . gmdate("D,d M Y H:i:s") . " GMT");
header ("Last-Modified: " . gmdate("D,d M Y H:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
$xls->send("test.xls");
$xls->close();
?>
The issue is that I get the following error when I actually open the file with Excel:
File error: data may have been lost.
Even stranger is the fact that, despite the error, the file seems fine. Any data I happen to be writing is there.
Any ideas on how to get rid of this error?
Edit
I've modified the code sample to better illustrate the problem. I don't think the first sample was a legit test.