PHP_XLSXWriter icon indicating copy to clipboard operation
PHP_XLSXWriter copied to clipboard

Hyperlinks Support Added

Open mayank opened this issue 9 years ago • 16 comments
trafficstars

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.

mayank avatar Jul 29 '16 07:07 mayank

@mk-j not merged yet, any issue? :confused:

mayank avatar May 03 '17 06:05 mayank

The last big release was in january, i'm not ready to add this in yet, but perhaps the next release.

mk-j avatar May 03 '17 18:05 mk-j

Hope you'll consider #105 in the next release. Let me know if you have any questions.

pathfindercb avatar May 03 '17 19:05 pathfindercb

+1

nitrag avatar May 31 '17 15:05 nitrag

+1

premax avatar Sep 14 '17 22:09 premax

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 avatar Dec 20 '17 12:12 slououou

@slououou share a sample file!

mayank avatar Dec 29 '17 13:12 mayank

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 avatar Jan 10 '18 12:01 slououou

@slououou repaired file works well?

mayank avatar Jan 10 '18 12:01 mayank

No, I checked the content of the files, the rels is removed after repaired, but I need it for the hyperlink.

slououou avatar Jan 19 '18 09:01 slououou

@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.

slououou avatar Feb 26 '18 10:02 slououou

+1

@mk-j @mayank What is the status of this merge request?

bartmika avatar Mar 19 '18 15:03 bartmika

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');

?>

epandzo avatar Apr 12 '18 10:04 epandzo

$writer->writeSheetRow('Sheet1', $row);

To bad the links are working on an laptop or android phone but not iPhone ;(

BIERAAP avatar Jan 11 '19 15:01 BIERAAP

@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>.

Somnium7 avatar Jan 26 '21 20:01 Somnium7

Hello there. Was there any update regarding the problem with the links? Even the example file doesn't seem to be working.

JulioPradera avatar Jul 04 '22 22:07 JulioPradera

I've added ex12-hyperlink.php

mk-j avatar May 31 '23 17:05 mk-j