複数のワークブックを 1 つのワークブックに結合する
Contents
[
Hide
]
場合によっては、ワークブックを画像、グラフ、データなどのさまざまなコンテンツと組み合わせて 1 つのワークブックにする必要があります。 Aspose.Cells はこの機能をサポートしています。この記事では、Aspose.Cells を使用して、ワークブックをいくつかの単純なコード行と結合する単純なアプリケーションを作成する方法を示します。
ワークブックの結合
サンプル コードは、Aspose.Cells for Java を使用して 2 つのワークブックを 1 つのワークブックに結合します。コードはソース ワークブックをロードし、Workbook.combine() メソッドを使用してそれらを結合し、出力ワークブックを保存します。
ソース ワークブック
出力ワークブック
スクリーンショット
以下は、ソース ワークブックと出力ワークブックのスクリーンショットです。
任意のソース ワークブックを使用できます。これらの画像は、説明のみを目的としています。
グラフ ワークブックの最初のワークシート - 積み上げ
グラフ ワークブックの 2 番目のワークシート - 線
ピクチャ ワークブックの最初のワークシート - ピクチャ
結合されたブック内の 3 つのワークシートすべて - 積み上げ、線、画像
次のコード スニペットは、複数のブックを 1 つのブックに結合する方法を示しています。
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-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"); |
その他のリソース
あなたは見つけるかもしれません複数のワークシートを 1 つのワークシートに結合する詳細については、記事を参照してください。