获取数据透视表的外部连接数据源

获取数据透视表的外部连接数据源

Aspose.Cells提供了获取数据透视表的外部连接数据源的能力。为此,API提供了ExternalConnectionDataSource类的PivotTable属性。ExternalConnectionDataSource属性返回ExternalConnection对象。以下代码片段演示了使用PivotTable.ExternalConnectionDataSource属性来获取数据透视表的外部连接数据源。

示例代码

// 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());

代码片段中使用的源文件已附上供参考。

源文件