PivotTablo alanının GörünenAdı ile Hücre nesnesini alın
Contents
[
Hide
]
Aspose.Cells for Node.js via C++, pivot alanının gösterim adına göre hücre nesnesine erişmek için PivotTable.getCellByDisplayName(string) metodunu sağlar. Bu yöntem, pivot alanı başlığını vurgulamak veya biçimlendirmek istediğinizde faydalıdır. Bu makale, veri alanının gösterim adını kullanarak hücre nesnesini nasıl almak ve sonra biçimlendirmek gerektiğini açıklar.
PivotTablosunun PivotAlanı’nın DisplayName’ine göre Hücre nesnesini alma yöntemi
Aşağıdaki kod, çalışma kitabının ilk pivot tablosuna erişir ve ardından pivot tablosunun ikinci veri alanının görüntü adıyla hücreyi alır. Daha sonra hücrenin dolum rengini açık mavi, yazı tipi rengini ise siyah olarak değiştirir. Aşağıdaki ekran görüntüleri, kodun yürütülmeden önce ve sonra pivot tablosunun nasıl göründüğünü göstermektedir.
Pivot Tablosu - Önce |
---|
![]() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("."); | |
//Create workbook object from source excel file | |
var workbook = new AsposeCells.Workbook(dataDir + "source.xlsx"); | |
//Access first worksheet | |
var worksheet = workbook.getWorksheets().get(0); | |
//Access first pivot table inside the worksheet | |
var pivotTable = worksheet.getPivotTables().get(0); | |
//Access cell by display name of 2nd data field of the pivot table | |
var cell = pivotTable.getCellByDisplayName(pivotTable.getDataFields().get(1).getDisplayName()); | |
//Access cell style and set its fill color and font color | |
var style = cell.getStyle(); | |
style.setForegroundColor(AsposeCells.Color.LightBlue); | |
style.getFont().setColor(AsposeCells.Color.Black); | |
//Set the style of the cell | |
pivotTable.format(cell.getRow(), cell.getColumn(), style); | |
//Save workbook | |
workbook.save(dataDir + "output_out.xlsx"); |
Pivot Tablosu - Sonra |
---|
![]() |