Hi,
I am creating one workbook with two sheets, one with data and other with the pivotable.
In the pivotable, i need the information to be presented with two columns with Sum values, as the labels of those values as Colum label, bt i only can preente that data as row label.
In the file that i have attached, you can understand better what i need.
As you will seed in the file, the PIVOT1 is generated by code, but the PIVOT2 is how i need it to be presented, can you help me on this?
Can you please tell me how i need to define the PivotTable?
Thanks in advance,
Regards
Hi,
Hi,
This is the code:
int index = pivotTables.Add("=" + Livro.Worksheets[OrigemDados].Name + "!A1:" + Livro.Worksheets[OrigemDados].Cells[Livro.Worksheets[OrigemDados].Cells.MaxDataRow, Livro.Worksheets[OrigemDados].Cells.MaxDataColumn].Name,
"A5", "PivotDados");
PivotTable pivotTable = pivotTables[index];
pivotTable.IsAutoFormat = true;
pivotTable.AutoFormatType = Aspose.Cells.Pivot.PivotTableAutoFormatType.Classic;
pivotTable.ColumnGrand = true;
pivotTable.AddFieldToArea(PivotFieldType.Row, 0); // cliente_nome
pivotTable.AddFieldToArea(PivotFieldType.Row, 17); // meio
pivotTable.AddFieldToArea(PivotFieldType.Row, 4); // site
pivotTable.AddFieldToArea(PivotFieldType.Row, 5); // formato
pivotTable.IsAutoFormat = true;
pivotTable.ColumnGrand = true;
pivotTable.RowGrand = true;
pivotTable.AddFieldToArea(PivotFieldType.Data, 11);
pivotTable.DataFields[0].Function = ConsolidationFunction.Sum;
pivotTable.DataFields[0].NumberFormat = "#,##0.00 €";
pivotTable.AddFieldToArea(PivotFieldType.Data, 18);
pivotTable.DataFields[1].Function = ConsolidationFunction.Sum;
pivotTable.DataFields[1].NumberFormat = "#,##0.00 €";
pivotTable.GrandTotalName = "Total Global";
pivotTable.CalculateData();int index = pivotTables.Add("=" + Livro.Worksheets[OrigemDados].Name + "!A1:" + Livro.Worksheets[OrigemDados].Cells[Livro.Worksheets[OrigemDados].Cells.MaxDataRow, Livro.Worksheets[OrigemDados].Cells.MaxDataColumn].Name,
"A5", "PivotDados");
PivotTable pivotTable = pivotTables[index];
pivotTable.IsAutoFormat = true;
pivotTable.AutoFormatType = Aspose.Cells.Pivot.PivotTableAutoFormatType.Classic;
pivotTable.ColumnGrand = true;
pivotTable.AddFieldToArea(PivotFieldType.Row, 0);
pivotTable.AddFieldToArea(PivotFieldType.Row, 17);
pivotTable.AddFieldToArea(PivotFieldType.Row, 4);
pivotTable.AddFieldToArea(PivotFieldType.Row, 5);
pivotTable.IsAutoFormat = true;
pivotTable.ColumnGrand = true;
pivotTable.RowGrand = true;
pivotTable.AddFieldToArea(PivotFieldType.Data, 11);
pivotTable.DataFields[0].Function = ConsolidationFunction.Sum;
pivotTable.DataFields[0].NumberFormat = "#,##0.00 €";
pivotTable.AddFieldToArea(PivotFieldType.Data, 18);
pivotTable.DataFields[1].Function = ConsolidationFunction.Sum;
pivotTable.DataFields[1].NumberFormat = "#,##0.00 €";
pivotTable.GrandTotalName = "Total Global";
pivotTable.CalculateData();
Thanks,
Pedro
Hi,
Thanks Amjad,
It worked fine.
Hi,