Add Relationship spreadsheet hyperlink issue?

Home Forums Open-Xml-Sdk-JavaScript Add Relationship spreadsheet hyperlink issue?

This topic contains 1 reply, has 2 voices, and was last updated by  Eric White 7 years, 6 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #3858

    skarn
    Participant

    Hey Eric – thanks for everything.
    I found trying to add a hyperlink relationship for a cell was failing for me – and I’ve determined the following rules and mod to code needed – but I don’t know if it’s a mistake in the openxml.js code or if I’m using it wrong.

    1. I have to manually add the ‘Hyperlinks/Hyperlink’ elements to the worksheet XDocument using new XElement methods (working from a BASE64 template which has no hyperlinks already).
    2. The Hyperlinks element has to be added before ‘pageMargins’ element which appears by default. I’m assuming this is a schema validation thing and I should probably go check and confirm.
    3. I then need to update the relationships part for the according sheet. I tried just using ‘worksheetPart.addRelationship’ and it does create a new part and add the relationship, but it adds it with a ‘rel:’ namespace prefix – this doesn’t seem to be liked by Excel and reports bad file. Manually editing the xlsx and removing the rel: prefix worked so..
    4. I changed openxml.js openXml.OpenXmlPart.prototype.addRelationship to add a non-prefix namespace attribute and now Excel is happy.

    What do you think? Does the openXml.OpenXmlPart.prototype.addRelationship need this modification to remove ‘rel’ namespace prefix, or am I doing something wrong?

    Bit of beginner here, so please forgive me if I’m making an obvious mistake.

    #3876

    Eric White
    Keymaster

    Hi,

    I am uncertain from your description what exactly was going wrong, and what you had to do to fix it.

    In general, I believe that it is possible to do everything that you need to do using the Open-Xml-Sdk-JavaScript. I know that we are deficient in example code in this area. I would love to create more example code, but earning a living sometimes prevents this. But one good thing – I have a big Open-Xml-Sdk-JavaScript project coming up in a couple of months, so it will be good to get back into it. I plan on moving it to GitHub at the same time.

    In general, if your fix works, and if the resulting file validates per the Open-Xml-Sdk productivity tool, then I would say go for it.

    Best, Eric

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.