javascript - (1) Download specific sheets (2) Download only values (not formulas) via Google Sheets App Script -
is possible have google app script following if triggered.
- download google sheets .xlsx format.
- download specified sheets
- removing formulas , download values
for example, let's there 4 arbitrary worksheets on google sheets. : samples , products , clientdata , companydata.
let's samples & products worksheet using formulas reference clientdata , companydata.
i trying find solution download samples & products worksheet values (without formulas or functions) excel worksheet abc.xlsx.
i have searched around learning other app script solution. however, closest can 1 create new google workbook, delete clientdata & companydata worksheet, downloading.
the problem repeatedly running script result in tons of duplicated workbook on google drive however, thought there must smarter way.
below sample script referring to.
function onopen() { var spreadsheet = spreadsheetapp.getactive(); var menuitems=[{name: 'make copy', functionname: 'makecopyofspreadsheet'}]; spreadsheet.addmenu('script', menuitems); }; function formatdatestring(date) { return utilities.formatdate(date, session.gettimezone(), 'yyyy-mm-dd h:mm'); }; function makecopyofspreadsheet() { var date = formatdatestring(new date()); var ss = spreadsheetapp.getactivespreadsheet(); var newss = ss.copy( ss.getname()+" - "+date+" - (values only)" ); var s = ss.getsheets(); for(var i=0;i<s.length;i++) { var r = s[i].getdatarange(); var v = r.getvalues(); r.setvalues(v); } // delete irrelevant sheets reports var ss = spreadsheetapp.getactivespreadsheet(); ss.setactivesheet(ss.getsheetbyname("clientdata")); ss.deleteactivesheet(); ss.setactivesheet(ss.getsheetbyname("companydata")); ss.deleteactivesheet(); };
Comments
Post a Comment