Fix missing set each cell's styles when set columns style

v2
xuri 4 years ago
parent 90d200a10b
commit 4f0d676eb7
No known key found for this signature in database
GPG Key ID: BA5E5BB1C948EDF7

@ -947,10 +947,7 @@ func isEndParenthesesToken(token efp.Token) bool {
// token. // token.
func isOperatorPrefixToken(token efp.Token) bool { func isOperatorPrefixToken(token efp.Token) bool {
_, ok := tokenPriority[token.TValue] _, ok := tokenPriority[token.TValue]
if (token.TValue == "-" && token.TType == efp.TokenTypeOperatorPrefix) || (ok && token.TType == efp.TokenTypeOperatorInfix) { return (token.TValue == "-" && token.TType == efp.TokenTypeOperatorPrefix) || (ok && token.TType == efp.TokenTypeOperatorInfix)
return true
}
return false
} }
// getDefinedNameRefTo convert defined name to reference range. // getDefinedNameRefTo convert defined name to reference range.

@ -435,6 +435,13 @@ func (f *File) SetColStyle(sheet, columns string, styleID int) error {
fc.Width = c.Width fc.Width = c.Width
return fc return fc
}) })
if rows := len(ws.SheetData.Row); rows > 0 {
for col := start; col <= end; col++ {
from, _ := CoordinatesToCellName(col, 1)
to, _ := CoordinatesToCellName(col, rows)
f.SetCellStyle(sheet, from, to, styleID)
}
}
return nil return nil
} }

@ -287,6 +287,7 @@ func TestOutlineLevel(t *testing.T) {
func TestSetColStyle(t *testing.T) { func TestSetColStyle(t *testing.T) {
f := NewFile() f := NewFile()
assert.NoError(t, f.SetCellValue("Sheet1", "B2", "Hello"))
style, err := f.NewStyle(`{"fill":{"type":"pattern","color":["#94d3a2"],"pattern":1}}`) style, err := f.NewStyle(`{"fill":{"type":"pattern","color":["#94d3a2"],"pattern":1}}`)
assert.NoError(t, err) assert.NoError(t, err)
// Test set column style on not exists worksheet. // Test set column style on not exists worksheet.

Loading…
Cancel
Save