Get External Connection Data Source of Pivot Table

Get External Connection Data Source of Pivot Table

Aspose.Cells provides the ability to get the external connection data source of the pivot table. For this, the API provides the ExternalConnectionDataSource property of the PivotTable class. The ExternalConnectionDataSource property returns the ExternalConnection object. The following code snippet demonstrates the use of the PivotTable.ExternalConnectionDataSource property to get the external connection data source of the pivot table.

Sample Code

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// Source directory
String sourceDir = Utils.Get_SourceDirectory();
// Load sample file
Workbook workbook = new Workbook(sourceDir + "SamplePivotTableExternalConnection.xlsx");
Worksheet worksheet = workbook.getWorksheets().get(0);
// Get the pivot table
PivotTable pivotTable = worksheet.getPivotTables().get(0);
// Print External Connection Details
System.out.println("External Connection Data Source");
System.out.println("Name: " + pivotTable.getExternalConnectionDataSource().getName());
System.out.println("Type: " + pivotTable.getExternalConnectionDataSource().getType());

The source file used in the code snippet is attached for reference.

Source File