2

我正在尝试将系统从 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,那也将非常有帮助!

4

0 回答 0