qax-os / excelize

Go language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets
https://xuri.me/excelize
BSD 3-Clause "New" or "Revised" License
18.05k stars 1.71k forks source link

condition A with style ,the unstyled condition will be applied with A's style. #1867

Closed ShowerBandV closed 6 months ago

ShowerBandV commented 6 months ago

@xuri I found something wrong in commit 866f308, if there is a condition A with style ,the unstyled condition will be applied with A's style.

func (f *File) extractCondFmtCellIs(c *xlsxCfRule, extLst *xlsxExtLst) ConditionalFormatOptions {
    format := ConditionalFormatOptions{StopIfTrue: c.StopIfTrue, Type: "cell", Criteria: operatorType[c.Operator]}
    if c.DxfID != nil {
        format.Format = *c.DxfID
    }
    if len(c.Formula) == 2 {
        format.MinValue, format.MaxValue = c.Formula[0], c.Formula[1]
        return format
    }
    format.Value = c.Formula[0]
    return format
}

because the condition A's DxfID is 0,that is to say c.DxfID is 0 , and the unstyled condition's DxfID is nil, format default is 0,so after extract,they all will be 0,we can't distinguish who is unstyled

xuri commented 6 months ago

Thanks for your issue. I have change the data type for the ConditionalFormatOptions structure field Format as a pointer to resolve this problem. Please upgrade to the master branch code, and this breaking change will be released in the next version.