إدراج أو حذف الصفوف في ورقة عمل Excel

Contents
[ ]

تقدم Aspose.Cells طريقتين لإدراج الصفوف وحذفها: Cells.InsertRows و Cells.DeleteRows. تم تحسين هذه الطرق لتحقيق أداء ممتاز ولإنجاز المهمة بسرعة كبيرة جدًا.

لإدراج أو إزالة عدد من الصفوف، نوصي دائمًا باستخدام الCells.InsertRows و الCells.DeleteRows بدلاً من استخدام الCells.InsertRow أو الDeleteRow في حلقة.

تعمل 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");