diff --git a/src/EPPlus/Utils/ConvertUtil.cs b/src/EPPlus/Utils/ConvertUtil.cs index a47b57512..a6a2e623b 100644 --- a/src/EPPlus/Utils/ConvertUtil.cs +++ b/src/EPPlus/Utils/ConvertUtil.cs @@ -428,7 +428,9 @@ internal static void ExcelEncodeString(StringBuilder sb, string t, bool encodeTa } for (int i = 0; i < t.Length; i++) { - if (t[i] <= 0x1f && ((t[i] != '\n' && encodeTabLF == false) || encodeTabLF)) //Not Tab, CR or LF + if (t[i] <= 0x1f && + ((t[i] != '\n' && t[i] != '\r' && t[i] != '\t' && encodeTabLF == false) || //Not Tab, CR or LF + encodeTabLF)) { sb.AppendFormat("_x00{0}_", (t[i] <= 0xf ? "0" : "") + ((int)t[i]).ToString("X")); } diff --git a/src/EPPlusTest/Issues/WorksheetIssues.cs b/src/EPPlusTest/Issues/WorksheetIssues.cs index 5817ae71c..6c57ee0fc 100644 --- a/src/EPPlusTest/Issues/WorksheetIssues.cs +++ b/src/EPPlusTest/Issues/WorksheetIssues.cs @@ -489,5 +489,16 @@ public void s746() } } + [TestMethod] + public void I1628() + { + using (var p = OpenPackage("i1628.xlsx", true)) + { + var ws = p.Workbook.Worksheets.Add("Sheet1"); + ws.Cells["A1"].Value = "A\r\n\tB"; + SaveAndCleanup(p); + + } + } } } \ No newline at end of file