Mehrere Arbeitsmappen zu einer einzigen Arbeitsmappe mit C++ kombinieren

Arbeitsbücher mit Bildern und Diagrammen kombinieren

Der Beispielcode kombiniert mit Aspose.Cells zwei Arbeitsbücher zu einem einzigen Arbeitsbuch. Der Code lädt die Quell-Arbeitsbücher, verwendet die Methode Workbook::Combine() zur Kombination und speichert das Ausgabearbeitsbuch.

Quell-Arbeitsbücher

Ausgabearbeitsbücher

Screenshots

Nachfolgend finden Sie Screenshots der Quell- und Ausgabearbeitsbücher.

Die erste Arbeitsblatt der Diagramme Arbeitsmappe - gestapelt

todo:image_alt_text

Zweites Arbeitsblatt der Diagramme Arbeitsmappe - Linie

todo:image_alt_text

Erstes Arbeitsblatt der Bild Arbeitsmappe - Bild

todo:image_alt_text

Alle drei Arbeitsblätter in der kombinierten Arbeitsmappe - gestapelt, Linie, Bild

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();
}

Erweiterte Themen