excel - Export Google sheet as xlsx to company network drive -
this function triggered when sheet changed.
function exportasxlsx() { var spreadsheet = spreadsheetapp.getactivespreadsheet(); var spreadsheetid = spreadsheet.getid() var file = drive.files.get(spreadsheetid); var url = file.exportlinks[mimetype.microsoft_excel]; var token = scriptapp.getoauthtoken(); var response = urlfetchapp.fetch(url, { headers: { 'authorization': 'bearer ' + token } }); var blobs = response.getblob(); var folder = driveapp.getfoldersbyname('\\gbc1234.fs1.util.xxint.com\shared\projects\test_google2excel'); if(folder.hasnext()) { var existingplan1 = driveapp.getfilesbyname('testgoogle2excel.xlsx'); if(existingplan1.hasnext()){ var existingplan2 = existingplan1.next(); var existingplanid = existingplan2.getid(); drive.files.remove(existingplanid); } } else { folder = driveapp.createfolder('\\gbc1234.fs1.util.xxint.com\shared\projects\test_google2excel'); } folder = driveapp.getfoldersbyname('\\gbc1234.fs1.util.xxint.com\shared\projects\test_google2excel').next(); folder.createfile(blobs).setname('testgoogle2excel.xlsx') }
what happens makes directory "\gbc1234.fs1.util.xxint.com\shared\projects\test_google2excel" in google drive saves file there.
how can save our company drive?
you need have locally hosted 'client' downloads said file known drive location network.
once start thinking client interact number of points on workflow describe.
i.e. 1. described, polls google drive see if output xlsx created , download. drive api 2. poll sheet in drive , trigger apps script perform conversion. apps script execution api 3. skip altogether , interact sheet directly. sheets api
in each case you'll want cache checksum of original sheet data act if things have changed. (there number of ways this)
Comments
Post a Comment