Download Google Sheets file and read data using SheetJS on Node

I have a spreadsheet on Google Sheets that contains some data. I have published it publicly, so that I can download the data as an .xlsx file using a URL. What I want to do is the following in Node:

  • Download the file from the URL
  • Prepare the contents as ArrayBuffer
  • Read it using SheetJS

The following is the URL for the file: Google Sheets link.

Going by SheetJS library, I know I need to use, opts), but I can’t seem to figure out how to do it exactly. I have the following code so far:

var https = require('https');
var fs = require('fs');
var XLSX = require("xlsx");

var fileURL = ""

// Somehow use the url to read the file using, opts) and store it in a variable called workbook

var sheet1 = workbook.Sheets[workbook.SheetNames[0]]
var sheet2 = workbook.Sheets[workbook.SheetNames[1]]

How do I actually do this? I can work with a file locally perfectly fine, but with the URL approach, I’m pretty lost. Any help is appreciated!


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

In your situation, how about the following modification?

Modified script:

const request = require("request");
const XLSX = require("xlsx");

const fileURL =

request.get(fileURL, { encoding: null }, function (err, res, data) {
  if (err || res.statusCode != 200) {
  const buf = Buffer.from(data);
  const workbook =;

  var sheet1 = workbook.Sheets[workbook.SheetNames[0]];
  var sheet2 = workbook.Sheets[workbook.SheetNames[1]];
  • In this modification, the module of request is used.


When this script is run, the following result is obtained.

  { Team: 'Manchester United' },
  { Team: 'PSG' },
  { Team: 'Barcelona' },
  { Team: 'Real Madrid' },
  { Team: 'Juventus' }
  { Name: 'Ronaldo', Age: 37 },
  { Name: 'Messi', Age: 34 },
  { Name: 'Neymar', Age: 30 }

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x