未验证 提交 6cc1a547 编写于 作者: M Marko Krstic 提交者: GitHub

This closes #1712, reduce memory consumption (#1713)

上级 fe639faa
......@@ -178,36 +178,39 @@ func (f *File) workSheetWriter() {
// trimRow provides a function to trim empty rows.
func trimRow(sheetData *xlsxSheetData) []xlsxRow {
var (
row xlsxRow
rows []xlsxRow
row xlsxRow
i int
)
for k, v := range sheetData.Row {
for k := range sheetData.Row {
row = sheetData.Row[k]
if row.C = trimCell(v.C); len(row.C) != 0 || row.hasAttr() {
rows = append(rows, row)
if row = trimCell(row); len(row.C) != 0 || row.hasAttr() {
sheetData.Row[i] = row
}
i++
}
return rows
return sheetData.Row[:i]
}
// trimCell provides a function to trim blank cells which created by fillColumns.
func trimCell(column []xlsxC) []xlsxC {
func trimCell(row xlsxRow) xlsxRow {
column := row.C
rowFull := true
for i := range column {
rowFull = column[i].hasValue() && rowFull
}
if rowFull {
return column
return row
}
col := make([]xlsxC, len(column))
i := 0
for _, c := range column {
if c.hasValue() {
col[i] = c
row.C[i] = c
i++
}
}
return col[:i]
row.C = row.C[:i]
return row
}
// setContentTypes provides a function to read and update property of contents
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册