This closes #1211, improve the compatibility with invalid internal styles count

pull/2/head
xuri 3 years ago committed by GitHub
parent 0f7a0c8f3b
commit df91b34a3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2443,7 +2443,7 @@ func setCellXfs(style *xlsxStyleSheet, fontID, numFmtID, fillID, borderID int, a
if borderID != 0 { if borderID != 0 {
xf.ApplyBorder = boolPtr(true) xf.ApplyBorder = boolPtr(true)
} }
style.CellXfs.Count++ style.CellXfs.Count = len(style.CellXfs.Xf) + 1
xf.Alignment = alignment xf.Alignment = alignment
if alignment != nil { if alignment != nil {
xf.ApplyAlignment = boolPtr(applyAlignment) xf.ApplyAlignment = boolPtr(applyAlignment)

@ -271,14 +271,14 @@ func TestNewStyle(t *testing.T) {
f.Styles.CellXfs.Xf = nil f.Styles.CellXfs.Xf = nil
style4, err := f.NewStyle(&Style{NumFmt: 160, Lang: "unknown"}) style4, err := f.NewStyle(&Style{NumFmt: 160, Lang: "unknown"})
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, 1, style4) assert.Equal(t, 0, style4)
f = NewFile() f = NewFile()
f.Styles.NumFmts = nil f.Styles.NumFmts = nil
f.Styles.CellXfs.Xf = nil f.Styles.CellXfs.Xf = nil
style5, err := f.NewStyle(&Style{NumFmt: 160, Lang: "zh-cn"}) style5, err := f.NewStyle(&Style{NumFmt: 160, Lang: "zh-cn"})
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, 1, style5) assert.Equal(t, 0, style5)
} }
func TestGetDefaultFont(t *testing.T) { func TestGetDefaultFont(t *testing.T) {

Loading…
Cancel
Save