我正在使用 aspose-cells-17.9 java 版本。我正在尝试从下面显示的原始数据样本创建一个数据透视表。
Affiliate ImpressionClicks
abc 1000 2000 等等。
如果我尝试使用以下代码创建数据透视表
PivotTable pivotTable = pivotTables.get(index);
// Unshowing grand totals for rows.
pivotTable.setRowGrand(true);
// Dragging the first field to the row area.
pivotTable.addFieldToArea(PivotFieldType.ROW, 0);
// Dragging the second field to the column area.
pivotTable.addFieldToArea(PivotFieldType.COLUMN, 1);
// Dragging the third field to the data area.
pivotTable.addFieldToArea(PivotFieldType.DATA, 2);
我得到以下输出作为选定值。
但我期待的是如下
任何帮助,将不胜感激。
请参阅以下示例代码、其注释和屏幕截图。正如您在屏幕截图中看到的,输出 Excel 文件根据您的需要具有数据透视表。请记住 Σ-values 字段由PivotTable.getDataField()表示,这是我在您的代码中所做的更改。
爪哇
PivotTable pivotTable = pivotTables.get(index);
// Unshowing grand totals for rows.
pivotTable.setRowGrand(true);
// Dragging the first field to the row area.
pivotTable.addFieldToArea(PivotFieldType.ROW, 0);
// Dragging the second field to the data area.
pivotTable.addFieldToArea(PivotFieldType.DATA, 1);
// Dragging the third field to the data area.
pivotTable.addFieldToArea(PivotFieldType.DATA, 2);
// Dragging the Σ-values field to the column area.
pivotTable.addFieldToArea(PivotFieldType.COLUMN, pivotTable.getDataField());
注意:我在 Aspose 担任开发布道师
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句