PHP Classes

Undefined variable: size

Recommend this page to a friend!

      MS-Excel Stream Handler  >  All threads  >  Undefined variable: size  >  (Un) Subscribe thread alerts  
Subject:Undefined variable: size
Summary:The class can’t attribute value to size variable. (I think)
Messages:4
Author:Joćo
Date:2005-06-21 16:37:41
Update:2009-06-23 11:55:11
 

  1. Undefined variable: size   Reply   Report abuse  
Picture of Joćo Joćo - 2005-06-21 16:37:41
Hello!
I’m trying to use this class but php show me this error:

“Notice: Undefined variable: size in path_to\Scripts\MS_Excel_StreamHandler\excel.php on line 162”


My php script is:
-----------------------------------------------------------------------
require_once "../Scripts/MS_Excel_StreamHandler/excel.php";
$export_file = "xlsfile://./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);
-------------------------------------------------------------------------

Can you tell me the error?


_________________________________________________________________________
Another question:
I have to put in the excel file more lines then a sheet can handler.
How your class deal with it?

  2. Re: Undefined variable: size   Reply   Report abuse  
Picture of Joćo Joćo - 2005-06-21 18:33:24 - In reply to message 1 from Joćo
Please ignore the firs question! Although the Notice error, file is created successfully. Sorry!

_____________________________________________________________________________

The really question is:
If I try:
«$export_file = "xlsfile://example.xls";»
PHP give me this “error”:
«Notice: Undefined index: path in Path_to\Scripts\MS_Excel_StreamHandler\excel.php on line 74»
And create the xls file in C: directory

But if I try:
«$export_file = "xlsfile://./example.xls";»
No error is displayed and the file is again created in C: directory

On the other hand, If I try:
«$export_file = "xlsfile://Calculos_Dados/example.xls";»
PHP give this error:
«Warning: fopen(xlsfile://Calculos_Dados/example.xls): failed to open stream: "xlsstream::stream_open" call failed in Path_to\TesteExcel.php on line 11»
No file is created.

And If I try:
«$export_file = "xlsfile://./Path_to/Calculos_Dados/example.xls";»
Where «./» corresponds to «C:/»
In this case no warning occurs and the file is created successfully in Calculos_Dados/ directory.

  3. Re: Undefined variable: size   Reply   Report abuse  
Picture of Joćo Joćo - 2005-06-21 18:37:34 - In reply to message 2 from Joćo
Can you tell me how I write a relative path to create file?
Thanks a lot!

  4. Re: Undefined variable: size   Reply   Report abuse  
Picture of cristian cristian - 2009-06-23 11:55:11 - In reply to message 3 from Joćo
$export_file = "xlsfile://./UsbWebserver/Root/xlsstream/example.xls";