aVadim483 / fast-excel-writer

Lightweight and very fast XLSX Excel Spreadsheet Writer in PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to set Hyperlink using writeRow

shulogsm opened this issue · comments

When i try to add options to an array to set a hyperlink for a cell, it shows only an empty cell:

This is how i´m trying to do:

$array_cells = array();
$array_cells[] = $name;
$array_cells[] = $company;
$array_cells[] = $otheroptions;
...
$Link = [$value, ['hyperlink' => true]];
$array_cells[] = $Link;
$sheet->writeRow($array_cells, $rowOptions, $cellsStyle);

What is the correct way to set an hyperlink using writeRow option?

Thanks for your great work!

The first argument is a value array, the 2nd - row styles, the 3rd - styles of specified cells in the row

$rowValues = [
    'text',
    'http://google.com',
    123456,
];
$rowStyle = [];
$cellStyles = [
    [], // style for the first cell,
    ['hyperlink' => true], // 2nd cell
    [], // 3rd cell
];

$sheet->writeRow($rowValues, $rowStyle, $cellStyles);

Other way

$cellStyles = [
    'B' => ['hyperlink' => true],
];
$sheet->writeRow($rowValues, [], $cellStyles);

Great! Second option is better for me! Thank you very much!!

I´m only getting error on get request with ampersand symbol (&), but if no GET data links works perfect.
For example it fails on links like this "https://www.google.com/search?q=testing&sca_esv=581771196" and i checked that problem is the &