Possible Solution:
You can use the Sheets API to get the format from one Spreadsheet and update another Spreadsheet.
Flow:
- Use
Spreadsheets.get
to get source format
- Use
updateCells
batchUpdate request to update another spreadsheet with source format
Sample Script:
function copyFormatFromSpreadsheetToSpreadsheet() {
var sourceSsId = SpreadsheetApp.getActiveSpreadsheet().getId(),
destSsId = '##destSpreadsheetIdHere##',
sourceRng = 'Sheet1!A1:B4',
destRng = {
//Must be of same dimensions as sourceRng
//Represents Sheet1!B1:C4
sheetId: 123456789, //use 9 digit GridId
startRowIndex: 0,
endRowIndex: 4, //end exclusive
startColumnIndex: 1,
endColumnIndex: 3,
};
/*Get Format of Source Spreadsheet*/
var rowData = Sheets.Spreadsheets.get(sourceSsId, {
ranges: sourceRng,
fields: 'sheets.data.rowData.values.userEnteredFormat',
}).sheets[0].data[0].rowData;
/*Copy Format to Destination Spreadsheet*/
var request = {
requests: [
{
updateCells: {
rows: rowData,
fields: 'userEnteredFormat',
range: destRng,
},
},
],
};
Sheets.Spreadsheets.batchUpdate(request, destSsId);
}
References: