设置列宽或行高

设置列宽

使用 Aspose.Cells.GridDesktop 设置列的宽度:

  1. 访问工作表。
  2. 访问要更改宽度的列。
  3. 设置列宽。
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Accessing the worksheet of the Grid that is currently active
Worksheet sheet = gridDesktop1.GetActiveWorksheet();
// Adding sample value to sheet cell
GridCell cell = sheet.Cells["a1"];
cell.SetCellValue("Welcome to Aspose!");
// Accessing the first column of the worksheet
Aspose.Cells.GridDesktop.Data.GridColumn column = sheet.Columns[0];
// Setting the width of the column
column.Width = 150;

设置行高

要使用 Aspose.Cells.GridDesktop 设置行高,请按照以下步骤操作:

  1. 访问任何所需的工作表。
  2. 访问要更改高度的行。
  3. 设置行高。
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Accessing the worksheet of the Grid that is currently active
Worksheet sheet = gridDesktop1.GetActiveWorksheet();
// Adding sample value to sheet cells
GridCell cell = sheet.Cells["b2"];
cell.SetCellValue("1");
cell = sheet.Cells["c2"];
cell.SetCellValue("2");
cell = sheet.Cells["d2"];
cell.SetCellValue("3");
cell = sheet.Cells["e2"];
cell.SetCellValue("4");
// Accessing the first row of the worksheet
Aspose.Cells.GridDesktop.Data.GridRow row = sheet.Rows[1];
// Setting the height of the row
row.Height = 100;