diff --git a/src/EPPlus/Core/Worksheet/WorksheetCopyHelper.cs b/src/EPPlus/Core/Worksheet/WorksheetCopyHelper.cs index 824d37cd1..65d1ff596 100644 --- a/src/EPPlus/Core/Worksheet/WorksheetCopyHelper.cs +++ b/src/EPPlus/Core/Worksheet/WorksheetCopyHelper.cs @@ -63,7 +63,7 @@ internal static ExcelWorksheet Copy(ExcelWorksheets worksheets, string name, Exc string relID = worksheets.CreateWorkbookRel(name, sheetID, uriWorksheet, false, null); ExcelWorksheet added = new ExcelWorksheet(nsm, pck, relID, uriWorksheet, name, sheetID, worksheets.Count + pck._worksheetAdd, eWorkSheetHidden.Visible); - + added.SetNewUid(); //Copy comments if (copy.ThreadedComments.Count > 0) { diff --git a/src/EPPlus/Encryption/EncryptionHandler.cs b/src/EPPlus/Encryption/EncryptionHandler.cs index 170b5ffc9..e57be397c 100644 --- a/src/EPPlus/Encryption/EncryptionHandler.cs +++ b/src/EPPlus/Encryption/EncryptionHandler.cs @@ -198,11 +198,7 @@ private MemoryStream EncryptPackageAgile(byte[] package, ExcelEncryption encrypt private byte[] EncryptDataAgile(byte[] data, EncryptionInfoAgile encryptionInfo, HashAlgorithm hashProvider) { var ke = encryptionInfo.KeyEncryptors[0]; -#if Core var aes = Aes.Create(); -#else - RijndaelManaged aes = new RijndaelManaged(); -#endif aes.KeySize = ke.KeyBits; aes.Mode = CipherMode.CBC; aes.Padding = PaddingMode.Zeros; @@ -472,11 +468,7 @@ private EncryptionInfoBinary CreateEncryptionInfo(string password, AlgorithmID a } private byte[] EncryptData(byte[] key, byte[] data, bool useDataSize) { -#if (Core) var aes = Aes.Create(); -#else - RijndaelManaged aes = new RijndaelManaged(); -#endif aes.KeySize = key.Length * 8; aes.Mode = CipherMode.ECB; aes.Padding = PaddingMode.Zeros; @@ -673,11 +665,7 @@ private MemoryStream DecryptBinary(EncryptionInfoBinary encryptionInfo, string p encryptionInfo.Header.AlgID == AlgorithmID.AES256 ) { -#if (Core) var decryptKey = Aes.Create(); -#else - RijndaelManaged decryptKey = new RijndaelManaged(); -#endif decryptKey.KeySize = encryptionInfo.Header.KeySize; decryptKey.Mode = CipherMode.ECB; decryptKey.Padding = PaddingMode.None; @@ -716,11 +704,7 @@ private MemoryStream DecryptBinary(EncryptionInfoBinary encryptionInfo, string p /// private bool IsPasswordValid(byte[] key, EncryptionInfoBinary encryptionInfo) { -#if (Core) var decryptKey = Aes.Create(); -#else - RijndaelManaged decryptKey = new RijndaelManaged(); -#endif decryptKey.KeySize = encryptionInfo.Header.KeySize; decryptKey.Mode = CipherMode.ECB; decryptKey.Padding = PaddingMode.None; @@ -845,7 +829,7 @@ private SymmetricAlgorithm GetEncryptionAlgorithm(EncryptionInfoAgile.Encryption switch (encr.CipherAlgorithm) { case eCipherAlgorithm.AES: - return new RijndaelManaged(); + return Aes.Create(); case eCipherAlgorithm.DES: return new DESCryptoServiceProvider(); case eCipherAlgorithm.TRIPLE_DES: diff --git a/src/EPPlus/ExcelWorksheet.cs b/src/EPPlus/ExcelWorksheet.cs index a3cc1b962..9351ed923 100644 --- a/src/EPPlus/ExcelWorksheet.cs +++ b/src/EPPlus/ExcelWorksheet.cs @@ -1238,7 +1238,10 @@ private void CreateVmlCollection() } } } - + internal void SetNewUid() + { + SetXmlNodeString("@xr:uid", "{" + Guid.NewGuid().ToString().ToUpperInvariant() + "}"); + } private void CreateXml() { _worksheetXml = new XmlDocument(); diff --git a/src/EPPlusTest/Issues.cs b/src/EPPlusTest/Issues.cs index 0fa8e40d9..b72ad52d4 100644 --- a/src/EPPlusTest/Issues.cs +++ b/src/EPPlusTest/Issues.cs @@ -5016,5 +5016,16 @@ public void I892() SaveAndCleanup(p); } } + [TestMethod] + public void SaveDialogIssue890() + { + using (var package = OpenTemplatePackage("issue890.xlsx")) + { + ExcelWorksheet worksheet = package.Workbook.Worksheets[0]; + ExcelWorksheet newWorksheet = package.Workbook.Worksheets.Add("Sheet2", worksheet); + SaveAndCleanup(package); + } + } + } } \ No newline at end of file