Add a button to automatically download a google sheet to excel from a google application scriptDownload “automatically” spreadsheet as .xlsx to local machine on eventGoogle Sheet script set cell valueReplicate with Google Script the behaviour of “File” > “Download as…” in Google SpreadsheetExport (or print) with a google script new version of google spreadsheets to pdf file, using pdf optionsGoogle Form Autosubmit using URLFetchApp attempting to authenticateHow to convert a Google Docs-File to an Excel-File (XLSX)How to add a button in Google Sheets that Automatically Adds Columns and formulasScript for a button in google sheetsSave Excel file from external URL in gmail message using Apps scriptAutomatically export Google Sheet to ExcelAdding button that adds custom sheet in Google Sheets

What factors could lead to bishops establishing monastic armies?

How does one acquire an undead eyeball encased in a gem?

Would a carnivorous diet be able to support a giant worm?

How was the Shuttle loaded and unloaded from its carrier aircraft?

Performance issue in code for reading line and testing for palindrome

How does the Melf's Minute Meteors spell interact with the Evocation wizard's Sculpt Spells feature?

Distinguish the explanations of Galadriel's test in LotR

VHF 50 Ω Antenna Over 75 Ω TV Coax

Hail hit my roof. Do I need to replace it?

Moving millions of files to a different directory with specfic name patterns

Did the Ottoman empire suppress the printing press?

How insert vertex in face?

Need a non-volatile memory IC with near unlimited read/write operations capability

Is it better in terms of durability to remove card+battery or to connect to charger/computer via USB-C?

Is there a method for differentiating informative comments from commented out code?

What happens to unproductive professors?

Adjust the Table

Generalized Behrend version for Grothendieck-Lefschetz trace formula

What was this character's plan?

Why does the Antonov AN-225 not have any winglets?

Reducing the cost of the trip from the Sydney Airport (SYD) to CBD

What minifigure is this?

Reference request: quantifier elimination test

Are all diatonic chords in the diminished scale diminished?



Add a button to automatically download a google sheet to excel from a google application script


Download “automatically” spreadsheet as .xlsx to local machine on eventGoogle Sheet script set cell valueReplicate with Google Script the behaviour of “File” > “Download as…” in Google SpreadsheetExport (or print) with a google script new version of google spreadsheets to pdf file, using pdf optionsGoogle Form Autosubmit using URLFetchApp attempting to authenticateHow to convert a Google Docs-File to an Excel-File (XLSX)How to add a button in Google Sheets that Automatically Adds Columns and formulasScript for a button in google sheetsSave Excel file from external URL in gmail message using Apps scriptAutomatically export Google Sheet to ExcelAdding button that adds custom sheet in Google Sheets






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have an application made on google than handdle different sheets on a google workbook. I need to add a button to allow users download some of these sheets but in an excel format if is possible. I took one code from StackOv and try to modify it, as i don´t want it name the file and save it in drive, i only need it download as same that when from excel it is download in Book1 ("libro1") without saving anywhere. THK!



var ss = SpreadsheetApp.openById("fffffffffffffffffffffffffffff...myID");
var sheetId = ss.ss.getSheetByName('nameSheetNeedToDownload');
var url = "https://docs.google.com/spreadsheets/d/" + sheetId + "/export?format=xlsx&access_token=" + ScriptApp.getOAuthToken();
var blob = UrlFetchApp.fetch(url).getBlob().setName(name + ".xlsx");
createFile(blob); // here need to create but without saving









share|improve this question
























  • About downloading a file by running script, this thread might be useful. stackoverflow.com/questions/37212135/…

    – Tanaike
    Mar 25 at 23:11






  • 1





    Possible duplicate of Download "automatically" spreadsheet as .xlsx to local machine on event

    – tehhowch
    Mar 26 at 1:10











  • Hi Tanaike, THK you again!...i have tried with this script you showed me but the following error pop appear "Request failed for docs.google.com/spreadsheets/d/Sheet/export?format=xlsx returned code 404. Truncated server " ...any idea? Marina

    – MarinaMontero
    Mar 27 at 13:42











  • @MarinaMontero Thank you for replying. Can you show us your current script which has the error? If you can do, please add it to your question. I would like to confirm it.

    – Tanaike
    Mar 27 at 22:45











  • THK you Tanaike! yes, i copy the code i'm triying

    – MarinaMontero
    Mar 29 at 18:44

















0















I have an application made on google than handdle different sheets on a google workbook. I need to add a button to allow users download some of these sheets but in an excel format if is possible. I took one code from StackOv and try to modify it, as i don´t want it name the file and save it in drive, i only need it download as same that when from excel it is download in Book1 ("libro1") without saving anywhere. THK!



var ss = SpreadsheetApp.openById("fffffffffffffffffffffffffffff...myID");
var sheetId = ss.ss.getSheetByName('nameSheetNeedToDownload');
var url = "https://docs.google.com/spreadsheets/d/" + sheetId + "/export?format=xlsx&access_token=" + ScriptApp.getOAuthToken();
var blob = UrlFetchApp.fetch(url).getBlob().setName(name + ".xlsx");
createFile(blob); // here need to create but without saving









share|improve this question
























  • About downloading a file by running script, this thread might be useful. stackoverflow.com/questions/37212135/…

    – Tanaike
    Mar 25 at 23:11






  • 1





    Possible duplicate of Download "automatically" spreadsheet as .xlsx to local machine on event

    – tehhowch
    Mar 26 at 1:10











  • Hi Tanaike, THK you again!...i have tried with this script you showed me but the following error pop appear "Request failed for docs.google.com/spreadsheets/d/Sheet/export?format=xlsx returned code 404. Truncated server " ...any idea? Marina

    – MarinaMontero
    Mar 27 at 13:42











  • @MarinaMontero Thank you for replying. Can you show us your current script which has the error? If you can do, please add it to your question. I would like to confirm it.

    – Tanaike
    Mar 27 at 22:45











  • THK you Tanaike! yes, i copy the code i'm triying

    – MarinaMontero
    Mar 29 at 18:44













0












0








0








I have an application made on google than handdle different sheets on a google workbook. I need to add a button to allow users download some of these sheets but in an excel format if is possible. I took one code from StackOv and try to modify it, as i don´t want it name the file and save it in drive, i only need it download as same that when from excel it is download in Book1 ("libro1") without saving anywhere. THK!



var ss = SpreadsheetApp.openById("fffffffffffffffffffffffffffff...myID");
var sheetId = ss.ss.getSheetByName('nameSheetNeedToDownload');
var url = "https://docs.google.com/spreadsheets/d/" + sheetId + "/export?format=xlsx&access_token=" + ScriptApp.getOAuthToken();
var blob = UrlFetchApp.fetch(url).getBlob().setName(name + ".xlsx");
createFile(blob); // here need to create but without saving









share|improve this question
















I have an application made on google than handdle different sheets on a google workbook. I need to add a button to allow users download some of these sheets but in an excel format if is possible. I took one code from StackOv and try to modify it, as i don´t want it name the file and save it in drive, i only need it download as same that when from excel it is download in Book1 ("libro1") without saving anywhere. THK!



var ss = SpreadsheetApp.openById("fffffffffffffffffffffffffffff...myID");
var sheetId = ss.ss.getSheetByName('nameSheetNeedToDownload');
var url = "https://docs.google.com/spreadsheets/d/" + sheetId + "/export?format=xlsx&access_token=" + ScriptApp.getOAuthToken();
var blob = UrlFetchApp.fetch(url).getBlob().setName(name + ".xlsx");
createFile(blob); // here need to create but without saving






google-apps-script google-sheets






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 23:11









Tanaike

30k3 gold badges16 silver badges31 bronze badges




30k3 gold badges16 silver badges31 bronze badges










asked Mar 25 at 16:55









MarinaMonteroMarinaMontero

34 bronze badges




34 bronze badges












  • About downloading a file by running script, this thread might be useful. stackoverflow.com/questions/37212135/…

    – Tanaike
    Mar 25 at 23:11






  • 1





    Possible duplicate of Download "automatically" spreadsheet as .xlsx to local machine on event

    – tehhowch
    Mar 26 at 1:10











  • Hi Tanaike, THK you again!...i have tried with this script you showed me but the following error pop appear "Request failed for docs.google.com/spreadsheets/d/Sheet/export?format=xlsx returned code 404. Truncated server " ...any idea? Marina

    – MarinaMontero
    Mar 27 at 13:42











  • @MarinaMontero Thank you for replying. Can you show us your current script which has the error? If you can do, please add it to your question. I would like to confirm it.

    – Tanaike
    Mar 27 at 22:45











  • THK you Tanaike! yes, i copy the code i'm triying

    – MarinaMontero
    Mar 29 at 18:44

















  • About downloading a file by running script, this thread might be useful. stackoverflow.com/questions/37212135/…

    – Tanaike
    Mar 25 at 23:11






  • 1





    Possible duplicate of Download "automatically" spreadsheet as .xlsx to local machine on event

    – tehhowch
    Mar 26 at 1:10











  • Hi Tanaike, THK you again!...i have tried with this script you showed me but the following error pop appear "Request failed for docs.google.com/spreadsheets/d/Sheet/export?format=xlsx returned code 404. Truncated server " ...any idea? Marina

    – MarinaMontero
    Mar 27 at 13:42











  • @MarinaMontero Thank you for replying. Can you show us your current script which has the error? If you can do, please add it to your question. I would like to confirm it.

    – Tanaike
    Mar 27 at 22:45











  • THK you Tanaike! yes, i copy the code i'm triying

    – MarinaMontero
    Mar 29 at 18:44
















About downloading a file by running script, this thread might be useful. stackoverflow.com/questions/37212135/…

– Tanaike
Mar 25 at 23:11





About downloading a file by running script, this thread might be useful. stackoverflow.com/questions/37212135/…

– Tanaike
Mar 25 at 23:11




1




1





Possible duplicate of Download "automatically" spreadsheet as .xlsx to local machine on event

– tehhowch
Mar 26 at 1:10





Possible duplicate of Download "automatically" spreadsheet as .xlsx to local machine on event

– tehhowch
Mar 26 at 1:10













Hi Tanaike, THK you again!...i have tried with this script you showed me but the following error pop appear "Request failed for docs.google.com/spreadsheets/d/Sheet/export?format=xlsx returned code 404. Truncated server " ...any idea? Marina

– MarinaMontero
Mar 27 at 13:42





Hi Tanaike, THK you again!...i have tried with this script you showed me but the following error pop appear "Request failed for docs.google.com/spreadsheets/d/Sheet/export?format=xlsx returned code 404. Truncated server " ...any idea? Marina

– MarinaMontero
Mar 27 at 13:42













@MarinaMontero Thank you for replying. Can you show us your current script which has the error? If you can do, please add it to your question. I would like to confirm it.

– Tanaike
Mar 27 at 22:45





@MarinaMontero Thank you for replying. Can you show us your current script which has the error? If you can do, please add it to your question. I would like to confirm it.

– Tanaike
Mar 27 at 22:45













THK you Tanaike! yes, i copy the code i'm triying

– MarinaMontero
Mar 29 at 18:44





THK you Tanaike! yes, i copy the code i'm triying

– MarinaMontero
Mar 29 at 18:44












1 Answer
1






active

oldest

votes


















0














THK you Tanaike!...Yes here i copy the code i have



function downloadAsXlsx() 
var bogus = DriveApp.getRootFolder();
var spreadSheet = SpreadsheetApp.openById('WorkbookID');
var ssID = spreadSheet.getSheetByName('SheetName');

Logger.log(ssID);

var url = "https://docs.google.com/spreadsheets/d/"+ssID+"/export?format=xlsx";
var params = method:"GET", headers:"authorization":"Bearer "+
ScriptApp.getOAuthToken();
var response = UrlFetchApp.fetch(url, params);

// save to drive
DriveApp.createFile(response);







share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55342861%2fadd-a-button-to-automatically-download-a-google-sheet-to-excel-from-a-google-app%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    THK you Tanaike!...Yes here i copy the code i have



    function downloadAsXlsx() 
    var bogus = DriveApp.getRootFolder();
    var spreadSheet = SpreadsheetApp.openById('WorkbookID');
    var ssID = spreadSheet.getSheetByName('SheetName');

    Logger.log(ssID);

    var url = "https://docs.google.com/spreadsheets/d/"+ssID+"/export?format=xlsx";
    var params = method:"GET", headers:"authorization":"Bearer "+
    ScriptApp.getOAuthToken();
    var response = UrlFetchApp.fetch(url, params);

    // save to drive
    DriveApp.createFile(response);







    share|improve this answer



























      0














      THK you Tanaike!...Yes here i copy the code i have



      function downloadAsXlsx() 
      var bogus = DriveApp.getRootFolder();
      var spreadSheet = SpreadsheetApp.openById('WorkbookID');
      var ssID = spreadSheet.getSheetByName('SheetName');

      Logger.log(ssID);

      var url = "https://docs.google.com/spreadsheets/d/"+ssID+"/export?format=xlsx";
      var params = method:"GET", headers:"authorization":"Bearer "+
      ScriptApp.getOAuthToken();
      var response = UrlFetchApp.fetch(url, params);

      // save to drive
      DriveApp.createFile(response);







      share|improve this answer

























        0












        0








        0







        THK you Tanaike!...Yes here i copy the code i have



        function downloadAsXlsx() 
        var bogus = DriveApp.getRootFolder();
        var spreadSheet = SpreadsheetApp.openById('WorkbookID');
        var ssID = spreadSheet.getSheetByName('SheetName');

        Logger.log(ssID);

        var url = "https://docs.google.com/spreadsheets/d/"+ssID+"/export?format=xlsx";
        var params = method:"GET", headers:"authorization":"Bearer "+
        ScriptApp.getOAuthToken();
        var response = UrlFetchApp.fetch(url, params);

        // save to drive
        DriveApp.createFile(response);







        share|improve this answer













        THK you Tanaike!...Yes here i copy the code i have



        function downloadAsXlsx() 
        var bogus = DriveApp.getRootFolder();
        var spreadSheet = SpreadsheetApp.openById('WorkbookID');
        var ssID = spreadSheet.getSheetByName('SheetName');

        Logger.log(ssID);

        var url = "https://docs.google.com/spreadsheets/d/"+ssID+"/export?format=xlsx";
        var params = method:"GET", headers:"authorization":"Bearer "+
        ScriptApp.getOAuthToken();
        var response = UrlFetchApp.fetch(url, params);

        // save to drive
        DriveApp.createFile(response);








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 29 at 18:50









        MarinaMonteroMarinaMontero

        34 bronze badges




        34 bronze badges


















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55342861%2fadd-a-button-to-automatically-download-a-google-sheet-to-excel-from-a-google-app%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript