You can set the row height or column width as a specified number of pixels. Each sheet uses and lets you set a default size, making all rows or columns in the sheet the same size. You can override that setting by setting the value for individual rows or columns.
Users can change the row height or column width by dragging the header lines between rows or columns.
For more details refer to the Column.Width method or Row.Height method. For more information, kindly refer to "Allowing the User to Resize Rows or Columns".
Get a collection of rows and columns in the Rows and Columns property of the SheetView class, and specify the target row and column by index. The row height is set by the Height property of the Row class, and the column width is set by the Width property of the Column class.
This example code sets the second column’s width to 100 pixels.
C# |
Copy Code
|
---|---|
// Set second column width to 100.
fpSpread1.Sheets[0].Columns[1].Width = 100;
|
VB |
Copy Code
|
---|---|
' Set second column width to 100.
fpSpread1.Sheets(0).Columns(1).Width = 100
|
Note: When the Column.Width or Row.Height methods are set to zero, the row height and column width are set to zero and they appear as hidden.
You can also set the row height and column width to zero to hide the rows and columns by using RowHeight and ColumnWidth properties. However, in this case, the originally set row height or column width is retained when they are re-displayed. The below example code explains this scenario. You can also use the Axis model to change the width and height which is restored on being re-displayed.
C# |
Copy Code
|
---|---|
GrapeCity.Spreadsheet.IWorksheet sheet1 = fpSpread1.AsWorkbook().ActiveSheet; sheet1.Rows[5].RowHeight = 50; // Initial row height is set to 50 sheet1.Rows[5].RowHeight = 0; // The row is now hidden, the row height is still 50 internally sheet1.Rows[5].Hidden = false; // The row is visible and the row height is 50 sheet1.Rows[5].Hidden = true; // The row height is still 50 internally fpSpread1.ActiveSheet.Models.RowAxis.SetSize(5, 100); // Use AxisModel to change row height sheet1.Rows[5].Hidden = false; // The row height is 100 |
VB |
Copy Code
|
---|---|
GrapeCity.Spreadsheet.IWorksheet sheet1 = fpSpread1.AsWorkbook().ActiveSheet sheet1.Rows(5).RowHeight = 50 'Initial row height is set to 50 sheet1.Rows(5).RowHeight = 0 'The row is now hidden, the row height is still 50 internally sheet1.Rows(5).Hidden = false 'The row is visible and the row height is 50 sheet1.Rows(5).Hidden = true 'The row height is still 50 internally fpSpread1.ActiveSheet.Models.RowAxis.SetSize(5, 100) 'Use AxisModel to change row height sheet1.Rows(5).Hidden = false 'The row height is 100 |