使用PHPExcel插入多个图像时出现问题

时间:2015-12-28 05:37:10

标签: php phpexcel

我想从php生成excel报告,其中每行有两个图像。但生成的Excel工作表仅显示第一行的图像。 以下是我用过的代码

  $pixels = 120;
  $points = PHPExcel_Shared_Drawing::pixelsToPoints($pixels);
  $wpixels = 95;
  $wpoints = PHPExcel_Shared_Drawing::pixelsToPoints($wpixels);

  while ($data = mysql_fetch_array($rsExport)) {
      @extract($data);
      $image_path = "../../../upload/jrf/".$img_upload;
      $sign_path  = "../../../upload/jrf/".$sign_upload;
     $activeSheet->setCellValue("A".$rowNum, $i);
     $activeSheet->setCellValue("B".$rowNum, $jrf_roll_no);
     $activeSheet->setCellValue("C".$rowNum, $name);

     $objDrawing = new PHPExcel_Worksheet_Drawing();
     $objDrawing->setPath($image_path);
     $objDrawing->setCoordinates('D'.$rowNum);
     $objDrawing->setResizeProportional(false);
     $objDrawing->setWidth($wpoints);   
    $objDrawing->setWorksheet($activeSheet);

     $activeSheet->getRowDimension($rowNum)->setRowHeight($points);
     $activeSheet->getColumnDimension('D'.$rowNum)->setAutoSize(true);

     $objDrawing1 = new PHPExcel_Worksheet_Drawing();
    $objDrawing1->setPath($sign_path);
    $objDrawing1->setCoordinates('E'.$rowNum);
    $objDrawing1->setResizeProportional(false);

    $objDrawing1->setWidthAndHeight($wpoints,$points);
    $objDrawing1->setWorksheet($activeSheet);

   $activeSheet->getColumnDimension('E'.$rowNum)->setAutoSize(true);
   $rowNum++;
   $i++;

}

0 个答案:

没有答案