Reputation: 1303
I have a spreadsheet names 'spreadsheet' and it has three sheets named 'a','b', and 'c' respectively. I currently published this spreadsheet with this url format
<!-- This script uses the super simple Dropbox Drop-In API -->
<script type="text/javascript" src="https://www.dropbox.com/static/api/2/dropins.js" id="dropboxjs" data-app-key="ex4mpl3K3y"></script>
<!-- This anchor establishes the dropbox button which determines the file to download to your dropbox folder. -->
<a href="https://docs.google.com/a/account/spreadsheets/d/r4Nd0MSpR34d5h33t/export?format=csv&id=r4Nd0MSpR34d5h33t" data-filename="file-name.csv" class="dropbox-saver"></a>
This url format allows anyone to download a csv version of the file, but it downloads sheets a,b, and c. How would I modify this url to download only sheet b or sheet c?
Upvotes: 1
Views: 1571
Reputation: 1303
docs.google.com || 127.0.0.1 || localhost || googleusercontent.com
<script type="text/javascript" src="https://www.dropbox.com/static/api/2/dropins.js" id="dropboxjs" data-app-key="YOURAPPKEYRECEIVEDFROMAPICONSOLE"></script>
Tools
> Script Editor
. This will open a new window where you will see an empty javascript file called code.gs
code.js
sheetId
is the random series of characters that follow the /d/ in the url. The gid
can by found by going to the publish sheet to the web
option and selecting a specific sheet to publish, copying the url given, and finding the value inside the http query parameter labeled &gid=
The code you will see is a very simple script that adds a menu option to your spreadsheet
function onOpen() {
var menuItems = [
{name: 'Dropbox', functionName: 'dropbox'}
];
SpreadsheetApp.getActive().addMenu('The Make Life Easy Button', menuItems);
}
function dropbox(){
var dropboxKey = 'string';
var sheetid = 'string';
var gid = 'string';
var fileName = 'string';
var testResults = '<script type="text/javascript" src="https://www.dropbox.com/static/api/2/dropins.js" id="dropboxjs" data-app-key="'+ dropboxKey +'"></script>';
testResults += '<h2>Store Content Sheet</h2><a href="https://docs.google.com/a/' + account + '/spreadsheets/d/' + sheetid + '/pub?gid=' + gid + '&single=true&output=csv" data-filename="' + fileName + '" class="dropbox-saver"></a>';
// Show a dialog with the test results.
var htmlApp = HtmlService
.createHtmlOutput(testResults)
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setTitle('Test Results')
.setWidth(600)
.setHeight(400);
SpreadsheetApp.getActiveSpreadsheet().show(htmlApp);
}
You will need to give permission to both google script and dropbox.
Please make sure to leave comments on any steps that need further clarification, and I will make sure to fill in the gaps. If content is out-of-date, leaving comments on updated material would be very much appreciated.
Upvotes: 1