使用 WebQuery 类型的外部数据连接
Contents
[
Hide
]
您可以使用访问任何类型的外部数据连接工作簿.DataConnections收藏。这种数据连接的一种类型是 WebQuery。本文将向您展示如何使用 WebQuery 数据连接。您可以使用 Microsoft Excel 在 Excel 中创建 WebQuery 数据连接数据 > 来自网络菜单。
使用 WebQuery 类型的外部数据连接
以下代码显示了如何使用类型的外部数据连接网络查询.它使用示例 excel 文件您可以从提供的链接下载。您还可以在下面进一步查看此代码的控制台输出。
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-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(WorkingWithExternalDataConnection.class); | |
Workbook workbook = new Workbook(dataDir + "WebQuerySample.xlsx"); | |
ExternalConnection connection = workbook.getDataConnections().get(0); | |
if (connection instanceof WebQueryConnection) | |
{ | |
WebQueryConnection webQuery = (WebQueryConnection)connection; | |
System.out.println("Web Query URL: " + webQuery.getUrl()); | |
} |
控制台输出
这是上面代码的控制台输出示例 excel 文件.
Web Query URL: http://www.aspose.com/docs/display/cellsnet/Home