العمل مع الصفوف والأعمدة في GridWeb

إدراج الصفوف والأعمدة

يشرح هذا الموضوع كيفية إدراج صفوف وأعمدة جديدة في ورقة عمل باستخدام واجهة برمجة تطبيقات Aspose.Cells.GridWeb. يمكن إدراج الصفوف أو الأعمدة في أي موقع في ورقة العمل.

إدراج الصفوف

لإدراج صف في أي موضع في ورقة العمل:

  1. أضف عنصر تحكم Aspose.Cells.GridWeb إلى النموذج الويب أو الصفحة.
  2. الوصول إلى ورقة العمل التي تقوم بإضافة الصفوف إليها.
  3. إدراج صف عن طريق تحديد فهرس الصف الذي سيتم إدراج الصف فيه.
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
//Accessing the reference of the worksheet that is currently active
GridWorksheet sheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex());
//Inserting a new row to the worksheet before 2nd row
sheet.getCells().insertRow(1);

إدراج الأعمدة

لإدراج عمود في أي موضع في ورقة العمل:

  1. أضف عنصر تحكم Aspose.Cells.GridWeb إلى نموذج ويب أو صفحة.
  2. الوصول إلى ورقة العمل التي تقوم بإضافة الأعمدة إليها.
  3. إدراج عمود عن طريق تحديد فهرس العمود الذي سيتم إدراج العمود فيه.
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
//Accessing the reference of the worksheet that is currently active
GridWorksheet sheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex());
//Inserting a new column to the worksheet before column "B"
sheet.getCells().insertColumn(1);

حذف الصفوف والأعمدة

يوضح هذا الموضوع كيفية حذف الصفوف والأعمدة من ورقة العمل باستخدام واجهة برمجة التطبيقات Aspose.Cells.GridWeb. بمساعدة هذه الميزة ، يمكن للمطورين حذف الصفوف أو الأعمدة أثناء التشغيل.

حذف الصفوف

لحذف صف من ورقة العمل الخاصة بك:

  1. أضف عنصر تحكم Aspose.Cells.GridWeb إلى نموذج ويب أو صفحة.
  2. الوصول إلى ورقة العمل التي تريد حذف الصفوف منها.
  3. حذف صف من ورقة العمل عن طريق تحديد فهرس صفه.
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
//Accessing the reference of the worksheet that is currently active
GridWorksheet sheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex());
//Deleting 2nd row from the worksheet
sheet.getCells().deleteRow(1);

حذف الأعمدة

لحذف عمود من ورقة العمل الخاصة بك:

  1. أضف عنصر تحكم Aspose.Cells.GridWeb إلى نموذج ويب أو صفحة.
  2. الوصول إلى ورقة العمل التي تريد حذف الأعمدة منها.
  3. حذف عمود من ورقة العمل عن طريق تحديد فهرس العمود الخاص به.
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
//Accessing the reference of the worksheet that is currently active
GridWorksheet sheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex());
//Deleting 2nd column from the worksheet
sheet.getCells().deleteColumn(1);

تعيين ارتفاع الصف وعرض العمود

في بعض الأحيان تكون قيم الخانات أوسع من الخانة التي تتواجد فيها أو تكون على عدة أسطر. هذه القيم لا تكون مرئية تماماً للمستخدمين ما لم يقوموا بتغيير ارتفاع الأسطر وعرض الأعمدة. تدعم Aspose.Cells.GridWeb تماماً ضبط ارتفاع الأسطر وعرض الأعمدة. يتناول هذا الموضوع هذه الميزات بالتفصيل بمساعدة الأمثلة.

العمل مع ارتفاعات الصفوف وأعراض الأعمدة

ضبط ارتفاع الصف

لضبط ارتفاع صف:

  1. أضف عنصر التحكم Aspose.Cells.GridWeb إلى نموذج الويب أو الصفحة الخاصة بك.
  2. الوصول إلى مجموعة GridCells في ورقة العمل.
  3. ضبط ارتفاع جميع الخلايا في أي صف محدد.

الناتج: تم ضبط ارتفاع الصف الأول إلى 50 نقطة

todo:image_alt_text

For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
//Accessing the cells collection of the worksheet that is currently active
GridCells cells = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()).getCells();
//Setting the height of 1st row to 50 points
cells.setRowHeight(0, 50);

ضبط عرض العمود

لضبط عرض عمود:

  1. أضف عنصر التحكم Aspose.Cells.GridWeb إلى نموذج الويب أو الصفحة الخاصة بك.
  2. الوصول إلى مجموعة GridCells في ورقة العمل.
  3. تعيين عرض جميع الخلايا في أي عمود محدد.
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
//Accessing the cells collection of the worksheet that is currently active
GridCells cells = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()).getCells();
//Setting the width of 1st column to 150 points
cells.setColumnWidth(0, 150);

تخصيص رؤوس الأسطر والأعمدة

مثل Microsoft Excel، يستخدم Aspose.Cells.GridWeb أيضًا رؤوس أو عناوين قياسية للصفوف (أرقام مثل 1، 2، 3 وهكذا) والأعمدة (أبجدية مثل A، B، C وهكذا). يجعل Aspose.Cells.GridWeb أيضاً من الممكن تخصيص العناوين. يتناول هذا الموضوع تخصيص رؤوس الأسطر والأعمدة في وقت التشغيل باستخدام واجهة برمجة تطبيقات Aspose.Cells.GridWeb.

تخصيص رأس الصف

لتخصيص رأس أو تسمية صف:

  1. أضف عنصر تحكم Aspose.Cells.GridWeb إلى صفحة ويب/ النموذج.
  2. قم بالوصول إلى ورقة العمل في مجموعة GridWorksheetCollection.
  3. قم بتعيين التسمية لأي صف محدد.

تم تخصيص رؤوس الصفين 1 و 2

todo:image_alt_text

For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
//Accessing the worksheet that is currently active
GridWorksheet worksheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex());
//Setting the header of 1st row to "ID"
worksheet.setRowCaption(1, "ID");
//Setting the header of 2nd row to "Name"
worksheet.setRowCaption(2, "Name");

تخصيص رأس العمود

لتخصيص الرأس أو التسمية لعمود:

  1. أضف عنصر تحكم Aspose.Cells.GridWeb إلى صفحة ويب/ النموذج.
  2. قم بالوصول إلى ورقة العمل في مجموعة GridWorksheetCollection.
  3. قم بتعيين التسمية لأي عمود محدد.

تم تخصيص رؤوس العمودين 1 و 2

todo:image_alt_text

For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
//Accessing the worksheet that is currently active
GridWorksheet worksheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex());
//Setting the header of 1st column to "ID"
worksheet.SetColumnCaption(0, "ID");
//Setting the header of 2nd column to "Name"
worksheet.SetColumnCaption(1, "Name");

تجميد وفك تجميد الصفوف والأعمدة

يشرح هذا الموضوع كيفية تجميد وإلغاء تجميد الصفوف والأعمدة. يسمح تجميد الأعمدة أو الصفوف للمستخدمين بالاحتفاظ بعناوين الأعمدة أو عناوين الصفوف مرئية أثناء التمرير إلى أجزاء أخرى من ورقة العمل. هذه الميزة مفيدة للغاية عند العمل مع ورق العمل الذي يحتوي على مجلدات كبيرة من البيانات. عندما يقوم المستخدمون بالتمرير، يتم التمرير فقط للبيانات، وتبقى العناوين في مكانها، مما يجعل البيانات أسهل في القراءة. ميزة تجميد الأجزاء معتمدة فقط في Internet Explorer 6.0 أو أعلى.

تجميد الصفوف والأعمدة

لتجميد عدد معين من الصفوف والأعمدة:

  1. أضف عنصر تحكم Aspose.Cells.GridWeb إلى صفحة ويب/ النموذج.
  2. الوصول إلى ورقة العمل.
  3. تجميد عدد من الصفوف والأعمدة.

الصفوف والأعمدة في حالة مجمدة

todo:image_alt_text

For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
//Accessing the reference of the worksheet that is currently active
GridWorksheet sheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex());
//Freezing 4th row and 3rd column
sheet.freezePanes(3, 2, 3, 2);

إلغاء تجميد الصفوف والأعمدة

لإلغاء تجميد الصفوف والأعمدة:

  1. أضف عنصر تحكم Aspose.Cells.GridWeb إلى صفحة ويب/ النموذج.
  2. الوصول إلى ورقة العمل.
  3. إلغاء تجميد الصفوف والأعمدة.

ورقة العمل بعد إلغاء التجميد

todo:image_alt_text

For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
//Accessing the reference of the worksheet that is currently active
GridWorksheet sheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex());
//Unfreezing rows and columns
sheet.unFreezePanes();

حماية الصفوف والأعمدة

يناقش هذا الموضوع بعض التقنيات لحماية الخلايا في الصفوف والأعمدة من أي نوع من الإجراءات التي يقوم بها المستخدمون النهائيون. يمكن للمطورين تنفيذ هذه الحماية باستخدام تقنيتين: عن طريق جعل الخلايا في الصفوف والأعمدة للقراءة فقط، أو عن طريق تقييد خيارات قائمة السياق في GridWeb.

تقييد خيارات القائمة السياقية

يوفر GridWeb قائمة سياق يمكن للمستخدمين النهائيين استخدامها لأداء العمليات على العنصر التحكم. توفر القائمة العديد من الخيارات للتلاعب بالخلايا والصفوف والأعمدة.

خيارات سياقية كاملة

todo:image_alt_text

من الممكن تقييد أي نوع من العمليات على الجانب العميلي على الصفوف والأعمدة عن طريق تقييد الخيارات المتاحة في قائمة السياق. يمكن القيام بذلك عن طريق ضبط سمات EnableClientColumnOperations و EnableClientRowOperations لعنصر التحكم GridWeb على false. كما يمكن تقييد المستخدمين من تجميد الصفوف والأعمدة عن طريق ضبط سمة EnableClientFreeze لعنصر التحكم GridWeb على false.

قائمة سياقية بعد تقييد خيارات الصف والعمود

todo:image_alt_text

For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
//Accessing the first worksheet that is currently active
GridWorksheet sheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex());
//Restricting column related operations in context menu
gridweb.setEnableClientColumnOperations(false);
//Restricting row related operations in context menu
gridweb.setEnableClientRowOperations(false);
//Restricting freeze option of context menu
gridweb.setEnableClientFreeze(false);