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,Çalışma kitabı , bu bir Microsoft Excel dosyasını temsil eder. buÇalışma kitabı sınıf bir içerirÇalışma Sayfası KoleksiyonuExcel dosyasındaki her çalışma sayfasına erişim sağlar. Bir çalışma sayfası şununla temsil edilir:Çalışma kağıdı sınıf. buÇalışma kağıdı sınıf bir sağlarCellsçalışma sayfasındaki tüm hücreleri temsil eden koleksiyon.

buCellskoleksiyon, 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.

Satır Yüksekliğini Ayarlama

çağırarak tek bir satırın yüksekliğini ayarlamak mümkündür.Cells koleksiyonunsetRowHeight yöntem. busetRowHeight yöntemi aşağıdaki 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-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");

Tüm Satırların Yüksekliğini Ayarlama

Bir çalışma sayfasındaki tüm satırlar için aynı satır yüksekliğini ayarlamak üzereCells koleksiyonunsetStandartYükseklikyöntem.

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

Sütunlarla Çalışmak

Bir Sütunun Genişliğini Ayarlama

öğesini çağırarak bir sütunun genişliğini ayarlayın.Cells koleksiyonunsetColumnWidth yöntem. busetColumnWidth yöntemi 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-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");

Tüm Sütunların Genişliğini Ayarlama

Bir çalışma sayfasındaki tüm sütunlar için aynı sütun genişliğini ayarlamak üzereCells koleksiyonunsetStandartGenişlikyöntem.

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