XLSX: Work with worksheets in XLSX document
In This Topic
WebSpreadsheetEditorControlJS control allows to view the XLSX worksheet in a web browser.
WebSpreadsheetDocumentEditorControlJS control allows to work (view, add, copy, rename, move, delete) with worksheets of XLSX document in a web browser.
Worksheets can be changed using mouse/keyboard or programmatically.
Add new worksheet to an XLSX document
If you want to add an XLSX worksheet using mouse, you should do the following steps:
Here is JavaScript code that demonstrates how to add the new worksheet to XLSX document:
// _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
// add new worksheet after focused worksheet
_spreadsheetDocumentEditorControl.addWorksheet();
Copy an existing worksheet into XLSX document
If you want to copy an existing worksheet into XLSX document using mouse, you should do the following steps:
- Click the right mouse button on worksheet name in worksheet's navigation panel, the context menu will appear, click "Copy worksheet" menu in context menu and a copy of worksheet will be added to XLSX document.
Here is JavaScript code that demonstrates how to copy an existing worksheet into XLSX document:
// _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
// create copy of focused worksheet and paste created copy after focused worksheet
_spreadsheetDocumentEditorControl.copyWorksheet();
Rename an existing worksheet of XLSX document
If you want to rename an existing worksheet of XLSX document using mouse, you should do the following steps:
- Click the right mouse button on worksheet name in worksheet's navigation panel, the context menu will appear, click "Rename worksheet" menu in context menu, dialog "Rename worksheet" will be opened.
- Change the worksheet name in the opened dialog and click "OK".
Here is JavaScript code that demonstrates how to rename an existing worksheet of XLSX document:
// _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
// rename the focused worksheet
_spreadsheetDocumentEditorControl.renameWorksheet("NewWorksheetName");
Move an existing worksheet of XLSX document
If you want to move an existing worksheet of XLSX document using mouse, you should do the following steps:
- Click the right mouse button on worksheet name in worksheet's navigation panel, the context menu will appear, click "Move worksheet" menu in context menu, dialog "Move worksheet" will be opened.
- Change the order of worksheets using "Move up" and "Move down" buttons in the opened dialog and click "OK".
Here is JavaScript code that demonstrates how to move the first worksheet to the third place in XLSX document with three worksheets:
// _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
// create and array with worksheet indexes
var newIndexes = [1, 2, 0];
// reorder the worksheets in workbook using order specified in array "newIndexes"
_spreadsheetDocumentEditorControl.moveWorksheets(newIndexes);
Delete an existing worksheet from XLSX document
If you want to delete an existing XLSX worksheet using mouse, you should do the following steps:
- Click the right mouse button on worksheet name in worksheet's navigation panel, the context menu will appear, click "Delete worksheet" menu in context menu and the worksheet will be deleted from XLSX document.
Here is JavaScript code that demonstrates how to delete an existing worksheet from XLSX document:
// _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
// remove the focused worksheet
_spreadsheetDocumentEditorControl.removeWorksheet();