Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed System.InvalidOperationException: 'The hyperlink for cell A1 references relation rId1, but that didn't exist!' #1370

Open
1 of 5 tasks
htoyama opened this issue Jun 25, 2024 · 0 comments
Labels

Comments

@htoyama
Copy link

htoyama commented Jun 25, 2024

NPOI Version

2.7.0

File Type

  • XLSX
  • XLS
  • DOCX
  • XLSM
  • OTHER

Upload the Excel File

Book1.xlsx

Reproduce Steps

workbook.CloneSheet("Sheet1");

Issue Description

System.InvalidOperationException: 'The hyperlink for cell A1 references relation rId1, but that didn't exist!'
RelationshipのIdは、コピー元のワークシートと同じにしないと例外になる。

diff --git a/ooxml/XSSF/UserModel/XSSFWorkbook.cs b/ooxml/XSSF/UserModel/XSSFWorkbook.cs
index 2940dc72..da0981aa 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);
                     }
                 }
             }
@htoyama htoyama added the bug label Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant