XLSX: Work with cell rows on XLSX page
In This Topic
WebSpreadsheetEditorControlJS control allows to work (add, delete, copy, cut, paste, clear, resize, hide/show) with cell rows of XLSX worksheet in a web browser.
Cell rows can be changed using mouse/keyboard or programmatically.
Add the new cell row to an XLSX worksheet
If you want to add the new cell row to an XLSX worksheet using mouse, you should do the following steps:
- Click the right mouse button on the header of the row, where you want to insert new row, context menu will appear, select "Insert rows" menu in context menu, the new cell row will be added to the worksheet.
Here is JavaScript code that demonstrates how to add the cell row to an XLSX worksheet:
// _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
// get spreadsheet editor
var spreadsheetEditorControl = _spreadsheetDocumentEditorControl.get_SpreadsheetEditorControl();
// select the entire cell row "2"
spreadsheetEditorControl.setFocusedAndSelectedCells("2:2");
// insert new cell row before row "2"
spreadsheetEditorControl.insertRows();
Delete cell row of XLSX worksheet
If you want to delete the cell row of XLSX worksheet using mouse, you should do the following steps:
- Click the right mouse button on the header of the row, which you want to delete, context menu will appear, select "Delete rows" menu in context menu, the cell row will be deleted.
Here is JavaScript code that demonstrates how to delete the cell row of XLSX worksheet:
// _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
// get spreadsheet editor
var spreadsheetEditorControl = _spreadsheetDocumentEditorControl.get_SpreadsheetEditorControl();
// select the entire cell row "2"
spreadsheetEditorControl.setFocusedAndSelectedCells("2:2");
// delete the selected rows
spreadsheetEditorControl.removeRows();
Copy and paste the cell row of XLSX worksheet
If you want to copy and paste the cell row of XLSX worksheet using mouse, you should do the following steps:
- Click the right mouse button on the header of the row, which you want to copy, context menu will appear, select "Copy" menu in context menu, the cell row will be selected to copy.
- Click the right mouse button on the header of the row, where you want to paste copied row, context menu will appear, select "Paste" menu in context menu, the cell row will be pasted.
Here is JavaScript code that demonstrates how to copy and paste the cell row of XLSX worksheet:
// _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
// get spreadsheet editor
var spreadsheetEditorControl = _spreadsheetDocumentEditorControl.get_SpreadsheetEditorControl();
// select the entire cell row "2"
spreadsheetEditorControl.setFocusedAndSelectedCells("2:2");
// copy the selected cell row
spreadsheetEditorControl.doCopy();
// select the entire cell row "4"
spreadsheetEditorControl.setFocusedAndSelectedCells("4:4");
// copy the content of row "2" into row "4"
spreadsheetEditorControl.doPaste(false);
Cut and paste the cell row of XLSX worksheet
If you want to cut and paste the cell row of XLSX worksheet using mouse, you should do the following steps:
- Click the right mouse button on the header of the row, which you want to cut, context menu will appear, select "Cut" menu in context menu, the cell row will be selected to cut.
- Click the right mouse button on the header of the row, where you want to paste cutted row, context menu will appear, select "Paste" menu in context menu, the cell row will be pasted.
Here is JavaScript code that demonstrates how to cut and paste the cell row of XLSX worksheet:
// _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
// get spreadsheet editor
var spreadsheetEditorControl = _spreadsheetDocumentEditorControl.get_SpreadsheetEditorControl();
// select the entire cell row "2"
spreadsheetEditorControl.setFocusedAndSelectedCells("2:2");
// cut the selected cell row
spreadsheetEditorControl.doCut();
// select the entire cell row "4"
spreadsheetEditorControl.setFocusedAndSelectedCells("4:4");
// paste the content of row "2" into row "4"
spreadsheetEditorControl.doPaste(false);
Clear the content of cell row of XLSX worksheet
If you want to clear the content of the cell row of XLSX worksheet using mouse, you should do the following steps:
- Click the right mouse button on the header of the row, where you want to clear the contents, context menu will appear, select "Clear Contents" menu in context menu, contents of the cell row will be cleared.
Here is JavaScript code that demonstrates how to clear the content of cell row of XLSX worksheet:
// _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
// get spreadsheet editor
var spreadsheetEditorControl = _spreadsheetDocumentEditorControl.get_SpreadsheetEditorControl();
// select the entire cell row "2"
spreadsheetEditorControl.setFocusedAndSelectedCells("2:2");
// clear the content of selected row
spreadsheetEditorControl.clearCellsContent();
Auto fit the height of cell row of XLSX worksheet
If you want to auto fit the height of cell row of XLSX worksheet using mouse, you should do the following steps:
- Click the right mouse button on the header of the row, where you want to auto fit the height of row, context menu will appear, select "AutoFit the row height" menu in context menu, the height of cell row will be fitted automatically.
Here is JavaScript code that demonstrates how to auto fit the height of cell row of XLSX worksheet:
// _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
// get spreadsheet editor
var spreadsheetEditorControl = _spreadsheetDocumentEditorControl.get_SpreadsheetEditorControl();
// select the entire cell row "2"
spreadsheetEditorControl.setFocusedAndSelectedCells("2:2");
// autofit height of cell row
spreadsheetEditorControl.autoFitRowHeight();
Hide/show the cell row of XLSX worksheet
If you want to hide/show the cell row of XLSX worksheet using mouse, you should do the following steps:
- To hide the cell row: click the right mouse button on the header of the row, which you want to hide, context menu will appear, select "Hide Rows" menu in context menu, the cell row will be hidden.
- To show the hidden cell row: Click and drag the left mouse button over the previous and the next row headers to select them, click the right mouse button, context menu will appear, select "Show Rows" menu in context menu, the cell row will be shown.
Here is JavaScript code that demonstrates how to hide and show the cell row of XLSX worksheet:
// _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
// get spreadsheet editor
var spreadsheetEditorControl = _spreadsheetDocumentEditorControl.get_SpreadsheetEditorControl();
// select the entire cell rows "2", "3", "4", "5" and "6"
spreadsheetEditorControl.setFocusedAndSelectedCells("2:6");
// hide the selected cell rows
spreadsheetEditorControl.hideRows();
// select the entire cell rows "3" and "4"
spreadsheetEditorControl.setFocusedAndSelectedCells("3:4");
// show the selected cell rows
spreadsheetEditorControl.showRows();