PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » File Formats » Spreadsheet_Excel_Writer » Bug #2539

Method call to getXfIndex() fails

Details

Submitted2004-10-15 16:12 UTC
Fromjon dot bertsch at ucop dot edu
StatusDuplicate
PackageSpreadsheet_Excel_Writer
PHP Version5.0.1
OSLinux SUSE 9.1
Roadmaps(Not assigned)

Comments

[2004-10-15 16:12 UTC] jon dot bertsch at ucop dot edu

Description:
------------
A spreadsheet is created but with an error

Reproduce code:
---------------
The spreadsheet contains;

<b>Fatal error</b>: Call to a member function
getXfIndex() on a non-object in <b>path_to_file/
spreadsheet/Writer/Worksheet.php</b> on line <b>1244</
b><br />

This is version 0.8, doesn't happen in 0.6 on my system

I commented out the if/else call to the function and
just left it with:

return(0x0F)

rather than this call:

return($format->getXfIndex());

The spreadsheet works so far, but...

Expected result:
----------------
Spreadsheet with expected content.

Actual result:
--------------
<b>Fatal error</b>: Call to a member function
getXfIndex() on a non-object in <b>path_to_file/
spreadsheet/Writer/Worksheet.php</b> on line <b>1244</
b><br />

[2005-02-22 10:18 UTC] smith at backendmedia dot com

The lines dont match up anymore in CVS. But it looks to me like the method should check for the proper class type instead:

function _XF(&$format)
{
if (is_a($format, 'Spreadsheet_Excel_Writer_Format') {
return($format->getXfIndex());
} else {
return(0x0F);
}
}

[2006-02-22 15:02 UTC] rainco at gmx dot net

I use version 0.9.0 on PHP5.1.2 and get a similar notice:

Object of class Spreadsheet_Excel_Writer_Format could not be converted to int in <path>/Spreadsheet/Excel/Writer/Worksheet.php line 1233

I think smith at backendmedia dot com is right. Further I think the default format should not be 0 but null.

[2006-03-08 18:02 UTC] eaflores at utep dot edu

I fixed this problem writing the following. I use php5.1.2

function _XF(&$format)
{
if (isset($format->xf_index))
{
return($format->get_xf_index());
}
else
{
return(0x0F);
}
}

[2006-03-20 23:38 UTC] cyrille37 at free dot fr

Perhaps the same as Bug #6509

Correction should be one of :

function _XF(&$format)
{
if( is_object($format) ){
return($format->getXfIndex());
} else {
return(0x0F);
}
}

or for PHP5 :

function _XF(&$format)
{
if( $format instanceof Spreadsheet_Excel_Writer_Format ){
return($format->getXfIndex());
} else {
return(0x0F);
}
}

PS: Thanks for that great package !