Skip to content

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.

Replace the viewer package with the editor:

npm remove @grid-is/mondrian-react
npm add @grid-is/editor-react
import { SpreadsheetViewer } from "@grid-is/mondrian-react";
import { SpreadsheetEditor } from "@grid-is/editor-react";

These props work identically in SpreadsheetEditor:

PropNotes
modelSame Model from @grid-is/apiaryModel.fromXlsx unchanged
initialSelectionIdentical
showFormulaReferencesOnCellSelectionIdentical
onChangeSame event shape (SelectionChangeEvent | SheetChangeEvent), handlers can be reused

The following SpreadsheetViewer props have no equivalent in SpreadsheetEditor yet. Both are on the roadmap.

PropNotes
themeThe experimental theming API is not yet available. Remove the prop for now.
showErrorTooltipsNot yet available. Remove the prop for now.
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>
);
}