@ -3190,8 +3190,21 @@ func (f *File) SetCellStyle(sheet, hCell, vCell string, styleID int) error {
// MaxColor - Same as MinColor, see above.
// MaxColor - Same as MinColor, see above.
//
//
// BarColor - Used for data_bar. Same as MinColor, see above.
// BarColor - Used for data_bar. Same as MinColor, see above.
//
// BarBorderColor - Used for sets the color for the border line of a data bar,
// this is only visible in Excel 2010 and later.
//
// BarOnly - Used for displays a bar data but not the data in the cells.
//
// BarSolid - Used for turns on a solid (non-gradient) fill for data bars, this
// is only visible in Excel 2010 and later.
//
// StopIfTrue - used to set the "stop if true" feature of a conditional
// formatting rule when more than one rule is applied to a cell or a range of
// cells. When this parameter is set then subsequent rules are not evaluated
// if the current rule is true.
func ( f * File ) SetConditionalFormat ( sheet , rangeRef string , opts [ ] ConditionalFormatOptions ) error {
func ( f * File ) SetConditionalFormat ( sheet , rangeRef string , opts [ ] ConditionalFormatOptions ) error {
drawContFmtFunc := map [ string ] func ( p int , ct string , fmtCond * ConditionalFormatOptions ) * xlsxCfRule {
drawContFmtFunc := map [ string ] func ( p int , ct , GUID string , fmtCond * ConditionalFormatOptions ) ( * xlsxCfRule , * xlsxX14CfRule ) {
"cellIs" : drawCondFmtCellIs ,
"cellIs" : drawCondFmtCellIs ,
"top10" : drawCondFmtTop10 ,
"top10" : drawCondFmtTop10 ,
"aboveAverage" : drawCondFmtAboveAverage ,
"aboveAverage" : drawCondFmtAboveAverage ,
@ -3207,6 +3220,12 @@ func (f *File) SetConditionalFormat(sheet, rangeRef string, opts []ConditionalFo
if err != nil {
if err != nil {
return err
return err
}
}
// Create a pseudo GUID for each unique rule.
var rules int
for _ , cf := range ws . ConditionalFormatting {
rules += len ( cf . CfRule )
}
GUID := fmt . Sprintf ( "{00000000-0000-0000-%04X-%012X}" , f . getSheetID ( sheet ) , rules )
var cfRule [ ] * xlsxCfRule
var cfRule [ ] * xlsxCfRule
for p , v := range opts {
for p , v := range opts {
var vt , ct string
var vt , ct string
@ -3219,7 +3238,14 @@ func (f *File) SetConditionalFormat(sheet, rangeRef string, opts []ConditionalFo
if ok || vt == "expression" {
if ok || vt == "expression" {
drawFunc , ok := drawContFmtFunc [ vt ]
drawFunc , ok := drawContFmtFunc [ vt ]
if ok {
if ok {
cfRule = append ( cfRule , drawFunc ( p , ct , & v ) )
rule , x14rule := drawFunc ( p , ct , GUID , & v )
if x14rule != nil {
if err = f . appendCfRule ( ws , x14rule ) ; err != nil {
return err
}
f . addSheetNameSpace ( sheet , NameSpaceSpreadSheetX14 )
}
cfRule = append ( cfRule , rule )
}
}
}
}
}
}
@ -3232,11 +3258,64 @@ func (f *File) SetConditionalFormat(sheet, rangeRef string, opts []ConditionalFo
return err
return err
}
}
// appendCfRule provides a function to append rules to conditional formatting.
func ( f * File ) appendCfRule ( ws * xlsxWorksheet , rule * xlsxX14CfRule ) error {
var (
err error
idx int
decodeExtLst * decodeWorksheetExt
condFmts * xlsxX14ConditionalFormattings
decodeCondFmts * decodeX14ConditionalFormattings
ext * xlsxWorksheetExt
condFmtBytes , condFmtsBytes , extLstBytes , extBytes [ ] byte
)
if ws . ExtLst != nil { // append mode ext
decodeExtLst = new ( decodeWorksheetExt )
if err = f . xmlNewDecoder ( strings . NewReader ( "<extLst>" + ws . ExtLst . Ext + "</extLst>" ) ) .
Decode ( decodeExtLst ) ; err != nil && err != io . EOF {
return err
}
for idx , ext = range decodeExtLst . Ext {
if ext . URI == ExtURIConditionalFormattings {
decodeCondFmts = new ( decodeX14ConditionalFormattings )
_ = f . xmlNewDecoder ( strings . NewReader ( ext . Content ) ) . Decode ( decodeCondFmts )
condFmtBytes , _ = xml . Marshal ( [ ] * xlsxX14ConditionalFormatting {
{
XMLNSXM : NameSpaceSpreadSheetExcel2006Main . Value ,
CfRule : [ ] * xlsxX14CfRule { rule } ,
} ,
} )
if condFmts == nil {
condFmts = & xlsxX14ConditionalFormattings { }
}
condFmts . Content = decodeCondFmts . Content + string ( condFmtBytes )
condFmtsBytes , _ = xml . Marshal ( condFmts )
decodeExtLst . Ext [ idx ] . Content = string ( condFmtsBytes )
}
}
extLstBytes , _ = xml . Marshal ( decodeExtLst )
ws . ExtLst = & xlsxExtLst {
Ext : strings . TrimSuffix ( strings . TrimPrefix ( string ( extLstBytes ) , "<extLst>" ) , "</extLst>" ) ,
}
return err
}
condFmtBytes , _ = xml . Marshal ( [ ] * xlsxX14ConditionalFormatting {
{ XMLNSXM : NameSpaceSpreadSheetExcel2006Main . Value , CfRule : [ ] * xlsxX14CfRule { rule } } ,
} )
condFmtsBytes , _ = xml . Marshal ( & xlsxX14ConditionalFormattings { Content : string ( condFmtBytes ) } )
extBytes , err = xml . Marshal ( & xlsxWorksheetExt {
URI : ExtURIConditionalFormattings ,
Content : string ( condFmtsBytes ) ,
} )
ws . ExtLst = & xlsxExtLst { Ext : strings . TrimSuffix ( strings . TrimPrefix ( string ( extBytes ) , "<extLst>" ) , "</extLst>" ) }
return err
}
// extractCondFmtCellIs provides a function to extract conditional format
// extractCondFmtCellIs provides a function to extract conditional format
// settings for cell value (include between, not between, equal, not equal,
// settings for cell value (include between, not between, equal, not equal,
// greater than and less than) by given conditional formatting rule.
// greater than and less than) by given conditional formatting rule.
func extractCondFmtCellIs ( c * xlsxCfRule ) ConditionalFormatOptions {
func extractCondFmtCellIs ( c * xlsxCfRule , extLst * xlsxExtLst ) ConditionalFormatOptions {
format := ConditionalFormatOptions { Type : "cell" , Criteria : operatorType [ c . Operator ] , Format : * c . DxfID }
format := ConditionalFormatOptions { StopIfTrue: c . StopIfTrue , Type: "cell" , Criteria : operatorType [ c . Operator ] , Format : * c . DxfID }
if len ( c . Formula ) == 2 {
if len ( c . Formula ) == 2 {
format . Minimum , format . Maximum = c . Formula [ 0 ] , c . Formula [ 1 ]
format . Minimum , format . Maximum = c . Formula [ 0 ] , c . Formula [ 1 ]
return format
return format
@ -3248,8 +3327,9 @@ func extractCondFmtCellIs(c *xlsxCfRule) ConditionalFormatOptions {
// extractCondFmtTop10 provides a function to extract conditional format
// extractCondFmtTop10 provides a function to extract conditional format
// settings for top N (default is top 10) by given conditional formatting
// settings for top N (default is top 10) by given conditional formatting
// rule.
// rule.
func extractCondFmtTop10 ( c * xlsxCfRule ) ConditionalFormatOptions {
func extractCondFmtTop10 ( c * xlsxCfRule , extLst * xlsxExtLst ) ConditionalFormatOptions {
format := ConditionalFormatOptions {
format := ConditionalFormatOptions {
StopIfTrue : c . StopIfTrue ,
Type : "top" ,
Type : "top" ,
Criteria : "=" ,
Criteria : "=" ,
Format : * c . DxfID ,
Format : * c . DxfID ,
@ -3265,8 +3345,9 @@ func extractCondFmtTop10(c *xlsxCfRule) ConditionalFormatOptions {
// extractCondFmtAboveAverage provides a function to extract conditional format
// extractCondFmtAboveAverage provides a function to extract conditional format
// settings for above average and below average by given conditional formatting
// settings for above average and below average by given conditional formatting
// rule.
// rule.
func extractCondFmtAboveAverage ( c * xlsxCfRule ) ConditionalFormatOptions {
func extractCondFmtAboveAverage ( c * xlsxCfRule , extLst * xlsxExtLst ) ConditionalFormatOptions {
return ConditionalFormatOptions {
return ConditionalFormatOptions {
StopIfTrue : c . StopIfTrue ,
Type : "average" ,
Type : "average" ,
Criteria : "=" ,
Criteria : "=" ,
Format : * c . DxfID ,
Format : * c . DxfID ,
@ -3277,8 +3358,9 @@ func extractCondFmtAboveAverage(c *xlsxCfRule) ConditionalFormatOptions {
// extractCondFmtDuplicateUniqueValues provides a function to extract
// extractCondFmtDuplicateUniqueValues provides a function to extract
// conditional format settings for duplicate and unique values by given
// conditional format settings for duplicate and unique values by given
// conditional formatting rule.
// conditional formatting rule.
func extractCondFmtDuplicateUniqueValues ( c * xlsxCfRule ) ConditionalFormatOptions {
func extractCondFmtDuplicateUniqueValues ( c * xlsxCfRule , extLst * xlsxExtLst ) ConditionalFormatOptions {
return ConditionalFormatOptions {
return ConditionalFormatOptions {
StopIfTrue : c . StopIfTrue ,
Type : map [ string ] string {
Type : map [ string ] string {
"duplicateValues" : "duplicate" ,
"duplicateValues" : "duplicate" ,
"uniqueValues" : "unique" ,
"uniqueValues" : "unique" ,
@ -3291,8 +3373,8 @@ func extractCondFmtDuplicateUniqueValues(c *xlsxCfRule) ConditionalFormatOptions
// extractCondFmtColorScale provides a function to extract conditional format
// extractCondFmtColorScale provides a function to extract conditional format
// settings for color scale (include 2 color scale and 3 color scale) by given
// settings for color scale (include 2 color scale and 3 color scale) by given
// conditional formatting rule.
// conditional formatting rule.
func extractCondFmtColorScale ( c * xlsxCfRule ) ConditionalFormatOptions {
func extractCondFmtColorScale ( c * xlsxCfRule , extLst * xlsxExtLst ) ConditionalFormatOptions {
var format ConditionalFormatOptions
format := ConditionalFormatOptions { StopIfTrue : c . StopIfTrue }
format . Type , format . Criteria = "2_color_scale" , "="
format . Type , format . Criteria = "2_color_scale" , "="
values := len ( c . ColorScale . Cfvo )
values := len ( c . ColorScale . Cfvo )
colors := len ( c . ColorScale . Color )
colors := len ( c . ColorScale . Color )
@ -3326,20 +3408,58 @@ func extractCondFmtColorScale(c *xlsxCfRule) ConditionalFormatOptions {
// extractCondFmtDataBar provides a function to extract conditional format
// extractCondFmtDataBar provides a function to extract conditional format
// settings for data bar by given conditional formatting rule.
// settings for data bar by given conditional formatting rule.
func extractCondFmtDataBar ( c * xlsxCfRule ) ConditionalFormatOptions {
func extractCondFmtDataBar ( c * xlsxCfRule , extLst * xlsxExtLst ) ConditionalFormatOptions {
format := ConditionalFormatOptions { Type : "data_bar" , Criteria : "=" }
format := ConditionalFormatOptions { Type : "data_bar" , Criteria : "=" }
if c . DataBar != nil {
if c . DataBar != nil {
format . StopIfTrue = c . StopIfTrue
format . MinType = c . DataBar . Cfvo [ 0 ] . Type
format . MinType = c . DataBar . Cfvo [ 0 ] . Type
format . MaxType = c . DataBar . Cfvo [ 1 ] . Type
format . MaxType = c . DataBar . Cfvo [ 1 ] . Type
format . BarColor = "#" + strings . TrimPrefix ( strings . ToUpper ( c . DataBar . Color [ 0 ] . RGB ) , "FF" )
format . BarColor = "#" + strings . TrimPrefix ( strings . ToUpper ( c . DataBar . Color [ 0 ] . RGB ) , "FF" )
if c . DataBar . ShowValue != nil {
format . BarOnly = ! * c . DataBar . ShowValue
}
}
extractDataBarRule := func ( condFmts [ ] decodeX14ConditionalFormatting ) {
for _ , condFmt := range condFmts {
for _ , rule := range condFmt . CfRule {
if rule . DataBar != nil {
format . BarSolid = ! rule . DataBar . Gradient
if rule . DataBar . BorderColor != nil {
format . BarBorderColor = "#" + strings . TrimPrefix ( strings . ToUpper ( rule . DataBar . BorderColor . RGB ) , "FF" )
}
}
}
}
}
extractExtLst := func ( extLst * decodeWorksheetExt ) {
for _ , ext := range extLst . Ext {
if ext . URI == ExtURIConditionalFormattings {
decodeCondFmts := new ( decodeX14ConditionalFormattings )
if err := xml . Unmarshal ( [ ] byte ( ext . Content ) , & decodeCondFmts ) ; err == nil {
condFmts := [ ] decodeX14ConditionalFormatting { }
if err = xml . Unmarshal ( [ ] byte ( decodeCondFmts . Content ) , & condFmts ) ; err == nil {
extractDataBarRule ( condFmts )
}
}
}
}
}
if c . ExtLst != nil {
ext := decodeX14ConditionalFormattingExt { }
if err := xml . Unmarshal ( [ ] byte ( c . ExtLst . Ext ) , & ext ) ; err == nil && extLst != nil {
decodeExtLst := new ( decodeWorksheetExt )
if err = xml . Unmarshal ( [ ] byte ( "<extLst>" + extLst . Ext + "</extLst>" ) , decodeExtLst ) ; err == nil {
extractExtLst ( decodeExtLst )
}
}
}
}
return format
return format
}
}
// extractCondFmtExp provides a function to extract conditional format settings
// extractCondFmtExp provides a function to extract conditional format settings
// for expression by given conditional formatting rule.
// for expression by given conditional formatting rule.
func extractCondFmtExp ( c * xlsxCfRule ) ConditionalFormatOptions {
func extractCondFmtExp ( c * xlsxCfRule , extLst * xlsxExtLst ) ConditionalFormatOptions {
format := ConditionalFormatOptions { Type : "formula" , Format : * c . DxfID }
format := ConditionalFormatOptions { StopIfTrue: c . StopIfTrue , Type: "formula" , Format : * c . DxfID }
if len ( c . Formula ) > 0 {
if len ( c . Formula ) > 0 {
format . Criteria = c . Formula [ 0 ]
format . Criteria = c . Formula [ 0 ]
}
}
@ -3349,7 +3469,7 @@ func extractCondFmtExp(c *xlsxCfRule) ConditionalFormatOptions {
// GetConditionalFormats returns conditional format settings by given worksheet
// GetConditionalFormats returns conditional format settings by given worksheet
// name.
// name.
func ( f * File ) GetConditionalFormats ( sheet string ) ( map [ string ] [ ] ConditionalFormatOptions , error ) {
func ( f * File ) GetConditionalFormats ( sheet string ) ( map [ string ] [ ] ConditionalFormatOptions , error ) {
extractContFmtFunc := map [ string ] func ( c * xlsxCfRule ) ConditionalFormatOptions {
extractContFmtFunc := map [ string ] func ( c * xlsxCfRule , extLst * xlsxExtLst ) ConditionalFormatOptions {
"cellIs" : extractCondFmtCellIs ,
"cellIs" : extractCondFmtCellIs ,
"top10" : extractCondFmtTop10 ,
"top10" : extractCondFmtTop10 ,
"aboveAverage" : extractCondFmtAboveAverage ,
"aboveAverage" : extractCondFmtAboveAverage ,
@ -3369,7 +3489,7 @@ func (f *File) GetConditionalFormats(sheet string) (map[string][]ConditionalForm
var opts [ ] ConditionalFormatOptions
var opts [ ] ConditionalFormatOptions
for _ , cr := range cf . CfRule {
for _ , cr := range cf . CfRule {
if extractFunc , ok := extractContFmtFunc [ cr . Type ] ; ok {
if extractFunc , ok := extractContFmtFunc [ cr . Type ] ; ok {
opts = append ( opts , extractFunc ( cr ))
opts = append ( opts , extractFunc ( cr , ws . ExtLst ))
}
}
}
}
conditionalFormats [ cf . SQRef ] = opts
conditionalFormats [ cf . SQRef ] = opts
@ -3396,9 +3516,10 @@ func (f *File) UnsetConditionalFormat(sheet, rangeRef string) error {
// drawCondFmtCellIs provides a function to create conditional formatting rule
// drawCondFmtCellIs provides a function to create conditional formatting rule
// for cell value (include between, not between, equal, not equal, greater
// for cell value (include between, not between, equal, not equal, greater
// than and less than) by given priority, criteria type and format settings.
// than and less than) by given priority, criteria type and format settings.
func drawCondFmtCellIs ( p int , ct string , format * ConditionalFormatOptions ) * xlsxCfRule {
func drawCondFmtCellIs ( p int , ct , GUID string , format * ConditionalFormatOptions ) ( * xlsxCfRule , * xlsxX14CfRule ) {
c := & xlsxCfRule {
c := & xlsxCfRule {
Priority : p + 1 ,
Priority : p + 1 ,
StopIfTrue : format . StopIfTrue ,
Type : validType [ format . Type ] ,
Type : validType [ format . Type ] ,
Operator : ct ,
Operator : ct ,
DxfID : & format . Format ,
DxfID : & format . Format ,
@ -3410,15 +3531,16 @@ func drawCondFmtCellIs(p int, ct string, format *ConditionalFormatOptions) *xlsx
if idx := inStrSlice ( [ ] string { "equal" , "notEqual" , "greaterThan" , "lessThan" , "greaterThanOrEqual" , "lessThanOrEqual" , "containsText" , "notContains" , "beginsWith" , "endsWith" } , ct , true ) ; idx != - 1 {
if idx := inStrSlice ( [ ] string { "equal" , "notEqual" , "greaterThan" , "lessThan" , "greaterThanOrEqual" , "lessThanOrEqual" , "containsText" , "notContains" , "beginsWith" , "endsWith" } , ct , true ) ; idx != - 1 {
c . Formula = append ( c . Formula , format . Value )
c . Formula = append ( c . Formula , format . Value )
}
}
return c
return c , nil
}
}
// drawCondFmtTop10 provides a function to create conditional formatting rule
// drawCondFmtTop10 provides a function to create conditional formatting rule
// for top N (default is top 10) by given priority, criteria type and format
// for top N (default is top 10) by given priority, criteria type and format
// settings.
// settings.
func drawCondFmtTop10 ( p int , ct string , format * ConditionalFormatOptions ) * xlsxCfRule {
func drawCondFmtTop10 ( p int , ct , GUID string , format * ConditionalFormatOptions ) ( * xlsxCfRule , * xlsxX14CfRule ) {
c := & xlsxCfRule {
c := & xlsxCfRule {
Priority : p + 1 ,
Priority : p + 1 ,
StopIfTrue : format . StopIfTrue ,
Bottom : format . Type == "bottom" ,
Bottom : format . Type == "bottom" ,
Type : validType [ format . Type ] ,
Type : validType [ format . Type ] ,
Rank : 10 ,
Rank : 10 ,
@ -3428,36 +3550,38 @@ func drawCondFmtTop10(p int, ct string, format *ConditionalFormatOptions) *xlsxC
if rank , err := strconv . Atoi ( format . Value ) ; err == nil {
if rank , err := strconv . Atoi ( format . Value ) ; err == nil {
c . Rank = rank
c . Rank = rank
}
}
return c
return c , nil
}
}
// drawCondFmtAboveAverage provides a function to create conditional
// drawCondFmtAboveAverage provides a function to create conditional
// formatting rule for above average and below average by given priority,
// formatting rule for above average and below average by given priority,
// criteria type and format settings.
// criteria type and format settings.
func drawCondFmtAboveAverage ( p int , ct string , format * ConditionalFormatOptions ) * xlsxCfRule {
func drawCondFmtAboveAverage ( p int , ct , GUID string , format * ConditionalFormatOptions ) ( * xlsxCfRule , * xlsxX14CfRule ) {
return & xlsxCfRule {
return & xlsxCfRule {
Priority : p + 1 ,
Priority : p + 1 ,
StopIfTrue : format . StopIfTrue ,
Type : validType [ format . Type ] ,
Type : validType [ format . Type ] ,
AboveAverage : & format . AboveAverage ,
AboveAverage : & format . AboveAverage ,
DxfID : & format . Format ,
DxfID : & format . Format ,
}
} , nil
}
}
// drawCondFmtDuplicateUniqueValues provides a function to create conditional
// drawCondFmtDuplicateUniqueValues provides a function to create conditional
// formatting rule for duplicate and unique values by given priority, criteria
// formatting rule for duplicate and unique values by given priority, criteria
// type and format settings.
// type and format settings.
func drawCondFmtDuplicateUniqueValues ( p int , ct string , format * ConditionalFormatOptions ) * xlsxCfRule {
func drawCondFmtDuplicateUniqueValues ( p int , ct , GUID string , format * ConditionalFormatOptions ) ( * xlsxCfRule , * xlsxX14CfRule ) {
return & xlsxCfRule {
return & xlsxCfRule {
Priority : p + 1 ,
Priority : p + 1 ,
StopIfTrue : format . StopIfTrue ,
Type : validType [ format . Type ] ,
Type : validType [ format . Type ] ,
DxfID : & format . Format ,
DxfID : & format . Format ,
}
} , nil
}
}
// drawCondFmtColorScale provides a function to create conditional formatting
// drawCondFmtColorScale provides a function to create conditional formatting
// rule for color scale (include 2 color scale and 3 color scale) by given
// rule for color scale (include 2 color scale and 3 color scale) by given
// priority, criteria type and format settings.
// priority, criteria type and format settings.
func drawCondFmtColorScale ( p int , ct string , format * ConditionalFormatOptions ) * xlsxCfRule {
func drawCondFmtColorScale ( p int , ct , GUID string , format * ConditionalFormatOptions ) ( * xlsxCfRule , * xlsxX14CfRule ) {
minValue := format . MinValue
minValue := format . MinValue
if minValue == "" {
if minValue == "" {
minValue = "0"
minValue = "0"
@ -3473,6 +3597,7 @@ func drawCondFmtColorScale(p int, ct string, format *ConditionalFormatOptions) *
c := & xlsxCfRule {
c := & xlsxCfRule {
Priority : p + 1 ,
Priority : p + 1 ,
StopIfTrue : format . StopIfTrue ,
Type : "colorScale" ,
Type : "colorScale" ,
ColorScale : & xlsxColorScale {
ColorScale : & xlsxColorScale {
Cfvo : [ ] * xlsxCfvo {
Cfvo : [ ] * xlsxCfvo {
@ -3489,31 +3614,53 @@ func drawCondFmtColorScale(p int, ct string, format *ConditionalFormatOptions) *
}
}
c . ColorScale . Cfvo = append ( c . ColorScale . Cfvo , & xlsxCfvo { Type : format . MaxType , Val : maxValue } )
c . ColorScale . Cfvo = append ( c . ColorScale . Cfvo , & xlsxCfvo { Type : format . MaxType , Val : maxValue } )
c . ColorScale . Color = append ( c . ColorScale . Color , & xlsxColor { RGB : getPaletteColor ( format . MaxColor ) } )
c . ColorScale . Color = append ( c . ColorScale . Color , & xlsxColor { RGB : getPaletteColor ( format . MaxColor ) } )
return c
return c , nil
}
}
// drawCondFmtDataBar provides a function to create conditional formatting
// drawCondFmtDataBar provides a function to create conditional formatting
// rule for data bar by given priority, criteria type and format settings.
// rule for data bar by given priority, criteria type and format settings.
func drawCondFmtDataBar ( p int , ct string , format * ConditionalFormatOptions ) * xlsxCfRule {
func drawCondFmtDataBar ( p int , ct , GUID string , format * ConditionalFormatOptions ) ( * xlsxCfRule , * xlsxX14CfRule ) {
var x14CfRule * xlsxX14CfRule
var extLst * xlsxExtLst
if format . BarSolid {
extLst = & xlsxExtLst { Ext : fmt . Sprintf ( ` <ext uri="%s" xmlns:x14="%s"><x14:id>%s</x14:id></ext> ` , ExtURIConditionalFormattingRuleID , NameSpaceSpreadSheetX14 . Value , GUID ) }
x14CfRule = & xlsxX14CfRule {
Type : validType [ format . Type ] ,
ID : GUID ,
DataBar : & xlsx14DataBar {
MaxLength : 100 ,
Cfvo : [ ] * xlsxCfvo { { Type : "autoMin" } , { Type : "autoMax" } } ,
NegativeFillColor : & xlsxColor { RGB : "FFFF0000" } ,
AxisColor : & xlsxColor { RGB : "FFFF0000" } ,
} ,
}
if format . BarBorderColor != "" {
x14CfRule . DataBar . BorderColor = & xlsxColor { RGB : getPaletteColor ( format . BarBorderColor ) }
}
}
return & xlsxCfRule {
return & xlsxCfRule {
Priority : p + 1 ,
Priority : p + 1 ,
StopIfTrue : format . StopIfTrue ,
Type : validType [ format . Type ] ,
Type : validType [ format . Type ] ,
DataBar : & xlsxDataBar {
DataBar : & xlsxDataBar {
ShowValue : boolPtr ( ! format . BarOnly ) ,
Cfvo : [ ] * xlsxCfvo { { Type : format . MinType } , { Type : format . MaxType } } ,
Cfvo : [ ] * xlsxCfvo { { Type : format . MinType } , { Type : format . MaxType } } ,
Color : [ ] * xlsxColor { { RGB : getPaletteColor ( format . BarColor ) } } ,
Color : [ ] * xlsxColor { { RGB : getPaletteColor ( format . BarColor ) } } ,
} ,
} ,
}
ExtLst : extLst ,
} , x14CfRule
}
}
// drawCondFmtExp provides a function to create conditional formatting rule
// drawCondFmtExp provides a function to create conditional formatting rule
// for expression by given priority, criteria type and format settings.
// for expression by given priority, criteria type and format settings.
func drawCondFmtExp ( p int , ct string , format * ConditionalFormatOptions ) * xlsxCfRule {
func drawCondFmtExp ( p int , ct , GUID string , format * ConditionalFormatOptions ) ( * xlsxCfRule , * xlsxX14CfRule ) {
return & xlsxCfRule {
return & xlsxCfRule {
Priority : p + 1 ,
Priority : p + 1 ,
StopIfTrue : format . StopIfTrue ,
Type : validType [ format . Type ] ,
Type : validType [ format . Type ] ,
Formula : [ ] string { format . Criteria } ,
Formula : [ ] string { format . Criteria } ,
DxfID : & format . Format ,
DxfID : & format . Format ,
}
} , nil
}
}
// getPaletteColor provides a function to convert the RBG color by given
// getPaletteColor provides a function to convert the RBG color by given