Trim blank cells which created by `completeCol()`, relate issue #81
This commit is contained in:
parent
4f942255e4
commit
3b2c80ddc3
19
sheet.go
19
sheet.go
|
@ -72,10 +72,29 @@ func (f *File) workbookWriter() {
|
||||||
func (f *File) worksheetWriter() {
|
func (f *File) worksheetWriter() {
|
||||||
for path, sheet := range f.Sheet {
|
for path, sheet := range f.Sheet {
|
||||||
if sheet != nil {
|
if sheet != nil {
|
||||||
|
for k, v := range sheet.SheetData.Row {
|
||||||
|
f.Sheet[path].SheetData.Row[k].C = trimCell(v.C)
|
||||||
|
}
|
||||||
output, _ := xml.Marshal(sheet)
|
output, _ := xml.Marshal(sheet)
|
||||||
f.saveFileList(path, replaceWorkSheetsRelationshipsNameSpace(string(output)))
|
f.saveFileList(path, replaceWorkSheetsRelationshipsNameSpace(string(output)))
|
||||||
|
ok := f.checked[path]
|
||||||
|
if ok {
|
||||||
|
f.checked[path] = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// trimCell provides function to trim blank cells which created by completeCol.
|
||||||
|
func trimCell(column []xlsxC) []xlsxC {
|
||||||
|
col := []xlsxC{}
|
||||||
|
for _, c := range column {
|
||||||
|
if c.S == 0 && c.V == "" && c.F == nil && c.T == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
col = append(col, c)
|
||||||
|
}
|
||||||
|
return col
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read and update property of contents type of XLSX.
|
// Read and update property of contents type of XLSX.
|
||||||
|
|
|
@ -203,7 +203,7 @@ type xlsxDefinedName struct {
|
||||||
FunctionGroupID int `xml:"functionGroupId,attr,omitempty"`
|
FunctionGroupID int `xml:"functionGroupId,attr,omitempty"`
|
||||||
Help string `xml:"help,attr,omitempty"`
|
Help string `xml:"help,attr,omitempty"`
|
||||||
Hidden bool `xml:"hidden,attr,omitempty"`
|
Hidden bool `xml:"hidden,attr,omitempty"`
|
||||||
LocalSheetID int `xml:"localSheetId,attr"`
|
LocalSheetID *int `xml:"localSheetId,attr"`
|
||||||
Name string `xml:"name,attr,omitempty"`
|
Name string `xml:"name,attr,omitempty"`
|
||||||
PublishToServer bool `xml:"publishToServer,attr,omitempty"`
|
PublishToServer bool `xml:"publishToServer,attr,omitempty"`
|
||||||
ShortcutKey string `xml:"shortcutKey,attr,omitempty"`
|
ShortcutKey string `xml:"shortcutKey,attr,omitempty"`
|
||||||
|
|
Loading…
Reference in New Issue