<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Thiago Zanluca</title>
    <description>The latest articles on DEV Community by Thiago Zanluca (@thiago_zanluca_25d94a7637).</description>
    <link>https://dev.to/thiago_zanluca_25d94a7637</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2348597%2Fe82f703d-0cb7-4222-bedd-15b7bc2d90f4.jpg</url>
      <title>DEV Community: Thiago Zanluca</title>
      <link>https://dev.to/thiago_zanluca_25d94a7637</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thiago_zanluca_25d94a7637"/>
    <language>en</language>
    <item>
      <title>I needed to read an old .xls file in Node and it was harder than it should be</title>
      <dc:creator>Thiago Zanluca</dc:creator>
      <pubDate>Mon, 06 Jul 2026 17:23:42 +0000</pubDate>
      <link>https://dev.to/thiago_zanluca_25d94a7637/i-needed-to-read-an-old-xls-file-in-node-and-it-was-harder-than-it-should-be-2bg7</link>
      <guid>https://dev.to/thiago_zanluca_25d94a7637/i-needed-to-read-an-old-xls-file-in-node-and-it-was-harder-than-it-should-be-2bg7</guid>
      <description>&lt;p&gt;A few weeks ago I had a boring task: read some old &lt;code&gt;.xls&lt;/code&gt; files (the Excel 97–2003 kind) and pull the numbers out. I figured this was a solved problem in 2026. It wasn't, quite.&lt;/p&gt;

&lt;p&gt;ExcelJS, which most people reach for, only reads &lt;code&gt;.xlsx&lt;/code&gt;. The old &lt;code&gt;.xls&lt;/code&gt; binary format isn't in scope. Fair enough.&lt;/p&gt;

&lt;p&gt;So I went for SheetJS, the library everyone points to for &lt;code&gt;.xls&lt;/code&gt;. That's when I hit the real surprise: it's not on npm anymore. The last version on the registry is &lt;code&gt;0.18.5&lt;/code&gt;, it's frozen, and it has known advisories. The fixed builds live on their own CDN. Installing from a CDN is fine until you realize &lt;code&gt;npm audit&lt;/code&gt; and Dependabot can't see it, so you quietly lose your vulnerability alerts for a library that parses untrusted binary files. That felt wrong for something going into a work project.&lt;/p&gt;

&lt;p&gt;I looked around for a small, npm-published option that just reads the cells outof an &lt;code&gt;.xls&lt;/code&gt;. Didn't find one I was happy with. So I wrote it.&lt;/p&gt;

&lt;p&gt;It's called &lt;code&gt;xls-reader&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;xls-reader

import &lt;span class="o"&gt;{&lt;/span&gt; readFile &lt;span class="o"&gt;}&lt;/span&gt; from &lt;span class="s2"&gt;"node:fs/promises"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
import &lt;span class="o"&gt;{&lt;/span&gt; readXls &lt;span class="o"&gt;}&lt;/span&gt; from &lt;span class="s2"&gt;"xls-reader"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

const workbook &lt;span class="o"&gt;=&lt;/span&gt; readXls&lt;span class="o"&gt;(&lt;/span&gt;await readFile&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"report.xls"&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;const sheet of workbook.sheets&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;const row of sheet.rows&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    console.log&lt;span class="o"&gt;(&lt;/span&gt;row&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; // &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"BANCO X S/A"&lt;/span&gt;, 1.1, 2024-04-02T00:00:00.000Z, ...]
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cells come back already typed: strings, numbers, booleans, and dates as real Date objects. Blank and error cells are null.&lt;/p&gt;

&lt;p&gt;If you need the rows as objects, using the header row as keys:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;import &lt;span class="o"&gt;{&lt;/span&gt; readFirstSheet &lt;span class="o"&gt;}&lt;/span&gt; from &lt;span class="s2"&gt;"xls-reader"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

const sheet &lt;span class="o"&gt;=&lt;/span&gt; readFirstSheet&lt;span class="o"&gt;(&lt;/span&gt;bytes&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
const &lt;span class="o"&gt;[&lt;/span&gt;header &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;[]&lt;/span&gt;, ...body] &lt;span class="o"&gt;=&lt;/span&gt; sheet?.rows ?? &lt;span class="o"&gt;[]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

const json &lt;span class="o"&gt;=&lt;/span&gt; body.map&lt;span class="o"&gt;((&lt;/span&gt;row&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
  Object.fromEntries&lt;span class="o"&gt;(&lt;/span&gt;header.map&lt;span class="o"&gt;((&lt;/span&gt;key, i&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;String&lt;span class="o"&gt;(&lt;/span&gt;key&lt;span class="o"&gt;)&lt;/span&gt;, row[i] ?? null]&lt;span class="o"&gt;))&lt;/span&gt;,
&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few things I cared about while building it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No runtime dependencies. It's about 4 KB min+gzip. It only uses
Uint8Array and DataView, so it also runs in the browser (handy for a file ).&lt;/li&gt;
&lt;li&gt;Published to npm with provenance. You can verify the build came from the repo's CI with npm audit signatures. This was the whole point for me.&lt;/li&gt;
&lt;li&gt;TypeScript, dual ESM/CJS.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I want to be honest about what it does not do, because it's narrow on purpose: it's read-only, it reads values (not styles, charts, or merged-cell layout), and it only handles BIFF8. If you need to write files or read .xlsx, ExcelJS or SheetJS are still the right call.&lt;/p&gt;

&lt;p&gt;If you've got an old .xls sitting around that it can't read, I'd genuinely like to know. A small sample file on the issues page helps a lot.&lt;/p&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/zanlucathiago/xls-reader" rel="noopener noreferrer"&gt;https://github.com/zanlucathiago/xls-reader&lt;/a&gt;&lt;br&gt;
npm: &lt;a href="https://www.npmjs.com/package/xls-reader" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/xls-reader&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>typescript</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
