Make a Copy of a Google Sheet with Apps Script

Поделиться
HTML-код
  • Опубликовано: 4 дек 2024

Комментарии • 9

  • @JoedAguilar
    @JoedAguilar 8 месяцев назад +1

    Thank you, I can't see this anywhere else

  • @khalidyoga7517
    @khalidyoga7517 4 месяца назад +1

    what if the folder is inside folder?

    • @yagisanatode
      @yagisanatode  4 месяца назад

      You can also directly target a folder location with the DriveApp API.

  • @myadventuresinflight
    @myadventuresinflight 3 месяца назад

    Instead of naming the copied file with an asterisk, how would I pull a name from list in column A of a different sheet to rename the new copy?
    For example, I have 100 names in column A on a sheet called "Names", and I want to copy a different sheet called "template", so I want to end up with 100 copies of my template, each renamed with a name from the 100 rows in column A of my "Names" sheet.
    How can I change the script code to do that?

    • @yagisanatode
      @yagisanatode  3 месяца назад

      You would use the getValues() method of the sheet and iterate over the ranges of the IDs of your template creating a template for each value retrieves and naming it with that value.
      Note! Creating a large number of files using the standard Google Apps Script libraries can be a little slow and it might be a better approach to copy files using batch operations with the Drive API advanced service.

  • @AlAqsaRetoWijaya
    @AlAqsaRetoWijaya 9 дней назад

    Is it possible to copy a tab to a new spreadsheet?

    • @yagisanatode
      @yagisanatode  8 дней назад +1

      Yes. Use `const ssNew = SpreadsheetApp.create("My new sheet");` then reference `ssNew` when copying the tab over.
      Check out the link to the playlist in the description on how to copy sheet tabs.

  • @FunkyFaulc
    @FunkyFaulc 7 месяцев назад

    Is there a way to just have it pop up the google drive picker? I've been playing with that when I hit my copy button but it's been unsuccessful.

    • @yagisanatode
      @yagisanatode  7 месяцев назад

      Sure, Google Has a handy example for this: developers.google.com/drive/picker/guides/overview
      You can add this to a modal dialogue in your Google Sheet.