الوصول إلى وتعديل قيمة Cell
Contents
[
Hide
]
في موضوعنا السابق ، ناقشنا حول الوصول إلى خلايا ورقة العمل. في هذا الموضوع ، سنقوم ببساطة بتوسيع هذا الموضوع لنوضح للمطورين كيف يمكنهم الوصول إلى قيم الخلايا وتعديلها باستخدام API من Aspose.Cells.GridDesktop.
قم بالوصول وتعديل قيمة Cell باستخدام Aspose.Cells.GridDesktop
قبل الوصول إلى قيمة الخلية وتعديلها ، يجب أن نعرف كيفية الوصول إلى الخلايا. هناك ثلاث طرق للوصول إلى خلايا ورقة العمل. لمزيد من التفاصيل حول هذه الأساليب الثلاثة ، من فضلكالوصول إلى Cells في ورقة عمل.
كل خلية لها خاصية تسمى القيمة. لذلك ، بمجرد الوصول إلى خلية ، يمكن للمطورين الوصول إلى محتويات خاصية القيمة وتعديلها من أجل الوصول إلى قيمة الخلية وتغييرها.
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 | |
// Accessing the worksheet of the Grid that is currently active | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Accessing the cell using its name | |
GridCell cell = sheet.Cells["A1"]; | |
// Accessing & modifying the value of "A1" cell | |
cell.Value = DateTime.Now; |
الأهمية:يعد استخدام خاصية Value لخلية لتعديل قيمتها طريقة جيدة لتعيين قيمة خلية مفردة أو خلايا قليلة. إذا كنت بحاجة إلى تعيين قيم العديد من الخلايا ، فلن يكون أداء هذا النهج جيدًا. لذلك ، لتعيين قيم العديد من الخلايا ، يجب عليك استخدامSetCellValue طريقة الخلية لتحسين أداء تطبيقاتك. نسخة معدلة من مقتطف الشفرة أعلاه باستخدامSetCellValue الطريقة الموضحة أدناه.
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 | |
// Accessing the worksheet of the Grid that is currently active | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Accessing the cell using its name | |
GridCell cell = sheet.Cells["A1"]; | |
// Setting the value of "A1" cell | |
cell.SetCellValue(DateTime.Now); |