قم بإدراج أو حذف صفوف في ورقة عمل Excel
Contents
[
Hide
]
عند إنشاء ورقة عمل جديدة ، أو العمل باستخدام ورقة عمل موجودة ، قد تحتاج إلى إضافة صفوف أو أعمدة إضافية لاستيعاب البيانات. في أوقات أخرى ، قد تحتاج إلى حذف صفوف أو أعمدة من مواضع محددة في ورقة العمل.
يوفر Aspose.Cells طريقتين لإدخال الصفوف وحذفها:Cells.InsertRows وCells.DeleteRows. تم تحسين هذه الأساليب للأداء والقيام بالمهمة بسرعة كبيرة.
لإدراج عدد من الصفوف أو إزالتها ، نوصيك دائمًا باستخدام ملفCells.InsertRows وCells.DeleteRows طرق بدلاً من استخدامCells.InsertRow أواحذف صفطرق في حلقة.
يعمل Aspose.Cells بنفس طريقة عمل Microsoft Excel. عند إضافة صفوف أو أعمدة ، يتم إزاحة محتوى ورقة العمل لأسفل وإلى اليمين. عند إزالة الصفوف أو الأعمدة ، ينتقل محتوى ورقة العمل لأعلى أو لليسار. يتم تحديث أي مراجع في أوراق العمل والخلايا الأخرى عند إضافة صفوف أو إزالتها.
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"); |