ضبط ارتفاع الصف وعرض العمود
العمل مع الصفوف
ضبط ارتفاع الصف
Aspose.Cells يوفر فصل دراسي ،دفتر العمل ، يمثل ملف Excel Microsoft. الدفتر العمل فئة تحتوي علىورقة العمليسمح بالوصول إلى كل ورقة عمل في ملف Excel. يتم تمثيل ورقة العمل بواسطةورقة عمل صف دراسي. الورقة عمل فئة توفر أCellsمجموعة تمثل جميع الخلايا في ورقة العمل.
الCellsتوفر المجموعة عدة طرق لإدارة الصفوف أو الأعمدة في ورقة العمل. تمت مناقشة بعض هذه أدناه بمزيد من التفصيل.
ضبط ارتفاع الصف
من الممكن ضبط ارتفاع صف واحد عن طريق استدعاءCells المجموعةsetRowHeight طريقة. الsetRowHeight تأخذ الطريقة المعلمات التالية:
- فهرس الصف، فهرس الصف الذي تقوم بتغيير ارتفاعه.
- ارتفاع الصف، ارتفاع الصف المراد تطبيقه على الصف.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(SettingHeightOfRow.class) + "rows_cloumns/"; | |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(dataDir + "book1.xls"); | |
// Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
Cells cells = worksheet.getCells(); | |
// Setting the height of the second row to 13 | |
cells.setRowHeight(1, 13); | |
// Saving the modified Excel file in default (that is Excel 2003) format | |
workbook.save(dataDir + "SettingHeightOfRow_out.xls"); |
ضبط ارتفاع كل الصفوف
لتعيين ارتفاع الصف نفسه لجميع الصفوف في ورقة العمل ، استخدم ملفCells المجموعةsetStandardHeightطريقة.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(SettingHeightAllRows.class) + "rows_cloumns/"; | |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(dataDir + "book1.xls"); | |
// Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
Cells cells = worksheet.getCells(); | |
// Setting the height of all rows in the worksheet to 15 | |
worksheet.getCells().setStandardHeight(15f); | |
// Saving the modified Excel file in default (that is Excel 2003) format | |
workbook.save(dataDir + "SettingHeightAllRows_out.xls"); |
العمل مع الأعمدة
ضبط عرض العمود
اضبط عرض العمود عن طريق استدعاءCells المجموعةsetColumnWidth طريقة. الsetColumnWidth تأخذ الطريقة المعلمات التالية:
- فهرس العمود، هو فهرس العمود الذي تقوم بتغيير عرضه.
- عرض العمود، عرض العمود المطلوب.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(SettingWidthOfColumn.class) + "rows_cloumns/"; | |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(dataDir + "book1.xls"); | |
// Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
Cells cells = worksheet.getCells(); | |
// Setting the width of the second column to 17.5 | |
cells.setColumnWidth(1, 17.5); | |
// Saving the modified Excel file in default (that is Excel 2003) format | |
workbook.save(dataDir + "SettingWidthOfColumn_out.xls"); |
ضبط عرض كل الأعمدة
لتعيين نفس عرض العمود لجميع الأعمدة في ورقة العمل ، استخدم ملفCells المجموعةsetStandardWidthطريقة.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(SettingWidthOfAllColumns.class) + "rows_cloumns/"; | |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(dataDir + "book1.xls"); | |
// Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
Cells cells = worksheet.getCells(); | |
// Setting the width of all columns in the worksheet to 20.5 | |
worksheet.getCells().setStandardWidth(20.5f); | |
// Saving the modified Excel file in default (that is Excel 2003) format | |
workbook.save(dataDir + "SettingWidthOfAllColumns_out.xls"); |