gpt4 book ai didi

c# - 如何让数据字段功能更改为从 EPPlus 中的总和计数?

转载 作者:行者123 更新时间:2023-11-30 13:48:23 25 4
gpt4 key购买 nike

在我的数据透视表中,我有一个数据字段,我想将其汇总为计数。我尝试将 subtotalfunction 属性更改为计数,但它仍然显示总和。有人可以举个例子说明我该怎么做吗?

换句话说,任何人都可以给我一个数据透视表的示例,您可以在其中看到计数而不是总和。

我正在使用 EPPlus 最新版本。 3.1.1

非常感谢:)

编辑:这就是我正在尝试的。

                    var wsPivot = package.Workbook.Worksheets.Add("Pivot");
var pivotTable = wsPivot.PivotTables.Add(wsPivot.Cells["A55"], dataRange, "Table");
pivotTable.MultipleFieldFilters = true;
pivotTable.RowGrandTotals = true;
pivotTable.ColumGrandTotals = true;
pivotTable.Compact = true;
pivotTable.CompactData = true;
pivotTable.GridDropZones = false;
pivotTable.Outline = false;
pivotTable.OutlineData = false;
pivotTable.ShowError = true;
pivotTable.ErrorCaption = "[error]";
pivotTable.ShowHeaders = true;
pivotTable.UseAutoFormatting = true;
pivotTable.ApplyWidthHeightFormats = true;
pivotTable.ShowDrill = true;
pivotTable.FirstDataCol = 3;
pivotTable.RowHeaderCaption = "Caption";

var pageField = pivotTable.Fields["field1"];
pivotTable.PageFields.Add(pageField);

var rowField = pivotTable.Fields["cust"];
pivotTable.RowFields.Add(rowField);

var dataField = pivotTable.Fields["id"];

dataField.SubTotalFunctions = OfficeOpenXml.Table.PivotTable.eSubTotalFunctions.Count;
pivotTable.DataFields.Add(dataField);

最佳答案

我想通了。这对我有用

pivotTable.DataFields.Add(dataField);
pivotTable.DataFields[0].Function = DataFieldFunctions.Count;

关于c# - 如何让数据字段功能更改为从 EPPlus 中的总和计数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12746815/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com