设置列宽或行高
Contents
[
Hide
]
本主题讨论了使用Aspose.Cells.GridDesktop API设置列宽和行高。有时,工作表单元格中包含的值比原始单元格宽。这使得用户难以阅读单元格内容。一些用户不喜欢使用右箭头键查看单元格中的完整值。为解决此类问题,开发人员可以更改列宽。更改行高可以解决类似问题。
如何设置列宽
使用Aspose.Cells.GridDesktop设置列宽:
- 访问工作表。
- 访问要更改宽度的列。
- 设置列宽。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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设置行高,请按照以下步骤进行:
- 访问任何所需的工作表。
- 访问要更改高度的行。
- 设置行高。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |