如何使用PHPExcel读取单元格内超链接的URL?
答案 0 :(得分:18)
$url = $objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->getUrl();
修改强>
您可能想要先测试单元格是否有超链接
$objPHPExcel->getActiveSheet()->getCell('E26')->hasHyperlink();
编辑2
请注意,setReadDataOnly(true)
时不会加载超链接答案 1 :(得分:0)
<?php
require 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
$reader = new Xlsx();
$spreadsheet = $reader->load("test.xlsx");
$sheetData = $spreadsheet->getActiveSheet()->getCell('B7')->getHyperlink()->getUrl();
print_r($sheetData);
?>