xou/elixlsx

Hyperlink support

manveru opened this issue · 0 comments

I need to support hyperlinks. I'm thinking of making a PR for it, but this will probably take a while and I'm not sure how to support cells that contain hyperlinks and normal text at the same time (though I don't personally need it, that seems allowed in the spec).

For anyone looking for a quick fix, you can use the HYPERLINK function like [{:formula, "HYPERLINK(\"#{url}\", \"#{url}\")"}].

So for now I'll just leave this issue here of how they look like in the XLSX:

In the sheet$n.xml row, the hyperlink is referenced via r, like r=C8.
In the sheet$n.xml, in the <workbook/> tag this section:

<hyperlinks>
  <hyperlink ref="C8" r:id="rId1" display="http://example.com"/>
</hyperlinks>

In worksheets/_rels/sheet$n.xml.rels is this content:

<?xml version="1.0" encoding="UTF-8"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
  <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="http://example.com" TargetMode="External"/>
</Relationships>

I'm not entirely sure how the code for a cell should look like, given that hyperlinks can be mixed with other content.