WebQueryタイプの外部データ接続の操作
Contents
[
Hide
]
Workbook.DataConnectionsコレクションを使用して、任意の種類の外部データ接続にアクセスできます。そのようなデータ接続の1つはWebQueryです。この記事では、WebQueryデータ接続の操作方法を示します。Microsoft ExcelでData > From Web メニューを使用してWebQueryデータ接続を作成できます。
WebQueryの外部データ接続を操作する
次のコードは、WebQueryタイプの外部データ接続を扱う方法を示しています。提供されたリンクからダウンロードできるサンプルエクセルファイルを使用しています。コンソールには、このコードの出力も示されています。
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 | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
Workbook workbook = new Workbook(dataDir + "WebQuerySample.xlsx"); | |
ExternalConnection connection = workbook.DataConnections[0]; | |
if (connection is WebQueryConnection) | |
{ | |
WebQueryConnection webQuery = (WebQueryConnection)connection; | |
Console.WriteLine("Web Query URL: " + webQuery.Url); | |
} |
コンソール出力
上記コードのコンソール出力は、このサンプルエクセルファイルとともに以下に示されています。
Web Query URL: https://docs.aspose.com/cells/net/