c# - 用于过滤数据透视表的 OpenXML 示例?
问题描述
我的任务是用数据填充 Excel 模板(在工作表 1 上)。该工作表中的数据将用于更新其他工作表上的 5 或 6 个数据透视表。到目前为止,下面的代码正在发挥作用。但是,我试图弄清楚如何从最终数据透视表结果中删除 $0 金额。
public void PivotTableTesting(int recCount)
{
PivotTableCacheDefinitionPart ptp = book.PivotTableCacheDefinitionParts.FirstOrDefault();
PivotTableDefinition def = sheetPart.PivotTableParts.FirstOrDefault().PivotTableDefinition;
ptp.PivotCacheDefinition.RefreshOnLoad = true;
ptp.PivotCacheDefinition.RecordCount = UInt32Value.ToUInt32((uint)recCount);
string val = ptp.PivotCacheDefinition.CacheSource.WorksheetSource.Reference.Value;
ptp.PivotCacheDefinition.CacheSource.WorksheetSource.Reference = @"A1:AO" + (recCount + 1).ToString();
ptp.PivotTableCacheRecordsPart.PivotCacheRecords.RemoveAllChildren();
ptp.PivotTableCacheRecordsPart.PivotCacheRecords.Count = 0;
}
有没有人有任何关于创建过滤器并将其应用于数据透视表定义的示例代码?