Hi Filip,

Hi,

I'm inserting a hyperlink with a non standard protocol into a XSSF
Worksheet like so

Hyperlink link = createHelper.createHyperlink(Hyperlink.LINK_URL);
                                                link.setAddress("my-proto://" + 
someURL);
                                                cell.setHyperlink(link);

This is working fine with HSSF but with XSSF it ignores the fact that
this is a URL and not a File link, and generates a
file://localhost/my-proto//... link.

Quickly browsing the source it seems to be related to XSSFHyperlink.java:

           // Try to figure out the type
           if (_location.startsWith("http://";) ||
_location.startsWith("https://";)
                   || _location.startsWith("ftp://";)) {
               _type = Hyperlink.LINK_URL;
           } else if (_location.startsWith("mailto:";)) {
               _type = Hyperlink.LINK_EMAIL;
           } else {
               _type = Hyperlink.LINK_FILE;
           }


That doesn't look right. It ought to use LINK_FILE only for "file"
URLs, LINK_EMAIL for "mailto" and LINK_URL for the rest.

I think the correct pattern is more like this:
           if (_location.contains("://") ) {
               _type = Hyperlink.LINK_URL;
           } else if (_location.startsWith("mailto:";)) {
               _type = Hyperlink.LINK_EMAIL;
           } else {
               _type = Hyperlink.LINK_FILE;
           }

Although the URL rule needs to be a pattern match, I am pretty certain that <protocol>:// signifies a URL and the other stuff can only be EMAIL or a FILE.

Does anybody know of any workarounds in the mean time ? Any chance one
of the developers could address this ?

You could do whatever you want if you build from source. Give it a day for the developers on the other side of the world to respond.

Regards,
Dave



Thanks much in advance,
- Filip

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to