PHP Classes

bad xls file

Recommend this page to a friend!

      MS-Excel Stream Handler  >  All threads  >  bad xls file  >  (Un) Subscribe thread alerts  
Subject:bad xls file
Summary:the code generates a .xls file, but content is in a single cell
Messages:31
Author:Jim A
Date:2005-01-21 03:07:09
Update:2009-10-09 05:13:59
 
  1 - 10   11 - 20   21 - 30   31 - 31  

  11. Re: bad xls file   Reply   Report abuse  
Picture of Ignatius Teo Ignatius Teo - 2007-12-13 05:55:51 - In reply to message 8 from Usman Ghani
[quote]" 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 "[/quote]

Failed to open stream errors can be attributed to either of these:
1. directory does not exist
2. directory does not have write permissions
3. your OS could not find the specified path


  12. Re: bad xls file   Reply   Report abuse  
Picture of paolo a paolo a - 2007-12-29 23:38:57 - In reply to message 11 from Ignatius Teo
Hi,
can i use "xlsfile://" with a relative path?

my SO is linux and the example "xlsfile://./mydir/myfile.xls" don.t work.

I can't access to the full path in my hosting service.

thanks

Paolo

  13. Re: bad xls file   Reply   Report abuse  
Picture of Ignatius Teo Ignatius Teo - 2007-12-31 00:57:52 - In reply to message 12 from paolo a
Absolute path - you wouldn't specify a relative path for, say, http:// would you?

PS: You should be able to specify the full path to your webroot for your virtual host.

  14. Re: bad xls file   Reply   Report abuse  
Picture of Thomas Thomas - 2008-01-14 15:03:22 - In reply to message 12 from paolo a
Hi,
you can fix this:

1. creating a new directory (tmp) and a new example.xls in it.

2. Give it write/read access.

3. then put your path to the full path:

(for instance)
/home/your_username/www/your_directory/tmp/example.xls.



  15. Re: bad xls file   Reply   Report abuse  
Picture of paragbhavsar paragbhavsar - 2008-04-28 05:14:24 - In reply to message 14 from Thomas
Hi Friend,

Its not working for me too. Giving same error as previously posted. I am using windows xp and php version 5.x. Please let me know why it is giving error.

Thanks.

Parag Bhavsar

  16. Re: bad xls file   Reply   Report abuse  
Picture of Jose Tiznado Jose Tiznado - 2008-06-16 00:58:22 - In reply to message 5 from Hani
check this example it uses a post from a php page
<?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 "excel.php";
$export_file = "xlsfile://".$_POST['archivo'].".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);

header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
header ("Content-type: application/x-msexcel");
header ("Content-Disposition: attachment; filename=\"" . basename($export_file) . "\"" );
header ("Content-Description: PHP/INTERBASE Generated Data" );
readfile($export_file);
exit;
?>

  17. Re: bad xls file   Reply   Report abuse  
Picture of Emily Evripidou Emily Evripidou - 2008-07-02 12:30:59 - In reply to message 11 from Ignatius Teo
OS: Windows XP
PHP Version 5.2.6

Hello, I do have the same problem. I use the 'excel.php' and the 'example_export.php' excactly as it is downloaded but I keep getting the error :

Warning: fopen(xlsfile://tmp/example.xls) [function.fopen]: failed to open stream: "xlsStream::stream_open" call failed in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\dokimes\example_export.php on line 11
Cannot open xlsfile://tmp/example.xls

I don't know why this is happening. I first thougth that it was a permission problem but their is no " Permission denied " message.

Any idea about what is going wrong?

  18. Re: bad xls file   Reply   Report abuse  
Picture of Emily Evripidou Emily Evripidou - 2008-07-02 12:44:02 - In reply to message 11 from Ignatius Teo
Ok I used jose tiznado's solution with $_POST so nowthe .xsl file is created but it has only one sell with the following value:

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;}}


Can you please help me find out how to make this format look like a real spreadsheet?

Thank you in advance.

  19. Re: bad xls file   Reply   Report abuse  
Picture of Emily Evripidou Emily Evripidou - 2008-07-03 14:29:50 - In reply to message 11 from Ignatius Teo
Hello !

I keep trying to resolve this but I have nothing yet. Did anyone find out what is the solution?


I have a thougth that we can change something in the format that everything is displayed throw excel. But since I'm a newbie I don't know to fix this.

Thnk you.

  20. Re: bad xls file   Reply   Report abuse  
Picture of kyungjoon min kyungjoon min - 2008-08-29 16:26:00 - In reply to message 19 from Emily Evripidou
Try removing the @ in the following code in the function stream_open.
$this->fp = @fopen($this->xlsfilename, $this->mode);

This will give more exact error code.

If you code like below in window 2003 server,

$fp = fopen('xlsfile://./temp/bar.xls',"wb");

it will open the file bar.xls in C:\temp directory.


 
  1 - 10   11 - 20   21 - 30   31 - 31