In SpreadJS, each sheet area has several rows and columns. SpreadJS provides methods for you to customize the rows and columns.
Use the addRows, addColumns, deleteRows, deleteColumns, setRowCount and setColumnCount methods to change the number of rows or columns in each sheet area.
When calling the setRowCount and setColumnCount methods, you can choose which used range type to protect.
sheet.setRowCount(20, GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.UsedRangeType.data);
sheet.setColumnCount(20, GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.UsedRangeType.style);
Each of the following lines could be used to change the row count of the sheet's viewport area.
sheet.setRowCount(20, GC.Spread.Sheets.SheetArea.viewport);
sheet.addRows(5, 10, GC.Spread.Sheets.SheetArea.viewport);
sheet.deleteRows(20, 10, GC.Spread.Sheets.SheetArea.viewport);
If a row or column's resizeable property is false, it cannot be resized by user operations, but you can change its height or width directly by using code.
sheet.setRowResizable(1, false);
sheet.setColumnResizable(1, true);
sheet.setRowHeight(1, 20);
sheet.setColumnWidth(1, 40);
Use the setRowVisible and setColumnVisible methods to specify whether a row or column is displayed.
sheet.setRowVisible(1, false);
sheet.setColumnVisible(1, true);
In the sheet's viewport area, when a row or column is automatically sized, its height or width will be determined by the content's length. Use the following code to set a row or column to auto fit:
sheet.autoFitColumn(1);
sheet.autoFitRow(1);
SpreadJS also provides many methods to get useful information about a sheet's row or column, as illustrated in these lines of code.
var rowCount = sheet.getRowCount();
var columnCount = sheet.getColumnCount();
var cell = sheet.getCell(7, 7);
var cells = sheet.getRange(2, 2, 7, 7);
var rowHeight = sheet.getRowHeight(7);
var columnWidth = sheet.getColumnWidth(7);
...
SpreadJS provides the resizeZeroIndicator method to control whether to display double or single gridlines in the row or column header when the row height or column width is 0. The parameter is a ResizeZeroIndicator enumeration value.
sheet.setRowHeight(4, 0);
sheet.setColumnWidth(2, 0);
spread.resizeZeroIndicator(GC.Spread.Sheets.ResizeZeroIndicator.enhanced);
// spread.resizeZeroIndicator(GC.Spread.Sheets.ResizeZeroIndicator.default);
Submit and view feedback for