Open-XML-SDK icon indicating copy to clipboard operation
Open-XML-SDK copied to clipboard

OpenXML does not allow special character such as &, ", >, < in hyperlink, it can throw exception when get worksheet instance

Open ttnnphuoc opened this issue 2 years ago • 1 comments

Before submitting an issue, please fill this out

Is this a:

  • [x] Issue with the OpenXml library
  • [x] Question on library usage

If you have answered that this is a question, please ask it on StackOverflow instead of here. This issue tracker is meant to track product issues while StackOverflow excels at answering questions

Description

OpenXML does not allow special character such as &, ", >, < in hyperlink, it can throw exception when get worksheet instance

Observed

OpenXML does not allow special character such as &, ", >, < in hyperlink, it can throw exception when get worksheet instance

Expected Allow special character such

ttnnphuoc avatar Jul 11 '22 06:07 ttnnphuoc

Hi @ttnnphuoc,

Can you be more specific about where the hyperlink is in the file format? Also can you provide an example of Open XML SDK code that demonstrates the problem (i.e. exception when adding or modifying a hyperlink in a worksheet)?

tomjebo avatar Jul 11 '22 19:07 tomjebo

This is a known issue due to the System.Uri class itself (see https://github.com/OfficeDev/Open-XML-SDK#known-issues). That links provides a mechanism to "sanitize" the document before reading it. It's not ideal, but the best option at this point.

twsouthwick avatar Sep 07 '22 02:09 twsouthwick

This has become much easier in v3.0 - see #1322. Docs to follow on how to use

twsouthwick avatar Feb 03 '23 18:02 twsouthwick