From 3dc47a85aed8dc7c2daf33c9093a97b4d85e5cd4 Mon Sep 17 00:00:00 2001 From: Tony Qu Date: Sat, 9 Nov 2024 08:54:17 +0800 Subject: [PATCH] fix #1370 --- ooxml/XSSF/UserModel/XSSFWorkbook.cs | 2 +- .../ooxml/XSSF/UserModel/TestCloneSheet.cs | 18 ++++++++++++++++++ .../1370_clonesheet_withhyperlink.xlsx | Bin 0 -> 9749 bytes 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 testcases/ooxml/XSSF/UserModel/TestCloneSheet.cs create mode 100644 testcases/test-data/spreadsheet/1370_clonesheet_withhyperlink.xlsx diff --git a/ooxml/XSSF/UserModel/XSSFWorkbook.cs b/ooxml/XSSF/UserModel/XSSFWorkbook.cs index 2940dc72f..da0981aa7 100644 --- a/ooxml/XSSF/UserModel/XSSFWorkbook.cs +++ b/ooxml/XSSF/UserModel/XSSFWorkbook.cs @@ -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); } } } diff --git a/testcases/ooxml/XSSF/UserModel/TestCloneSheet.cs b/testcases/ooxml/XSSF/UserModel/TestCloneSheet.cs new file mode 100644 index 000000000..c04c77af9 --- /dev/null +++ b/testcases/ooxml/XSSF/UserModel/TestCloneSheet.cs @@ -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"); + } + } + } +} \ No newline at end of file diff --git a/testcases/test-data/spreadsheet/1370_clonesheet_withhyperlink.xlsx b/testcases/test-data/spreadsheet/1370_clonesheet_withhyperlink.xlsx new file mode 100644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