Skip to content

Commit afc8447

Browse files
Optimization of SaveAsTemplate method (#749)
* Refactoring and cleanup * Optimization of methods UpdateDimensionAndGetRowsInfo and WriteSheetXml
1 parent 6b0a604 commit afc8447

File tree

6 files changed

+767
-914
lines changed

6 files changed

+767
-914
lines changed

src/MiniExcel/OpenXml/ExcelOpenXmlUtils.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ static class ExcelOpenXmlUtils
1414
/// <summary>
1515
/// Encode to XML (special characteres: &apos; &quot; &gt; &lt; &amp;)
1616
/// </summary>
17-
public static string EncodeXML(string value) => value == null
18-
? string.Empty
19-
: XmlEncoder.EncodeString(value)
20-
.Replace("&", "&amp;")
21-
.Replace("<", "&lt;")
22-
.Replace(">", "&gt;")
23-
.Replace("\"", "&quot;")
24-
.Replace("'", "&apos;")
25-
.ToString();
17+
public static string EncodeXML(string value)
18+
=> value == null ? string.Empty
19+
: XmlEncoder.EncodeString(value)
20+
.Replace("&", "&amp;")
21+
.Replace("<", "&lt;")
22+
.Replace(">", "&gt;")
23+
.Replace("\"", "&quot;")
24+
.Replace("'", "&apos;")
25+
.ToString();
2626

2727
/// <summary>X=CellLetter,Y=CellNumber,ex:A1=(1,1),B2=(2,2)</summary>
2828
public static string ConvertXyToCell(Tuple<int, int> xy)
@@ -34,14 +34,14 @@ public static string ConvertXyToCell(Tuple<int, int> xy)
3434
public static string ConvertXyToCell(int x, int y)
3535
{
3636
int dividend = x;
37-
string columnName = String.Empty;
37+
string columnName = string.Empty;
3838
int modulo;
3939

4040
while (dividend > 0)
4141
{
4242
modulo = (dividend - 1) % 26;
43-
columnName = Convert.ToChar(65 + modulo).ToString() + columnName;
44-
dividend = (int)((dividend - modulo) / 26);
43+
columnName = Convert.ToChar(65 + modulo) + columnName;
44+
dividend = (dividend - modulo) / 26;
4545
}
4646
return $"{columnName}{y}";
4747
}

0 commit comments

Comments
 (0)