Excel ワークシートでの行の挿入または削除

Contents
[ ]

Aspose.Cells は、行を挿入および削除するための 2 つの方法を提供します。Cells.InsertRowsCells.DeleteRows.これらのメソッドは、パフォーマンスのために最適化されており、ジョブを非常に迅速に実行します。

複数の行を挿入または削除するには、常にCells.InsertRowsCells.DeleteRowsメソッドを使用する代わりにCells.InsertRowまた行の削除ループ内のメソッド。

Aspose.Cells は、Microsoft Excel と同じように機能します。行または列が追加されると、ワークシートの内容が右下に移動します。行または列が削除されると、ワークシートの内容が上または左に移動します。行が追加または削除されると、他のワークシートおよびセル内のすべての参照が更新されます。

// 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);
// Instantiate a Workbook object.
// Load a template file.
Workbook workbook = new Workbook(dataDir+ "book1.xlsx");
// Get the first worksheet in the book.
Worksheet sheet = workbook.Worksheets[0];
// Insert 10 rows at row index 2 (insertion starts at 3rd row)
sheet.Cells.InsertRows(2, 10);
// Delete 5 rows now. (8th row - 12th row)
sheet.Cells.DeleteRows(7, 5);
// Save the excel file.
workbook.Save(dataDir+ "out_book1.out.xlsx");