複数のワークブックを1つに結合する(C++)

画像とグラフを使用したワークブックの結合

例のコードは、Aspose.Cellsを使用して2つのワークブックを1つのワークブックに結合します。コードはソースワークブックを読み込み、Workbook::Combine()メソッドを使用してそれらを結合し、出力ワークブックを保存します。

ソースワークブック

出力ワークブック

スクリーンショット

以下は、ソースおよび出力ワークブックのスクリーンショットです。

チャートワークブックの最初のワークシート - 積み重ね

todo:image_alt_text

チャートワークブックの2番目のワークシート - 折れ線

todo:image_alt_text

画像ワークブックの最初のワークシート - 画像

todo:image_alt_text

結合されたワークブックの3つのワークシート - 積み重ね、折れ線、画像

todo:image_alt_text

#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;

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

    // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C

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

    // Path of the first source excel file
    U16String sourceFile1 = srcDir + u"SampleChart.xlsx";

    // Path of the second source excel file
    U16String sourceFile2 = srcDir + u"SampleImage.xlsx";

    // Open the first excel file.
    Workbook sourceBook1(sourceFile1);

    // Open the second excel file.
    Workbook sourceBook2(sourceFile2);

    // Combining the two workbooks
    sourceBook1.Combine(sourceBook2);

    // Define the output file path
    U16String outputFilePath = srcDir + u"Combined.out.xlsx";

    // Save the target book file.
    sourceBook1.Save(outputFilePath);

    std::cout << "Workbooks combined and saved successfully!" << std::endl;

    Aspose::Cells::Cleanup();
}

高度なトピック