生成后,在Excel中embedded超链接

我已经创build了我的Excel文件。 它从数据库设置数据,它工作正常。 现在我想要一列( Image )成为一个URL,点击后,下载开始。 在“ Image列中,图像的名称与数据库中的其他值一样设置。 我的代码示例的列:

  $this->excel->setActiveSheetIndex(0)->setCellValue('C'.$j, $Cooperation->getPhone()); $this->excel->setActiveSheetIndex(0)->setCellValue('C'.$j, $Cooperation->getImage()); $this->excel->setActiveSheetIndex(0)->setCellValue('D'.$j, $Cooperation->getEmail()); $this->excel->setActiveSheetIndex(0)->setCellValue('E'.$j, $Cooperation->getMajor()); $this->excel->setActiveSheetIndex(0)->setCellValue('F'.$j, $Cooperation->getLastDegree()); $this->excel->setActiveSheetIndex(0)->setCellValue('G'.$j, $Cooperation->getJobCategory()); $this->excel->setActiveSheetIndex(0)->setCellValue('H'.$j, $Cooperation->getName() ." ". $Cooperation->getLastName()); 

这是我试图为图像列:

  $this->excel->setActiveSheetIndex(0)->setCellValue('H'.$j, echo '<a href="/media/images/footer/'.$Cooperation['Image'].'">'.$Cooperation['Image'].'</a>' 

PHP不是我的强项,而是像这样:

 $this->excel->setActiveSheetIndex(0)->setCellValue('J'.$row, '=HYPERLINK("/media/images/footer/'.$Cooperation['Image']. '",'.$Cooperation['Image'].')'); 

除非文件将位于相对于Excel文件的某个固定位置,否则您可能还需要使用完整path。

你可能不得不整理这些报价。