[App Script] How to copy sheet to another sheet

google spreadsheet crud article

How to copy sheet to another google sheet?

First, we import our source sheet and target sheet by ss_spreadsheet, ts_spreadsheet.

Then we can use copyTo function to copy the tab to another spredsheet tab.

How to copy one raw to target raw?

In this case, we also need import our source sheet and target sheet by ss_spreadsheet, ts_spreadsheet.

Second, we get the tab name by getSheetByName, and input your source range and target range to getRange.

At the end, if you want to copy the value then you can use the setValues and getValues function to copy the raw to target raw. If you want to copy the formulas then need to choose setFormulas and setFormulas function.

How to copy the format to target range in google sheet?

After you import the source sheet and target sheet by ss_spreadsheet, ts_spreadsheet and set the range.

You can use below function to change the format:

  1. setFontStyles
  2. setFontWeights
  3. setFontSizes
  4. setFontLines
  5. setFontFamilies
  6. setBackgrounds
  7. setHorizontalAlignments
  8. setVerticalAlignments

How to create raw DataValidation to target raw?

If you want to create DataValidation, first you need to use newDataValidation function to build the rule and use the setDataValidation functino to set the rule.

How to set the range name?

First, import the target sheet as ts_spreadsheet.
Then, you can use the setNamedRange, put the “string” and the range to be parameters as below.


Thanks for your reading. I hope this article will help you better understand how to copy the row or sheet in google app script.

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *