|
Jim A - 2005-01-21 03:07:09
First, I changed the file locations in the example programs:
$export_file = "xlsfile://tmp/example.xls";
to
$export_file = "Test.xls";
The examples created the .xls file, but the file contains a single cell (A1) with the following data:
------------------------------------------------------------
a:3:{i:0;a:5:{s:12:"Sales Person";s:11:"Sam Jackson";s:2:"Q1";s:5:"$3255";s:2:"Q2";s:5:"$3167";s:2:"Q3";i:3245;s:2:"Q4";i:3943;}i:1;a:5:{s:12:"Sales Person";s:9:"Jim Brown";s:2:"Q1";s:5:"$2580";s:2:"Q2";s:5:"$2677";s:2:"Q3";i:3225;s:2:"Q4";i:3410;}i:2;a:5:{s:12:"Sales Person";s:12:"John Hancock";s:2:"Q1";s:5:"$9367";s:2:"Q2";s:5:"$9875";s:2:"Q3";i:9544;s:2:"Q4";i:10255;}}
------------------------------------------------------------
What's wrong?
I'm on Windows XP, PHP 4.3.4, Excel 2002 SP3.
Thanks!
Ignatius Teo - 2005-01-21 03:38:56 - In reply to message 1 from Jim A
Check that you aren't echoing stuff to the browser (e.g. blank spaces before and after the <?php ?> tags. It could be that output is being buffered and dumped to the stream after the headers have been sent.
Jim A - 2005-01-21 04:21:49 - In reply to message 2 from Ignatius Teo
I used the example_export.php supplied. Only changed the path to the file so it would run.
Ignatius Teo - 2005-01-28 01:03:08 - In reply to message 1 from Jim A
This has been resolved. Make sure the export/download filename contains the xlsfile:// protocol.
Hani - 2005-05-02 20:24:52 - In reply to message 4 from Ignatius Teo
it is still the same, what do u think? please post another example if you can.
Ignatius Teo - 2005-05-03 00:35:31 - In reply to message 5 from Hani
RTFM.... that PHP one that is. You need to define the file with the xlsfile:// protocol - otherwise it doesn't work.
mat - 2007-07-11 15:55:56 - In reply to message 6 from Ignatius Teo
Doesn't work, i've read your instructions, played around with it for ages and nothing works. I just get the same as the other guy (above).
Usman Ghani - 2007-12-05 12:41:34 - In reply to message 7 from mat
I used the example code to export excel file. If I use
$export_file = "xlsfile://tmp/example.xls"; the application displays an error which is:
" fopen(xlsfile://tmp/example.xls) [function.fopen]: failed to open stream: "xlsStream::stream_open" call failed in c:\Inetpub\wwwroot\usman\xls.php on line 11
Cannot open xlsfile://tmp/example.xlsPHP Warning: fopen(xlsfile://tmp/example.xls) [function.fopen]: failed to open stream: "xlsStream::stream_open" call failed in c:\Inetpub\wwwroot\usman\xls.php on line 11 "
If I remove the "xlsfile://" portion from the export file path, it saves a file in text format and write that array directly in to that file in simple form.
I am sure that there no spaces before and after <?php?> tags and i am not producing any other output to the browser.
Below is the code of that example export file.
<?php
/**
* MS-Excel stream handler
* Excel export example
* @author Ignatius Teo <ignatius@act28.com>
* @copyright (C)2004 act28.com <http://act28.com>
* @date 21 Oct 2004
*/
require_once "classes/excel.php";
$export_file = "xlsfile://tmp/example.xls";
$fp = fopen($export_file, "wb");
if (!is_resource($fp))
{
die("Cannot open $export_file");
}
// typically this will be generated/read from a database table
$assoc = array(
array("Sales Person" => "Sam Jackson", "Q1" => "$3255", "Q2" => "$3167", "Q3" => 3245, "Q4" => 3943),
array("Sales Person" => "Jim Brown", "Q1" => "$2580", "Q2" => "$2677", "Q3" => 3225, "Q4" => 3410),
array("Sales Person" => "John Hancock", "Q1" => "$9367", "Q2" => "$9875", "Q3" => 9544, "Q4" => 10255),
);
fwrite($fp, serialize($assoc));
fclose($fp);
?>
Abdul-Aziz Al-Oraij - 2007-12-12 18:34:41 - In reply to message 1 from Jim A
Same here :(
Exactly the same, I have even kept the "xlsfile://", yet it gives a warning!!!
Ignatius Teo - 2007-12-13 05:50:45 - In reply to message 1 from Jim A
If you are having issues with getting the xls file generating correctly, it would help greatly if you could post a few details about your system:
E.g.
Operating System/Platform
PHP Version
Excel/Open Office version
Simply saying it doesn't work for you doesn't help at all.
|