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

ワークブックの結合

サンプル コードは、Aspose.Cells for Java を使用して 2 つのワークブックを 1 つのワークブックに結合します。コードはソース ワークブックをロードし、Workbook.combine() メソッドを使用してそれらを結合し、出力ワークブックを保存します。

ソース ワークブック

出力ワークブック

スクリーンショット

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

グラフ ワークブックの最初のワークシート - 積み上げ

todo:画像_代替_文章

グラフ ワークブックの 2 番目のワークシート - 線

todo:画像_代替_文章

ピクチャ ワークブックの最初のワークシート - ピクチャ

todo:画像_代替_文章

結合されたブック内の 3 つのワークシートすべて - 積み上げ、線、画像

todo:画像_代替_文章

次のコード スニペットは、複数のブックを 1 つのブックに結合する方法を示しています。

// 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(CombineMultipleWorkbooks.class);
// Open the first excel file.
Workbook SourceBook1 = new Workbook(dataDir + "charts.xlsx");
// Define the second source book.
// Open the second excel file.
Workbook SourceBook2 = new Workbook(dataDir + "picture.xlsx");
// Combining the two workbooks
SourceBook1.combine(SourceBook2);
// Save the target book file.
SourceBook1.save(dataDir + "combined.xlsx");

その他のリソース

先行トピック