Re: spreadsheet_excel_writer Cannot modify header information error

From: Date: Wed, 04 Oct 2006 14:44:26 +0000
Subject: Re: spreadsheet_excel_writer Cannot modify header information error
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-25344@lists.php.net to get a copy of this message
David Shumway wrote:
Hi, This is my first time using pear so I'm not totally sure about all this. Basically, I'm trying to use spreadsheet_excel_writer to create xls files. So I installed pear and then installed OLE-0.5 and spreadsheet_excel_writer 0.9.1. I'm running php version 4.4.4. Here's my code: <?php phpinfo(); require_once 'Spreadsheet/Excel/Writer.php'; // Creating a workbook $workbook = new Spreadsheet_Excel_Writer(); // sending HTTP headers $workbook->send('test.xls'); // Creating a worksheet $worksheet =& $workbook->addWorksheet('My first worksheet'); // The actual data $worksheet->write(0, 0, 'Name'); $worksheet->write(0, 1, 'Age'); $worksheet->write(1, 0, 'John Smith'); $worksheet->write(1, 1, 30); $worksheet->write(2, 0, 'Johann Schmidt'); $worksheet->write(2, 1, 31); $worksheet->write(3, 0, 'Juan Herrera'); $worksheet->write(3, 1, 32); // Let's send the file $workbook->close(); ?> When I run this I get the following error: *Warning*: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test.php:2) in * C:\PHP\pear\Spreadsheet\Excel\Writer.php* on line *67 *and then below this a bunch of weird characters. Can you help? Thanks. :)
Remove the phpinfo(); line. It's failing because you've already output data to the client by the time the script gets to the send() line ("sending HTTP headers"). b

« previous php.pear.general (#25344) next »