How To Download All Tabs as CSV in a Zip File

About this Tutorial

Download All Tabs as CSV in a Zip File, instead of downloading each one by hand, one by one.  This apps script is super awesome to implement for those sheets you need a zip file of all the Tabs.

Video Transcript

0:00 Here's a very interesting problem and a very simple solution with Apps Script. Basically, we want to download all of the tabs in a CSV file, but when we go up to File, Download, a CSV, it's only going to download this exact tab that we're on.
0:16 It's not going to download every single CSV file. So, in order to do that, we need a little bit of Script.
0:22 Go up to Extensions, Apps Script, and I've written out all of this Script for you so far, but we're going to implement this into the sheet so it's super easy to use for a user.
0:34 So, just want to explain the Script a little bit before we implement it. We're getting the active sheet, we're getting all of the sheets, and then we're going to actually use URL Fetch App to go to the very specific URL, which is, you can add, at the end of a spreadsheet file, URL, you can add slash 
0:55 export question mark format equals CSV, and then you can combine that with the GID, which is the very specific ID of the tab.
1:05 And now what it's going to do is it's going to save each of those URLs as a CSV. CSV file, then it's going to zip it all up and save it to your Google Drive here.
1:19 And at the end it's going to give us a URL of a zip drive that's created on our Google Drive.
1:26 So let's see that in action and then implement it in our sheet. So we're just going to click run. And over on our tab, it's a zip created and we're just going to go to that URL.
1:44 And here's the two files. I can download this as a zip file, but let's make this super easy to use.
1:50 I'm going to go to bettersheets.co snippets slash snippets. And I'm going to grab this code here, which is a function on open.
1:59 I'm going to go back to my Apps Script. Go to the very top, hit enter a few times, make some space to paste this.
2:05 I don't need document app or form app. I just need spreadsheet app, custom menu. I'm going to call this download csv menu.
2:14 And the first item is, I'm going to say download all cs, all tabs as zip. And And I'm going to take the, function name and put it right here.
2:26 I'm actually going to delete the second item. We only need one item. I'm going to save it. Now, once it's saved, I'm going to close my app script.
2:35 I'm going to go back to my sheet and I'm going to refresh it, meaning I'm going to open it again.
2:38 I can close it and open it or refresh it. Once it happens up at the top next to extensions, help, now there's download csv Many new, click it.
2:49 And now I can click this and run it from the sheet itself. And there we go. We just created another zip file with all the CSV files.
2:59 They're pretty cool, right? And if you're a better member and watching this on better sheets, go down below and you can get this exact sheet and this code directly.
3:11 Download it. Enjoy it for free. If you're not watching this on better sheets, become a better sheets member today and get this code over at bettersheets.co.