PEAR Excel电子表格作家 - writeURL()

时间:2014-04-02 21:27:29

标签: php pear spreadsheet-excel-writer

我正在尝试将系统从PHPExcel移植到PEAR的Spreadsheet_Excel_Writer。当我对writeURL进行超过23次调用时,我得到了一个损坏的电子表格。我试图解决这个问题,把头撞在桌子上。以下是发生这种情况时的一个小小的独立示例:

//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();

您需要取消注释任何其他writeURL调用才能发生错误。

此外,如果有一种解决方法可以让我在没有该调用的情况下编写URL,那也非常有帮助!

0 个答案:

没有答案