使用 WebQuery 类型的外部数据连接
Contents
[
Hide
]
您可以使用Workbook.DataConnections集合访问任何类型的外部数据连接。这种数据连接的一种类型是WebQuery。本文将向您展示如何处理WebQuery数据连接。您可以使用Microsoft Excel中的数据 > 从Web菜单来创建WebQuery数据连接。
处理 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