Excel is JavaScript is JSON

I simultaneously love & hate Microsoft Excel. On the one hand, it’s the gold standard for spreadsheet apps, way faster than Google Docs, and gets shit done. On the other hand, I can crash it just by looking at it funny.

Where Excel falls short though, is connecting with programming languages outside of .NET. For ages, if you wanted to create, edit, or read Excel files, you had to resort to some really esoteric wizardry. But with ExcelJS, a node library by Guyon Roche, you can Excel with JavaScript.

Run the code below and check it against my sample spreadsheet:

```javascript var Excel = require(‘exceljs’);

// create workbook & add worksheet var workbook = new Excel.Workbook(); var worksheet = workbook.addWorksheet(‘Discography’);

// add column headers worksheet.columns = [ { header: ‘Album’, key: ‘album’}, { header: ‘Year’, key: ‘year’} ];

// add row using keys worksheet.addRow({album: “Taylor Swift”, year: 2006});

// add rows the dumb way worksheet.addRow([“Fearless”, 2008]);

// add an array of rows var rows = [ [“Speak Now”, 2010], {album: “Red”, year: 2012} ]; worksheet.addRows(rows);

// edit cells directly worksheet.getCell(‘A6’).value = “1989”; worksheet.getCell(‘B6’).value = 2014;

// save workbook to disk workbook.xlsx.writeFile(‘taylor_swift.xlsx’).then(function() { console.log(“saved”); }); ```

Even if it only let you write spreadsheets with JSON, ExcelJS would be incredibly useful, but it also supports formulas, hyperlinks, merged cells, streams, and more.

Now go star this repo, because—I’ve got a blank cell, baby and I’ll type your name.

Comments :)
2017 Neal Shyam