You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2019/03/01 20:37:47 UTC

[Bug 62969] HYPERLINK() function needs a way to return link reference when display label is also specified

https://bz.apache.org/bugzilla/show_bug.cgi?id=62969

--- Comment #6 from Greg Woolsey <gw...@apache.org> ---
I also came up with a workaround hack just now that I'll document here in case
others find it helpful.

I had a Cell, whose formula was HYPERLINK(...).  It sometimes had one arg,
sometimes two.  Parsing the text with a REGEX was a nightmare, and often hit
runaway cases.

However, I realized I could leverage Excel formulas here, and POI formula
parsing.

I did this:

        String formula = cell.getCellFormula()
                .replaceFirst("(?i)hyperlink\\s*\\(", "IF(true, ");


I can then evaluate the resulting IF formula instead, which will return the
first argument from the former HYPERLINK function.  So simple, and arguments
can be arbitrarily complex Excel formulas involving all sorts of crazy stuff.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org