parent
fe639faa45
commit
6cc1a547ab
23
sheet.go
23
sheet.go
|
@ -179,35 +179,38 @@ func (f *File) workSheetWriter() {
|
||||||
func trimRow(sheetData *xlsxSheetData) []xlsxRow {
|
func trimRow(sheetData *xlsxSheetData) []xlsxRow {
|
||||||
var (
|
var (
|
||||||
row xlsxRow
|
row xlsxRow
|
||||||
rows []xlsxRow
|
i int
|
||||||
)
|
)
|
||||||
for k, v := range sheetData.Row {
|
|
||||||
|
for k := range sheetData.Row {
|
||||||
row = sheetData.Row[k]
|
row = sheetData.Row[k]
|
||||||
if row.C = trimCell(v.C); len(row.C) != 0 || row.hasAttr() {
|
if row = trimCell(row); len(row.C) != 0 || row.hasAttr() {
|
||||||
rows = append(rows, row)
|
sheetData.Row[i] = row
|
||||||
}
|
}
|
||||||
|
i++
|
||||||
}
|
}
|
||||||
return rows
|
return sheetData.Row[:i]
|
||||||
}
|
}
|
||||||
|
|
||||||
// trimCell provides a function to trim blank cells which created by fillColumns.
|
// 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
|
rowFull := true
|
||||||
for i := range column {
|
for i := range column {
|
||||||
rowFull = column[i].hasValue() && rowFull
|
rowFull = column[i].hasValue() && rowFull
|
||||||
}
|
}
|
||||||
if rowFull {
|
if rowFull {
|
||||||
return column
|
return row
|
||||||
}
|
}
|
||||||
col := make([]xlsxC, len(column))
|
|
||||||
i := 0
|
i := 0
|
||||||
for _, c := range column {
|
for _, c := range column {
|
||||||
if c.hasValue() {
|
if c.hasValue() {
|
||||||
col[i] = c
|
row.C[i] = c
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return col[:i]
|
row.C = row.C[:i]
|
||||||
|
return row
|
||||||
}
|
}
|
||||||
|
|
||||||
// setContentTypes provides a function to read and update property of contents
|
// setContentTypes provides a function to read and update property of contents
|
||||||
|
|
Loading…
Reference in New Issue