Parse an excel workbook, and all its worksheets, into a single CSV file.

Usage no npm install needed!

<script type="module">
  import excelcsv from 'https://cdn.skypack.dev/excelcsv';



Parse an excel workbook (.xlsx), and all its worksheets, into a single CSV file, and transform the output.

I wrote ExcelCSV to solve this problem:

A client needed some black magic to transform a massive excel workbook, with hundreds of worksheets, into a single CSV, to eventually import the CSV into a database. Messy, I know. Unfortunately, excel does not have native support for exporting a collection of worksheets as a CSV. There are plenty of other excel parsers out there, but most of them only help you read data, when I needed to both read and transform my data.


npm install excelcsv


git clone https://github.com/Moonfuse/excelcsv.git
cd excelcsv
npm install


  • Preprocess each row
    • Transform data
    • Ignore data
  • Append a header


var ExcelCSV = require('excelcsv');

var header  = ['id', 'email']
  , fileIn  = 'src/example.xlsx'
  , fileOut = 'dist/example.csv';

// fileOut is optional.
var parser = new ExcelCSV( fileIn, fileOut );
var csv = parser
            // optional.
            .header( header )
            // optional.
            .row(function(worksheet, row) {
              // Transform data here or return false to skip the row.
              return row;



Runs the script and returns the CSV as a string.

header( Array )

[optional] Append a header to the beginning of the CSV.

row( callback(Array row, String worksheetName) )

[optional] Preprocess your data.

The callback accepts two parameters:

  • row (Array)
  • worksheetName (String)

Row values are not modified by reference, so you must return an array w/ the desired output for each row, or false to skip the row altogether.

worksheetName can be useful for adding extra data to your rows



It should be known, that there are other ways to solve this problem.

  • If your're a VB guy, you can write a excel macro and export your data as a XML file, and perhaps a CSV.
  • Excel for Windows, has functionality that allows you to attach an XML schema, map cells to said schema, and eventually export and XML file.


Feedback is most welcome; if you want to help make improvements, fork and pull, file an issue, or shoot jay@moonfuse.co an email.