Working with External Data Connection of type WebQuery
Contents
[
Hide
]
You can access the external data connection of any type using the Workbook.DataConnections collection. One type of such a data connection is WebQuery. This article will show you how to work with the WebQuery data connection. You can create WebQuery data connection in Microsoft Excel using the Data > From Web menu.
Working with External Data Connection of type WebQuery
The following code shows how to work with external data connection of type WebQuery. It uses the sample excel file which you can download from the provided link. You can also see the console output of this code further below.
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()); | |
} |
Console Output
Here is the console output of the above code with this sample excel file.
Web Query URL: http://www.aspose.com/docs/display/cellsnet/Home