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

GetConditionalFormats need get databar gradient #1769

Closed
ShowerBandV opened this issue Dec 27, 2023 · 1 comment
Closed

GetConditionalFormats need get databar gradient #1769

ShowerBandV opened this issue Dec 27, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@ShowerBandV
Copy link
Contributor

Description
When I tried to use GetConditionFormats to obtain the conditional format of a data bar, I didn't know if the data bar was gradient filled. I looked at the XML and found that if it wasn't gradient filled, there would be an attr with gradient="0". If it was gradient filled, there wouldn't be this attr. I hope excelize can support the function of obtaining whether the data bar is gradient filled

<x14:cfRule type="dataBar" id="{259B75A4-6F18-4B61-83F0-580C0D906035}">
<x14:dataBar minLength="0" maxLength="100" gradient="0">
<x14:cfvo type="autoMin"/>
<x14:cfvo type="autoMax"/>
<x14:negativeFillColor rgb="FFFF0000"/>
<x14:axisColor rgb="FF000000"/>
</x14:dataBar>
</x14:cfRule>

test (2).xlsx

@xuri xuri added bug Something isn't working in progress Working in progress labels Dec 28, 2023
@xuri xuri closed this as completed in bb8e5da Dec 28, 2023
@xuri
Copy link
Member

xuri commented Dec 28, 2023

Thanks for your issue. I have fixed this. Please upgrade to the master branch code, and this patch will be released in the next version. Please determine the gradient data bar with the BarSolid field, for example:

package main

import (
    "fmt"

    "github.com/xuri/excelize/v2"
)

func main() {
    f, err := excelize.OpenFile("test.2.xlsx")
    if err != nil {
        fmt.Println(err)
        return
    }
    defer func() {
        if err := f.Close(); err != nil {
            fmt.Println(err)
        }
    }()
    cfs, err := f.GetConditionalFormats("Sheet1")
    if err != nil {
        fmt.Println(err)
        return
    }
    for _, cf := range cfs {
        for _, rule := range cf {
            fmt.Println("is gradient:", !rule.BarSolid)
        }
    }
}

@xuri xuri removed the in progress Working in progress label Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants