Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way to set custom style on DataBar Conditional Formatting #1462

Closed
coolseven opened this issue Feb 3, 2023 · 4 comments
Closed
Labels
enhancement New feature or request

Comments

@coolseven
Copy link

coolseven commented Feb 3, 2023

I'm trying to set custom style on a conditional formatting data_bar

I'm using the code like below:

// my custom style
solidFillStyle, _ := f.NewConditionalStyle(&excelize.Style{Fill: excelize.Fill{Color: []string{"#A9D08E"}, Type: "pattern", Pattern: 1}})

_ = f.SetConditionalFormat(sheetAlias, someRangeRef, []excelize.ConditionalFormatOptions{{Type: "data_bar", BarColor: "#A9D08E", Format: solidFillStyle, Criteria: "=", MinType: "min", MaxType: "max"}})

I'm expecting the data_bar to be filled with solid color , as defined in solidFillStyle ,

But what I get is a gradient-filled data_bar

Seems that it will use an internal style for data_bar, which uses gradient fill, and any custom style will just be ignored

Am I doing something wrong here ? thank you.


go version I'm using

go version go1.17.2 linux/amd64

lib version:

github.com/xuri/excelize/v2 v2.7.0
@xuri xuri added the enhancement New feature or request label Feb 4, 2023
@xuri
Copy link
Member

xuri commented Feb 4, 2023

Thanks for your issue. Currently, the library doesn't support creating a conditional format with a solid color data bar style. I will consider adding this feature support in the future.

@xuri xuri added the in progress Working in progress label Feb 6, 2023
@xuri xuri closed this as completed in 3e24060 Feb 6, 2023
@xuri
Copy link
Member

xuri commented Feb 6, 2023

I have added support for creating a conditional format with a solid color data bar style. Please try to upgrade to the master branch code, and this patch will be released in the next version. Now you can specify solid color by BarSolid like this:

err := f.SetConditionalFormat(sheetAlias, someRangeRef,
    []excelize.ConditionalFormatOptions{
        {
            Type:     "data_bar",
            BarColor: "#A9D08E",
            Format:   solidFillStyle,
            Criteria: "=",
            MinType:  "min",
            MaxType:  "max",
+           BarSolid: true,
        },
    },
)

@xuri xuri removed the in progress Working in progress label Feb 6, 2023
@coolseven
Copy link
Author

Thanks a lot!

xuri added a commit to JDavidVR/excelize that referenced this issue Jul 11, 2023
- Support creating a conditional format with a "stop if true" rule
- Support set border color and create solid color for the color data bar
- Fix incorrect cell type when modifying string cell with the time number
- Update unit test for the add pivot table to avoid pivot table range overlap
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
- Support creating a conditional format with a "stop if true" rule
- Support set border color and create solid color for the color data bar
- Fix incorrect cell type when modifying string cell with the time number
- Update unit test for the add pivot table to avoid pivot table range overlap
@ShowerBandV
Copy link
Contributor

can i get gradient attr from data_bar ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants