ضبط ارتفاع الصف وعرض العمود
العمل مع الصفوف
ضبط ارتفاع الصف
توفر Aspose.Cells فئة تمثل دفتر العمل الذي يمثل ملف Microsoft Excel. تحتوي فئة دفتر العمل على مجموعة أوراق العمل التي تسمح بالوصول إلى كل ورقة عمل في ملف Excel. تمثل ورقة العمل بواسطة فئة ورقة العمل وتوفر فئة ورقة العمل مجموعة الخلايا التي تمثل جميع الخلايا في ورقة العمل. تقدم مجموعة الخلايا عدة أساليب لإدارة الصفوف أو الأعمدة في ورقة العمل. يتم مناقشة بعض هذه الأساليب أدناه بتفصيل أكثر.
تعيين ارتفاع الصف
من الممكن تعيين ارتفاع صف واحد عن طريق استدعاء مجموعة الخلايا وتعيين ارتفاع الصف والتي تأخذ المعلمات التالية كما يلي:
- مؤشر الصف, مؤشر الصف الذي كنت تغير ارتفاعه.
- ارتفاع الصف, ارتفاع الصف المطبق على الصف.
Aspose::Cells::Startup(); | |
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input | |
U16String dirPath(u""); | |
//Path of output | |
U16String outPath(u""); | |
//Path of input excel file | |
U16String sampleRowsAndColumns = dirPath + u"sampleRowsAndColumns.xlsx"; | |
//Path of output excel file | |
U16String outputRowsAndColumns = outPath + u"outputRowsAndColumns.xlsx"; | |
//Read input excel file | |
Workbook workbook(sampleRowsAndColumns); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.GetWorksheets().Get(0); | |
//Setting the height of the second row to 35 | |
worksheet.GetCells().SetRowHeight(1, 35); | |
//Save the Excel file. | |
workbook.Save(outputRowsAndColumns); | |
Aspose::Cells::Cleanup(); |
تعيين ارتفاع جميع الصفوف في ورقة العمل
إذا كان لدى المطورين حاجة لتعيين نفس ارتفاع الصف لجميع الصفوف في ورقة العمل، فيمكنهم فعل ذلك باستخدام مجموعة الخلايا وتعيين ارتفاع قياسي للصفوف.
Aspose::Cells::Startup(); | |
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input | |
U16String dirPath(u""); | |
//Path of output | |
U16String outPath(u""); | |
//Path of input excel file | |
U16String sampleRowsAndColumns = dirPath + u"sampleRowsAndColumns.xlsx"; | |
//Path of output excel file | |
U16String outputRowsAndColumns = outPath + u"outputRowsAndColumns.xlsx"; | |
//Read input excel file | |
Workbook workbook(sampleRowsAndColumns); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.GetWorksheets().Get(0); | |
// Setting the height of all rows in the worksheet to 25 | |
worksheet.GetCells().SetStandardHeight(25); | |
//Save the Excel file. | |
workbook.Save(outputRowsAndColumns); | |
Aspose::Cells::Cleanup(); |
العمل مع الأعمدة
ضبط عرض العمود
قم بتعيين عرض العمود عن طريق استدعاء Cells مجموعة SetColumnWidth استخدم الأسلوب. SetColumnWidth يأخذ البيانات التالية:
- فهرس العمود, فهرس العمود الذي تريد تغيير عرضه.
- عرض العمود, العرض المطلوب للعمود.
Aspose::Cells::Startup(); | |
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input | |
U16String dirPath(u""); | |
//Path of output | |
U16String outPath(u""); | |
//Path of input excel file | |
U16String sampleRowsAndColumns = dirPath + u"sampleRowsAndColumns.xlsx"; | |
//Path of output excel file | |
U16String outputRowsAndColumns = outPath + u"outputRowsAndColumns.xlsx"; | |
//Read input excel file | |
Workbook workbook(sampleRowsAndColumns); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.GetWorksheets().Get(0); | |
//Setting the width of the second column to 56.5 | |
worksheet.GetCells().SetColumnWidth(1, 56.5); | |
//Save the Excel file. | |
workbook.Save(outputRowsAndColumns); | |
Aspose::Cells::Cleanup(); |
تعيين عرض جميع الأعمدة في ورقة العمل
لتعيين نفس عرض العمود لجميع الأعمدة في ورقة العمل، استخدم الأسلوب SetStandardWidth من مجموعة Cells.
Aspose::Cells::Startup(); | |
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input | |
U16String dirPath(u""); | |
//Path of output | |
U16String outPath(u""); | |
//Path of input excel file | |
U16String sampleRowsAndColumns = dirPath + u"sampleRowsAndColumns.xlsx"; | |
//Path of output excel file | |
U16String outputRowsAndColumns = outPath + u"outputRowsAndColumns.xlsx"; | |
//Read input excel file | |
Workbook workbook(sampleRowsAndColumns); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.GetWorksheets().Get(0); | |
//Setting the width of all columns in the worksheet to 20.5 | |
worksheet.GetCells().SetStandardWidth(20.5); | |
//Save the Excel file. | |
workbook.Save(outputRowsAndColumns); | |
Aspose::Cells::Cleanup(); |