PDA

View Full Version : PEAR: Spreadsheet_Excel_Writer - no output



DHDesign
March 2nd, 2007, 11:00 AM
i recently installed the pear package Spreadsheet_Excel_Writer...the package installed successfully (beta version since no stable is available) and also the OLE package was installed too. I took the following sample script from a tutorial site and when I run it, I get an Excel file but it has no values in the table (all blank).

The class is being found properly because if I don't include the require_once, then all I get is a blank screen.

Any thoughts? Please, this is urgent...




<?php

// Include PEAR::Spreadsheet_Excel_Writer
require_once "Spreadsheet/Excel/Writer.php";

// Create an instance
$xls =& new Spreadsheet_Excel_Writer();

// Send HTTP headers to tell the browser what's coming
$xls->send("test.xls");

// Add a worksheet to the file, returning an object to add data to
$sheet =& $xls->addWorksheet('Binary Count');

// Write some numbers
for ( $i=0;$i<11;$i++ ) {
// Use PHP's decbin() function to convert integer to binary
$sheet->write($i,0,decbin($i));
}

// Finish the spreadsheet, dumping it to the browser
$xls->close();

?>

DHDesign
March 4th, 2007, 04:18 PM
any thoughts at all?
I've posted on every forum I can, and no one seems to have any answers.

If it helps:

Spreadsheet_Excel_Writer 0.9.1 (tried it with 0.7 & 0.8 too)
OLE 0.5 (I tried it with 0.4 & 0.3 too)
PHP 4.3.9

Please help.
Thanks.

DHDesign
March 5th, 2007, 05:48 PM
thanks for the responses (lol)...anyway, just for future reference for anyone else, the OLE package of PEAR requires a temp directory to be accessible for the Excel file to be written to until the user downloads the file...so the easy solution is to set the temp dir using the setTempDir function.

bwh2
March 5th, 2007, 05:51 PM
so that solved your problem?

DHDesign
March 6th, 2007, 01:55 PM
yeah, that solved it...difficult part was that no real documentation is available on this issue...after digging deep into the bugs of the package, I finally found a line that had mentioned this, tried it and it worked.