Bugfix 15517
diff --git a/EPPlus/ExcelWorksheet.cs b/EPPlus/ExcelWorksheet.cs index 995febe..a88aa33 100644 --- a/EPPlus/ExcelWorksheet.cs +++ b/EPPlus/ExcelWorksheet.cs
@@ -1,4 +1,4 @@ -/******************************************************************************* + /******************************************************************************* * You may amend and distribute as you like, but don't remove this header! * * EPPlus provides server-side generation of Excel 2007/2010 spreadsheets. @@ -1122,21 +1122,27 @@ { var rId = xr.GetAttribute("id", ExcelPackage.schemaRelationships); var uri = Part.GetRelationship(rId).TargetUri; + + // Get Location, if any. EPPlus Bug 15517 + var location = xr.GetAttribute("location"); + location = (string.IsNullOrEmpty(location)) ? "" : "#" + location; + if (uri.IsAbsoluteUri) { try { - hl = new ExcelHyperLink(uri.AbsoluteUri); + hl = new ExcelHyperLink(uri.AbsoluteUri + location); } catch { - hl = new ExcelHyperLink(uri.OriginalString, UriKind.Absolute); + hl = new ExcelHyperLink(uri.OriginalString + location, UriKind.Absolute); } } else { - hl = new ExcelHyperLink(uri.OriginalString, UriKind.Relative); + hl = new ExcelHyperLink(uri.OriginalString + location, UriKind.Relative); } + hl.RId = rId; Part.DeleteRelationship(rId); //Delete the relationship, it is recreated when we save the package. }