how do I use the between condition in conditional formatting #1609
-
hey so I ran into a couple of problems when writing a report automation for my dad(I have been using golang for 12 days so I am still getting used to a couple of things) and I ran into a problem where I need to use a between comparison and when I checked the documentation the operation section for between was empty. does anyone have any idea how that works it is the last part of the project and I cant figure it out. thanks in advanced. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Here are examples for highlight A1:A10 cells which value between 6 to 8 in yellow color, and you can get more details about conditional format in the documentation: package main
import (
"fmt"
"github.com/xuri/excelize/v2"
)
func main() {
f := excelize.NewFile()
defer func() {
if err := f.Close(); err != nil {
fmt.Println(err)
}
}()
// Light yellow format for neutral conditional.
format, err := f.NewConditionalStyle(
&excelize.Style{
Font: &excelize.Font{Color: "9B5713"},
Fill: excelize.Fill{
Type: "pattern", Color: []string{"FEEAA0"}, Pattern: 1,
},
},
)
if err != nil {
fmt.Println(err)
return
}
// Highlight cells rule: between...
if err := f.SetConditionalFormat("Sheet1", "A1:A10",
[]excelize.ConditionalFormatOptions{
{
Type: "cell",
Criteria: "between",
Format: format,
MinValue: "6",
MaxValue: "8",
},
},
); err != nil {
fmt.Println(err)
return
}
if err := f.SaveAs("Book1.xlsx"); err != nil {
fmt.Println(err)
}
} |
Beta Was this translation helpful? Give feedback.
Here are examples for highlight A1:A10 cells which value between 6 to 8 in yellow color, and you can get more details about conditional format in the documentation: