fix(xlsx): wire aboveAverage stdDev=/equalAverage= on CF rule

conditional formatting rule=aboveAverage previously silently dropped
the stdDev= and equalAverage= properties. Both now flow onto the
cfRule attributes: stdDev=N (integer deviations from mean) and
equalAverage=true (include values equal to the mean). Also accepted
the aboveaverage= spelling as an alias for above= to mirror the
OOXML attribute name.
This commit is contained in:
zmworm 2026-04-19 08:10:09 +08:00
parent 14171d018d
commit 8b58e2acb8

View file

@ -3267,13 +3267,33 @@ public partial class ExcelHandler
}
case "aboveaverage":
{
var aboveBelow = properties.GetValueOrDefault("above", "true");
cfNewRule = new ConditionalFormattingRule
// `above=` is the legacy spelling; `aboveaverage=false`
// (matching the cfType name) is accepted as an alias
// so users can mirror the OOXML attribute.
var aboveBelow = properties.GetValueOrDefault("above",
properties.GetValueOrDefault("aboveaverage", "true"));
var aboveRule = new ConditionalFormattingRule
{
Type = ConditionalFormatValues.AboveAverage,
Priority = cfNewPriority,
AboveAverage = ParseHelpers.IsTruthy(aboveBelow) ? null : false
};
// R15-3: wire stdDev= (deviations above/below mean)
// and equalAverage= (include values equal to the mean)
// onto the cfRule.
if (properties.TryGetValue("stdDev", out var stdDevRaw)
&& !string.IsNullOrWhiteSpace(stdDevRaw)
&& int.TryParse(stdDevRaw, out var stdDevVal))
{
aboveRule.StdDev = stdDevVal;
}
if (properties.TryGetValue("equalAverage", out var eqAvgRaw)
&& !string.IsNullOrWhiteSpace(eqAvgRaw)
&& ParseHelpers.IsTruthy(eqAvgRaw))
{
aboveRule.EqualAverage = true;
}
cfNewRule = aboveRule;
break;
}
case "uniquevalues":