WebQueryタイプの外部データ接続の操作
Contents
[
Hide
]
Workbook.DataConnectionsコレクションを使用して、任意のタイプの外部データ接続にアクセスできます。そのようなデータ接続の1つはWebQueryです。この記事では、WebQueryデータ接続の操作方法を紹介します。Microsoft ExcelでData > From 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