With this script I could export a spreadsheet to a excel file keeping formulas and a specific range that I need.
But I need also to keep the style of the spreadsheet like colors, row height, text style...
What to add then to the code below?
function downloadXLS_GUI() {
var sh = SpreadsheetApp.getActiveSheet();
var nSheet = SpreadsheetApp.create(sh.getName()+": copy");
var numCols = 10;
var d = sh.getRange(1,1,sh.getLastRow(),numCols);
nSheet.getSheets()[0].getRange(1,1,sh.getLastRow(),numCols).setValues(d.getValues());
["A3", "C3", "F3", "G3", "H3", "F5", "G5", "H5"].forEach(a1Notation => {
var sourceFormulas = sh.getRange(a1Notation).getFormulas();
nSheet.getRange(a1Notation).setFormulas(sourceFormulas);
});
var URL = 'https://docs.google.com/spreadsheets/d/'+nSheet.getId()+'/export?format=xlsx';
var htmlOutput = HtmlService
.createHtmlOutput('<a href="'+URL+'">Clicca qui per scaricare</a>')
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setWidth(380)
.setHeight(160);
SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'Scarica Allegato 2 in Excel');
}