conditional formatting not allowing me to use percent formating #1610
Unanswered
CorbinAutomations
asked this question in
Q&A
Replies: 1 comment 4 replies
-
I have added support for creating a conditional format with number format and protection, Please try to upgrade the master branch code, and this feature will be released in the next version. For example, you can format A1:A10 cells with values between 0 to 1 with 2 places decimal percentage number format: 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)
}
}()
format, err := f.NewConditionalStyle(
&excelize.Style{
// Using built-in number format code at here,
// you can also using the custom number format code
NumFmt: 10,
},
)
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: "0",
MaxValue: "1",
},
},
); err != nil {
fmt.Println(err)
return
}
if err := f.SaveAs("Book1.xlsx"); err != nil {
fmt.Println(err)
}
} |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
so I have some code that uses conditional formatting and I ran into this problem where anywhere that had conditional formatting my percentage formatting using SetCellStyle would disappear. I tried to add this style to the conditional formatting by using
SetConditionalformatting but this still did not work. I have no Idea why this is happening does anyone have any ideas thx in advanced
Beta Was this translation helpful? Give feedback.
All reactions