誰でも特定のシートの特定の範囲のフォーマットをコピーしたい場合
/**
copying full formatting including sizez and merging from one range to new location
https://stackoverflow.com/questions/25106580/copy-value-and-format-from-a-sheet-to-a-new-google-spreadsheet-document
below first coordinates of original range we want to copy and then cooridinaes of the begining of the place ino which we want to copy our range
@param startColumnOfOriginal {Number}
@param startRowOfOriginal {Number}
@param numberOfRows {Number}
@param numberOfColumns {Number}
@param startColumnOfTarget {Number}
@param startRowOfTarget {Number}
@param sheetOfOrigin {Sheet} sheet object of where our source is
@param sheetOfTarget {Sheet} sheet object where we want to copy it
*/
function copyFullFormatting(startRowOfOriginal,startColumnOfOriginal,numberOfRows
,numberOfColumns, startRowOfTarget, startColumnOfTarget, sheetOfOrigin, sheetOfTarget
){
const sourceRange = sheetOfOrigin.getRange(
startRowOfOriginal, startColumnOfOriginal, numberOfRows, numberOfColumns)
const targetRange = sheetOfTarget.getRange(
startRowOfTarget, startColumnOfTarget, numberOfRows, numberOfColumns)
sourceRange.copyFormatToRange(sheetOfTarget,startColumnOfOriginal, startColumnOfTarget+ numberOfColumns, startRowOfTarget, startRowOfTarget+numberOfRows )
//iterating over rows of source range
for(var rowNumb=startRowOfOriginal;rowNumb<startRowOfOriginal+numberOfRows;rowNumb++ ){
const targetRowNumb = rowNumb-startRowOfOriginal+startRowOfTarget
sheetOfTarget.setRowHeight(targetRowNumb, sheetOfOrigin.getRowHeight(rowNumb))
}
// iterating over columns in target range
for (var colNumb=startColumnOfOriginal;colNumb<startColumnOfOriginal+numberOfColumns;colNumb++ ){
const targetColNumb = colNumb-startColumnOfOriginal+startColumnOfTarget
sheetOfTarget.setColumnWidth(targetColNumb, sheetOfOrigin.getColumnWidth(colNumb))
}
}