调整行和列大小
Contents
[
Hide
]
有时单元格值比它们所在的单元格宽,或者跨越了几行。除非改变行和列的高度和宽度,否则这些值对最终用户来说不是完全可见的。Aspose.Cells.GridWeb完全支持设置行高和列宽。本主题将通过示例详细讨论这些特性。
操作行高度和列宽度
设置行高度
设置行的高度:
- 将Aspose.Cells.GridWeb控件添加到您的Web表单中。
- 访问工作表的单元格集合。
- 设置任意指定行中所有单元格的高度。
Cells集合的SetRowHeight和SetColumnWidth方法还有可用于以英寸和像素设置行高和列宽度的变量。
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 | |
// Get row index entered by user | |
int rowIndex = Convert.ToInt16(txtRowIndex.Text.Trim()); | |
// Get row height entered by user | |
int rowHeight = Convert.ToInt16(txtRowHeight.Text.Trim()); | |
// Accessing the cells collection of the worksheet that is currently active | |
GridCells cells = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex].Cells; | |
// Resize row at specified index to specified height | |
cells.SetRowHeight(rowIndex, rowHeight); |
设置列宽度
要设置列的宽度:
- 将Aspose.Cells.GridWeb控件添加到您的Web表单中。
- 访问工作表的单元格集合。
- 设置任意指定列中所有单元格的宽度。
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 | |
// Get column index entered by user | |
int columnIndex = Convert.ToInt16(txtColumnIndex.Text.Trim()); | |
// Get column width entered by user | |
int columnWidth = Convert.ToInt16(txtColumnWidth.Text.Trim()); | |
// Accessing the cells collection of the worksheet that is currently active | |
GridCells cells = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex].Cells; | |
// Resize column at specified index to specified width | |
cells.SetColumnWidth(columnIndex, columnWidth); |