PHP_XLSXWriter
PHP_XLSXWriter copied to clipboard
Hyperlinks Support Added
Added Support for adding Hyperlinks to the Cells using a separate array to be passed when writeSheet() is called.
You can see example for more details.
@mk-j not merged yet, any issue? :confused:
The last big release was in january, i'm not ready to add this in yet, but perhaps the next release.
Hope you'll consider #105 in the next release. Let me know if you have any questions.
+1
+1
Seems not work for excel 2016. The link is gone after being forced recovered while other data remains. Is there's a way to make those code work for it?
@slououou share a sample file!
example.xlsx is the file generated with the code while example_changed.xlsx is the file "repaired" by the ms excel 2016. example_changed.xlsx example.xlsx The repaire info is:
<?xml version="1.0" encoding="UTF-8" standalone="true"?>
-<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<logFileName>error171880_01.xml</logFileName>
<summary>Errors were detected in file 'C:\Users\someone\Desktop\example.xlsx'</summary>
-<additionalInfo>
<info>Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded.</info>
</additionalInfo>
</recoveryLog>
@slououou repaired file works well?
No, I checked the content of the files, the rels is removed after repaired, but I need it for the hyperlink.
@mayank This "forced repair" can be avoided by adding:
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
into [Content_Types].xml.
But still, the hyperlink is not shown in the cell.
+1
@mk-j @mayank What is the status of this merge request?
Hi,
There is a simple workaround for adding hyperlinks. Excel supports HYPERLINK as a formula, so example would be something like this:
<?php
include_once("xlsxwriter.class.php");
$filename = "example.xlsx";
$rows = array(
array('2003','TEST', '=HYPERLINK("HTTP://WWW.GOOGLE.COM", "GOOGLE")'),
);
$writer = new XLSXWriter();
foreach($rows as $row)
$writer->writeSheetRow('Sheet1', $row);
$writer->writeToFile('example.xlsx');
?>
$writer->writeSheetRow('Sheet1', $row);
To bad the links are working on an laptop or android phone but not iPhone ;(
@mayank This "forced repair" can be avoided by adding:
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>into [Content_Types].xml. But still, the hyperlink is not shown in the cell.
Regarding broken Excel file, see @slououou comment and <hyperlinks> section should go just before <printOptions>.
Hello there. Was there any update regarding the problem with the links? Even the example file doesn't seem to be working.
I've added ex12-hyperlink.php