C++を使用したWebQueryタイプの外部データ接続の操作

WebQueryの外部データ接続を操作する

次のコードは、WebQueryタイプの外部データ接続を扱う方法を示しています。提供されたリンクからダウンロードできるサンプルエクセルファイルを使用しています。コンソールには、このコードの出力も示されています。

#include <iostream>
#include "Aspose.Cells.h"

using namespace Aspose::Cells;
using namespace Aspose::Cells::ExternalConnections;

int main()
{
    Aspose::Cells::Startup();

    // Source directory path
    U16String srcDir(u"..\\Data\\01_SourceDirectory\\");

    // Path of input excel file
    U16String inputFilePath = srcDir + u"WebQuerySample.xlsx";

    // Create workbook
    Workbook workbook(inputFilePath);

    // Get the first external connection from the workbook
    ExternalConnection connection = workbook.GetDataConnections().Get(0);

    // Check if the connection is a WebQueryConnection
    if (connection.GetClassType() == ExternalConnectionClassType::WebQuery)
    {
        // Cast to WebQueryConnection
        WebQueryConnection webQuery(connection);

        // Print the URL of the web query
        std::cout << "Web Query URL: " << webQuery.GetUrl().ToUtf8() << std::endl;
    }

    Aspose::Cells::Cleanup();
}

コンソール出力

上記コードのコンソール出力は、このサンプルエクセルファイルとともに以下に示されています。

Web Query URL: https://docs.aspose.com/cells/net/