Switching from SpreadsheetViewer to SpreadsheetEditor
If you are currently using the read-only SpreadsheetViewer component and want to let users edit cells, enter formulas, or rename sheets, SpreadsheetEditor is the drop-in replacement. This guide covers what changes.
Package swap
Section titled “Package swap”Replace the viewer package with the editor:
npm remove @grid-is/mondrian-reactnpm add @grid-is/editor-reactimport { SpreadsheetViewer } from "@grid-is/mondrian-react";import { SpreadsheetEditor } from "@grid-is/editor-react";Props that stay the same
Section titled “Props that stay the same”These props work identically in SpreadsheetEditor:
| Prop | Notes |
|---|---|
model | Same Model from @grid-is/apiary — Model.fromXlsx unchanged |
initialSelection | Identical |
showFormulaReferencesOnCellSelection | Identical |
onChange | Same event shape (SelectionChangeEvent | SheetChangeEvent), handlers can be reused |
Props not yet available
Section titled “Props not yet available”The following SpreadsheetViewer props have no equivalent in SpreadsheetEditor yet. Both are on the roadmap.
| Prop | Notes |
|---|---|
theme | The experimental theming API is not yet available. Remove the prop for now. |
showErrorTooltips | Not yet available. Remove the prop for now. |
Complete example
Section titled “Complete example”import { Model } from "@grid-is/apiary";import { SpreadsheetEditor } from "@grid-is/editor-react";
function App() { const [model, setModel] = useState<Model | null>(null);
// Model creation is identical to SpreadsheetViewer useEffect(() => { Model.preconditions.then(() => Model.fromXlsx(buffer, "file.xlsx").then(setModel) ); }, []);
if (!model) return null;
return ( <div style={{ width: "100vw", height: "100vh" }}> <SpreadsheetEditor model={model} /> </div> );}