1

我陷入了 SPREADSHEET_EXCEL_WRITER 中的问题。当我使用 insertBitmap() 函数时,它会生成错误并且没有将位图图像嵌入到 excel 中。

我已经浏览了链接(PEAR Spreadsheet_Excel_Writer insertBitmap() 无法正常工作 ),但它并没有帮助我......

我的代码如下...

    $exp_name = "National_Regional_Scores_" . time() . ".xls";
    $file_location = $exp_name;
    $workbook = new Spreadsheet_Excel_Writer();
    $workbook->setVersion(8);
    $worksheetName = "National_Regional_Scores";

    $worksheet = &$workbook->addWorksheet($worksheetName);
    $worksheet->setColumn(0, 0, 60);
    $worksheet->setColumn(1, 20 * 2, 10);
    reset($header_file);
    $round = &$workbook->addFormat();
    $round->setNumFormat('0');


    $i = 0;
    foreach ($header_file as $a) {
        $j = 0;

        foreach ($a as $p) {

            if ($i == 1) {
                $format_center = & $workbook->addFormat();
                $format_center->setAlign('center');
                $q = 1;
                $r = 2;
                for ($x = 0; $x < $regions_cnt + 1; $x++) {
                    $worksheet->setMerge(1, $q, 1, $r);
                    $q += 2;
                    $r += 2;
                }


                $worksheet->write($i, $j, $p, $format_center);
                $worksheet->setMerge(1, 1, 1, 2);
            }if ($i == 2) {
                $format_center = & $workbook->addFormat();
                $format_center->setAlign('center');
                $worksheet->write($i, $j, $p, $format_center);
            } else {
                $format_center = & $workbook->addFormat();
                if ($j == 0) {
                    $format_center->setTextWrap();
                } else {
                    $format_center->setAlign('center');
                }

                $worksheet->write($i, $j, $p, $format_center);
            }

            $j++;
        }

        $i++;
    }

    $worksheet->insertBitmap('0','0', DOCUMENT_ROOT.'\public\testbmp.bmp','1','1','2','2');
    $worksheet->setRow(0,50);

    $workbook->send($file_location);
    $workbook->close();
    die;

我得到的错误如下......

Fatal error: Call to undefined method Spreadsheet_Excel_Writer_Worksheet::isError() in E:\apd360\staging\mbaup360stage\library\Lib\excel\Worksheet.php on line 3098    

请帮忙....

4

1 回答 1

1

呸呸呸呸……

最后我实现了这个......

我刚刚将PEAR.PHPPEAR5.PHP添加到 excel 库中,它对我有用...

谢谢大家帮助。

于 2014-06-10T10:13:22.270 回答