複数のワークブックを単一のワークブックに結合する
Contents
[
Hide
]
時々、画像、グラフ、データなど、さまざまなコンテンツを組み合わせて単一のワークブックに結合する必要があります。Aspose.Cellsはこの機能をサポートしています。この記事では、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); |