diff --git a/stream.go b/stream.go index 0cffe45..84299cb 100644 --- a/stream.go +++ b/stream.go @@ -34,7 +34,7 @@ type StreamWriter struct { worksheet *xlsxWorksheet rawData bufferedWriter mergeCellsCount int - mergeCells string + mergeCells strings.Builder tableParts string } @@ -417,7 +417,11 @@ func (sw *StreamWriter) MergeCell(hCell, vCell string) error { return err } sw.mergeCellsCount++ - sw.mergeCells += fmt.Sprintf(``, hCell, vCell) + _, _ = sw.mergeCells.WriteString(``) return nil } @@ -526,10 +530,15 @@ func (sw *StreamWriter) Flush() error { } _, _ = sw.rawData.WriteString(``) bulkAppendFields(&sw.rawData, sw.worksheet, 8, 15) + mergeCells := strings.Builder{} if sw.mergeCellsCount > 0 { - sw.mergeCells = fmt.Sprintf(`%s`, sw.mergeCellsCount, sw.mergeCells) + _, _ = mergeCells.WriteString(``) + _, _ = mergeCells.WriteString(sw.mergeCells.String()) + _, _ = mergeCells.WriteString(``) } - _, _ = sw.rawData.WriteString(sw.mergeCells) + _, _ = sw.rawData.WriteString(mergeCells.String()) bulkAppendFields(&sw.rawData, sw.worksheet, 17, 38) _, _ = sw.rawData.WriteString(sw.tableParts) bulkAppendFields(&sw.rawData, sw.worksheet, 40, 40)