Free Support Forum - aspose.com

Pivot Blank Row and Column Delete!

Hi Team,

I have my excel data sheet is 12 rows, I am trying to get a pivot table that shows like,
one "Blank" rows , i have used below code ,

Aspose.Cells.Worksheet pivotTableSheet = obj.ExcelWorkBook.Worksheets["Pivot"];

pivotTableSheet.PivotTables.Clear();

Aspose.Cells.PivotTable pt = pivotTableSheet.PivotTables[pivotTableSheet.PivotTables.Add("Data!A6:" + obj.ExcelWorkBook.Worksheets["Data"].Cells[dt.Rows.Count+6, dt.Columns.Count -1].Name, 0, 0, "PivotTable")];

pt.RowFields.AddByBaseIndex(dt.Columns["Agent"].Ordinal);

pt.ColumnFields.AddByBaseIndex(dt.Columns["Ageing"].Ordinal);

pt.ColumnFields[0].IsAutoSort = true;

pt.ColumnFields[0].IsAscendSort = true;

// pt.DisplayNullString = true;

//pt.AutoSortField = 0;

pt.ColumnFields[0].AutoSortField = -1;

//pivotTableSheet.PivotTables[0].NullString.Remove(1);

pt.DataFields.AddByBaseIndex(dt.Columns["Advanced USD"].Ordinal);

pt.DataFields.AddByBaseIndex(dt.Columns["Appointment No"].Ordinal);

Aspose.Cells.PivotField datafieldnomination = pt.DataFields[1];

pt.DataFields[1].DisplayName = "Count";

pt.AddFieldToArea(PivotFieldType.Column, pt.DataField);

pt.ColumnGrand = true;

pt.AutoFormatType = Aspose.Cells.PivotTableAutoFormatType.Table2;

and I have attached Error image also .How can i remove the pivot table blank rows and columns,

Thanks

SamyT

Hi,

I think you may try to use PivotTable.HasBlankRows to set the attribute to false, if it works for your need.

Thank you.