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 <
[email protected]>
* @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);
?>