Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Excel export: added a special case to add HYPERLINK Formula when text… #352

Closed
wants to merge 3 commits into from

Conversation

mdsimpson
Copy link

… in the cell matches =HYPERLINK("link","name")

A very basic start at adding support for Excel function.

… in the cell matches =HYPERLINK("link","name")
@boxcla
Copy link

boxcla commented Nov 2, 2016

Hi @mdsimpson, thanks for the pull request. Before we can merge it, we need you to sign our Contributor License Agreement. You can do so electronically here: http://opensource.box.com/cla

Once you have signed, just add a comment to this pull request saying, "CLA signed". Thanks!

Copy link
Collaborator

@adrilo adrilo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pull request @mdsimpson !

I'm not a big fan of one-off changes like this one. It's definitely interesting to add formulas support to Spout but it needs to be thought as a whole, not just in the scope of hyperlinks.

if ($this->shouldUseInlineStrings) {
$cellXML .= ' t="inlineStr"><is><t>' . $this->stringsEscaper->escape($cellValue) . '</t></is></c>';
$matches = array();
if (preg_match('/=HYPERLINK\("(.*)","(.*)"\)/', $cellValue, $matches)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regex should be changed to support other ways of writing the formula: /=HYPERLINK\([\'"](.*)[\'"],\s*[\'"](.*)[\'"]\)/. This support single and double quotes as well as any number of spaces after the comma (it may also need the same \s before the comma)

@slewitan
Copy link

@mdsimpson,
I tried to implement your code on my local sever and (unless I missed something) it's not compatible with
$writer->addRowWithStyle()

for example: 
$style = (new StyleBuilder())
           ->setBackgroundColor('ff6600')
           ->build();
$writer->addRowWithStyle($row, $style); 

The entire row is colored except the hyperlink column.

@stevesweets
Copy link

My pull request here:

#425

Appears to achieve this.

@adrilo adrilo mentioned this pull request Sep 24, 2018
97WaterPolo added a commit to 97WaterPolo/spout that referenced this pull request Jun 28, 2019
Adaptation of a previous version PR box#352
@97WaterPolo 97WaterPolo mentioned this pull request Jun 28, 2019
@adrilo
Copy link
Collaborator

adrilo commented Jun 29, 2019

Outdated PR

@adrilo adrilo closed this Jun 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants