Hi, I created a pivot table with 8 rowfields (.Net platform), but I do not need the report. After opening the xls file generated, the report in blank is displayed. I'm using Aspose version 7.2.0.0.
I tried doing the following,
1. I set the Autoformat in true and formatType None.
pivotTable.IsAutoFormat = true;
pivotTable.AutoFormatType = PivotTableAutoFormatType.None;
2. I tied to set a new style to apply in an existent format.
Aspose.Cells.Style stylePivot = workbook.CreateStyle();
stylePivot.HorizontalAlignment = TextAlignmentType.Bottom;
stylePivot.VerticalAlignment = TextAlignmentType.General;
pivotTable.FormatAll(stylePivot);
In excel I can remove the report doing right clic on the report or pivot table PivotTable Options=> Display tab => Uncheck Classic Pivot Table Layout (That's why I set the autoformat to None but with no luck). But how can I do it using Aspose?
3. I want to display all the data without plus sign to expand, so I tried using ShowDrill = false; but it didn't work.
pivotTable.ShowDrill = false;
In excel I can remove the plus doing right clic on the pivot table PivotTable Options=> Display Tab=> Show expand/collapse buttons (Uncheck).
4. When opening the saved xsl file a message is displayed saying: "Do you want to replace the contents of the destination cells in "nameOfReport.xsl" Pivot Table? Yes/No buttons".
Why does it appear? How can I remove it?
5. Let me add the code for further information, perhaps I'm missing something.
private void ImportDataTable()
{
Workbook workbook = new Workbook();
Worksheet sheet2 = workbook.Worksheets[0];//workbook.Worksheets[workbook.Worksheets.Add()];
//Naming the sheet
sheet2.Name = "PivotTable";
sheet2.Cells.ImportDataTable(GetPivotTimesData(), true, "A3");
//Getting the pivottables collection in the sheet
Aspose.Cells.Pivot.PivotTableCollection pivotTables = sheet2.PivotTables;
//Adding a PivotTable to the worksheet
int index = pivotTables.Add("=PivotTable!A3:H7", "A3", "PivotTable1", true);
//Accessing the instance of the newly added PivotTable
Aspose.Cells.Pivot.PivotTable pivotTable = pivotTables[index];
//UnShowing the grand totals
pivotTable.RowGrand = false;
pivotTable.ColumnGrand = false;
pivotTable.ShowEmptyCol = false;
pivotTable.ShowPivotStyleRowHeader = true;
////Draging the first field to the row area.
pivotTable.AddFieldToArea(PivotFieldType.Row, 0);
////Draging the second field to the row area.
pivotTable.AddFieldToArea(PivotFieldType.Row, 1);
////Draging the third field to the row area.
pivotTable.AddFieldToArea(PivotFieldType.Row, 2);
pivotTable.AddFieldToArea(PivotFieldType.Row, 3);
pivotTable.AddFieldToArea(PivotFieldType.Row, 4);
pivotTable.AddFieldToArea(PivotFieldType.Row, 5);
pivotTable.AddFieldToArea(PivotFieldType.Row, 6);
pivotTable.AddFieldToArea(PivotFieldType.Row, 7);
//Accessing the row fields.
Aspose.Cells.Pivot.PivotFieldCollection pivotFields = pivotTable.RowFields;
//Accessing the first row field in the row fields.
for (int i = 0; i < pivotFields.Count; i++)
{
Aspose.Cells.Pivot.PivotField pivotField = pivotFields[i];
pivotField.SetSubtotals(Aspose.Cells.Pivot.PivotFieldSubtotalType.None, true);
pivotField.IsAutoShow = false;
pivotField.IsAutoSubtotals = false;
}
//Get the cells collection in the worksheet
setPivotStyle(sheet2, pivotTable, workbook);
setRotatingStyleStage2(sheet2, workbook);
//Saving the Excel file
workbook.Save("C:\\test\\TableTimesReport.xls");
}
private void setPivotStyle(Worksheet sheet2, Aspose.Cells.Pivot.PivotTable pivotTable, Workbook workbook)
{
//Setting the PivotTable report is automatically formatted
pivotTable.IsAutoFormat = true;
//Setting the PivotTable atuoformat type.
pivotTable.PivotTableStyleType = PivotTableStyleType.PivotTableStyleDark1;
pivotTable.AutoFormatType = PivotTableAutoFormatType.None;
Aspose.Cells.Style stylePivot = workbook.CreateStyle();
stylePivot.HorizontalAlignment = TextAlignmentType.Bottom;
stylePivot.VerticalAlignment = TextAlignmentType.General;
pivotTable.FormatAll(stylePivot);
pivotTable.ShowDrill = false;
}
private DataTable GetPivotTimesData()
{
//Create a datatable and add three columns to it
DataTable dataTable = new DataTable("PivotTimes");
dataTable.Columns.Add("PROJECT ID", typeof(Int32));
dataTable.Columns.Add("PROJECT CODE", typeof(string));
dataTable.Columns.Add("PROJECT TITLE", typeof(string));
dataTable.Columns.Add("PROJECT MODE", typeof(string));
dataTable.Columns.Add("PROJECT TYPE", typeof(string));
dataTable.Columns.Add("USER DIRECTOR ID", typeof(string));
dataTable.Columns.Add("MANAGMENT AREA", typeof(string));
dataTable.Columns.Add("AMOUNT TYPE", typeof(string));
dataTable.Columns.Add("RELEASED DATE", typeof (string));
dataTable.Columns.Add("RELEASED MONTH", typeof (string));
dataTable.Columns.Add("RELEASED YEAR", typeof (string));
//Stage Columns
dataTable.Columns.Add("INICIO", typeof(DateTime));
dataTable.Columns.Add("QUALITY ASSURANCE OPTE PM", typeof(string));
dataTable.Columns.Add("QUALITY ASSURANCE PO", typeof(string));
dataTable.Columns.Add("APROBACIÓN KU", typeof(string));
dataTable.Columns.Add("APROBACIÓN IT MNG", typeof(string));
dataTable.Columns.Add("AUTORIZACIÓN USER DIRECTOR", typeof(string));
dataTable.Columns.Add("AUTORIZACIÓN IT DIRECTION", typeof(string));
dataTable.Columns.Add("AUTORIZACIÓN CIO", typeof(string));
dataTable.Columns.Add("AUTORIZACIÓN CEO", typeof(string));
dataTable.Columns.Add("AUTORIZACIÓN AREA MANAGER", typeof(string));
dataTable.Columns.Add("SET-UP ADMINISTRATIVO", typeof(string));
dataTable.Columns.Add("LIBERACIÓN CONTABILIDADES", typeof(string));
dataTable.Columns.Add("COMUNICACIÓN", typeof(string));
dataTable.Columns.Add("REJECT", typeof(string));
//Stage Columns
dataTable.Columns.Add("INICIO ", typeof(DateTime));
dataTable.Columns.Add("QUALITY ASSURANCE OPTE PM " , typeof(string));
dataTable.Columns.Add("QUALITY ASSURANCE PO ", typeof(string));
dataTable.Columns.Add("APROBACIÓN KU ", typeof(string));
dataTable.Columns.Add("APROBACIÓN IT MNG " , typeof(string));
dataTable.Columns.Add("AUTORIZACIÓN USER DIRECTOR ", typeof(string));
dataTable.Columns.Add("AUTORIZACIÓN IT DIRECTION ", typeof(string));
dataTable.Columns.Add("AUTORIZACIÓN CIO ", typeof(string));
dataTable.Columns.Add("AUTORIZACIÓN CEO ", typeof(string));
dataTable.Columns.Add("AUTORIZACIÓN AREA MANAGER ", typeof(string));
dataTable.Columns.Add("SET-UP ADMINISTRATIVO ", typeof(string));
dataTable.Columns.Add("LIBERACIÓN CONTABILIDADES ", typeof(string));
dataTable.Columns.Add("COMUNICACIÓN ", typeof(string));
//Add the first record to it
DataRow dr = dataTable.NewRow();
dr[0] = 4212;
dr[1] = "TEST1";
dr[2] = "Interfaces";
dr[3] = "Project";
dr[4] = "Investment";
dr[5] = "User1";
dr[6] = "Canada";
dr[7] = "1";
dr[8] = "3/7/2012 9:29:20 PM";
dr[9] = "Abril";
dr[10] = "2012";
// Stage values
dr[11] = "3/7/2012 9:29:20 PM";
dr[12] = "3/7/2012 9:29:20 PM";
dr[13] = "3/7/2012 9:29:20 PM";
dr[14] = "3/7/2012 9:29:20 PM";
dr[15] = "3/7/2012 9:29:20 PM";
dr[16] = "3/7/2012 9:29:20 PM";
dr[17] = "3/7/2012 9:29:20 PM";
dr[18] = "3/7/2012 9:29:20 PM";
dr[19] = "3/7/2012 9:29:20 PM";
dr[20] = "3/7/2012 9:29:20 PM";
dr[21] = "3/7/2012 9:29:20 PM";
dr[22] = "3/7/2012 9:29:20 PM";
dr[23] = "3/7/2012 9:29:20 PM";
// Stage values2
dr[24] = "3/7/2012 9:29:20 PM";
dr[25] = "3/7/2012 9:29:20 PM";
dr[26] = "3/7/2012 9:29:20 PM";
dr[27] = "3/7/2012 9:29:20 PM";
dr[28] = "3/7/2012 9:29:20 PM";
dr[29] = "3/7/2012 9:29:20 PM";
dr[30] = "3/7/2012 9:29:20 PM";
dr[31] = "3/7/2012 9:29:20 PM";
dr[32] = "3/7/2012 9:29:20 PM";
dr[33] = "3/7/2012 9:29:20 PM";
dr[34] = "3/7/2012 9:29:20 PM";
dr[35] = "3/7/2012 9:29:20 PM";
dr[36] = "3/7/2012 9:29:20 PM";
dataTable.Rows.Add(dr);
//Add the second record to it
dr = dataTable.NewRow();
dr[0] = 4585;
dr[1] = "Test2";
dr[2] = "Bla12345";
dr[3] = "Project";
dr[4] = "Investment";
dr[5] = "BLA";
dr[6] = "Manufacturing System";
dr[7] = "2";
dr[8] = Convert.ToDateTime("3/7/2012 9:29:20 PM");
dr[9] = "Abril";
dr[10] = "2012";
// Stage values
dr[11] = "3/7/2012 9:29:20 PM";
dr[12] = "3/7/2012 9:29:20 PM";
dr[13] = "3/7/2012 9:29:20 PM";
dr[14] = "3/7/2012 9:29:20 PM";
dr[15] = "3/7/2012 9:29:20 PM";
dr[16] = "3/7/2012 9:29:20 PM";
dr[17] = "3/7/2012 9:29:20 PM";
dr[18] = "3/7/2012 9:29:20 PM";
dr[19] = "3/7/2012 9:29:20 PM";
dr[20] = "3/7/2012 9:29:20 PM";
dr[21] = "3/7/2012 9:29:20 PM";
dr[22] = "3/7/2012 9:29:20 PM";
dr[23] = "3/7/2012 9:29:20 PM";
// Stage values2
dr[24] = "3/7/2012 9:29:20 PM";
dr[25] = "3/7/2012 9:29:20 PM";
dr[26] = "3/7/2012 9:29:20 PM";
dr[27] = "3/7/2012 9:29:20 PM";
dr[28] = "3/7/2012 9:29:20 PM";
dr[29] = "3/7/2012 9:29:20 PM";
dr[30] = "3/7/2012 9:29:20 PM";
dr[31] = "3/7/2012 9:29:20 PM";
dr[32] = "3/7/2012 9:29:20 PM";
dr[33] = "3/7/2012 9:29:20 PM";
dr[34] = "3/7/2012 9:29:20 PM";
dr[35] = "3/7/2012 9:29:20 PM";
dr[36] = "3/7/2012 9:29:20 PM";
dataTable.Rows.Add(dr);
//Add the second record to it
dr = dataTable.NewRow();
dr[0] = 4821;
dr[1] = "TEST5";
dr[2] = "ABCD-";
dr[3] = "Extension";
dr[4] = "Investment";
dr[5] = "123'20010926";
dr[6] = "Argentina";
dr[7] = "3";
dr[8] = "3/7/2012 9:29:20 PM";
dr[9] = "Abril";
dr[10] = "2012";
// Stage values
dr[11] = "3/7/2012 9:29:20 PM";
dr[12] = "3/7/2012 9:29:20 PM";
dr[13] = "3/7/2012 9:29:20 PM";
dr[14] = "3/7/2012 9:29:20 PM";
dr[15] = "3/7/2012 9:29:20 PM";
dr[16] = "3/7/2012 9:29:20 PM";
dr[17] = "3/7/2012 9:29:20 PM";
dr[18] = "3/7/2012 9:29:20 PM";
dr[19] = "3/7/2012 9:29:20 PM";
dr[20] = "3/7/2012 9:29:20 PM";
dr[21] = "3/7/2012 9:29:20 PM";
dr[22] = "3/7/2012 9:29:20 PM";
dr[23] = "3/7/2012 9:29:20 PM";
// Stage values2
dr[24] = "3/7/2012 9:29:20 PM";
dr[25] = "3/7/2012 9:29:20 PM";
dr[26] = "3/7/2012 9:29:20 PM";
dr[27] = "3/7/2012 9:29:20 PM";
dr[28] = "3/7/2012 9:29:20 PM";
dr[29] = "3/7/2012 9:29:20 PM";
dr[30] = "3/7/2012 9:29:20 PM";
dr[31] = "3/7/2012 9:29:20 PM";
dr[32] = "3/7/2012 9:29:20 PM";
dr[33] = "3/7/2012 9:29:20 PM";
dr[34] = "3/7/2012 9:29:20 PM";
dr[35] = "3/7/2012 9:29:20 PM";
dr[36] = "3/7/2012 9:29:20 PM";
dataTable.Rows.Add(dr);
return dataTable;
}
I'll really appreciate any help on this!!
Thanks in Advance!
PS: I attached the error message and the format of the pivot table I need. Please check them out.