summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2021-07-08 00:52:07 +0800
committerxuri <xuri.me@gmail.com>2021-07-08 00:52:07 +0800
commit4f0d676eb765472d1fe7a29cacd165b982785bd2 (patch)
treeccf5057aa8beeff38b6948c3dd5541fe0003d399
parent90d200a10ba4d8c2ae2eff47ad8e1cca0ab28e76 (diff)
Fix missing set each cell's styles when set columns style
-rw-r--r--calc.go5
-rw-r--r--col.go7
-rw-r--r--col_test.go1
3 files changed, 9 insertions, 4 deletions
diff --git a/calc.go b/calc.go
index 934ae43..2d10e3b 100644
--- a/calc.go
+++ b/calc.go
@@ -947,10 +947,7 @@ func isEndParenthesesToken(token efp.Token) bool {
// token.
func isOperatorPrefixToken(token efp.Token) bool {
_, ok := tokenPriority[token.TValue]
- if (token.TValue == "-" && token.TType == efp.TokenTypeOperatorPrefix) || (ok && token.TType == efp.TokenTypeOperatorInfix) {
- return true
- }
- return false
+ return (token.TValue == "-" && token.TType == efp.TokenTypeOperatorPrefix) || (ok && token.TType == efp.TokenTypeOperatorInfix)
}
// getDefinedNameRefTo convert defined name to reference range.
diff --git a/col.go b/col.go
index 91ca3da..5171f34 100644
--- a/col.go
+++ b/col.go
@@ -435,6 +435,13 @@ func (f *File) SetColStyle(sheet, columns string, styleID int) error {
fc.Width = c.Width
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
}
diff --git a/col_test.go b/col_test.go
index 8159a11..58f424b 100644
--- a/col_test.go
+++ b/col_test.go
@@ -287,6 +287,7 @@ func TestOutlineLevel(t *testing.T) {
func TestSetColStyle(t *testing.T) {
f := NewFile()
+ assert.NoError(t, f.SetCellValue("Sheet1", "B2", "Hello"))
style, err := f.NewStyle(`{"fill":{"type":"pattern","color":["#94d3a2"],"pattern":1}}`)
assert.NoError(t, err)
// Test set column style on not exists worksheet.