获取数据透视表的外部连接数据源
Contents
[
Hide
]
获取数据透视表的外部连接数据源
Aspose.Cells提供获取数据透视表外部连接数据源的能力。为此,API提供了ExternalConnectionDataSource类的PivotTable属性。ExternalConnectionDataSource属性返回ExternalConnection对象。以下代码片段演示如何使用PivotTable.ExternalConnectionDataSource属性获取数据透视表的外部连接数据源。
示例代码
This file contains 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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Source directory | |
string sourceDir = RunExamples.Get_SourceDirectory(); | |
// Load sample file | |
Workbook workbook = new Workbook(sourceDir + "SamplePivotTableExternalConnection.xlsx"); | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Get the pivot table | |
var pivotTable = worksheet.PivotTables[0]; | |
// Print External Connection Details | |
Console.WriteLine("External Connection Data Source"); | |
ExternalConnection[] connections = pivotTable.GetSourceDataConnections(); | |
foreach(ExternalConnection conn in connections) | |
{ | |
Console.WriteLine("Name: " + conn.Name); | |
Console.WriteLine("Type: " + conn.SourceType); | |
} |
代码片段中使用的源文件已附上供参考。