无法使用PHPExcel& amp;笨

时间:2014-10-13 07:13:43

标签: php phpexcel export-to-excel worksheet

我在这部分有一些问题。工作表中没有导出的图像。

$objDrawing = new PHPExcel_Worksheet_Drawing();
              $objDrawing->setName("logo_sci");
              $objDrawing->setDescription("logo_sci");
              $objDrawing->setPath('./assets/images/sucofindo_logo.PNG');
              $objDrawing->setCoordinates('C6');
              $objDrawing->setHeight(120); 
              $objDrawing->setWidth(120);
              $objDrawing->setWorksheet($objPHPExcel->getActiveSheet());

需要帮助!感谢..

1 个答案:

答案 0 :(得分:2)

此代码适用于我:

    if (file_exists('includes/temp/signatures/'.$id.'.jpg')) {
        $objDrawing = new PHPExcel_Worksheet_Drawing();
        $objDrawing->setName('Customer Signature');
        $objDrawing->setDescription('Customer Signature');
        //Path to signature .jpg file
        $signature = FCPATH.'/includes/temp/signatures/'.$id.'.jpg';    
        $objDrawing->setPath($signature);
        $objDrawing->setOffsetX(8);                     //setOffsetX works properly
        $objDrawing->setCoordinates('E38');             //set image to cell E38
        $objDrawing->setHeight(75);                     //signature height  
        $objDrawing->setWorksheet($this->excel->getActiveSheet());  //save      
    }

正如您所看到的,所有与您的代码不同的是setPath()。需要成为文件的根路径

注意:我正在使用PHPExcel作为Codeigniter的库。 请参见此处:http://fally.ro/using-phpexcel-class-with-codeigniter/