PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » File Formats » Spreadsheet_Excel_Writer » Bug #6509

Object of class Spreadsheet_Excel_Writer_Format could not be converted to int

Details

Submitted2006-01-17 20:28 UTC
Fromoswaldo dot otero at gmail dot com
Assignedtuupola
StatusClosed
PackageSpreadsheet_Excel_Writer
PHP Version5.1.1
OSWindows 2000
Roadmaps(Not assigned)

Comments

[2006-01-17 20:28 UTC] oswaldo dot otero at gmail dot com

Description:
------------
Trying to create a Excel file, i notice the follow error, when I comment some lines in Writer.php Lines(144-151) function send.

The thing is that the function _XF(&$format) in Lines(1238-1247) in Worksheet.php are wrong because it's trying to change an Object into an int

Test script:
---------------
The fucntion was like:
function _XF(&$format)
{
//echo __FILE__.'This is Format Index: '.$format;
if ($format != 0) {
return($format->getXfIndex());
}
else {
return(0x0F);
}
}

But we tweak like this:

function _XF(&$format)
{
//echo __FILE__.'This is Format Index: '.$format;
if (is_object($format)) {
return($format->getXfIndex());
}
else {
return(0x0F);
}
}

Expected result:
----------------
Create a Excel File

Actual result:
--------------
Right now it's working

[2006-02-03 19:01 UTC] erik dot buelens at telenet dot be

I have the same error when using the function: $worksheet->writeUrl(). I'm using a winXP platform. Spreadsheet_Excel_Writer-0.9.0.tgz

[2006-02-22 05:38 UTC] feyd at devnetwork dot net

I've run into this bug as well. Here are the lines I've altered to fix this issue:

Writer/Worksheet.php:1233: if (is_object($format)) {
Writer/Worksheet.php:1686: if (!is_object($format)) {
Writer/Worksheet.php:1873: if (!is_object($format)) {
Writer/Worksheet.php:1933: if (!is_object($format)) {
Writer/Worksheet.php:2005: if (!is_object($format)) {
Writer/Worksheet.php:2161: if (is_object($format)) {

As with the original poster's situation, $format was being compared against zero, except for the last case where it was simply being if'd.

[2006-03-15 10:04 UTC] rabus at users dot sourceforge dot net

I can confirm that the your patch fixes the problem for me on php 5.1.2. It would be great if it could find its way into the PEAR package. :-)

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

Yes, of course your correction is working.

Is there someone to post the correction in the source code ?

Thanks
cyrille

[2006-06-15 08:39 UTC] sausis at vtex dot lt

I have the same error on WindowsXP PHP 5.1.4 (works with is_object()).

But no errors on PHP Version 5.1.4-pl0-gentoo!

[2006-09-08 14:53 UTC] henson dot garth at gmail dot com

I have also run into this issue. What's more, it errors out even with the sample code given in the API:

require_once "Spreadsheet/Excel/Writer.php";
$workbook = new Spreadsheet_Excel_Writer();
$format =& $workbook->addFormat(array('Size' => 10,
'Align' => 'center',
'Color' => 'white',
'Pattern' => 1,
'FgColor' => 'magenta'));
$worksheet =& $workbook->addWorksheet();
$worksheet->writeString(1, 0, "Magenta Hello", $format);
$workbook->close();

I've tested this on PHP 4.3 as well as 5.1 with no luck. Any chance the fix above could make its way into the PEAR module would be wonderful!

[2006-09-21 12:20 UTC] tuupola at php dot net

This bug has been fixed in CVS.

If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET).

If this was a problem with the pear.php.net website, the change should be live shortly.

Otherwise, the fix will appear in the package's next release.

Thank you for the report and for helping us make PEAR better.

[2007-02-15 07:02 UTC] bonda1_007 at yahoo dot com

My problem is Column Length is fiexd 255 in Package Spreadsheet_Excel_Writer . I want To Insert More Than 255 char( string) in Column. Rest Is Working Fine.

thanks
James