A user uploads an .xlsx and you want to show it. Not convert it, not edit it: just show it, the way Excel would.
The usual answer is SheetJS. It reads data very well, but its free edition renders plain, unstyled HTML, the full build is 328 KB gzipped, and on a 50,000-row workbook it blocks the main thread for about a second. Your users see a frozen tab and then a grey table that looks nothing like the file they uploaded.
I wanted a viewer, not a converter. So I built EatSheet.
What EatSheet is
EatSheet is a 27 KB (gzipped), zero-dependency library that opens XLSX, CSV and TSV files and renders them as styled HTML tables. Parsing runs in a Web Worker, so the page never freezes, and on a 50,000-row workbook the first rows show up in about 140 ms.
It keeps what makes a spreadsheet readable:
- fonts, fills, borders, alignment and wrapping
- merged cells, hidden rows and columns, widths and heights
- Excel number formats: currency, dates, percentages, fractions, conditional sections like
[>100] - conditional formatting: comparisons, text rules, duplicates, top/bottom, colour scales
- common formulas, recalculated on open (
SUM,IF,ROUNDand about 20 more)
It is read-only on purpose. It does not write files or open .xls, .xlsb or .ods.
| 50,000-row workbook | EatSheet | SheetJS 0.20.3 |
|---|---|---|
| Open in Node | 128 ms | 546 ms |
| Memory | 16 MB | 85 MB |
| First view in the browser | 131 ms | 1,142 ms |
| Longest page freeze | none | 1,141 ms |
| Bundle (gzipped) | 27 KB | 328 KB |
Medians of 7 runs on a plain-text workbook. Times vary by machine, so compare the ratios. The method is on the benchmarks page.
A complete viewer in 8 lines
npm install eatsheet
import { openWorkbook } from 'eatsheet/worker';
import 'eatsheet/eatsheet.css';
const container = document.querySelector('#sheet'); // fixed height, overflow: auto
const book = await openWorkbook(fileOrUrl); // File, Blob, URL, Response or ArrayBuffer
const draw = async () => (container.innerHTML = (await book.render(0, { offset: container.scrollTop })).html);
container.addEventListener('scroll', () => requestAnimationFrame(draw));
await draw();
That's the whole thing. render() returns only the rows in view, plus spacer rows that keep the scrollbar honest. Pass another index to switch sheets, and call book.close() when you're done.
If you want the data rather than HTML, read the workbook directly:
import { read } from 'eatsheet';
const book = await read(file);
const sheet = book.sheet('Summary') ?? book.sheets[0];
sheet.cell('B2'); // { type, value, style, formula?, cached?, status? }
It works with Vite and webpack 5 without configuration, in Chrome 103+, Firefox 113+ and Safari 16.4+, and in Node.js 20.12+. There are guides for React, Vue, Svelte, Angular, Next.js and Electron.
Under the hood
Everything heavy happens in a Web Worker. The main thread only sends the file in and puts HTML on the page.
-
No dependencies, including for zip. An .xlsx is a zip of XML files. EatSheet reads the zip itself and inflates each part with the browser's native
DecompressionStream('deflate-raw'), so there's no bundled inflate code. -
Cells live in typed arrays. Row, column, type, value and style each sit in a flat
Uint32ArrayorFloat64Array. Only formula cells get an object. That's why a 50,000-row workbook takes 16 MB instead of 85 MB. - Sheets are lazy. Shared parts (styles, strings) are read up front, and each worksheet is parsed and calculated the first time you touch it.
-
Only the window is rendered.
render()builds HTML for the rows in view, and two spacer rows fill the rest of the height so the scrollbar is the right size. Scrolling just asks the worker for a new window.
What Excel taught me
The hard part wasn't parsing. It was matching Excel. I saved formula and number-format results from real Excel (16 for Mac) into a test workbook and compared EatSheet against them. That check found plenty I'd got wrong.
Excel cheats near zero, but only sometimes. In JavaScript, 0.1 + 0.2 - 0.3 is 5.55e-17. In Excel, =0.1+0.2-0.3 is exactly 0: when the final addition or subtraction differs from zero only by binary rounding, Excel snaps it. But =(0.1+0.2-0.3)+0 is not zero, because the last operation no longer cancels anything.
Excel thinks in 15 digits. Numbers are rounded to 15 significant digits before display and before functions like ROUND and INT see them. The General format shows at most 11 characters and switches to scientific notation for very large or small values.
Some answers depend on where you are. Turning text like a date or a currency amount into a number depends on the machine's locale. EatSheet can't know that, so instead of guessing it shows the result Excel saved in the file and marks the cell as such. Same for any formula it doesn't support: you get the saved value, never a wrong one.
Real files are messier than the spec. Running EatSheet against about 1,500 public workbooks from the test suites of Apache POI, LibreOffice, ClosedXML, EPPlus, ExcelJS and calamine turned up ZIP64 archives, backslashes and odd casing in part names, shared-string cells with no value, sheets without relationship ids and unescaped sheet names. Each now has its own fixture.
Uploads are hostile until proven otherwise. A spreadsheet is a zip of XML, which means zip bombs and XML entity tricks. EatSheet caps unzipped size, refuses XML entities, limits sheets, styles, merges and rendered text, and escapes every cell. Links only work for http, https and mailto, so a javascript: link stays plain text.
Try it, then try to break it
Next on the roadmap: image and chart previews, wider number-format and conditional-formatting coverage, a ready-made viewer component and print layout. Writing XLSX comes later.
- Drop your own file into the live demo. It's parsed in your browser and nothing is uploaded.
- Install it:
npm install eatsheet(Apache-2.0, TypeScript types included). - Coming from SheetJS? There's a migration guide.
I'd really like to see it fail on your worst workbook. I'm paying $10 per qualifying bug (security issues, crashes or wrong data) until a $100 pool runs out. The rules are on the bounty page.
If you've fought with showing spreadsheets in a web app, I'd love to hear what broke for you in the comments.

Top comments (0)