Excel (XLSX)
Show Excel workbooks (XLSX, XLSM, XLTX) in React with sheet tabs, formatting, merges, frozen panes, charts, comments and conditional formatting. Windowed for 100,000-row sheets.
Workbooks are read by our own parser and drawn as an accessible grid that looks and moves like Excel.
File types: .xlsx, .xlsm (macros are never run), .xltx. Password-protected workbooks open after the reader enters the password.
Supported
- Sheets: sheet tabs, chart sheets, hidden sheets, column widths and row heights, frozen panes.
- Cells: number formats (dates, currency, percentages, custom codes), fonts, fills, borders, alignment, rich text, merges, links. Numbers too wide for a column shorten or show
####, as in Excel. - Formulas: shown in the formula bar with their saved results.
- Conditional formatting: highlight rules (values, text, blanks, errors, duplicates, top and bottom, above average, dates, formulas through a built-in evaluator), colour scales, data bars and every icon set.
- Objects: charts, pictures, shapes and text boxes on sheets.
- Comments: notes and threaded comments, with a corner marker and a card on hover, click or keyboard focus.
- Interaction: select by dragging, Shift+click, row and column headers or the keyboard; Ctrl+Arrow jumps to the edge of the data; drag a column or row edge to resize, double-click to fit. Copy pastes into Excel and Google Sheets as cells.
Large workbooks
Sheets over 2,000 rows are windowed: rows are drawn in blocks near the view, frozen rows stay put, and keyboard, search and copy still cover the whole sheet. Parsing streams the sheet's XML instead of building a tree, which in our tests kept a 100,000-row workbook under 200 MB of browser memory, against over 500 MB before.
Controller
In a workbook, a "page" is a sheet.
| State | For a workbook |
|---|---|
pageKind, page, pageCount | 'sheet', the active sheet (1-based among visible sheets), and the number of visible sheets. Chart sheets count. |
goTo(n), next(), prev() | Switch sheet, like clicking its tab. |
zoom, scale | Number zooms scale the grid only; the formula bar and sheet tabs keep their size. Fit modes do not apply (can.fit is false). |
rotation | Not supported. |
outline, thumbnails | None (can.sidebar is false). Sheet tabs are drawn inside the surface. |
search.count | Matches in the active sheet's cells, including rows not drawn yet in large sheets. |
can | zoom, search, print, download. |
Things to know:
- Sheet names appear on the tabs inside the surface; the controller gives you the index and count, so your own sheet switcher can label them "Sheet 2 of 3".
- Cell selection, copying, Ctrl+Arrow and column resizing are handled inside the grid.
print()prints the active sheet, scaled to the page width.
Headless
A workbook viewer with sheet navigation, a zoom menu, search and printing:
'use client';
// A workbook viewer. For spreadsheets a "page" is a sheet: pageCount is the number of visible
// sheets and goTo(n) switches sheet. The grid, formula bar and sheet tabs are part of the surface.
import { useState } from 'react';
import { DocumentSurface, useDocViewer, useDocumentSearch, type DocSource } from '@openpreview/react';
import '@openpreview/react/styles.css';
export default function WorkbookViewer({ source }: { source: DocSource }) {
const viewer = useDocViewer({ source });
const [query, setQuery] = useState('');
const results = useDocumentSearch(viewer, query);
return (
<div className="flex h-full flex-col text-sm">
<header className="flex flex-wrap items-center gap-3 border-b p-2">
<span>
Sheet {viewer.page ?? '–'} of {viewer.pageCount}
</span>
<button onClick={viewer.prev} disabled={(viewer.page ?? 1) <= 1}>Previous sheet</button>
<button onClick={viewer.next} disabled={(viewer.page ?? 1) >= viewer.pageCount}>Next sheet</button>
<select aria-label="Zoom" value={viewer.scale} onChange={(e) => viewer.setZoom(Number(e.target.value))}>
{[0.5, 0.75, 1, 1.25, 1.5, 2].map((z) => (
<option key={z} value={z}>{z * 100}%</option>
))}
</select>
{/* Search covers every cell of every row, including rows not drawn yet in large sheets. */}
<input className="rounded border px-2" placeholder="Find in sheet" value={query} onChange={(e) => setQuery(e.target.value)} />
{query && (
<span>
{results.count ? `${results.current + 1} / ${results.count}` : 'Not found'} <button onClick={results.next}>Next</button>
</span>
)}
<button className="ml-auto" onClick={() => void viewer.print()}>Print sheet</button>
<button onClick={viewer.download}>Download</button>
</header>
<DocumentSurface viewer={viewer} className="min-h-0 flex-1" />
</div>
);
}Not yet
- Recalculating formulas. Cells show the values Excel saved.
- Office 2016 chart types (waterfall, funnel, treemap and similar).
- Legacy
.xlsand binary.xlsbfiles.
Word (DOCX)
Show Word documents (DOCX, DOCM, DOTX) in React with real page layout, styles, tables, headers, footers, footnotes, comments and charts, entirely in the browser.
PowerPoint (PPTX)
Show PowerPoint decks (PPTX, PPTM, PPSX, POTX) in React with masters, layouts, all 187 preset shapes, tables, charts, speaker notes, media and a full-screen presenter.