mirror of
https://github.com/iOfficeAI/OfficeCLI
synced 2026-04-21 13:37:23 +00:00
fix(xlsx): complete pivot calculatedField end-to-end (known prop)
_knownPivotKeys was missing calculatedField / calculatedFields, so even though ApplyCalculatedFields wired up the cacheField + dataField + calculatedFields block, the Add pipeline still warned 'UNSUPPORTED props: calculatedField' to stderr. Add both keys to the known set and strip trailing digits in CollectUnknownPivotKeys so numbered variants (calculatedField1, calculatedField2, ...) also match. Expose the check as a public IsKnownPivotProperty helper for tests.
This commit is contained in:
parent
5932303e06
commit
a23c854241
1 changed files with 21 additions and 1 deletions
|
|
@ -221,6 +221,10 @@ internal static partial class PivotTableHelper
|
|||
// PV7: labelFilter=field:type:value — row-level pre-cache filter
|
||||
// (see ApplyLabelFilter).
|
||||
"labelfilter",
|
||||
// R4-3: calculatedField[N]=Name:=Formula — numbered variants are
|
||||
// also accepted; CollectUnknownPivotKeys normalizes trailing
|
||||
// digits before the known-set check.
|
||||
"calculatedfield", "calculatedfields",
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -240,12 +244,28 @@ internal static partial class PivotTableHelper
|
|||
{
|
||||
if (string.IsNullOrEmpty(key)) continue;
|
||||
var canonical = NormalizePivotPropKey(key);
|
||||
if (!_knownPivotKeys.Contains(canonical))
|
||||
// R4-3: strip trailing digits before lookup so `calculatedField1`,
|
||||
// `calculatedField2`, etc. match the canonical `calculatedfield`.
|
||||
var stripped = System.Text.RegularExpressions.Regex.Replace(canonical, @"\d+$", "");
|
||||
if (!_knownPivotKeys.Contains(canonical)
|
||||
&& !_knownPivotKeys.Contains(stripped))
|
||||
unknown.Add(key);
|
||||
}
|
||||
return unknown;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Public wrapper around <see cref="_knownPivotKeys"/> + alias/digit
|
||||
/// normalization for tests and external callers.
|
||||
/// </summary>
|
||||
public static bool IsKnownPivotProperty(string key)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key)) return false;
|
||||
var canonical = NormalizePivotPropKey(key);
|
||||
var stripped = System.Text.RegularExpressions.Regex.Replace(canonical, @"\d+$", "");
|
||||
return _knownPivotKeys.Contains(canonical) || _knownPivotKeys.Contains(stripped);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Emit an UNSUPPORTED props warning to stderr for the Add pivot path.
|
||||
/// Set already surfaces unknown keys through its return list; Add has
|
||||
|
|
|
|||
Loading…
Reference in a new issue