Closed htoyama closed 2 months ago
2.7.0
Book1.xlsx
Workbook.CloneSheet("Sheet1,") Workbook.Write(New_File)
diff --git a/ooxml/XSSF/UserModel/XSSFSheet.cs b/ooxml/XSSF/UserModel/XSSFSheet.cs index 7a12241b..02b8e410 100644 --- a/ooxml/XSSF/UserModel/XSSFSheet.cs +++ b/ooxml/XSSF/UserModel/XSSFSheet.cs @@ -5521,7 +5521,31 @@ private CellRangeAddress GetRepeatingRowsOrColums(bool rows) return null; } - string[] parts = refStr.Split(",".ToCharArray()); + // The character(') used to quote sheet names when they contain special characters + bool skipComma = false; + string subStr = String.Empty; + List<string> parts = new List<string>(); + + foreach (char c in refStr) + { + if (c == '\'') + skipComma = !skipComma; + + if (c == ',' && !skipComma) + { + if (subStr.Length > 0) + { + parts.Add(subStr); + subStr = String.Empty; + } + continue; + } + subStr += c; + } + if (subStr.Length > 0) + parts.Add(subStr); + + //string[] parts = refStr.Split(",".ToCharArray()); int maxRowIndex = SpreadsheetVersion.EXCEL2007.LastRowIndex; int maxColIndex = SpreadsheetVersion.EXCEL2007.LastColumnIndex; foreach (string part in parts)
Hi, I don't fully understand this issue.
Are you providing a fix for this issue? If so, can you use the Pull Request?
I agree with you. This issue, occur exception with book1.xlsx.
NPOI Version
2.7.0
File Type
Upload the Excel File
Book1.xlsx
Reproduce Steps
Workbook.CloneSheet("Sheet1,") Workbook.Write(New_File)
Issue Description