Node.js ve C++ kullanarak Pivot Bağlantısı Ekleme

Olası Kullanım Senaryoları

Excel’de bir dilimleyici ve pivot tablosunu ilişkilendirmek istiyorsanız, dilimleyiciyi sağ tıklayın ve “Rapor Bağlantıları…” seçeneğini seçin. Seçenek listesinden onay kutusunu kullanabilirsiniz. Benzer şekilde, Aspose.Cells API kullanarak programlı olarak bir dilimleyici ve pivot tablosunu ilişkilendirmek için lütfen Slicer.addPivotConnection(PivotTable pivot) metodunu kullanın. Bu, dilimleyici ve pivot tabloyu ilişkilendirecektir.

Dilimleyiciyi ve Pivot Tablosunu İlişkilendir

Aşağıdaki örnek kod, var olan bir dilimleyici içeren örnek Excel dosyasını yükler. Dilimleyiciyi erişir ve ardından dilimleyici ile pivot tabloyu ilişkilendirir. Son olarak çalışma kitabını çıktı Excel dosyası olarak kaydeder.

Örnek Kod

const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "add-pivot-connection.xlsx");

// Load sample Excel file containing slicer.
const workbook = new AsposeCells.Workbook(filePath);

// Access first worksheet.
const worksheet = workbook.getWorksheets().get(0);

// Access the first PivotTable inside the PivotTable collection.
const pivotTable = worksheet.getPivotTables().get(0); 

// Access the first slicer inside the slicer collection.
const slicer = worksheet.getSlicers().get(0);

// Adds PivotTable connection.
slicer.addPivotConnection(pivotTable);

workbook.save(path.join(dataDir, "add-pivot-connection-out.xlsx"));