Skip to content

Commit df91b34

Browse files
authored
This closes qax-os#1211, improve the compatibility with invalid internal styles count
1 parent 0f7a0c8 commit df91b34

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

styles.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2443,7 +2443,7 @@ func setCellXfs(style *xlsxStyleSheet, fontID, numFmtID, fillID, borderID int, a
24432443
if borderID != 0 {
24442444
xf.ApplyBorder = boolPtr(true)
24452445
}
2446-
style.CellXfs.Count++
2446+
style.CellXfs.Count = len(style.CellXfs.Xf) + 1
24472447
xf.Alignment = alignment
24482448
if alignment != nil {
24492449
xf.ApplyAlignment = boolPtr(applyAlignment)

styles_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,14 @@ func TestNewStyle(t *testing.T) {
271271
f.Styles.CellXfs.Xf = nil
272272
style4, err := f.NewStyle(&Style{NumFmt: 160, Lang: "unknown"})
273273
assert.NoError(t, err)
274-
assert.Equal(t, 1, style4)
274+
assert.Equal(t, 0, style4)
275275

276276
f = NewFile()
277277
f.Styles.NumFmts = nil
278278
f.Styles.CellXfs.Xf = nil
279279
style5, err := f.NewStyle(&Style{NumFmt: 160, Lang: "zh-cn"})
280280
assert.NoError(t, err)
281-
assert.Equal(t, 1, style5)
281+
assert.Equal(t, 0, style5)
282282
}
283283

284284
func TestGetDefaultFont(t *testing.T) {

0 commit comments

Comments
 (0)