Pivot Tablosunu Biçimlendirme

Döndürme Tablosu Görünümü

Bir Pivot Tablosu Nasıl Oluşturulur, basit bir pivot tablosu nasıl oluşturulurun açıklanmasının yanı sıra bu makale, çeşitli özellikleri ayarlayarak bir pivot tablosunun görünümünü özelleştirmeyi açıklar:

  • Pivot tablo format seçenekleri
  • Pivot alanları format seçenekleri
  • Veri alanı format seçenekleri

Pivot Tablo Format Seçeneklerini Ayarlama

Toplam Otomatik Biçim Türünü Ayarlama

Otomatik Biçim Türünün Ayarlanması

Microsoft Excel çeşitli önceden ayarlanmış rapor formatları sunar. Aspose.Cells for Node.js via C++ bu biçimlendirme seçeneklerini de destekler. Bu seçeneklere erişmek için:

  1. PivotTable.setIsAutoFormat(value) değerini true olarak ayarlayın.
  2. PivotTableAutoFormatType numaralandırmasından bir biçimlendirme seçeneği atayın.
const AsposeCells = require("aspose.cells.node");
//For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
//The path to the documents directory.
var dataDir = RunExamples.GetDataDir(".");
//Load a template file
var workbook = new AsposeCells.Workbook(dataDir + "Book1.xls");
var pivotindex = 0;
//Get the first worksheet
var worksheet = workbook.getWorksheets().get(0);
//Accessing the PivotTable
var pivotTable = worksheet.getPivotTables().get(pivotindex);
//Setting the PivotTable report is automatically formatted
pivotTable.setIsAutoFormat(true);
//Setting the PivotTable atuoformat type.
pivotTable.setAutoFormatType(AsposeCells.PivotTableAutoFormatType.Report5);
//Saving the Excel file
workbook.save(dataDir + "output.xls");

Biçim Seçeneklerini Ayarlama

Biçim Seçeneklerini Ayarlama

const AsposeCells = require("aspose.cells.node");
//For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
//The path to the documents directory.
var dataDir = RunExamples.GetDataDir(".");
//Load a template file
var workbook = new AsposeCells.Workbook(dataDir + "Book1.xls");
//Get the first worksheet
var worksheet = workbook.getWorksheets().get(0);
var pivotindex = 0;
//Accessing the PivotTable
var pivotTable = worksheet.getPivotTables().get(pivotindex);
//Setting the PivotTable report shows grand totals for rows.
pivotTable.setRowGrand(true);
//Setting the PivotTable report shows grand totals for columns.
pivotTable.setColumnGrand(true);
//Setting the PivotTable report displays a custom string in cells that contain null values.
pivotTable.setDisplayNullString(true);
pivotTable.setNullString("null");
//Setting the PivotTable report's layout
pivotTable.setPageFieldOrder(AsposeCells.PrintOrderType.DownThenOver);
//Saving the Excel file
workbook.save(dataDir + "output.xls");

Aşağıdaki kod örneği, pivot tablosunu satır ve sütunlar için toplamları göstermek üzere biçimlendirme ve raporun alan sırasını ayarlamayı gösterir. Ayrıca, null değerler için özel bir dize ayarlamak da gösterilir.

Önceden belirlenmiş rapor biçimleri yerine, pivot tablo raporunun nasıl görüneceğini manuel olarak düzenlemek için PivotTable.formatAll(style) ve PivotTable.format(row, column, style) yöntemlerini kullanın. İstenen biçimlendirme için bir stil nesnesi oluşturun.

const AsposeCells = require("aspose.cells.node");
//For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
//The path to the documents directory.
var dataDir = RunExamples.GetDataDir(".")
//Load a template file
var workbook = new AsposeCells.Workbook(dataDir + "Book1.xls");
//Get the first worksheet
var worksheet = workbook.getWorksheets().get(0);
var pivot = worksheet.getPivotTables().get(0);
pivot.setPivotTableStyleType(AsposeCells.PivotTableStyleType.PivotTableStyleDark1);
var style = workbook.createStyle();
style.getFont().setName("Arial Black");
style.setPattern(AsposeCells.BackgroundType.Solid);
style.setForegroundColor(AsposeCells.Color.Yellow);
pivot.formatAll(style);
//Saving the Excel file
workbook.save(dataDir + "output.xls");

Pivot Alanı Biçim Seçeneklerini Ayarlama

Pivot Alanı Biçim Seçeneklerini Ayarlama

  • Satır alanlarına erişim.
  • Alt toplamları ayarlama.
  • Otomatik sıralamayı ayarlama.
  • Otomatik gösterimi ayarlama.

Satır/Sütun/Sayfa Alan Biçimini Nasıl Ayarlanır

const AsposeCells = require("aspose.cells.node");
//For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
//The path to the documents directory.
var dataDir = RunExamples.GetDataDir(".");
//Load a template file
var workbook = new AsposeCells.Workbook(dataDir + "Book1.xls");
//Get the first worksheet
var worksheet = workbook.getWorksheets().get(0);
var pivotindex = 0;
//Accessing the PivotTable
var pivotTable = worksheet.getPivotTables().get(pivotindex);
//Setting the PivotTable report shows grand totals for rows.
pivotTable.setRowGrand(true);
//Accessing the row fields.
var pivotFields = pivotTable.getRowFields();
//Accessing the first row field in the row fields.
var pivotField = pivotFields.get(0);
//Setting Subtotals.
pivotField.setSubtotals(AsposeCells.PivotFieldSubtotalType.Sum, true);
pivotField.setSubtotals(AsposeCells.PivotFieldSubtotalType.Count, true);
//Setting autosort options.
//Setting the field auto sort.
pivotField.setIsAutoSort(true);
//Setting the field auto sort ascend.
pivotField.setIsAscendSort(true);
//Setting the field auto sort using the field itself.
pivotField.setAutoSortField(-5);
//Setting autoShow options.
//Setting the field auto show.
pivotField.setIsAutoShow(true);
//Setting the field auto show ascend.
pivotField.setIsAscendShow(false);
//Setting the auto show using field(data field).
pivotField.setAutoShowField(0);
//Saving the Excel file
workbook.save(dataDir + "output.xls");

Veri alanı biçimini nasıl ayarlanır

Aşağıdaki kod örneği, veri alanları için görüntü biçimlerini ve sayı biçimini ayarlamayı göstermektedir.

const AsposeCells = require("aspose.cells.node");
//For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
//The path to the documents directory.
var dataDir = RunExamples.GetDataDir(".");
//Load a template file
var workbook = new AsposeCells.Workbook(dataDir + "Book1.xls");
//Get the first worksheet
var worksheet = workbook.getWorksheets().get(0);
var pivotindex = 0;
//Accessing the PivotTable
var pivotTable = worksheet.getPivotTables().get(pivotindex);
//Accessing the data fields.
var pivotFields = pivotTable.getDataFields();
//Accessing the first data field in the data fields.
var pivotField = pivotFields.get(0);
//Setting data display format
pivotField.showValuesAs(AsposeCells.PivotFieldDataDisplayFormat.PercentageOf, 1, AsposeCells.PivotItemPositionType.Next, 0);
//Setting number format
pivotField.setNumber(10);
//Saving the Excel file
workbook.save(dataDir + "output.xls");

Pivot Alanlarını Temizleme Yöntemi

PivotFieldCollection, örneğin sayfa, sütun, satır veya veri gibi tüm pivot alanlarını temizlemenize izin veren clear() adında bir yönteme sahiptir. Örneğin, tüm veri alanlarını temizlemek istediğinizde, bunu kullanın. Aşağıdaki kod örneği, bir veri alanındaki tüm pivot alanlarını temizlemeyi göstermektedir.

const AsposeCells = require("aspose.cells.node");
//For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
//The path to the documents directory.
var dataDir = RunExamples.GetDataDir(".")
//Load a template file
var workbook = new AsposeCells.Workbook(dataDir + "Book1.xls");
//Get the first worksheet
var sheet = workbook.getWorksheets().get(0);
//Get the pivot tables in the sheet
var pivotTables = sheet.getPivotTables();
//Get the first PivotTable
var pivotTable = pivotTables.get(0);
//Clear all the data fields
pivotTable.getDataFields().clear();
//Add new data field
pivotTable.addFieldToArea(AsposeCells.PivotFieldType.Data, "Betrag Netto FW");
//Set the refresh data flag on
pivotTable.setRefreshDataFlag(true);
//Refresh and calculate the pivot table data
pivotTable.refreshData();
pivotTable.calculateData();
pivotTable.setRefreshDataFlag(false);
//Saving the Excel file
workbook.save(dataDir + "output.xls");