2014-06-06 70 views
1

我陷入SPREADSHEET_EXCEL_WRITER中的問題。當我使用insertBitmap()函數時,它生成一個錯誤,而不是在Excel中嵌入位圖圖像。Pear - spreadsheet_excel_writer insertBitmap函數錯誤

我已經通過鏈接(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  

請幫助....

+0

請添加導致此錯誤的完整代碼。您顯示的代碼不會產生錯誤。 – cweiske

+0

我已經添加完整的代碼....請檢查並恢復... – tanrich

+0

你從哪裏得到'Lib \ excel \ Worksheet.php'? – cweiske

回答

1

雨披EEEEEEE ....

最後我實現了這個....

我剛添加的對PEAR.phpPEAR5.PHP對Excel庫,它是爲我工作...

謝謝你們的幫助。

+0

謝謝我只是有同樣的問題。你節省了我的時間。 – user818455