Pear - spreadsheet_excel_writer insertBitmap函数错误

时间:2014-06-06 07:15:23

标签: php pear spreadsheet-excel-writer

我遇到了SPREADSHEET_EXCEL_WRITER中的问题。当我使用insertBitmap()函数时,它生成一个错误,而不是在excel中嵌入位图图像。

我已浏览过该链接(PEAR Spreadsheet_Excel_Writer insertBitmap() not working correctly 但它并没有帮助我......

我的代码如下......

    $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    

请帮忙......

1 个答案:

答案 0 :(得分:1)

... Yupieeeeeee

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

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

谢谢你的帮助。