ワークシートを追加または挿入する
Contents
[
Hide
]
このトピックでは、Aspose.Cells.GridDesktop を使用して Excel ファイルにワークシートを追加または挿入する手法について説明します。ワークシートの追加と挿入の違いは、さらに、ワークシートは Excel ファイルのワークシート コレクションの最後に追加されるだけですが、挿入とはワークシート コレクション内の特定の位置にワークシートを追加することを意味します。
ワークシートの追加
Aspose.Cells.GridDesktop を使用してワークシートを追加するには、次の手順に従ってください。
- Aspose.Cells.GridDesktop コントロールをフォームに追加します。
- GridDesktop コントロールで Worksheet コレクションの Add メソッドを呼び出します。
This file contains hidden or 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 | |
// Adding a worksheet to the Grid | |
int i = gridDesktop1.Worksheets.Add(); | |
Worksheet sheet = gridDesktop1.Worksheets[i]; |
Add メソッドのオーバーロードされたバージョンが多数用意されています。たとえば、上記のオーバーロードされたバージョンを使用すると、デフォルトのシート名でワークシートが Excel ファイルに追加されます。 Add メソッドの他のオーバーロードされたバージョンを使用すると、以下の例に示すように名前を定義できます。
This file contains hidden or 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 | |
// Adding a worksheet to the Grid with a specific name | |
Worksheet sheet1 = gridDesktop1.Worksheets.Add("AddWorksheetWithName"); |
ワークシートの挿入
Aspose.Cells.GridDesktop を使用してワークシートを挿入するには、次の手順に従ってください。
- Aspose.Cells.GridDesktop コントロールをフォームに追加します。
- GridDesktop コントロールで Worksheets コレクションの Insert メソッドを呼び出します。
This file contains hidden or 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 | |
// Inserting a worksheet to Grid at first position of the worksheets collection | |
gridDesktop1.Worksheets.Insert(0); |
重要: Microsoft Excel (97-2003 XLS) は、最大 65,536 行および 256 列の Excel シートをサポートします。 Aspose.Cells.GridDesktop も同じ基準に従います。 Aspose.Cells.GridDesktop コントロールでは、開発者は標準の制限よりも多くの行と列を持つワークシートを追加または挿入できますが、グリッド データを Excel ファイルに保存しようとすると、例外がスローされます。これは、Aspose.Cells.GridDesktop を使用して 65,536 行 256 列に含まれるデータのみが Excel XLS ファイルに保存できることを意味します。ただし、XLSX (MS Excel 2007/2010) ファイル形式を使用する場合、そのような制限はありません。