someguy
someguy

Reputation: 21

PEAR Excel Spreadsheet Writer - writeURL()

I am trying to port a system from PHPExcel over to PEAR's Spreadsheet_Excel_Writer. When I make more than 23 calls to writeURL I get a corrupted spreadsheet. I have beaten my head against a desk trying to solve this. Below is a small, stand-alone example of when this is occurring:

//using Spreadsheet_Excel_Writer-0.9.3

    require_once(dirname(__FILE__) . '/lib/Spreadsheet_Excel_Writer-0.9.3/Spreadsheet/Excel/Writer.php');




    $workbook = new Spreadsheet_Excel_Writer();

    // sending HTTP headers
    $workbook->send('test.xls');

    $info =& $workbook->addWorksheet('info');


    //write some stuff in the info worksheet
    $info->write(0, 0, 'Name');
    $info->write(0, 1, 'Age');
    $info->write(1, 0, 'John Smith');
    $info->write(1, 1, 30);
    $info->write(2, 0, 'Johann Schmidt');
    $info->write(2, 1, 31);
    $info->write(3, 0, 'Juan Herrera');
    $info->write(3, 1, 32);


    //lets make some links, using the writeURL call
    $r = 4;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;

    //Everything works as expected up to this point.
    //but adding any more links into the workbook causes excel to say that it is corrupted..
    // try un-commenting one of these...
    /*
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    $info->writeUrl($r, 0, "http://www.yahoo.com/$r","Yahoo!$r");
    $r++;
    */

    //close the workbook
    $workbook->close();

You will need to un-comment any of the additional writeURL calls for the error to occur.

Additionally, if there is a workaround that will let me write URLs without that call, that would be extremely helpfull too!

Upvotes: 2

Views: 390

Answers (0)

Related Questions