Migrate from Spreadsheet Viewer to Handsontable DataGrid 19.0
Verified December 3, 2026, with Handsontable DataGrid 19.0.0
This guide replaces Spreadsheet Viewer 1.0.1 with Handsontable DataGrid 19.0 in an app that opens .xlsx workbooks in the browser. You keep the same integration shape (loadWorkbook(), selectCells(), configure(), and the same DOM events) and drop the iframe.
- Applies to: Spreadsheet Viewer 1.0.1 (the
SpreadsheetViewer.zipSDK or thespreadsheet-viewernpm package), in plain JavaScript, React, Angular, or Vue. - Target:
handsontable@19.0.0(released 2026-11-26), optionallyhyperformula@4.0.0. - Verified on: 2026-12-03, Chromium (Playwright 1.65.2), Vite 8.4.1, TypeScript 7.0.2, with the
sample-file.xlsxworkbook that ships in the Spreadsheet Viewer package. The reference implementation and its 19 end-to-end tests are in the migration skill’sassets/example/folder.
Download the migration skill
Download the migration skill (ZIP, 248 KB). It’s an agent skill that carries everything this guide refers to:
assets/example/src/: the adapter (workbookViewer.ts,workbookViewer.css) and the React component.scripts/find-sv-usage.mjs: the scanner that finds every Spreadsheet Viewer call.assets/example/: the reference app the guide was verified with, and its 19 Playwright tests.references/migration-guide.md: this guide, for the agent to read.
Unzip it into your app’s .claude/skills/ folder. The paths in this guide assume it’s there. Claude Code then picks the skill up when you ask it to migrate the app.
Who needs to act
Every app that still ships Spreadsheet Viewer. It’s no longer maintained: version 1.0.1 (October 21, 2021) runs on a 2020 fork of Handsontable from before 8.0 and gets no security fixes, updates, or support, and no new licenses are sold. Source: the Spreadsheet Viewer page.
Handsontable DataGrid 19.0 covers the same job without the iframe: it reads .xlsx files in the browser with a built-in XLSX engine (the file isn’t sent to a server), shows one tab per sheet in the sheets bar, and can export back to .xlsx.
What changes
| Spreadsheet Viewer 1.0.1 | Handsontable DataGrid 19.0 | |
|---|---|---|
| Rendering | In an <iframe>, from static assets you host (assetsUrl) |
Directly in your page, from the handsontable npm package |
| Setup | SpreadsheetViewer({ container, assetsUrl }) returns a Promise (30 s timeout) |
createWorkbookViewer({ container, licenseKey }) returns the instance at once |
| Communication | window.postMessage to the iframe |
Direct method calls |
loadWorkbook() |
Returns nothing; no completion or error signal | Returns a Promise with the sheet names and what wasn’t imported |
Open .xlsx, one tab per sheet, read-only |
Yes | Yes |
Export to .xlsx, cell editing |
No | Yes |
| Live formula recalculation | No | Yes, with HyperFormula (separate license) |
| Charts, images | Rendered | Not rendered (see Known differences) |
| License key | configure({ licenseKey }), 'evaluation' worked |
licenseKey at construction; a missing or invalid key locks the grid |
| Security fixes, support | No | Yes |
Before you start
- License key. Handsontable DataGrid 19.0 removed the
non-commercial-and-evaluationkey and locks the grid with a modal when the key is missing or invalid. To evaluate, get a 45-day trial key at the pricing page. Teaching and research projects can apply for a free license through sales. A Spreadsheet Viewer key doesn’t work. - Browsers. 19.0 builds for Chrome and Edge 130, Firefox 132, and Safari and iOS 18.2 or later (per the 19.0.0 changelog). Spreadsheet Viewer also supported Internet Explorer 11; Handsontable DataGrid 19.0 doesn’t.
- TypeScript. 5.1 or later if your app uses TypeScript.
- Bundler. The adapter is a TypeScript module that imports CSS. Vite compiles
.tsfiles with no setup, and so do Angular CLI and Next.js. A webpack setup needs a TypeScript loader. An app on an old toolchain (Parcel 1, Create React App, webpack 4) is easiest to move to Vite first. A plain HTML page with no build step should also get Vite for production: the CDN option in Step 2 can’t read the key from the build environment and doesn’t include the adapter’s fixes, so use it for prototypes only. When you add Vite to an existing site, keep its URLs:base: './'if it’s served from a sub-path, workbooks inpublic/loaded throughimport.meta.env.BASE_URL, andenvDirset to the folder the key guard reads if you changeroot. - JavaScript apps. Your own code can stay JavaScript; only the adapter files are TypeScript, and the bundler compiles them. You don’t need to run
tsc. - React. The React component needs React 18 or later. Spreadsheet Viewer’s React example used React 17.
- File format.
.xlsxonly. Legacy.xls,.ods, and.csvfiles are rejected with an error.
Step 1: Find every Spreadsheet Viewer call
Run the scanner from the skill folder against your app. It has no dependencies and needs Node.js 18 or later.
node .claude/skills/spreadsheet-viewer-migration/scripts/find-sv-usage.mjs path/to/your/appIt lists each file and line under two headings:
- MUST CHANGE: code that only works with Spreadsheet Viewer, such as
clientLibraryimports,SpreadsheetViewer(...),assetsUrl, iframe query parameters, rawpostMessagecalls, and the'evaluation'key. The exit code is1while any remain. - REVIEW: calls the adapter keeps on purpose (
loadWorkbook,selectCells,configure,activeSheetChanged). Check that each call site handles thePromisethatloadWorkbook()now returns.
Add --json for machine-readable output. The scanner skips node_modules, dist, build, and hidden folders.
Step 2: Replace the packages
-
Remove Spreadsheet Viewer.
npm uninstall spreadsheet-viewerIf you copied the SDK instead, delete the
spreadsheet-viewer/folder from your static assets:client-library/, andsv/if your app hosts it. Nothing loads them after the migration. -
Install Handsontable DataGrid. Pin the exact version: plugins such as
sheetsBarandimportFileare new in 19.0, and the adapter depends on their behavior.npm install --save-exact handsontable@19.0.0Handsontable DataGrid 19.0 has no runtime dependencies. You don’t need ExcelJS for XLSX import or export.
-
Optional: install HyperFormula only if you want formulas recalculated in the browser. See Optional: editing, export, and formulas.
npm install --save-exact hyperformula@4.0.0
Without a bundler, load the full build and styles from a CDN, with the version pinned:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@19.0.0/styles/handsontable.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@19.0.0/styles/ht-theme-main.min.css" />
<script src="https://cdn.jsdelivr.net/npm/handsontable@19.0.0/dist/handsontable.full.min.js"></script>The adapter in Step 4 is an ES module written for a bundler. With the CDN build, follow Use Handsontable DataGrid without the adapter and use the global Handsontable.
Step 3: Add the license key
Read the key from your build environment, not from source code. With Vite:
# .env.local (keep it out of git)
VITE_HANDSONTABLE_LICENSE_KEY=your-license-keyconst licenseKey = import.meta.env.VITE_HANDSONTABLE_LICENSE_KEY;Warning: the key is read once
Handsontable DataGrid reads licenseKey once, when the grid is created. Passing it later, as configure({ licenseKey }) did in Spreadsheet Viewer, has no effect. Set the key in every environment, including CI, Storybook, and end-to-end tests, or the grid is locked there.
A Handsontable DataGrid key is validated offline, so it ends up in your JavaScript bundle. That’s expected. It also means:
-
The key is fixed at build time. Vite and webpack replace
import.meta.envandprocess.envvalues when they build, so a bundle built without the key stays locked, and you can’t add the key at deploy time. Set it in the build environment of every pipeline. -
Fail the production build when the key is missing, so a locked bundle never ships. With Vite:
// vite.config.ts import { defineConfig, loadEnv } from 'vite'; export default defineConfig(({ mode }) => { if (mode === 'production' && !loadEnv(mode, process.cwd()).VITE_HANDSONTABLE_LICENSE_KEY) { throw new Error('VITE_HANDSONTABLE_LICENSE_KEY is not set.'); } return {}; }); -
Add
.env.localto.gitignore, and commit a.env.examplewith the variable name and no value. -
createWorkbookViewer()throws aTypeErrorwhen the key is empty. The React component catches it and callsonError, so a missing key in development shows your error message instead of crashing the tree.
Step 4: Add the viewer module
Copy these files from .claude/skills/spreadsheet-viewer-migration/assets/example/src/ into your app.
| File | What it is |
|---|---|
workbookViewer.ts |
The adapter: createWorkbookViewer() with the Spreadsheet Viewer instance API |
workbookViewer.css |
Hides the sheet-tab menu chevron in read-only mode |
react/WorkbookViewer.tsx |
Optional React component on top of the adapter |
The adapter does the work that a plain importFile call doesn’t:
- Imports every sheet into its own tab. In 19.0,
importFilewrites into the active tab only. - Leaves out hidden and very hidden sheets, as Excel does, and keeps each tab’s name matched with its content.
- Keeps the viewer read-only: no edits, no paste, and no adding, renaming, moving, or deleting tabs.
- Rejects files that aren’t
.xlsx(by the file name you pass or the user picks, and by ZIP signature) or are larger than 50 MB, before it clears the current workbook. A download URL such as/api/files/42/downloadis accepted when its content is an.xlsxfile. - Lets the last
loadWorkbook()call win when several overlap, supportsAbortSignal, and ignores tab clicks while sheets are being imported. - Registers only the modules a viewer needs, instead of
registerAllModules(). - Works around three issues found in 19.0.0 (see Workarounds for 19.0.0 issues).
Import the Handsontable DataGrid styles once, in your app’s entry file:
import 'handsontable/styles/handsontable.min.css';
import 'handsontable/styles/ht-theme-main.min.css';Give the container a height. The grid fills it, and the sheets bar sits at its bottom.
#spreadsheet-viewer {
height: 600px; /* or flex: 1 inside a column layout */
}Adapter options
| Option | Default | Description |
|---|---|---|
container |
required | The element the grid renders into |
licenseKey |
required | Your Handsontable DataGrid key |
readOnly |
true |
false allows editing and tab changes |
importStyles |
true |
Fonts, fills, alignment, and borders from the file |
themeStylesheet |
'light' |
'light' or 'dark', as in Spreadsheet Viewer |
themeBase |
'ht-theme-main' |
'ht-theme-horizon' or 'ht-theme-classic' (import the matching CSS) |
height |
'100%' |
Grid height |
showHiddenSheets |
false |
Show sheets the file marks as hidden. Very hidden sheets never show. |
maxBytes |
52428800 (50 MB) |
Larger files are rejected |
fetchInit |
none | fetch() options for URL sources, such as credentials or headers |
gridSettings |
{} |
Extra Handsontable DataGrid settings. Hooks here run alongside the adapter’s hooks. In read-only mode, readOnly, fillHandle, and sheetsBar.controls can’t be overridden. |
Step 5: Replace the initialization
Before (Spreadsheet Viewer, plain JavaScript):
<div id="spreadsheet-viewer"></div>
<script type="module">
import { SpreadsheetViewer } from './spreadsheet-viewer/client-library/clientLibrary.js';
SpreadsheetViewer({
container: document.querySelector('#spreadsheet-viewer'),
assetsUrl: './spreadsheet-viewer/sv/index.html',
})
.then((instance) => {
instance.configure({ licenseKey: 'evaluation' });
instance.loadWorkbook('/workbooks/q3-sales.xlsx', 0);
})
.catch((error) => console.error(error.message));
</script>After (Handsontable DataGrid 19.0):
import 'handsontable/styles/handsontable.min.css';
import 'handsontable/styles/ht-theme-main.min.css';
import { createWorkbookViewer } from './workbookViewer';
const viewer = createWorkbookViewer({
container: document.querySelector<HTMLElement>('#spreadsheet-viewer')!,
licenseKey: import.meta.env.VITE_HANDSONTABLE_LICENSE_KEY,
});
try {
const { sheetNames, dropped } = await viewer.loadWorkbook('/workbooks/q3-sales.xlsx', 0);
console.info(`Opened ${sheetNames.length} sheets`, dropped);
} catch (error) {
if ((error as Error).name !== 'AbortError') {
showError((error as Error).message); // your UI
}
}What changed:
- No
assetsUrland no iframe. - No
Promisearound the factory: the instance is ready at once. - The license key moves from
configure()to the factory. loadWorkbook()returns aPromise. Handle its rejection, or the browser reports an unhandled rejection when a file fails to load.
Step 6: Update API calls and events
Methods
| Spreadsheet Viewer | Adapter | Plain Handsontable DataGrid |
|---|---|---|
SpreadsheetViewer({ container, assetsUrl }) |
createWorkbookViewer({ container, licenseKey }) |
new Handsontable(container, { importFile: true, sheetsBar: true, licenseKey }) |
loadWorkbook(url, sheet) |
await loadWorkbook(url, sheet) |
fetch(), then importFile.importFromArrayBuffer('xlsx', buffer, { sheet }) per sheet |
loadWorkbook(arrayBuffer, sheet, fileName) |
Same; fileName is still required |
importFromArrayBuffer('xlsx', buffer) |
| none | loadWorkbook(file) for a File or Blob |
importFile.importFromBlob('xlsx', file) |
selectCells([row, col, row2, col2]) |
Same | hot.selectCell(row, col, row2, col2) |
| none | setActiveSheet(index) |
sheetsBar.setActiveSheet(id) |
configure({ themeStylesheet: 'dark' }) |
Same | hot.useTheme('ht-theme-main-dark') |
configure({ licenseKey }) or configure({ license }) |
Ignored with a console warning; pass the key to createWorkbookViewer() |
licenseKey at construction |
| none | exportActiveSheet(filename?) |
exportFile.downloadFileAsync('xlsx', { filename }) |
| none | destroy() |
hot.destroy() |
| none | viewer.hot |
The Handsontable instance itself |
sheet is a 0-based index into the visible tabs, as in Spreadsheet Viewer. An index past the last tab opens the last tab.
loadWorkbook() result and errors
interface LoadedWorkbook {
fileName: string | undefined;
sheetNames: string[]; // the tabs, in workbook order
hiddenSheets: string[]; // sheets the file hides, left out
activeSheet: number;
dropped: Record<string, string[]>; // per sheet: features not imported, e.g. 'images', 'tables'
}| Rejection | When |
|---|---|
TypeError |
Bad arguments, the same checks as Spreadsheet Viewer (fileName missing for an ArrayBuffer) |
WorkbookViewerError |
Download failed (HTTP status in the message), not .xlsx, too large, unreadable file, no visible sheets, or the viewer was destroyed. The original error is in cause. |
DOMException named AbortError |
Your AbortSignal fired, a newer loadWorkbook() call replaced this one, or destroy() ran during the load. Ignore it. |
A file that fails the name, signature, or size check leaves the current workbook on screen. A file that passes those checks but fails while its sheets are imported leaves an empty grid with one blank tab, so show the error message to the user.
Events
The adapter dispatches the same CustomEvents on the container. They bubble.
| Spreadsheet Viewer event | Adapter event.detail |
Handsontable DataGrid hook |
|---|---|---|
activeSheetChanged |
{ sheet, sheetName } |
afterSheetTabChange(oldSheetId, newSheetId, source) |
cellSelectionChanged |
{ range: [row, col, row2, col2] }, never negative (header selections are clamped to 0) |
afterSelectionEnd(row, col, row2, col2) |
readyForMessages |
Not needed: the instance is ready when createWorkbookViewer() returns |
none |
viewActivated |
Not needed: focus stays in your page | afterListen |
keydown, keyup, drop, dragover, dragleave |
Not re-dispatched: the native events now bubble from the grid to your container | none |
import { ACTIVE_SHEET_CHANGED, CELL_SELECTION_CHANGED } from './workbookViewer';
container.addEventListener(ACTIVE_SHEET_CHANGED, (event) => {
const { sheet, sheetName } = (event as CustomEvent).detail;
});Check any code that read other fields from the old event.detail. Spreadsheet Viewer passed its raw iframe message there.
Step 7: Update framework components
React
Before:
useLayoutEffect(() => {
SpreadsheetViewer({ assetsUrl: '/spreadsheet-viewer/sv/index.html', container: svRef.current })
.then((instance) => {
instance.configure({ license: 'demo' });
instance.loadWorkbook('/workbooks/q3-sales.xlsx', 0);
})
.catch(console.error);
}, []);
return <div ref={svRef} />;After, with react/WorkbookViewer.tsx from Step 4:
import { WorkbookViewer } from './react/WorkbookViewer';
<WorkbookViewer
workbook="/workbooks/q3-sales.xlsx" // URL, ArrayBuffer (with fileName), or File
sheet={0}
licenseKey={import.meta.env.VITE_HANDSONTABLE_LICENSE_KEY}
height={600}
onLoad={(result) => setStatus(`${result.sheetNames.length} sheets`)}
onError={(error) => setStatus(error.message)}
onActiveSheetChange={({ sheetName }) => track(sheetName)}
/>;If your app named its own wrapper component SpreadsheetViewer (as the Spreadsheet Viewer React example did), rename it, for example to WorkbookPreview. The name still works, but it keeps old searches and code reviews pointing at a library that’s gone.
The component creates one grid per licenseKey, cancels the previous load when workbook changes, switches tabs without reloading when sheet changes, applies themeStylesheet without recreating the grid, and cleans up on unmount. It’s tested under <StrictMode>. It needs React 18 or later.
Angular
Run Handsontable DataGrid outside the Angular zone, so grid events don’t trigger change detection on every mouse move.
import { Component, ElementRef, Input, NgZone, OnChanges, OnDestroy, AfterViewInit, ViewChild } from '@angular/core';
import { createWorkbookViewer, type WorkbookViewer } from './workbookViewer';
import { environment } from '../environments/environment';
@Component({
selector: 'app-workbook-viewer',
standalone: true,
template: '<div #host style="height: 600px"></div>',
})
export class WorkbookViewerComponent implements AfterViewInit, OnChanges, OnDestroy {
@Input() workbook: string | Blob | null = null;
@Input() sheet = 0;
@ViewChild('host', { static: true }) host!: ElementRef<HTMLDivElement>;
private viewer?: WorkbookViewer;
private controller?: AbortController;
constructor(private zone: NgZone) {}
ngAfterViewInit(): void {
this.viewer = this.zone.runOutsideAngular(() => createWorkbookViewer({
container: this.host.nativeElement,
licenseKey: environment.handsontableLicenseKey,
}));
this.load();
}
ngOnChanges(): void {
this.load();
}
ngOnDestroy(): void {
this.controller?.abort();
this.viewer?.destroy();
}
private load(): void {
if (!this.viewer || !this.workbook) {
return;
}
this.controller?.abort();
this.controller = new AbortController();
const { signal } = this.controller;
this.zone.runOutsideAngular(() => this.viewer!.loadWorkbook(this.workbook!, this.sheet, undefined, { signal }))
.catch((error: Error) => {
if (error.name !== 'AbortError') {
console.error(error);
}
});
}
}Vue 3
<script setup lang="ts">
import { onBeforeUnmount, onMounted, ref, watch } from 'vue';
import { createWorkbookViewer, type WorkbookViewer } from './workbookViewer';
const props = defineProps<{ workbook: string | Blob | null; sheet?: number }>();
const emit = defineEmits<{ error: [Error] }>();
const host = ref<HTMLDivElement>();
let viewer: WorkbookViewer | undefined;
let controller: AbortController | undefined;
function load() {
if (!viewer || !props.workbook) {
return;
}
controller?.abort();
controller = new AbortController();
viewer.loadWorkbook(props.workbook, props.sheet ?? 0, undefined, { signal: controller.signal })
.catch((error: Error) => error.name !== 'AbortError' && emit('error', error));
}
onMounted(() => {
viewer = createWorkbookViewer({
container: host.value!,
licenseKey: import.meta.env.VITE_HANDSONTABLE_LICENSE_KEY,
});
load();
});
watch(() => [props.workbook, props.sheet], load);
onBeforeUnmount(() => {
controller?.abort();
viewer?.destroy();
});
</script>
<template>
<div ref="host" style="height: 600px" />
</template>Tip: test the Angular and Vue components
The Angular and Vue components above follow the same lifecycle as the tested React component, but only the React one runs in the end-to-end suite. Run the checklist in Step 10 in your app.
Step 8: Replace iframe URL integrations
Some apps skipped the client library and embedded the viewer page directly:
<iframe src="/spreadsheet-viewer/sv/index.html?workbookUrl=/workbooks/q3-sales.xlsx&sheet=0&themeStylesheet=dark&licenseKey=..."></iframe>Spreadsheet Viewer read these query parameters: workbookUrl, sheet, fileName, licenseKey, themeStylesheet, and svId. Replace the iframe with a container and pass the same values to the adapter:
const params = new URLSearchParams(location.search);
const viewer = createWorkbookViewer({
container,
licenseKey: import.meta.env.VITE_HANDSONTABLE_LICENSE_KEY,
themeStylesheet: params.get('themeStylesheet') === 'dark' ? 'dark' : 'light',
});
const url = params.get('workbookUrl');
if (url) {
await viewer.loadWorkbook(url, Number(params.get('sheet') ?? 0));
}Warning: allow only your own URLs
If you keep workbookUrl in your page’s own URL, allow only your own origins or paths. Otherwise anyone can make your page fetch a URL of their choice with your users’ cookies when you set fetchInit: { credentials: 'include' }.
If you need an isolated page that other apps embed, host a small page that runs the code above and embed that page. Talk to it with your own postMessage protocol, and check event.origin on every message. Spreadsheet Viewer posted with target origin '*'.
Step 9: Configure security and deployment
- Assets: remove the
spreadsheet-viewer/sv/folder and any server rules for it (cache headers, MIME types for.woff, rewrites). The grid is now part of your bundle: about 460 KB gzipped for the viewer in.claude/skills/spreadsheet-viewer-migration/assets/example/(Vite 8 production build,handsontablemodules only). - CORS:
loadWorkbook(url)usesfetch()from your page. A workbook on another origin needsAccess-Control-Allow-Originfor your origin. PassfetchInit: { credentials: 'include' }for cookie-authenticated downloads. - Content Security Policy: with
importStyles: true, Handsontable DataGrid adds a<style>element with the workbook’s fonts, fills, and borders. Astyle-srcpolicy without'unsafe-inline'blocks it, and the cells lose their formatting. Either allow inline styles or setimportStyles: false. The adapter itself needs nounsafe-eval. - Code splitting: Vite warns that the viewer chunk is over 500 kB. If the viewer isn’t on the first screen, load it on demand with
const { createWorkbookViewer } = await import('./workbookViewer');. - File size: the import runs on the main thread. The adapter rejects files over 50 MB (
maxBytes). Lower it for your typical workbooks, and validate size on the server too. - Parsing: Handsontable DataGrid 19.0 has no call that imports a whole workbook, so the adapter parses the file once per visible sheet (the sheet list comes from a small read of
xl/workbook.xml). Cost grows with sheets × file size: a 20-sheet, 20 MB file is parsed 20 times. The 4-sheet, 100 KB sample loaded in 0.3 s in Chromium on an Apple M4 Pro (one measurement, 2026-12-03). Measure your largest real workbook before you ship. - HTML in cells: cell values render as text. If you add custom renderers that write HTML, sanitize it: Handsontable DataGrid stopped bundling DOMPurify in 18.0.
Step 10: Test the migration
Run these checks with your own production workbooks, not only the sample.
- The grid opens without the license modal in every environment (dev, CI, staging, production).
- Every visible sheet has a tab with the right name and contents. Hidden sheets don’t show.
- The sheet passed to
loadWorkbook()opens first. - Dates, times, currencies, and percentages show as in Excel. No cell shows
#bad-value#. - Merged cells, frozen panes, hidden rows and columns, column widths, and borders match.
- Nothing can be edited, pasted, or deleted. Tabs can’t be renamed, moved, or deleted.
activeSheetChangedandcellSelectionChangedhandlers still work.- A
.xls,.csv, a renamed HTML page, and a 404 URL each show an error and keep the previous workbook. - Opening a second file while the first is loading shows only the second.
- Theme switching works, if you use
themeStylesheet: 'dark'(see Known differences). - Keyboard: Tab reaches the grid, arrow keys move the selection, and the sheet tabs are reachable.
- The scanner reports no MUST CHANGE lines.
The .claude/skills/spreadsheet-viewer-migration/assets/example/tests/viewer.spec.ts Playwright suite automates most of these against the demo pages in .claude/skills/spreadsheet-viewer-migration/assets/example/. Run it there to check the adapter on your machine, then write the same checks against your own pages: the selectors (.ht-sheets-bar__tab-label, .ht-sheets-bar__tab--active, .handsontable td) carry over, while #status, #file, and window.viewer belong to the demo. The Playwright config starts its own dev server on port 5199 and fails if the port is taken, so it never tests another app by mistake.
cd .claude/skills/spreadsheet-viewer-migration/assets/example
npm install
npx playwright install chromium
echo "VITE_HANDSONTABLE_LICENSE_KEY=your-license-key" > .env.local
npm run test:e2eOptional: editing, export, and formulas
Spreadsheet Viewer only displayed workbooks. With Handsontable DataGrid you can go further.
Editing. Create the viewer with readOnly: false. Users can then edit cells, paste, use autofill, and add, rename, move, or delete tabs. Read the result with viewer.hot.getPlugin('sheetsBar').getSheetData(sheetId).
Export. viewer.exportActiveSheet('q3-sales') downloads the active sheet as .xlsx. In 19.0, an export writes the active sheet only. To write several sheets into one file, pass several grid instances in sheets to exportFile.downloadFileAsync('xlsx', { sheets: [...] }). The synchronous exportAsBlob('xlsx') throws; use exportAsBlobAsync() or downloadFileAsync().
Formulas. Without HyperFormula, formula cells show the values Excel last saved in the file, as Spreadsheet Viewer did. To recalculate in the browser:
import { HyperFormula } from 'hyperformula';
import { registerPlugin, Formulas } from 'handsontable/plugins';
registerPlugin(Formulas);
const viewer = createWorkbookViewer({
container,
licenseKey,
gridSettings: {
formulas: { engine: HyperFormula },
},
});Warning: HyperFormula 4.0 changed its license
HyperFormula 4.0 (December 2026) moved from GPLv3 to a proprietary license. The gpl-v3 key is now invalid: formulas return #LIC!. When Handsontable DataGrid creates the engine, as above, it uses the internal-use-in-handsontable key. Confirm your Handsontable DataGrid license covers HyperFormula before you ship, or stay on cached values.
The adapter was tested without HyperFormula. Test formulas with your own workbooks if you turn them on.
Use Handsontable DataGrid without the adapter
If you don’t need Spreadsheet Viewer compatibility, the core of the adapter is short. This version imports every sheet into the sheets bar (Handsontable DataGrid 19.0, ES module build):
import Handsontable from 'handsontable';
import { registerAllModules } from 'handsontable/registry';
import 'handsontable/styles/handsontable.min.css';
import 'handsontable/styles/ht-theme-main.min.css';
registerAllModules();
const hot = new Handsontable(container, {
licenseKey,
themeName: 'ht-theme-main',
height: '100%',
rowHeaders: true,
colHeaders: true,
readOnly: true,
importFile: true,
sheetsBar: { controls: false },
});
async function openWorkbook(file: Blob) {
const importFile = hot.getPlugin('importFile');
const sheetsBar = hot.getPlugin('sheetsBar');
const buffer = await file.arrayBuffer();
// Sheet names only: a 1-cell preview that changes nothing.
const { sheetNames } = await importFile.importFromArrayBuffer('xlsx', buffer, { apply: false, range: [0, 0, 0, 0] });
hot.updateSettings({ sheetsBar: { sheets: [{ name: 'Sheet1', data: [[]] }], activeSheet: 0 } });
for (const [index, name] of sheetNames.entries()) {
if (index === 0) {
sheetsBar.renameSheet(sheetsBar.getSheets()[0].id, name);
} else {
sheetsBar.setActiveSheet(sheetsBar.addSheet(name)!.id);
}
// The import fills the active tab only. Import by name: the numeric `sheet` option skips very hidden sheets.
await importFile.importFromArrayBuffer('xlsx', buffer, { sheet: name, importStyles: true });
}
sheetsBar.setActiveSheet(sheetsBar.getSheets()[0].id);
}This snippet runs in the end-to-end suite (.claude/skills/spreadsheet-viewer-migration/assets/example/plain.html). It shows hidden sheets, still offers the tab menu, has no overlap or error handling, and doesn’t include the fixes in Workarounds for 19.0.0 issues. The adapter adds all of that.
Known differences
Measured with the Spreadsheet Viewer sample workbook. Each import reports what it left out in dropped and in one console warning per sheet. The numFmt: entries hold raw Excel format codes, so summarize them before you show them to users:
const notShown = new Set(Object.values(result.dropped).flat().map((item) => (item.startsWith('numFmt:') ? 'some number formats' : item)));| Workbook feature | Handsontable DataGrid 19.0 |
|---|---|
| Values, number formats, dates, times | Imported. A few custom Excel number formats (for example accounting formats with [$€-2]) aren’t converted and show as plain numbers; they’re listed in dropped as numFmt:.... |
| Fonts, fills, alignment, borders | Imported (importStyles: true) |
| Merged cells, frozen panes, hidden rows and columns, widths, heights | Imported |
| Comments | Imported, read-only |
| Data validation lists | Imported as dropdown cells |
| Formulas | Cached values; live with HyperFormula |
| Conditional formatting | Read but not applied (returned in the import result) |
| Charts | Not rendered. Spreadsheet Viewer rendered them. |
| Images | Not rendered (images in dropped) |
Excel tables (ListObject) |
Cell values and styles show; the table object isn’t (tables in dropped) |
| Hyperlinks | Not imported as links (hyperlink in dropped). The autoLink option can turn URL text into links. |
| Hidden sheets | Left out by the adapter; showHiddenSheets: true shows them |
| Right-to-left sheets | Create the grid with gridSettings: { layoutDirection: 'rtl' }; the import doesn’t switch direction |
Charts and images. If your users rely on charts in workbooks, Handsontable DataGrid 19.0 doesn’t replace that. Render the charts separately from the data, or keep those workbooks as downloads.
Dark theme. configure({ themeStylesheet: 'dark' }) switches the grid to ht-theme-main-dark. Colors stored in the workbook stay as they are, so black text without a fill becomes black on dark gray. For workbooks with their own colors, keep the light theme or set importStyles: false in dark mode.
Console warning. For a text cell in a date column, Handsontable DataGrid logs Source data warning (1 cell). Invalid value for "date" cell type. during the import. The adapter fixes the cell right after, and it renders as text. The warning is expected.
Fonts. Spreadsheet Viewer shipped Carlito, Caladea, and Liberation fonts as metric-compatible stand-ins for Calibri, Cambria, and Arial. Handsontable DataGrid uses your page’s fonts, so text can wrap differently than in Excel. Load those fonts in your page if column fit matters.
Workarounds for 19.0.0 issues
The adapter works around three behaviors found while building it. Each is marked in the code. Re-check them when you upgrade Handsontable DataGrid.
- Loading overlay stays on screen. With overlapping
loading.show()andloading.hide()calls around sheet switches, the Loading plugin’s dialog can stay displayed, and block clicks, whileisVisible()returnsfalse. The adapter uses its own overlay witharia-busyinstead. #bad-value#in text cells of a date column. The import types whole columns from number formats. A header such as “Last check date” above a date column getstype: 'text', but keeps the column’s datevalueFormatterand renders as#bad-value#. The adapter sets those cells to text with a pass-through formatter after the import.- The sheet-tab menu can’t be turned off. There’s no
sheetsBarsetting for it. The adapter rejects rename, move, add, and delete through thebeforeSheetTab*hooks, and in read-only mode stops the menu from opening (click, right-click, double-click, keyboard) and hides its chevron. This depends on the 19.0 class names.ht-sheets-bar__tab,.ht-sheets-bar__tab--active, and.ht-sheets-bar__tab-chevron.
Roll back
The migration doesn’t change your workbooks or any server data. To roll back, revert the commit, run npm install, and redeploy the spreadsheet-viewer/ assets. Keep the old build artifact until the new version has run in production for one release cycle.
Related
- Spreadsheet Viewer end-of-life notice
- Import from Excel
- Sheets bar
- Export to Excel
- License key
- Migrating from 18.1 to 19.0
- Handsontable DataGrid 19.0 release notes
- HyperFormula 3.x to 4.0 migration
Microsoft and Excel are trademarks of the Microsoft group of companies.
Make every data point count. Turn millions of them into actionable wisdom.
Let’s make it easier.
Smoother. Faster. All Handsontable.