Andre J
Andre J

Reputation: 227

How to unzip a blob (xlsx file) with google scripts

I am trying to get the contents of a xlsx file with Google Script.

Step 1 is to get a blob and unzip it.

Here is my code :

var file = DocsList.getFileById(docId);
var b1 = file.getBlob().setContentType('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
var b2 = Utilities.unzip(b1)[0];

But I keep getting an "Invalid Argument" error on the last line.

Am I doing something wrong?

Upvotes: 3

Views: 1304

Answers (1)

Corey G
Corey G

Reputation: 7858

Set the content type to application/zip - the unzip method won't accept anything else.

Upvotes: 3

Related Questions