PivotTable.RepeatItemsOnEachPrintedPage
PivotTable.RepeatItemsOnEachPrintedPage property
Indicates whether pivot item captions on the row area are repeated on each printed page for pivot fields in tabular form.
public bool RepeatItemsOnEachPrintedPage { get; set; }
Examples
namespace AsposeCellsExamples
{
using Aspose.Cells;
using Aspose.Cells.Pivot;
using System;
public class PivotTablePropertyRepeatItemsOnEachPrintedPageDemo
{
public static void Run()
{
// Create a new workbook
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
// Add sample data for the pivot table
worksheet.Cells["A1"].PutValue("Region");
worksheet.Cells["A2"].PutValue("North");
worksheet.Cells["A3"].PutValue("North");
worksheet.Cells["A4"].PutValue("South");
worksheet.Cells["A5"].PutValue("South");
worksheet.Cells["B1"].PutValue("Product");
worksheet.Cells["B2"].PutValue("Apples");
worksheet.Cells["B3"].PutValue("Oranges");
worksheet.Cells["B4"].PutValue("Apples");
worksheet.Cells["B5"].PutValue("Oranges");
worksheet.Cells["C1"].PutValue("Sales");
worksheet.Cells["C2"].PutValue(1000);
worksheet.Cells["C3"].PutValue(1500);
worksheet.Cells["C4"].PutValue(2000);
worksheet.Cells["C5"].PutValue(2500);
// Create a pivot table
int pivotIndex = worksheet.PivotTables.Add("A1:C5", "E3", "PivotTable1");
PivotTable pivotTable = worksheet.PivotTables[pivotIndex];
// Add row fields and data field
pivotTable.AddFieldToArea(PivotFieldType.Row, "Region");
pivotTable.AddFieldToArea(PivotFieldType.Row, "Product");
pivotTable.AddFieldToArea(PivotFieldType.Data, "Sales");
// Set page setup for printing
worksheet.PageSetup.PrintTitleRows = "$1:$1";
worksheet.PageSetup.PrintArea = "A1:G20";
worksheet.PageSetup.FitToPagesTall = 0;
worksheet.PageSetup.FitToPagesWide = 1;
// Display current RepeatItemsOnEachPrintedPage value
Console.WriteLine("Current RepeatItemsOnEachPrintedPage value: " + pivotTable.RepeatItemsOnEachPrintedPage);
// Enable repeating items on each printed page
pivotTable.RepeatItemsOnEachPrintedPage = true;
Console.WriteLine("RepeatItemsOnEachPrintedPage set to: " + pivotTable.RepeatItemsOnEachPrintedPage);
// Calculate data to populate the pivot table
pivotTable.CalculateData();
// Save the workbook
workbook.Save("PivotTableRepeatItemsOnEachPrintedPageDemo.xlsx");
}
}
}
See Also
- class PivotTable
- namespace Aspose.Cells.Pivot
- assembly Aspose.Cells