我正在打印一些url,它将在phpexcel中动态运行。
$sheet->setCellValue('M'.($results+2),($result['headline']).$result['url']);
但是输出就像这个Govt to start Air India roadshows in Singapore this weekhttp://www.windowtonews.com/news.php?id=288115
我怎样写才能让链接出现在带有超链接的文本上
发布于 2019-11-22 09:53:09
您可以分三步完成此操作:
string2
的链接
$sheet->setCellValue('M'.($results+2),$result['headline']);
$sheet->getCell('M'.($results+2))->setDataType(PHPExcel_Cell_DataType::TYPE_STRING2);
$sheet->getCell('M'.($results+2))->getHyperlink()->setUrl(strip_tags($result['url']));
在一行中,看起来是这样的:
$sheet->setCellValueExplicit('M'.($results+2), $result['headline'], PHPExcel_Cell_DataType::TYPE_STRING2, TRUE)
->getHyperlink()
->setUrl(strip_tags($result['url']));
setCellValueExplicit() -类似于getCell(),如果设置为true
,则返回单元格而不是工作表(类似于getActiveSheet())。
https://stackoverflow.com/questions/58991264
复制相似问题