Excel Çalışma Sayfasına Satır Ekleme veya Silme
Contents
[
Hide
]
Yeni bir çalışma sayfası oluştururken veya mevcut bir çalışma sayfasıyla çalışırken, verileri barındırmak için fazladan satır veya sütun eklemeniz gerekebilir. Diğer zamanlarda, çalışma sayfasında belirtilen konumlardaki satırları veya sütunları silmeniz gerekebilir.
Aspose.Cells, satır eklemek ve silmek için iki yöntem sunar:Cells.InsertRows veCells.DeleteRows. Bu yöntemler performans için optimize edilmiştir ve işi çok hızlı bir şekilde yapar.
Bir dizi satır eklemek veya çıkarmak için her zamanCells.InsertRows veCells.DeleteRows yöntemleri kullanmak yerineCells.InsertRow veyaSırayı silbir döngüdeki yöntemler.
Aspose.Cells, Microsoft Excel’in yaptığı gibi çalışır. Satır veya sütun eklendiğinde, çalışma sayfası içeriği aşağı ve sağa kaydırılır. Satır veya sütunlar kaldırıldığında, çalışma sayfası içeriği yukarı veya sola kaydırılır. Diğer çalışma sayfalarındaki ve hücrelerdeki referanslar, satırlar eklendiğinde veya kaldırıldığında güncellenir.
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); | |
// 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"); |