複数のワークブックを 1 つのワークブックに結合する
Contents
[
Hide
]
場合によっては、ワークブックを画像、グラフ、データなどのさまざまなコンテンツと組み合わせて 1 つのワークブックにする必要があります。 Aspose.Cells はこの機能をサポートしています。この記事では、Visual Studio でコンソール アプリケーションを作成し、Aspose.Cells を使用して数行の単純なコードとワークブックを組み合わせる方法を示します。
ワークブックと画像およびチャートの結合
サンプル コードは、Aspose.Cells を使用して 2 つのワークブックを 1 つのワークブックに結合します。コードはソース ワークブックをロードし、Workbook.combine()メソッドを使用してそれらを結合し、出力ワークブックを保存します。
ソース ワークブック
出力ワークブック
スクリーンショット
以下は、ソース ワークブックと出力ワークブックのスクリーンショットです。
任意のソース ワークブックを使用できます。これらの画像は、説明のみを目的としています。
グラフ ワークブックの最初のワークシート - 積み上げ
グラフ ワークブックの 2 番目のワークシート - 線
ピクチャ ワークブックの最初のワークシート - ピクチャ
結合されたブック内の 3 つのワークシートすべて - 積み上げ、線、画像
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-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Define the first source | |
// Open the first excel file. | |
Workbook SourceBook1 = new Workbook(dataDir+ "SampleChart.xlsx"); | |
// Define the second source book. | |
// Open the second excel file. | |
Workbook SourceBook2 = new Workbook(dataDir+ "SampleImage.xlsx"); | |
// Combining the two workbooks | |
SourceBook1.Combine(SourceBook2); | |
dataDir = dataDir + "Combined.out.xlsx"; | |
// Save the target book file. | |
SourceBook1.Save(dataDir); |