Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
This topic explains how to insert new rows and columns into a worksheet using the Aspose.Cells.GridWeb API. Rows or columns can be inserted at any position in the worksheet.
To insert a row at any position in a worksheet:
| For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
| //Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()); | |
| //Inserting a new row to the worksheet before 2nd row | |
| sheet.getCells().insertRow(1); | |
To insert a column at any position in a worksheet:
| For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
| //Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()); | |
| //Inserting a new column to the worksheet before column "B" | |
| sheet.getCells().insertColumn(1); | |
This topic demonstrates how to delete rows and columns from a worksheet using the Aspose.Cells.GridWeb API. With the help of this feature, developers can take delete rows or columns at runtime.
To delete a row from your worksheet:
| For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
| //Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()); | |
| //Deleting 2nd row from the worksheet | |
| sheet.getCells().deleteRow(1); | |
To delete a column from your worksheet:
| For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
| //Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()); | |
| //Deleting 2nd column from the worksheet | |
| sheet.getCells().deleteColumn(1); | |
Sometimes cell values are wider than the cell they are in or are on several lines. Such values are not fully visible to users unless they change the height and width of rows and columns. Aspose.Cells.GridWeb fully supports setting row heights and column width. This topic discusses these features in detail with the help of examples.
To set the height of a row:
Output: the height of the 1st row has been set to 50 points

| For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
| //Accessing the cells collection of the worksheet that is currently active | |
| GridCells cells = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()).getCells(); | |
| //Setting the height of 1st row to 50 points | |
| cells.setRowHeight(0, 50); | |
To set the width of a column:
| For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
| //Accessing the cells collection of the worksheet that is currently active | |
| GridCells cells = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()).getCells(); | |
| //Setting the width of 1st column to 150 points | |
| cells.setColumnWidth(0, 150); | |
Like Microsoft Excel, Aspose.Cells.GridWeb also uses standard headers or captions for rows (numbers like 1, 2, 3 and so on) and columns (alphabetic like A, B, C and so on). Aspose.Cells.GridWeb also makes it possible to customize captions. This topic discusses customizing row and column headers at runtime using Aspose.Cells.GridWeb API.
To customize the header or caption of a row:
The headers of row 1 and 2 have been customized

| For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
| //Accessing the worksheet that is currently active | |
| GridWorksheet worksheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()); | |
| //Setting the header of 1st row to "ID" | |
| worksheet.setRowCaption(1, "ID"); | |
| //Setting the header of 2nd row to "Name" | |
| worksheet.setRowCaption(2, "Name"); | |
To customize the header or caption of a column:
The headers of column 1 and 2 have been customized

| For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
| //Accessing the worksheet that is currently active | |
| GridWorksheet worksheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()); | |
| //Setting the header of 1st column to "ID" | |
| worksheet.SetColumnCaption(0, "ID"); | |
| //Setting the header of 2nd column to "Name" | |
| worksheet.SetColumnCaption(1, "Name"); | |
This topic explains how to freeze and unfreeze rows and columns. Freezing columns or rows allows users to keep the column headings or row titles visible while they scroll to other parts of the worksheet. This feature is very helpful when working with worksheets that contain large volumes of data. When users scroll only data is scrolled down and the headings stay in place, making the date easier to read. The freeze panes feature is only supported in Internet Explorer 6.0 or above.
To freeze a specific number of rows and columns:
Rows & columns in a frozen state

| For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
| //Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()); | |
| //Freezing 4th row and 3rd column | |
| sheet.freezePanes(3, 2, 3, 2); | |
To unfreeze rows and columns:
Worksheet after being unfrozen

| For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
| //Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()); | |
| //Unfreezing rows and columns | |
| sheet.unFreezePanes(); | |
This topic discusses a few techniques for protecting cells in rows and columns from any kind of action performed by end users. Developers can implement this protection using two techniques: by making cells in rows and columns read-only, or by restricting the GridWeb’s context menu options.
GridWeb provides a context menu that end users can use to perform operations on the control. The menu provides many options for manipulating cells, rows, and columns.
Complete contextual options

It is possible to restrict any kind of client-side operations on rows and columns by restricting the options available in the context menu. It can be done by setting the EnableClientColumnOperations and EnableClientRowOperations attributes of the GridWeb control to false. It is also possible to restrict users from freezing rows and columns by setting the GridWeb control’s EnableClientFreeze attribute to false.
Context menu after restricting row & column options

| For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
| //Accessing the first worksheet that is currently active | |
| GridWorksheet sheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()); | |
| //Restricting column related operations in context menu | |
| gridweb.setEnableClientColumnOperations(false); | |
| //Restricting row related operations in context menu | |
| gridweb.setEnableClientRowOperations(false); | |
| //Restricting freeze option of context menu | |
| gridweb.setEnableClientFreeze(false); | |
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.