ضبط ارتفاع الصف وعرض العمود

العمل مع الصفوف

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

Aspose.Cells يوفر فصل دراسي ،IWorkbook يمثل ملف Excel Microsoft. الIWorkbook فئة تحتوي علىIWorksheetCollectionيسمح بالوصول إلى كل ورقة عمل في ملف Excel. يتم تمثيل ورقة العمل بواسطةIWorksheet صف دراسي. الIWorksheet فئة توفر أآيسيلس مجموعة تمثل جميع الخلايا في ورقة العمل. الآيسيلستوفر المجموعة عدة طرق لإدارة الصفوف أو الأعمدة في ورقة العمل. تمت مناقشة بعض هذه أدناه بمزيد من التفصيل.

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

من الممكن ضبط ارتفاع صف واحد عن طريق استدعاءآيسيلس المجموعةSetRowHeight طريقة. الSetRowHeightتأخذ الطريقة المعلمات التالية على النحو التالي:

  • فهرس الصف، فهرس الصف الذي تقوم بتغيير ارتفاعه.
  • ارتفاع الصف، ارتفاع الصف المراد تطبيقه على الصف.
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
//Path of input excel file
StringPtr sampleRowsAndColumns = dirPath->StringAppend(new String("sampleRowsAndColumns.xlsx"));
//Path of output excel file
StringPtr outputRowsAndColumns = outPath->StringAppend(new String("outputRowsAndColumns.xlsx"));
//Read input excel file
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleRowsAndColumns);
//Accessing the first worksheet in the Excel file
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0);
//Setting the height of the second row to 35
worksheet->GetICells()->SetRowHeight(1, 35);
//Save the Excel file.
workbook->Save(outputRowsAndColumns);

ضبط ارتفاع كل الصفوف في ورقة عمل

إذا احتاج المطورون إلى تعيين ارتفاع الصف نفسه لجميع الصفوف في ورقة العمل ، فيمكنهم القيام بذلك باستخدام ملحقSetStandardHeight طريقةآيسيلسمجموعة.

//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
//Path of input excel file
StringPtr sampleRowsAndColumns = dirPath->StringAppend(new String("sampleRowsAndColumns.xlsx"));
//Path of output excel file
StringPtr outputRowsAndColumns = outPath->StringAppend(new String("outputRowsAndColumns.xlsx"));
//Read input excel file
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleRowsAndColumns);
//Accessing the first worksheet in the Excel file
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0);
// Setting the height of all rows in the worksheet to 25
worksheet->GetICells()->SetStandardHeight(25);
//Save the Excel file.
workbook->Save(outputRowsAndColumns);

العمل مع الأعمدة

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

اضبط عرض العمود عن طريق استدعاءآيسيلس المجموعةSetColumnWidth طريقة. الSetColumnWidthتأخذ الطريقة المعلمات التالية:

  • فهرس العمود، هو فهرس العمود الذي تقوم بتغيير عرضه.
  • عرض العمود، عرض العمود المطلوب.
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
//Path of input excel file
StringPtr sampleRowsAndColumns = dirPath->StringAppend(new String("sampleRowsAndColumns.xlsx"));
//Path of output excel file
StringPtr outputRowsAndColumns = outPath->StringAppend(new String("outputRowsAndColumns.xlsx"));
//Read input excel file
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleRowsAndColumns);
//Accessing the first worksheet in the Excel file
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0);
//Setting the width of the second column to 56.5
worksheet->GetICells()->SetColumnWidth(1, 56.5);
//Save the Excel file.
workbook->Save(outputRowsAndColumns);

ضبط عرض كل الأعمدة في ورقة عمل

لتعيين نفس عرض العمود لجميع الأعمدة في ورقة العمل ، استخدم ملفآيسيلس المجموعةSetStandardWidthطريقة.

//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
//Path of input excel file
StringPtr sampleRowsAndColumns = dirPath->StringAppend(new String("sampleRowsAndColumns.xlsx"));
//Path of output excel file
StringPtr outputRowsAndColumns = outPath->StringAppend(new String("outputRowsAndColumns.xlsx"));
//Read input excel file
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleRowsAndColumns);
//Accessing the first worksheet in the Excel file
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0);
//Setting the width of all columns in the worksheet to 20.5
worksheet->GetICells()->SetStandardWidth(20.5);
//Save the Excel file.
workbook->Save(outputRowsAndColumns);