@@ -1071,25 +1071,28 @@ var (
1071
1071
"gray0625" ,
1072
1072
}
1073
1073
// styleFillVariants list all preset variants of the fill style.
1074
- styleFillVariants = []xlsxGradientFill {
1075
- {Degree : 90 , Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}},
1076
- {Degree : 270 , Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}},
1077
- {Degree : 90 , Stop : []* xlsxGradientFillStop {{}, {Position : 0.5 }, {Position : 1 }}},
1078
- {Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}},
1079
- {Degree : 180 , Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}},
1080
- {Stop : []* xlsxGradientFillStop {{}, {Position : 0.5 }, {Position : 1 }}},
1081
- {Degree : 45 , Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}},
1082
- {Degree : 255 , Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}},
1083
- {Degree : 45 , Stop : []* xlsxGradientFillStop {{}, {Position : 0.5 }, {Position : 1 }}},
1084
- {Degree : 135 , Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}},
1085
- {Degree : 315 , Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}},
1086
- {Degree : 135 , Stop : []* xlsxGradientFillStop {{}, {Position : 0.5 }, {Position : 1 }}},
1087
- {Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}, Type : "path" },
1088
- {Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}, Type : "path" , Left : 1 , Right : 1 },
1089
- {Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}, Type : "path" , Bottom : 1 , Top : 1 },
1090
- {Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}, Type : "path" , Bottom : 1 , Left : 1 , Right : 1 , Top : 1 },
1091
- {Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}, Type : "path" , Bottom : 0.5 , Left : 0.5 , Right : 0.5 , Top : 0.5 },
1074
+ styleFillVariants = func () []xlsxGradientFill {
1075
+ return []xlsxGradientFill {
1076
+ {Degree : 90 , Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}},
1077
+ {Degree : 270 , Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}},
1078
+ {Degree : 90 , Stop : []* xlsxGradientFillStop {{}, {Position : 0.5 }, {Position : 1 }}},
1079
+ {Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}},
1080
+ {Degree : 180 , Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}},
1081
+ {Stop : []* xlsxGradientFillStop {{}, {Position : 0.5 }, {Position : 1 }}},
1082
+ {Degree : 45 , Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}},
1083
+ {Degree : 255 , Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}},
1084
+ {Degree : 45 , Stop : []* xlsxGradientFillStop {{}, {Position : 0.5 }, {Position : 1 }}},
1085
+ {Degree : 135 , Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}},
1086
+ {Degree : 315 , Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}},
1087
+ {Degree : 135 , Stop : []* xlsxGradientFillStop {{}, {Position : 0.5 }, {Position : 1 }}},
1088
+ {Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}, Type : "path" },
1089
+ {Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}, Type : "path" , Left : 1 , Right : 1 },
1090
+ {Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}, Type : "path" , Bottom : 1 , Top : 1 },
1091
+ {Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}, Type : "path" , Bottom : 1 , Left : 1 , Right : 1 , Top : 1 },
1092
+ {Stop : []* xlsxGradientFillStop {{}, {Position : 1 }}, Type : "path" , Bottom : 0.5 , Left : 0.5 , Right : 0.5 , Top : 0.5 },
1093
+ }
1092
1094
}
1095
+
1093
1096
// getXfIDFuncs provides a function to get xfID by given style.
1094
1097
getXfIDFuncs = map [string ]func (int , xlsxXf , * Style ) bool {
1095
1098
"numFmt" : func (numFmtID int , xf xlsxXf , style * Style ) bool {
@@ -1132,6 +1135,7 @@ var (
1132
1135
return reflect .DeepEqual (xf .Protection , newProtection (style )) && xf .ApplyProtection != nil && * xf .ApplyProtection
1133
1136
},
1134
1137
}
1138
+
1135
1139
// extractStyleCondFuncs provides a function set to returns if shoudle be
1136
1140
// extract style definition by given style.
1137
1141
extractStyleCondFuncs = map [string ]func (xlsxXf , * xlsxStyleSheet ) bool {
@@ -1157,6 +1161,7 @@ var (
1157
1161
return xf .ApplyProtection == nil || (xf .ApplyProtection != nil && * xf .ApplyProtection )
1158
1162
},
1159
1163
}
1164
+
1160
1165
// drawContFmtFunc defines functions to create conditional formats.
1161
1166
drawContFmtFunc = map [string ]func (p int , ct , ref , GUID string , fmtCond * ConditionalFormatOptions ) (* xlsxCfRule , * xlsxX14CfRule ){
1162
1167
"cellIs" : drawCondFmtCellIs ,
@@ -1176,6 +1181,7 @@ var (
1176
1181
"expression" : drawCondFmtExp ,
1177
1182
"iconSet" : drawCondFmtIconSet ,
1178
1183
}
1184
+
1179
1185
// extractContFmtFunc defines functions to get conditional formats.
1180
1186
extractContFmtFunc = map [string ]func (* File , * xlsxCfRule , * xlsxExtLst ) ConditionalFormatOptions {
1181
1187
"cellIs" : func (f * File , c * xlsxCfRule , extLst * xlsxExtLst ) ConditionalFormatOptions {
@@ -1233,6 +1239,7 @@ var (
1233
1239
return f .extractCondFmtIconSet (c , extLst )
1234
1240
},
1235
1241
}
1242
+
1236
1243
// validType defined the list of valid validation types.
1237
1244
validType = map [string ]string {
1238
1245
"cell" : "cellIs" ,
@@ -1456,7 +1463,7 @@ func (f *File) extractFills(fl *xlsxFill, s *xlsxStyleSheet, style *Style) {
1456
1463
var fill Fill
1457
1464
if fl .GradientFill != nil {
1458
1465
fill .Type = "gradient"
1459
- for shading , variants := range styleFillVariants {
1466
+ for shading , variants := range styleFillVariants () {
1460
1467
if fl .GradientFill .Bottom == variants .Bottom &&
1461
1468
fl .GradientFill .Degree == variants .Degree &&
1462
1469
fl .GradientFill .Left == variants .Left &&
@@ -2024,7 +2031,7 @@ func newFills(style *Style, fg bool) *xlsxFill {
2024
2031
if len (style .Fill .Color ) != 2 || style .Fill .Shading < 0 || style .Fill .Shading > 16 {
2025
2032
break
2026
2033
}
2027
- gradient := styleFillVariants [style .Fill .Shading ]
2034
+ gradient := styleFillVariants () [style .Fill .Shading ]
2028
2035
gradient .Stop [0 ].Color .RGB = getPaletteColor (style .Fill .Color [0 ])
2029
2036
gradient .Stop [1 ].Color .RGB = getPaletteColor (style .Fill .Color [1 ])
2030
2037
if len (gradient .Stop ) == 3 {
0 commit comments