Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/MiniExcel/SaveByTemplate/ExcelOpenXmlTemplate.Impl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,6 @@ private void GenerateCellValues(string endPrefix, StreamWriter writer, ref int r
{
// Just need to remove space string one time https://github.com/mini-software/MiniExcel/issues/751
var cleanOuterXmlOpen = CleanXml(outerXmlOpen, endPrefix);
var cleanInnerXml = CleanXml(innerXml, endPrefix);

// https://github.com/mini-software/MiniExcel/issues/771 Saving by template introduces unintended value replication in each row #771
var notFirstRowElement = rowElement.Clone();
Expand All @@ -556,15 +555,14 @@ private void GenerateCellValues(string endPrefix, StreamWriter writer, ref int r
if (v != null && !_nonTemplateRegex.IsMatch(v.InnerText))
v.InnerText = string.Empty;
}
var cleanNotFirstRowInnerXml = CleanXml(notFirstRowElement.InnerXml, endPrefix);

foreach (var item in rowInfo.CellIEnumerableValues)
{
iEnumerableIndex++;
rowXml.Clear()
.Append(cleanOuterXmlOpen)
.AppendFormat(@" r=""{0}"">", newRowIndex)
.Append(cleanInnerXml)
.Append(innerXml)
.Replace("{{$rowindex}}", newRowIndex.ToString())
.AppendFormat("</{0}>", row.Name);

Expand Down Expand Up @@ -739,7 +737,7 @@ private void GenerateCellValues(string endPrefix, StreamWriter writer, ref int r
if (isFirst)
{
// https://github.com/mini-software/MiniExcel/issues/771 Saving by template introduces unintended value replication in each row #771
cleanInnerXml = cleanNotFirstRowInnerXml;
innerXml = notFirstRowElement.InnerXml;
isFirst = false;
}

Expand All @@ -748,7 +746,7 @@ private void GenerateCellValues(string endPrefix, StreamWriter writer, ref int r

// replace formulas
ProcessFormulas(rowXml, newRowIndex);
writer.Write(rowXml);
writer.Write(CleanXml(rowXml, endPrefix));

//mergecells
if (rowInfo.RowMercells == null)
Expand Down
Loading