Quantcast
Channel: EPPlus Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 2262

Edited Unassigned: Encode Hyperlink location to prevent errors when sheet names contain special charcters like '&' [15039]

$
0
0
Tested in version 4.0.0 beta 2. Provided a solution as part of this post.

While updating hyperlinks in a WorkSheet, the location is not encoded. This causes an error when trying to load the updated workbook if any of the hyperlinks use a location from a worksheet which has a special character in the name (for e.g. '&')


I have a workbook with two worksheets ("Sheet1" and 'L & F"). The worksheet "Sheet1" has hyperlinks which are linked to the worksheet "L & F'.

I use EPPlus to make some changes to the workbook and save. On re-opening the workbook in Excel, fails to load the worksheet "Sheet1" with an "Invalid Character" error message. A sample workbook to replicate the problem is attached. Just open the workbook with EPPlus, save it back and try opening the workbook again in Excel, the error should appear and WorkSheet "Sheet1" should be empty.

To fix this issue, modify ExcelWorkSheet.UpdateHyperLinks(StreamWriter sw) to encode the HyperLink location as shown below

```
Change
ExcelCellBase.GetFullAddress(Name, hl.ReferenceAddress)

to
SecurityElement.Escape(ExcelCellBase.GetFullAddress(Name, hl.ReferenceAddress) )

```

Viewing all articles
Browse latest Browse all 2262

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>