Spreadsheet Editor Edit mode allows users to modify and interact with spreadsheets using familiar grid-based, Excel-like interactions. Users can interact with cells, including:
Cell Formatting: Modify text size and color, fonts, border styles, cell colors, border colors, and text styling for bold, italic, underline, and strikethrough.
Formula and Function Support: Execute standard mathematical operations, statistical calculations, date/time functions, and other common formulas.
Dynamic Data Manipulation: Easily add, edit, and delete rows and columns. Seamlessly cut, copy, and paste data.
Cell Adjustments: Merge cells and preserve formatting.
File Support: Open and export files in .xlsx format.
Edit mode is ideal for tasks like data entry, adjusting cell styles, and organizing sheet content.
Users can click the dropdown on the Mode flyout in the upper right corner of the Spreadsheet Editor UI to switch between Viewing and Editing mode.
A workbook is the top-level container for all spreadsheet data. It includes multiple sheets and supports operations such as creating, removing, or switching sheets. Users can interact with the workbook through the UI or programmatically using the Workbook API. The workbook instance can be retrieved with the following sample:
Sheets are tabbed pages within a workbook, each with its own grid of cells, or rows of cells. They help organize data into separate sections, like months, categories, or teams. Only the active sheet is visible and editable at a time. Sheets can also be managed programmatically for dynamic workflows. A sheet instance can be retrieved from a workbook instance using the Workbook.getSheet or Workbook.getSheetAt APIs:
9// Removes 5 rows and columns starting from the top-left of a sheet.
10sheet.removeRows(startIndex, count);
11sheet.removeColumns(startIndex, count);
Cells
Cells are the basic building blocks of a spreadsheet, used to enter data, text, or formulas. Each is identified by its row and column (e.g., B2) and can be styled, merged, or formatted. Users can edit cells directly through the formula bar, or, programmatically via API.
Access a single cell
The following code sample shows how to access a cell programmatically using the Sheet APIs and alternative Row APIs:
The following code sample shows how to set the value of cell using different types of values, including strings, booleans, numbers, and dates. See the Cell class documentation for a detailed look at the available APIs.
The following code sample shows how to apply various styles to the actively selected cells using the SpreadsheetEditorManager.setSelectedCellsStyle API:
The formula bar is where users can view and edit the contents of active cells. It serves as a single-line input field that supports both plain values and formulas (e.g., =A1+B1). When a cell is selected, its content automatically appears in the formula bar for quick inspection or modification.
Set a cell formula
The following code sample shows how to programmatically set a formula on a specific cell using the Cell.setFormula API:
The following events can be used for various formula bar functionality, including selection changes, text changes, retrieving formula lists, and fetching formula information.
formulaSearchEvent
The formulaSearchEvent event fires when a user types in the formula bar before confirming a formula. The editor returns a list of formulas that closely match the search query. The following code sample shows how to listen to the search event and logs out an array of results:
The formulaHelpEvent event fires when the selection of a formula is confirmed and returns formula name, description, and parameter information. The following code sample shows how to listen to the help event and logs out the available formula information using the getFormulaInfo event function:
The formulaBarTextChangedEvent event fires when the formula bar text input changes. The following code shows how to listen to the text changed event and logs out each segment of the formula bar using the getInfo event function: