Satır Yüksekliğini ve Sütun Genişliğini Ayarlama

Satırlarla Çalışmak

Satır Yüksekliğini Ayarlama

Aspose.Cells bir sınıf sağlar,IÇalışma Kitabı bu bir Microsoft Excel dosyasını temsil eder. buIÇalışma Kitabı sınıf bir içerirIÇalışma Sayfası KoleksiyonuExcel dosyasındaki her çalışma sayfasına erişim sağlar. Bir çalışma sayfası şununla temsil edilir:IÇalışma Sayfası sınıf. buIÇalışma Sayfası sınıf bir sağlarICell’ler çalışma sayfasındaki tüm hücreleri temsil eden koleksiyon. buICell’lerkoleksiyon, bir çalışma sayfasındaki satırları veya sütunları yönetmek için çeşitli yöntemler sağlar. Bunlardan bazıları aşağıda daha ayrıntılı olarak tartışılmaktadır.

Bir Satırın Yüksekliğini Ayarlama

çağırarak tek bir satırın yüksekliğini ayarlamak mümkündür.ICell’ler koleksiyonunSatır Yüksekliğini Ayarla yöntem. buSatır Yüksekliğini Ayarlamethod aşağıdaki gibi parametreleri alır:

  • Satır dizini, yüksekliğini değiştirdiğiniz satırın dizini.
  • Satır yüksekliği, satıra uygulanacak satır yüksekliği.
//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);

Çalışma Sayfasındaki Tüm Satırların Yüksekliğini Ayarlama

Geliştiricilerin çalışma sayfasındaki tüm satırlar için aynı satır yüksekliğini ayarlamaları gerekirse, bunuStandart Yüksekliği Ayarla yöntemiICell’lerToplamak.

//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);

Sütunlarla Çalışmak

Bir Sütunun Genişliğini Ayarlama

öğesini çağırarak bir sütunun genişliğini ayarlayın.ICell’ler koleksiyonunSütun Genişliğini Ayarla yöntem. buSütun Genişliğini Ayarlayöntem aşağıdaki parametreleri alır:

  • Sütun dizini, genişliğini değiştirdiğiniz sütunun dizini.
  • Sütun genişliği, istenen sütun genişliği.
//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);

Çalışma Sayfasındaki Tüm Sütunların Genişliğini Ayarlama

Çalışma sayfasındaki tüm sütunlar için aynı sütun genişliğini ayarlamak üzereICell’ler koleksiyonunStandart Genişliği Ayarlayöntem.

//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);