Skip to content

Commit

Permalink
Merge pull request #1441 from tonyqus/Clonesheet_1370_fix
Browse files Browse the repository at this point in the history
Fix Clone sheet when the sheet contains hyperlinks
  • Loading branch information
tonyqus authored Nov 10, 2024
2 parents e99f945 + 3dc47a8 commit 148d805
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ooxml/XSSF/UserModel/XSSFWorkbook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ public ISheet CloneSheet(int sheetNum, String newName)
if (pr.TargetMode == TargetMode.External)
{
clonedSheet.GetPackagePart().AddExternalRelationship
(pr.TargetUri.OriginalString, pr.RelationshipType, null);
(pr.TargetUri.OriginalString, pr.RelationshipType, pr.Id);
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions testcases/ooxml/XSSF/UserModel/TestCloneSheet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using NUnit.Framework;
using System.IO;

namespace NPOI.XSSF.UserModel
{
[TestFixture]
public class TestCloneSheet
{
[Test]
public void TestCloneHyperlink()
{
using(var workbook = XSSFTestDataSamples.OpenSampleWorkbook("1370_clonesheet_withhyperlink.xlsx"))
{
workbook.CloneSheet(0,"Sheet2");
}
}
}
}
Binary file not shown.

0 comments on commit 148d805

Please sign in to comment.