├── .babelrc ├── .clasp.json.pull ├── .claspignore ├── .eslintrc ├── .gitattributes ├── .gitignore ├── .markdownlint.json ├── .nojekyll ├── .prettierignore ├── .prettierrc ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md ├── LICENSE ├── README.md ├── extra ├── .eslintrc ├── README.ru.md └── hslToHex.js ├── gulpfile.js ├── package-lock.json ├── package.json ├── readme.md ├── recast ├── README1.md ├── SPREADSHEETS │ └── SPREADSHEETS.GS ├── gapps │ ├── README.MD │ ├── gilp-simple-project.js │ ├── gulpfile-analitycs.js │ ├── gulpfile-gist-stack.js │ ├── gulpfile-notify-send.js │ ├── gulpfile-variant.js │ ├── gulpfile-with-gappsinit-and-backups.js │ └── push.sh └── test_gpg_sign ├── settings ├── container-bound-doc │ └── .clasp.json ├── container-bound-form │ └── .clasp.json ├── container-bound-sheet │ └── .clasp.json ├── standalone │ └── .clasp.json └── webapp │ └── .clasp.json ├── shims ├── .eslintrc ├── Array.find.js ├── Array.findIndex.js ├── Array.findIndexRight.js ├── Array.flat.js ├── Math.sign.js ├── String.repeat.js ├── URL.js ├── URLSearchParams.js ├── jsonata.js ├── ramda.js └── xml-js.js ├── snippets ├── .eslintrc ├── addons │ └── minimal-workspace-drive-addon │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ └── readme.md ├── apps │ ├── file-upload-to-drive │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ └── readme.md │ └── importxml-scrapper │ │ ├── .clasp.json │ │ ├── 1.md │ │ ├── app │ │ └── index.js │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── screenrecord.mp4 │ │ └── triggers │ │ └── index.js ├── cache │ └── chunky-cache │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ ├── index.min.js │ │ ├── readme.md │ │ ├── run.js │ │ └── screenshot.png ├── calendar │ ├── clear-all-events │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ ├── readme.md │ │ └── run.js │ └── delete-one-of-series │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ ├── readme.md │ │ ├── run.js │ │ └── screenshot.png ├── common_js │ ├── 2darray_to_collection │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ ├── index.min.js │ │ ├── readme.md │ │ ├── run.js │ │ └── screenshot.png │ ├── column_names_and_numbers │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── first_250_column_to_number.md │ │ ├── index.js │ │ ├── readme.md │ │ ├── test.js │ │ └── tools.js │ ├── date-range-iterator │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ ├── readme.md │ │ ├── run.js │ │ └── screenshot.png │ ├── get_id_from_url │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ ├── readme.md │ │ ├── run.js │ │ └── test.js │ └── sheet_datetime │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ ├── readme.md │ │ └── run.js ├── common_ui │ ├── check_ui │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── open-dialog-from-sidebar │ │ ├── app │ │ │ ├── dialog.html │ │ │ ├── index.js │ │ │ └── sidebar.html │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── readme.md │ │ ├── run.js │ │ ├── screenrecord.mp4 │ │ └── triggerActionss.js │ ├── open_url_in_browser │ │ ├── app.html │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ ├── readme.md │ │ ├── screenrecord.gif │ │ └── screenrecord.mp4 │ └── sheet_sidebar_select │ │ ├── app.html │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js ├── customfunctions │ ├── GETSHEETS │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ └── screenrecord.mp4 │ ├── LET │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ ├── screenrecord.gif │ │ └── screenrecord.mp4 │ ├── PARSEAPINET │ │ ├── .clasp.json │ │ ├── Code.js │ │ ├── appsscript.json │ │ └── config.json │ ├── RAINREPORT │ │ ├── .clasp.json │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── customfunction_flatten-arguments │ │ ├── appsscript.json │ │ ├── config.json │ │ └── flatten-arguments.js │ ├── customfunction_jaro-winker-distance │ │ ├── 1.md │ │ ├── appsscript.json │ │ ├── config.json │ │ └── jaro-winker-distance.js │ ├── customfunction_union_ranges │ │ ├── appsscript.json │ │ └── customfunction_union_ranges.js │ └── using_cache_service │ │ ├── .clasp.json │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js ├── docs │ ├── api_find_and_replace_named_ranges │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── create_footnote │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ └── readme.md │ ├── docs_push_2D_array_to_table │ │ ├── Code.js │ │ ├── appsscript.json │ │ └── config.json │ ├── document-copy_and_replace │ │ ├── appsscript.json │ │ ├── config.json │ │ └── copy_and_replace.js │ ├── document_center-align-table-cell-content │ │ ├── appsscript.json │ │ ├── center-align-table-cell-content.js │ │ ├── config.json │ │ └── screenshot.png │ ├── document_copy-inline-image │ │ ├── appsscript.json │ │ ├── config.json │ │ └── copy-inline-image.js │ ├── document_paste-data-to-selection │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── document_paste-data-to-selection.js │ │ ├── screenrecord.gif │ │ └── screenrecord.mp4 │ ├── find_and_replace_bulk │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ └── readme.md │ ├── horizontal_align_samples │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── insert_image │ │ ├── appsscript.json │ │ ├── config.json │ │ └── insert_image.js │ └── uncheck-checklist │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ ├── readme.md │ │ ├── run.js │ │ ├── screenrecord.mp4 │ │ ├── screenshot.png │ │ └── triggerActions.js ├── drive │ ├── convert_file_to_drive_format │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── copying_access_rights_between_two_entities │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── drive-upload_file_from_url │ │ ├── appsscript.json │ │ ├── config.json │ │ └── upload_file_from_url.js │ ├── drive_change_user_role │ │ ├── appsscript.json │ │ └── drive_change_user_role.js │ ├── driveapp_change_owner_in_folder │ │ ├── appsscript.json │ │ └── driveapp_change_owner_in_folder.js │ ├── save_file_to_drive │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ └── utf8_bom_to_utf8 │ │ ├── appsscript.json │ │ ├── config.json │ │ └── utf8_bom_to_utf8.js ├── external │ ├── czech-national-bank-public-api │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── external_forismatic_com │ │ └── external_forismatic_com.js │ └── external_smartlabru │ │ ├── Code.gs │ │ └── README.md ├── extra │ └── xml-js_demo │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── init.js │ │ ├── readme.md │ │ └── run.js ├── forms │ ├── arrange_list │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── create_file_upload_field │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── get_pre_fill_entries_map │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── on_form_submit_event │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ └── send_other_multiple_choice │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js ├── gae │ └── start_stop_instance │ │ ├── GAE │ │ └── instances.js │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js ├── gmail │ ├── answering_machine │ │ ├── .clasp.json │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ └── forward_without_attachments │ │ ├── appsscript.json │ │ ├── config.json │ │ └── forward_without_attachments.js ├── gpf │ └── copy_paste_data_between_sheets │ │ ├── .clasp.json │ │ ├── Code.js │ │ ├── Code2.js │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── screenrecord.gif │ │ └── screenrecord.mp4 ├── js │ └── datesRangeIterator │ │ ├── 1590513969504.png │ │ ├── appsscript.json │ │ ├── config.json │ │ └── datesRangeIterator.js ├── patterns │ ├── bootstrap_jquery │ │ ├── .clasp.json │ │ ├── appsscript.json │ │ ├── bootstrap.html │ │ ├── client.html │ │ ├── config.json │ │ ├── index.js │ │ ├── jquery.html │ │ └── tools.js │ └── default_app │ │ ├── App │ │ └── index.js │ │ ├── Triggers │ │ └── index.js │ │ ├── appsscript.json │ │ └── config.json ├── sheets │ ├── append_row_with_date_time │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ ├── screenrecord.gif │ │ └── screenrecord.mp4 │ ├── append_values_from_sheet_to_one │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ ├── screenrecord.gif │ │ └── screenrecord.mp4 │ ├── autoid │ │ ├── appsscript.json │ │ ├── autoid.js │ │ ├── config.json │ │ ├── screenrecord.gif │ │ └── screenrecord.mp4 │ ├── clean_cells_by_find_result copy │ │ └── index.js │ ├── clean_cells_by_find_result │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── copy_format_between_sheets │ │ ├── appsscript.json │ │ ├── config.json │ │ └── copy_format_between_sheets.js │ ├── copying_protected_ranges_between_two_entities │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── count_cells │ │ ├── .clasp.json │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ ├── screenrecord.gif │ │ └── screenrecord.mp4 │ ├── delete_move_rows_by_conditional │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ ├── readme.md │ │ ├── run.js │ │ ├── screenrecord.mp4 │ │ ├── screenshot.png │ │ └── userActions.js │ ├── dynamic_meny │ │ ├── appsscript.json │ │ ├── code.js │ │ ├── config.json │ │ ├── screenrecord22.gif │ │ └── screenrecord22.mp4 │ ├── export-import-to-csv │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── filters_samples │ │ ├── 000.png │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── find_and_replace_samples │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── get_data_sheet_as_array_of_objects │ │ ├── appsscript.json │ │ ├── code.js │ │ └── config.json │ ├── hide_empty_columns │ │ ├── appsscript.json │ │ ├── code.js │ │ ├── config.json │ │ ├── screenrecord.gif │ │ └── screenrecord.mp4 │ ├── hyperlinks │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── insert_image_blob_to_cell │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── is_range_a_cell │ │ ├── appsscript.json │ │ ├── code.js │ │ └── config.json │ ├── join_rich-text-values │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ ├── readme.md │ │ └── run.js │ ├── on_change_trigger_sample │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── on_change_trigger_sample_DEPRECATED_ES5 │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── on_edit_active_user │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── on_edit_sort │ │ ├── .clasp.json │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── on_edit_timestamp │ │ ├── .clasp.json │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── on_edit_timestamp_with_check │ │ ├── .clasp.json │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── on_selection_change_simple_trigger │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ ├── screenrecord.gif │ │ └── screenrecord.mp4 │ ├── protection_multiple_sheets │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ └── readme.md │ ├── rename_sheets_by_patt │ │ ├── appsscript.json │ │ ├── code.js │ │ ├── config.json │ │ ├── screenrecord.gif │ │ └── screenrecord.mp4 │ ├── reset_sheet_data │ │ ├── .clasp.json │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ ├── makeCopyBeforeReset.js │ │ ├── readme.md │ │ ├── screenrecord.mp4 │ │ ├── screenrecord2.mp4 │ │ ├── screenshot.png │ │ ├── triggerActions.js │ │ └── userActions.js │ ├── shuffle_some_data │ │ ├── .clasp.json │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ ├── screenrecord.gif │ │ ├── screenrecord.mp4 │ │ ├── screenrecord1.gif │ │ └── screenrecord1.mp4 │ ├── sort_book_sheets │ │ ├── .clasp.json │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── sort_sheet_when_form_submit │ │ ├── appsscript.json │ │ ├── config.json │ │ └── sort_sheet_when_form_submit.js │ ├── split_data_to_two_array_by_condition │ │ ├── .clasp.json │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ └── readme.md │ ├── spreadsheet-apply_format │ │ ├── apply_format.js │ │ ├── appsscript.json │ │ └── config.json │ ├── spreadsheet-autoincrement │ │ ├── appsscript.json │ │ ├── autoincrement.js │ │ ├── config.json │ │ ├── screenrecord.gif │ │ └── screenrecord.mp4 │ ├── spreadsheet-charts_calendar │ │ ├── appsscript.json │ │ ├── charts_calendar.js │ │ ├── charts_calendar_ui.html │ │ ├── config.json │ │ ├── screenrecord.gif │ │ └── screenrecord.mp4 │ ├── spreadsheet-closest_match_analog │ │ ├── appsscript.json │ │ ├── closest_match_analog.js │ │ └── config.json │ ├── spreadsheet-colored_cell_by_list_value │ │ ├── appsscript.json │ │ ├── colored_cell_by_list_value.js │ │ ├── config.json │ │ ├── screenrecord.gif │ │ └── screenrecord.mp4 │ ├── spreadsheet-copy_active_rows_two_sheets │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── copy_active_rows_two_sheets.js │ │ └── screenrecord.gif │ ├── spreadsheet-draft │ │ ├── Code.js │ │ ├── appsscript.json │ │ ├── config.json │ │ └── spreadsheet-draft │ │ │ ├── Code.js │ │ │ ├── appsscript.json │ │ │ └── config.json │ ├── spreadsheet-dragg_down_formulas │ │ ├── appsscript.json │ │ ├── config.json │ │ └── dragg_down_formulas.js │ ├── spreadsheet-get_error_value_formulas │ │ ├── Untitled.png │ │ ├── appsscript.json │ │ ├── config.json │ │ └── get_error_value_formulas.js │ ├── spreadsheet-get_last_values │ │ ├── appsscript.json │ │ ├── config.json │ │ └── get_last_values.js │ ├── spreadsheet-images_simple │ │ ├── appsscript.json │ │ ├── config.json │ │ └── images_simple.js │ ├── spreadsheet-lodasgs_sample │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── lodasgs_sample.js │ │ ├── screenrecord.gif │ │ └── screenrecord.mp4 │ ├── spreadsheet-maps-check_streetview │ │ ├── .clasp.json │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── spreadsheet-maps-check_streetview.js │ │ └── strv.html │ ├── spreadsheet-multiple_formats │ │ ├── appsscript.json │ │ ├── config.json │ │ └── multiple_formats.js │ ├── spreadsheet-null_values │ │ ├── appsscript.json │ │ ├── config.json │ │ └── null_values.js │ ├── spreadsheet-onedit-check-value │ │ ├── appsscript.json │ │ ├── config.json │ │ └── onedit-check-value.js │ ├── spreadsheet-simple_search_engine │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── screenrecord.gif │ │ ├── screenrecord.mp4 │ │ └── simple_search_engine.js │ ├── spreadsheet-split_data_on_each_row │ │ ├── appsscript.json │ │ ├── config.json │ │ └── split_data_on_each_row.js │ ├── spreadsheet_add-row-to-filtered-range │ │ ├── add-row-to-filtered-range.js │ │ ├── appsscript.json │ │ └── config.json │ ├── spreadsheet_appndRow-formula-increment │ │ ├── appsscript.json │ │ ├── config.json │ │ └── spreadsheet_appndRow-formula-increment.js │ ├── spreadsheet_autosort │ │ ├── appsscript.json │ │ ├── autosort1.js │ │ ├── autosort2.js │ │ ├── config.json │ │ └── onEdit.js │ ├── spreadsheet_binding-notes │ │ ├── appsscript.json │ │ ├── binding-notes.js │ │ ├── config.json │ │ ├── screenrecord.gif │ │ └── screenrecord.mp4 │ ├── spreadsheet_change-basic-event │ │ ├── appsscript.json │ │ ├── config.json │ │ └── spreadsheet_change-basic-event.js │ ├── spreadsheet_change_user_role │ │ ├── appsscript.json │ │ └── spreadsheet.users.js │ ├── spreadsheet_clear-bandings │ │ ├── appsscript.json │ │ ├── clear-bandings.js │ │ └── config.json │ ├── spreadsheet_collect_data_from_multiple_sheets │ │ ├── appsscript.json │ │ ├── config.json │ │ └── spreadsheet_collect_data_from_multiple_sheets.js │ ├── spreadsheet_compare_dates │ │ ├── appsscript.json │ │ ├── config.json │ │ └── spreadsheet_compare_dates.js │ ├── spreadsheet_copy-chart │ │ ├── appsscript.json │ │ ├── config.json │ │ └── spreadsheet_copy-chart.js │ ├── spreadsheet_copy_formats_between_two_sheets │ │ ├── appsscript.json │ │ ├── config.json │ │ └── copy_formats_from_template.js │ ├── spreadsheet_copy_values_between_two_sheets │ │ ├── appsscript.json │ │ ├── config.json │ │ └── spreadsheet_copy_values_between_two_sheets.js │ ├── spreadsheet_data_to_html_table │ │ ├── appsscript.json │ │ └── spreadsheet_data_to_html_table.js │ ├── spreadsheet_insert-rows-before-by-condition │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── insert-rows-before-by-condition.js │ │ ├── screenrecord.gif │ │ └── screenrecord.mp4 │ ├── spreadsheet_insert_rich_text_to_active_cell │ │ ├── appsscript.json │ │ ├── config.json │ │ └── insert_rich_text_to_active_cell.js │ ├── spreadsheet_on-form-submit-event │ │ ├── appsscript.json │ │ ├── config.json │ │ └── on-form-submit-event.js │ ├── spreadsheet_onedit-copy-row-if-edit │ │ ├── appsscript.json │ │ ├── config.json │ │ └── onedit-copy-row-if-edit.js │ ├── spreadsheet_onedit-sample │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── onedit-sample.js │ │ ├── screenrecord.gif │ │ └── screenrecord.mp4 │ ├── spreadsheet_painting-specific-characters │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── painting-specific-characters.js │ │ └── screenshot.png │ ├── spreadsheet_rainbow_active_cell │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── rainbow_active_cell.js │ │ └── screenshot.png │ ├── spreadsheet_update-colored-notes │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── screenshot.png │ │ └── update-colored-notes.js │ ├── toc_generator │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ ├── readme.md │ │ ├── run.js │ │ └── screenrecord.gif │ ├── unlink_urls │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── index.js │ │ ├── readme.md │ │ ├── run.js │ │ └── screenrecord.gif │ └── unset_checkbox_by_condition │ │ ├── .clasp.json │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js ├── standalone │ ├── birthdays │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── copy_protected_file │ │ ├── appsscript.json │ │ ├── config.json │ │ └── index.js │ ├── export-document-to │ │ ├── appsscript.json │ │ ├── config.json │ │ └── standalone_export-document-to.js │ ├── export_spreadsheet_to │ │ ├── appsscript.json │ │ ├── config.json │ │ └── export-spreadsheet-to.js │ ├── google_cloud_print │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── gcp.js │ │ └── index.js │ ├── parse_html │ │ ├── appsscript.json │ │ ├── code.js │ │ └── config.json │ ├── scriptapp-delete-trigger │ │ └── Code.gs │ ├── standalone-copy_image_as_string │ │ ├── appsscript.json │ │ ├── config.json │ │ └── copy_image_as_string.js │ ├── standalone-gmail_remove_forever │ │ ├── .clasp.json │ │ ├── appsscript.json │ │ ├── config.json │ │ └── gmail_remove_forever.js │ ├── standalone-triggers_timebased_daily_exact_time │ │ ├── 1576074760009.png │ │ ├── appsscript.json │ │ ├── config.json │ │ └── triggers_timebased_daily_exact_time.js │ ├── standalone_batch-create-calendar-events │ │ ├── appsscript.json │ │ ├── batch.js │ │ └── config.json │ ├── standalone_content-server │ │ ├── appsscript.json │ │ ├── config.json │ │ └── content-serverl.js │ ├── standalone_create-file-from-url │ │ ├── appsscript.json │ │ ├── config.json │ │ └── create-file-from-url.js │ ├── standalone_drive-changes │ │ ├── appsscript.json │ │ ├── config.json │ │ └── drive-changes.js │ ├── standalone_driveapp-save-file-to-drive-from-web │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── screenrecord.gif │ │ ├── screenrecord.mp4 │ │ └── standalone_driveapp-save-file-to-drive-from-web.js │ ├── standalone_echo-server │ │ ├── appsscript.json │ │ ├── config.json │ │ └── echo-serverl.js │ ├── standalone_file-backuper │ │ ├── appsscript.json │ │ ├── config.json │ │ └── file-backuper.js │ ├── standalone_get-list-files-from-folder │ │ ├── appsscript.json │ │ ├── config.json │ │ └── get-list-files-from-folder.js │ ├── standalone_gmail-import-csv-to-sheet │ │ ├── appsscript.json │ │ ├── config.json │ │ └── gmail-import-csv-to-sheet.js │ ├── standalone_gmail-save-attachmets-content-to-spreadsheet │ │ ├── appsscript.json │ │ ├── config.json │ │ └── gmail-save-attachmets-content-to-spreadsheet.js │ ├── standalone_gmail-save-attachmets-to-drive │ │ ├── appsscript.json │ │ ├── config.json │ │ └── gmail-save-attachmets-to-drive.js │ ├── standalone_parse-html-table │ │ ├── appsscript.json │ │ ├── config.json │ │ └── parse-html-table.js │ ├── standalone_parse-html │ │ ├── appsscript.json │ │ ├── config.json │ │ └── parse-html.js │ ├── standalone_ramda-demo │ │ ├── appsscript.json │ │ ├── config.json │ │ └── ramda-demo.js │ ├── standalone_simple-advanced-api-pagination │ │ ├── appsscript.json │ │ ├── config.json │ │ └── simple-advanced-api-pagination.js │ ├── standalone_simple-webapp │ │ ├── app.html │ │ ├── appsscript.json │ │ ├── config.json │ │ └── simple-webapp.js │ ├── standalone_telegram-bot │ │ ├── .clasp.json │ │ ├── api.js │ │ ├── appsscript.json │ │ ├── config.json │ │ ├── logic.js │ │ └── telegram-bot.js │ ├── standalone_use-url-polyfill │ │ ├── appsscript.json │ │ ├── config.json │ │ └── use-url-polyfill.js │ └── standalone_use-urlsearchparams-polyfill copy │ │ ├── app.html │ │ ├── appsscript.json │ │ ├── config.json │ │ └── use-urlsearchparams-polyfill.js └── webapp │ ├── form2Json │ ├── appsscript.json │ ├── config.json │ ├── form2Json.js │ └── index.js │ ├── materializecss_form_to_sheet │ ├── Code.js │ ├── appsscript.json │ ├── config.json │ ├── functions.js │ ├── page-css.html │ ├── page-js.html │ └── page.html │ ├── responsive-meta │ ├── appsscript.json │ ├── config.json │ ├── index.js │ ├── readme.md │ └── screenshot.png │ ├── spreadsheet_to_json │ ├── appsscript.json │ ├── config.json │ ├── screenrecord.gif │ ├── screenrecord.mp4 │ ├── spreadsheet_to_json.js │ └── spreadsheet_to_json_ui.html │ └── webserver │ ├── appsscript.json │ ├── client │ └── index.html │ ├── config.json │ └── server │ └── index.js ├── templates └── sheet_snippet │ ├── appsscript.json │ ├── config.json │ ├── index.js │ └── readme.md └── tools ├── flat-polyfill └── index.js ├── jsonata └── index.js ├── ramda └── index.js ├── shims-url └── index.js ├── shims-urlsearchparams └── index.js └── xml-js └── index.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/env"], 3 | "plugins": ["transform-es5-property-mutators"] 4 | } 5 | -------------------------------------------------------------------------------- /.clasp.json.pull: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "", 3 | "rootDir": "external" 4 | } 5 | -------------------------------------------------------------------------------- /.claspignore: -------------------------------------------------------------------------------- 1 | **/formatter.js 2 | !appsscript.json 3 | !**/*.gs 4 | !**/*.js 5 | !**/*.ts 6 | !**/*.html -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["eslint:recommended", "google", "plugin:prettier/recommended"], 3 | "plugins": ["prettier"], 4 | "parser": "babel-eslint", 5 | "env": { 6 | "node": true, 7 | "es6": true 8 | }, 9 | "rules": { 10 | "code": 120, 11 | "prettier/prettier": "error" 12 | }, 13 | "globals": {} 14 | } 15 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | readme.md merge=union 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.clasp.json 2 | .clasprc.json 3 | dist/ 4 | drafts/ 5 | node_modules/ 6 | .preliminary/ 7 | snippets/.brename_detail.txt 8 | -------------------------------------------------------------------------------- /.markdownlint.json: -------------------------------------------------------------------------------- 1 | { 2 | "default": true, 3 | "MD013": false, 4 | "MD033": false, 5 | "MD041": false 6 | } 7 | -------------------------------------------------------------------------------- /.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/.nojekyll -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "es5", 4 | "printWidth": 120 5 | } 6 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | If you have something to add, go ahead. 4 | Transparency and simplicity are supported as: 5 | 6 | - Short syllable in the main file (readme.md is fine) 7 | - Detailed description in issues (Its are fine too) 8 | -------------------------------------------------------------------------------- /ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | I want to know ... 2 | 3 | I need help ... 4 | 5 | How can I ... 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Google Apps Script Snippets 2 | 3 | The website [Google Apps Script snippets ᕦʕ •ᴥ•ʔᕤ](https://google-apps-script-snippets.contributor.pw/) 4 | 5 | ## How to build 6 | 7 | Clone the repo. 8 | 9 | Don't forget `$> npm init`. 10 | 11 | Override the [settings](./settings) to your `.clasp.json`. 12 | 13 | Push the snippet `sheets/export-import-to-csv` to the cloud: 14 | 15 | ```sh 16 | $> S=./snippets/sheets/export-import-to-csv && npm run dsw $S 17 | ``` 18 | -------------------------------------------------------------------------------- /extra/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["eslint:recommended", "google", "plugin:prettier/recommended"], 3 | "plugins": ["prettier"], 4 | "env": {}, 5 | "rules": { 6 | "prettier/prettier": "error", 7 | "no-var": "off", 8 | "no-unused-vars": ["error", { "varsIgnorePattern": "hslToHex" }], 9 | "valid-jsdoc": "error", 10 | "require-jsdoc": "error", 11 | "prefer-rest-params": "off" 12 | }, 13 | "globals": {} 14 | } 15 | -------------------------------------------------------------------------------- /extra/README.ru.md: -------------------------------------------------------------------------------- 1 | # Экстра 2 | 3 | Дополнительный код 4 | -------------------------------------------------------------------------------- /recast/gapps/README.MD: -------------------------------------------------------------------------------- 1 | # gapps 2 | 3 | Gulp is a very simple and helpful tool. 4 | 5 | * A simple way to append a google analitycs script to the gs ui [gulpfile-analitycs.js](./gulpfile-analitycs.js) 6 | * Show system notification after script deploy [gulpfile-notify-send.js](./gulpfile-notify-send.js) -------------------------------------------------------------------------------- /recast/gapps/gulpfile-gist-stack.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var del = require('del'); 3 | var exec = require('child_process').exec; 4 | 5 | gulp.task('default', ['src'], function (cb) { 6 | exec('gapps push | while read OUTPUT; do notify-send "$OUTPUT"; done', function (err, stdout, stderr) { 7 | console.log(stdout); 8 | console.log(stderr); 9 | cb(err); 10 | }); 11 | }); 12 | 13 | gulp.task('clean', function () { 14 | del(['src/*']); 15 | }); 16 | 17 | gulp.task('src', ['clean'], function () { 18 | gulp.src(['*.html', '*.gs', '*.js', '!gulpfile.js']).pipe(gulp.dest('src')); 19 | }); 20 | 21 | gulp.task('init', function () { 22 | gulp.src(['src/*.html', 'src/*.gs', 'src/*.js']).pipe(gulp.dest('.')); 23 | }); 24 | -------------------------------------------------------------------------------- /recast/gapps/gulpfile-notify-send.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Using notify-send 3 | **/ 4 | 5 | var gulp = require('gulp'); 6 | var exec = require('child_process').exec; 7 | 8 | gulp.task('default', function (cb) { 9 | exec('gapps push | while read OUTPUT; do notify-send "$OUTPUT"; done', function (err, stdout, stderr) { 10 | console.log(stdout); 11 | console.log(stderr); 12 | cb(err); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /recast/gapps/push.sh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | rm -rf ./src/*.html 4 | rm -rf ./src/*.gs 5 | cp ./*.html ./src/ 6 | cp ./*.gs ./src/ 7 | 8 | exec gapps push -------------------------------------------------------------------------------- /recast/test_gpg_sign: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /settings/container-bound-doc/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "1BPDSdmekvF-Su2euwFo_dV2y405FQ0TCXGzSDju3YwHZxIvZco-ftouO", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /settings/container-bound-form/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "13F7zvpjgrURb8LU7xA2X8JZbpRzhsXbTGQIbvBeAjRpU4pAeHzYY-f1c", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /settings/container-bound-sheet/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "13F7zvpjgrURb8LU7xA2X8JZbpRzhsXbTGQIbvBeAjRpU4pAeHzYY-f1c", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /settings/standalone/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "1mt5rBJZH2ZnsoFifXp4BPCg-ftumrOUsSOaWcc5Q5N4Ot3-YHaAsXl9P", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /settings/webapp/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "1HbtO9xPhT-Mxixaz1FyeflFMC3Vuz2PMuaA9yOdMCUlmEhl3tCPqA1Un", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /shims/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["eslint:recommended", "google", "plugin:prettier/recommended"], 3 | "plugins": ["prettier"], 4 | "env": {}, 5 | "rules": { 6 | "prettier/prettier": "error", 7 | "no-var": "off", 8 | "no-unused-vars": ["error", { "varsIgnorePattern": "hslToHex" }], 9 | "valid-jsdoc": "error", 10 | "require-jsdoc": "error", 11 | "prefer-rest-params": "off" 12 | }, 13 | "globals": {} 14 | } 15 | -------------------------------------------------------------------------------- /shims/Array.flat.js: -------------------------------------------------------------------------------- 1 | if (!Array.prototype.flat) { 2 | Object.defineProperty(Array.prototype, 'flat', { 3 | configurable: true, 4 | value: function flat() { 5 | var depth = isNaN(arguments[0]) ? 1 : Number(arguments[0]); 6 | 7 | return depth 8 | ? Array.prototype.reduce.call( 9 | this, 10 | function (acc, cur) { 11 | if (Array.isArray(cur)) { 12 | acc.push.apply(acc, flat.call(cur, depth - 1)); 13 | } else { 14 | acc.push(cur); 15 | } 16 | 17 | return acc; 18 | }, 19 | [] 20 | ) 21 | : Array.prototype.slice.call(this); 22 | }, 23 | writable: true, 24 | }); 25 | } 26 | -------------------------------------------------------------------------------- /shims/Math.sign.js: -------------------------------------------------------------------------------- 1 | // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign 2 | if (!Math.sign) { 3 | Math.sign = function (x) { 4 | x = +x; // convert to a number 5 | if (x === 0 || isNaN(x)) { 6 | return Number(x); 7 | } 8 | return x > 0 ? 1 : -1; 9 | }; 10 | } 11 | -------------------------------------------------------------------------------- /snippets/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["eslint:recommended", "google", "plugin:prettier/recommended"], 3 | "plugins": ["prettier", "googleappsscript"], 4 | "env": { 5 | "googleappsscript/googleappsscript": true 6 | }, 7 | "rules": { 8 | "code": 120, 9 | "prettier/prettier": "error", 10 | "no-var": "off", 11 | "no-unused-vars": ["error", { "varsIgnorePattern": "[on|run]*" }], 12 | "require-jsdoc": "error", 13 | "prefer-rest-params": "off", 14 | "valid-jsdoc": "off", 15 | "no-console": "warn" 16 | }, 17 | "globals": { 18 | "Sheets": true 19 | }, 20 | "parserOptions": { "ecmaVersion": 7 } 21 | } 22 | -------------------------------------------------------------------------------- /snippets/addons/minimal-workspace-drive-addon/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8", 6 | "oauthScopes": ["https://www.googleapis.com/auth/drive.addons.metadata.readonly"], 7 | "addOns": { 8 | "common": { 9 | "name": "Google Apps Script Snippets", 10 | "logoUrl": "https://www.gstatic.com/images/icons/material/system/1x/pets_black_48dp.png", 11 | "homepageTrigger": { 12 | "runFunction": "onHomepage", 13 | "enabled": true 14 | } 15 | }, 16 | "docs": {}, 17 | "sheets": {}, 18 | "slides": {}, 19 | "gmail": {}, 20 | "drive": { 21 | "onItemsSelectedTrigger": { 22 | "runFunction": "onDriveItemsSelected" 23 | } 24 | }, 25 | "calendar": {} 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /snippets/addons/minimal-workspace-drive-addon/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/addons/minimal-workspace-drive-addon/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'To clear all events from a Google Calendar' 3 | date: '2021-03-29' 4 | description: 'Loops through all events and removes them. Demonstrates differences in event types.' 5 | tags: ['calendar'] 6 | categories: ['snippets'] 7 | --- 8 | 9 | {{< toc >}} 10 | 11 | ## Clear all events from a Calendar 12 | 13 | ### Snippet 14 | 15 | - {{< externalLink >}} 16 | - {{< commentLink >}} 17 | - {{< scrvizLink >}} 18 | 19 | {{< codeFromFile "index.js" >}} 20 | 21 | ### Manifest 22 | 23 | {{< codeFromFile "appsscript.json" >}} 24 | -------------------------------------------------------------------------------- /snippets/apps/file-upload-to-drive/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8", 6 | "oauthScopes": ["https://www.googleapis.com/auth/drive.addons.metadata.readonly"], 7 | "addOns": { 8 | "common": { 9 | "name": "Google Apps Script Snippets", 10 | "logoUrl": "https://www.gstatic.com/images/icons/material/system/1x/pets_black_48dp.png", 11 | "homepageTrigger": { 12 | "runFunction": "onHomepage", 13 | "enabled": true 14 | } 15 | }, 16 | "docs": {}, 17 | "sheets": {}, 18 | "slides": {}, 19 | "gmail": {}, 20 | "drive": { 21 | "onItemsSelectedTrigger": { 22 | "runFunction": "onDriveItemsSelected" 23 | } 24 | }, 25 | "calendar": {} 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /snippets/apps/file-upload-to-drive/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/apps/file-upload-to-drive/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'To clear all events from a Google Calendar' 3 | date: '2021-03-29' 4 | description: 'Loops through all events and removes them. Demonstrates differences in event types.' 5 | tags: ['calendar'] 6 | categories: ['snippets'] 7 | --- 8 | 9 | {{< toc >}} 10 | 11 | ## Clear all events from a Calendar 12 | 13 | ### Snippet 14 | 15 | - {{< externalLink >}} 16 | - {{< commentLink >}} 17 | - {{< scrvizLink >}} 18 | 19 | {{< codeFromFile "index.js" >}} 20 | 21 | ### Manifest 22 | 23 | {{< codeFromFile "appsscript.json" >}} 24 | -------------------------------------------------------------------------------- /snippets/apps/importxml-scrapper/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "1VmFn5OjF8zgF3I_mUTJ-FXoGK1D4z0JcJSv0ZkDE0MteHqpCxDVuDE2I", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/apps/importxml-scrapper/1.md: -------------------------------------------------------------------------------- 1 | # importxml-scrapper 2 | 3 | Скрапер на основе формулы IMPORTXML. 4 | 5 | ## Принцип работы 6 | 7 | Метод `scrape` ищет первый лист, в имени которого есть слова `[inproc]` в любом месте в любом регистре. Производит замену подстановки на формулу, дожидается ее расчета, заменяет формулу на ее значение. 8 | 9 | `scrape` по умолчанию делает 50 замен за один вызов. 10 | 11 | Если замен нет, то лист автоматически переименовывается из `[inproc]` в `[done]`. 12 | 13 | В сниппете приведены также элементы меню и создание триггера для автоматического запуска и инициализации новго проекта. 14 | 15 | ## Примеры 16 | 17 | [Последняя версия в Таблице](https://docs.google.com/spreadsheets/d/130aJWlbTvvE2-XqTglb5GngAVjq9U5CHcT2mGhJbRkA/edit?usp=sharing) 18 | -------------------------------------------------------------------------------- /snippets/apps/importxml-scrapper/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/apps/importxml-scrapper/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "single", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/apps/importxml-scrapper/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/apps/importxml-scrapper/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/cache/chunky-cache/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/cache/chunky-cache/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/cache/chunky-cache/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/cache/chunky-cache/screenshot.png -------------------------------------------------------------------------------- /snippets/calendar/clear-all-events/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/calendar/clear-all-events/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/calendar/clear-all-events/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @param {GoogleAppsScript.Calendar.Calendar} calendar 4 | */ 5 | function clearAllEvents_(calendar) { 6 | const marks = []; 7 | return calendar.getEvents(new Date(0), new Date()).map((event) => { 8 | const id = event.getId(); 9 | if (!marks.includes(id)) 10 | if (event.isRecurringEvent()) { 11 | calendar.getEventSeriesById(id).deleteEventSeries(); 12 | marks.push(id); 13 | } else event.deleteEvent(); 14 | return id; 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /snippets/calendar/clear-all-events/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'To clear all events from a Google Calendar' 3 | date: '2021-03-29' 4 | description: 'Loops through all events and removes them. Demonstrates differences in event types.' 5 | tags: ['calendar'] 6 | categories: ['snippets'] 7 | --- 8 | 9 | {{< toc >}} 10 | 11 | ## Clear all events from a Calendar 12 | 13 | ### Snippet 14 | 15 | - {{< externalLink >}} 16 | - {{< commentLink >}} 17 | - {{< scrvizLink >}} 18 | 19 | {{< codeFromFile "index.js" >}} 20 | 21 | ### Run it 22 | 23 | {{< codeFromFile "run.js" >}} 24 | -------------------------------------------------------------------------------- /snippets/calendar/clear-all-events/run.js: -------------------------------------------------------------------------------- 1 | /* global clearAllEvents_ */ 2 | 3 | /** 4 | * 5 | */ 6 | function run() { 7 | const calendar = CalendarApp.getCalendarById('1fq7choqdctaal2sk5i5du43qc@group.calendar.google.com'); 8 | console.log(clearAllEvents_(calendar)); 9 | } 10 | -------------------------------------------------------------------------------- /snippets/calendar/delete-one-of-series/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "V8", 5 | "dependencies": { 6 | "enabledAdvancedServices": [ 7 | { 8 | "userSymbol": "Calendar", 9 | "version": "v3", 10 | "serviceId": "calendar" 11 | } 12 | ] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /snippets/calendar/delete-one-of-series/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/calendar/delete-one-of-series/run.js: -------------------------------------------------------------------------------- 1 | /* global deleteEventFromSeries */ 2 | 3 | /** 4 | * Run the snippet 5 | */ 6 | function run() { 7 | const calendar = CalendarApp.getCalendarById('jllt2nf095qf4ea1pfl1qm1o4o@group.calendar.google.com'); 8 | const now = new Date(); 9 | now.setDate(now.getDate()); 10 | const start = new Date(now); 11 | start.setHours(0, 0, 0, 0); 12 | const end = new Date(now); 13 | end.setHours(23, 59, 59, 999); 14 | end.setDate(end.getDate() + 2); 15 | console.log(deleteEventFromSeries(calendar.getId(), start, end, 'event')); 16 | } 17 | -------------------------------------------------------------------------------- /snippets/calendar/delete-one-of-series/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/calendar/delete-one-of-series/screenshot.png -------------------------------------------------------------------------------- /snippets/common_js/2darray_to_collection/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/common_js/2darray_to_collection/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/common_js/2darray_to_collection/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Converts a 2D array to a collection. 3 | * 4 | * @param {Array.>} array 5 | * @returns {Array.} 6 | */ 7 | function arrayToCollection_(array) { 8 | return array.slice(1).map( 9 | (_, rowIndex) => 10 | array[0].reduce((rowCollection, header, columnIndex) => { 11 | rowCollection[header] = array[rowIndex + 1][columnIndex]; 12 | return rowCollection; 13 | }, {}), 14 | [] 15 | ); 16 | } 17 | -------------------------------------------------------------------------------- /snippets/common_js/2darray_to_collection/index.min.js: -------------------------------------------------------------------------------- 1 | function arrtocoll_(e) { 2 | return e.slice(1).map((r, c) => e[0].reduce((r, n, o) => ((r[n] = e[c + 1][o]), r), {}), []); 3 | } 4 | -------------------------------------------------------------------------------- /snippets/common_js/2darray_to_collection/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/common_js/2darray_to_collection/screenshot.png -------------------------------------------------------------------------------- /snippets/common_js/column_names_and_numbers/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/common_js/column_names_and_numbers/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/common_js/column_names_and_numbers/test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | function runTest() { 5 | let n = 0; 6 | while (n <= 1000) { 7 | const curN = n; 8 | const nextCol = base26ABCfrom10(curN + 1); 9 | n = base26ABCto10(nextCol); 10 | console.log(`${n} ~ ${nextCol}`); 11 | if (n !== curN + 1) console.error(`Unexpected output: "${n} ~ ${nextCol}"`); 12 | } 13 | } 14 | 15 | /** 16 | * 17 | */ 18 | function runTestArt() { 19 | const strings = ['ABC', 'AF', 'ALEX', 'ALL', 'COFE', 'GAS', 'TEA', 'UI']; 20 | console.log(strings.map((string) => [string, base26ABCto10(string)])); 21 | 22 | const numbers = [255, 1000, 2048, new Date().getTime()]; 23 | console.log(numbers.map((number) => [number, base26ABCfrom10(number)])); 24 | } 25 | -------------------------------------------------------------------------------- /snippets/common_js/column_names_and_numbers/tools.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | function genMDStrForPost() { 5 | console.log( 6 | ['a', 'b', 'c', '...', 'y', 'z', 'aa', '...', 'zz'] 7 | .map( 8 | (s) => 9 | ' - ' + 10 | (s.toLowerCase().charCodeAt(0) >= 64 11 | ? `${s.toUpperCase()}26 = ${s}26 = ${base26ABCto10(s)}10` 12 | : s) 13 | ) 14 | .join('\n') 15 | ); 16 | } 17 | 18 | /** 19 | * 20 | */ 21 | function genFirs250ColumnNumbers() { 22 | console.log( 23 | [...Array(251).keys()] 24 | .slice(1) 25 | .map((n) => ` - ${base26ABCfrom10(n)} = ${n}`) 26 | .join('\n') 27 | ); 28 | } 29 | -------------------------------------------------------------------------------- /snippets/common_js/date-range-iterator/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/common_js/date-range-iterator/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/common_js/date-range-iterator/index.js: -------------------------------------------------------------------------------- 1 | /* exported makeDatesRangeIterator */ 2 | /** 3 | * 4 | * @param {Date} start 5 | * @param {Date} end 6 | * @param {number} step ms 7 | */ 8 | function* makeDatesRangeIterator_(start, end, step = 1000 * 60 * 60 * 24) { 9 | const _start = new Date(start); 10 | let _iterationCount = 0; 11 | while (_start <= end) { 12 | _iterationCount++; 13 | yield _start; 14 | _start.setTime(_start.getTime() + step); 15 | } 16 | return _iterationCount; 17 | } 18 | -------------------------------------------------------------------------------- /snippets/common_js/date-range-iterator/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Date range iterator' 3 | date: '2021-04-19' 4 | description: 'Gets an iterator of dates for the specified range.' 5 | tags: ['js', 'common'] 6 | categories: ['snippets'] 7 | images: ['./snippets/sheets/date-range-iterator/screenshot.png'] 8 | --- 9 | 10 | {{< toc >}} 11 | 12 | ## Date range iterator 13 | 14 | ![Snippet of Date range iterator](./screenshot.png) 15 | 16 | ### Snippet 17 | 18 | - {{< externalLink >}} 19 | - {{< commentLink >}} 20 | - {{< scrvizLink >}} 21 | 22 | {{< codeFromFile "index.js" >}} 23 | 24 | ### Run it 25 | 26 | {{< codeFromFile "run.js" >}} 27 | -------------------------------------------------------------------------------- /snippets/common_js/date-range-iterator/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/common_js/date-range-iterator/screenshot.png -------------------------------------------------------------------------------- /snippets/common_js/get_id_from_url/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/common_js/get_id_from_url/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/common_js/get_id_from_url/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Gets ID from URL 3 | * 4 | * @param {string} url The file url 5 | * @returns {string} The file id 6 | */ 7 | function getIdFromUrl(url) { 8 | const match = url.match(/[\w-_]{15,}/); 9 | return match ? match[0] : undefined; 10 | } 11 | -------------------------------------------------------------------------------- /snippets/common_js/get_id_from_url/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Get file/folder ID from url' 3 | date: '2021-03-07' 4 | description: 'Shows how to get file ID from url' 5 | tags: ['js', 'common'] 6 | categories: ['snippets'] 7 | --- 8 | 9 | {{< toc >}} 10 | 11 | ## Get file/folder ID from url 12 | 13 | ### Snippet 14 | 15 | - {{< externalLink >}} 16 | - {{< commentLink >}} 17 | - {{< scrvizLink >}} 18 | 19 | {{< codeFromFile "index.js" >}} 20 | 21 | ### Run it 22 | 23 | {{< codeFromFile "run.js" >}} 24 | 25 | ### Test 26 | 27 | > Info! You need enable `Drive` advanced service manually 28 | 29 | {{< codeFromFile "test.js" >}} 30 | -------------------------------------------------------------------------------- /snippets/common_js/get_id_from_url/run.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This code runs the snippet 3 | */ 4 | function run() { 5 | let url = 'https://docs.google.com/spreadsheets/d/19GRd3EarV_SM3Y8MYdpWvQNYZVZgLZih4EO4gX_JSko/edit#gid=1702180728'; 6 | console.log(getIdFromUrl(url)); 7 | url = 'https://drive.google.com/drive/folders/1nUB4UDrCNSbNmjSXy2H5DNz09s1LDEIb'; 8 | console.log(getIdFromUrl(url)); 9 | } 10 | -------------------------------------------------------------------------------- /snippets/common_js/sheet_datetime/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/common_js/sheet_datetime/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/common_js/sheet_datetime/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Converts date-time to numeric Sheets format 3 | * 4 | * @param {(number|Date)} date JS Date or time in ms 5 | * @param {number} timezoneOffset 6 | * @return {number} Google Sheets Date number 7 | */ 8 | function toGoogleSheetsDateNumber(date, timezoneOffset) { 9 | const _date = new Date(date); 10 | timezoneOffset = timezoneOffset || _date.getTimezoneOffset(); 11 | const _start = new Date(Date.UTC(1899, 11, 30, 0, 0, 0, 0)); 12 | return ((_date.getTime() - _start.getTime()) / 60000 - timezoneOffset) / 1440; 13 | } 14 | -------------------------------------------------------------------------------- /snippets/common_js/sheet_datetime/run.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Returns Sheets datetime number from date of F5 cell 3 | * @customfunction 4 | */ 5 | function GETSHEETDATETIMENUMBER() { 6 | return toGoogleSheetsDateNumber(SpreadsheetApp.getActiveSheet().getRange('F5').getValue()); 7 | } 8 | -------------------------------------------------------------------------------- /snippets/common_ui/check_ui/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "V8" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/common_ui/check_ui/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/common_ui/check_ui/index.js: -------------------------------------------------------------------------------- 1 | /* "runtimeVersion": "STABLE" */ 2 | 3 | /** 4 | * @param {GoogleAppsScript.Events.SheetsOnChange} e 5 | */ 6 | function asdfsd() { 7 | // SpreadsheetApp.getActive(); 8 | // SlidesApp.get.getActivePresentation(); 9 | 10 | // console.log( 11 | // ['Spreadsheet', 'Document', 'Slides'].map(app => 12 | // this[`${app}App`].getActive() 13 | // ) 14 | // ); 15 | console.log(this['Slides' + 'App']['getActivePresentation']()); 16 | } 17 | -------------------------------------------------------------------------------- /snippets/common_ui/open-dialog-from-sidebar/app/dialog.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 |
Hi!
11 |
I'm the dialog
12 | 13 | 14 | -------------------------------------------------------------------------------- /snippets/common_ui/open-dialog-from-sidebar/app/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Opens the sidebar 3 | */ 4 | function openSidebarDialog() { 5 | SpreadsheetApp.getUi().showSidebar(HtmlService.createHtmlOutputFromFile('app/sidebar.html')); 6 | } 7 | 8 | /** 9 | * Opens the modal dialog 10 | */ 11 | function showModalDialog() { 12 | SpreadsheetApp.getUi().showModalDialog(HtmlService.createHtmlOutputFromFile('app/dialog.html'), 'Modal dialog'); 13 | } 14 | -------------------------------------------------------------------------------- /snippets/common_ui/open-dialog-from-sidebar/app/sidebar.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | Show the modal dialog 11 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /snippets/common_ui/open-dialog-from-sidebar/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/common_ui/open-dialog-from-sidebar/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/common_ui/open-dialog-from-sidebar/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Open an dialog from the sidebar' 3 | date: '2021-08-27' 4 | description: 'The snippet demonstrates how to open additional UI elements in Google Sheets.' 5 | tags: ['common_ui'] 6 | categories: ['snippets'] 7 | --- 8 | 9 | ## Open an dialog from the sidebar 10 | 11 | {{< toc >}} 12 | 13 | 17 | 18 | - {{< externalLink >}} 19 | - {{< commentLink >}} 20 | - {{< scrvizLink >}} 21 | 22 | ### The main code 23 | 24 | {{< codeFromFile "app/sidebar.html" >}} 25 | {{< codeFromFile "app/index.js" >}} 26 | 27 | ### Run it 28 | 29 | {{< codeFromFile "run.js" >}} 30 | 31 | {{< clipboard >}} 32 | -------------------------------------------------------------------------------- /snippets/common_ui/open-dialog-from-sidebar/run.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Runs the snippet 3 | */ 4 | function run() { 5 | openSidebarDialog(); 6 | } 7 | -------------------------------------------------------------------------------- /snippets/common_ui/open-dialog-from-sidebar/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/common_ui/open-dialog-from-sidebar/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/common_ui/open-dialog-from-sidebar/triggerActionss.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Create menu for handy use 3 | */ 4 | function onOpen() { 5 | SpreadsheetApp.getUi().createMenu('Apps Script Snippets').addItem('Open sidebar', 'run').addToUi(); 6 | } 7 | -------------------------------------------------------------------------------- /snippets/common_ui/open_url_in_browser/app.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 |
12 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /snippets/common_ui/open_url_in_browser/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/common_ui/open_url_in_browser/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/common_ui/open_url_in_browser/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Open an url in browser' 3 | date: '2021-02-21' 4 | description: '' 5 | tags: [] 6 | categories: ['snippets'] 7 | --- 8 | 9 | ## Open an url in browser 10 | 11 | This snippet shows how to open a link using Apps Script in a browser. As a particular example it shows how to get/create a file and open it in browser. 12 | This may not always work as browsers protect tabs from opening spontaneously. 13 | 14 | - {{< externalLink >}} 15 | - {{< commentLink >}} 16 | - {{< scrvizLink >}} 17 | 18 | {{< codeFromFile "index.js" >}} 19 | {{< codeFromFile "app.html" >}} 20 | {{< codeFromFile "appsscript.json" >}} 21 | 22 | {{< clipboard >}} 23 | -------------------------------------------------------------------------------- /snippets/common_ui/open_url_in_browser/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/common_ui/open_url_in_browser/screenrecord.gif -------------------------------------------------------------------------------- /snippets/common_ui/open_url_in_browser/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/common_ui/open_url_in_browser/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/common_ui/sheet_sidebar_select/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/common_ui/sheet_sidebar_select/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/customfunctions/GETSHEETS/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8", 6 | "sheets": { 7 | "macros": [ 8 | { 9 | "menuName": "Generate TOC", 10 | "functionName": "userActionGenerateTOC", 11 | "defaultShortcut": "Ctrl+Alt+Shift+1" 12 | } 13 | ] 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /snippets/customfunctions/GETSHEETS/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/customfunctions/GETSHEETS/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/customfunctions/GETSHEETS/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/customfunctions/LET/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/customfunctions/LET/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/customfunctions/LET/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/customfunctions/LET/screenrecord.gif -------------------------------------------------------------------------------- /snippets/customfunctions/LET/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/customfunctions/LET/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/customfunctions/PARSEAPINET/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "13SPrXX9Xn-Peg_ZEvVhD_PMDPlBIQRHWtY4oRKRLoQXDcaLZmKXsEiDq", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/customfunctions/PARSEAPINET/Code.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @param {any} pics 4 | * @param {Boolean} increase 5 | */ 6 | function PARSEAPINET(pics, increase) { 7 | return (Array.isArray(pics) ? pics : [[pics]]).map((row) => { 8 | try { 9 | const obj = JSON.parse(row[0]); 10 | if (!!increase === true) return obj.map((pic) => Array(pic[1]).fill(pic[4])).flat(); 11 | else return obj.map((pic) => pic[4]); 12 | } catch (err) { 13 | return ['#ERR.PARSEAPINET']; 14 | } 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /snippets/customfunctions/PARSEAPINET/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "America/New_York", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/customfunctions/PARSEAPINET/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "single", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/customfunctions/RAINREPORT/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "1cYjSy-JHkip9vmlDdxxUP5o1Fu4xF3EV5fov1djyh7Xcp5fVPDfh9Qbv", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/customfunctions/RAINREPORT/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "V8" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/customfunctions/RAINREPORT/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "single", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/customfunctions/customfunction_flatten-arguments/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/customfunctions/customfunction_flatten-arguments/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": ["./shims/Array.flat.js"] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/customfunctions/customfunction_jaro-winker-distance/1.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Сходство Джаро — Винклера 3 | show: true 4 | --- 5 | 6 | ## Сходство Джаро — Винклера 7 | 8 | Сниппет демонстиррует применение расчета [Сходства Джаро — Винклера](https://ru.wikipedia.org/wiki/Сходство_Джаро_—_Винклера) 9 | 10 | 11 | 12 | [![Watch the video](https://img.youtube.com/vi/UeULVV1wylU/hqdefault.jpg)](https://youtu.be/UeULVV1wylU) 13 | -------------------------------------------------------------------------------- /snippets/customfunctions/customfunction_jaro-winker-distance/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": [], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/customfunctions/customfunction_jaro-winker-distance/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": ["./node_modules/jaro-winkler/index.js"] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/customfunctions/customfunction_jaro-winker-distance/jaro-winker-distance.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Returns Jaro–Winkler distance 3 | * @param {string} s1 4 | * @param {string} s2 5 | * @param {boolean} caseSensetive 6 | * @return {number} 7 | * @customfunction 8 | */ 9 | function DISTANCE_JW(s1, s2, caseSensetive) { 10 | return distance(s1, s2, { caseSensitive: !!caseSensetive }); 11 | } 12 | -------------------------------------------------------------------------------- /snippets/customfunctions/customfunction_union_ranges/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "enabledAdvancedServices": [], 5 | "libraries": [] 6 | }, 7 | "exceptionLogging": "STACKDRIVER" 8 | } 9 | -------------------------------------------------------------------------------- /snippets/customfunctions/using_cache_service/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "19luPd6NC4s1J6tex6jFzEKZkYXNQeYJ5Tz5HYU9hE4TQBLZeeSDGdgpn", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/customfunctions/using_cache_service/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "V8" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/customfunctions/using_cache_service/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "single", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/customfunctions/using_cache_service/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @see {@link https://docs.google.com/spreadsheets/d/11Z1pT2y28Bwm6QikGMH_kB-MehuKak3liJ8b4bbTJ9E/edit?usp=sharing} 4 | * @see {@link https://qna.habr.com/q/778215} 5 | */ 6 | 7 | /* exported TESTCACHESERVICE */ 8 | 9 | /** 10 | * @OnlyCurrentDoc 11 | */ 12 | 13 | /** 14 | * 15 | * The TESTCACHESERVICE function 16 | * 17 | * @param {param} param 18 | * @return {number} 19 | * @customfunction 20 | */ 21 | function TESTCACHESERVICE(param) { 22 | const cache = CacheService.getScriptCache(); 23 | const cached = param === 'break' ? 0 : +cache.get('cached') + 1 || 0; 24 | cache.put('cached', cached); 25 | return cached; 26 | } 27 | -------------------------------------------------------------------------------- /snippets/docs/api_find_and_replace_named_ranges/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "enabledAdvancedServices": [ 5 | { 6 | "userSymbol": "Docs", 7 | "serviceId": "docs", 8 | "version": "v1" 9 | } 10 | ] 11 | }, 12 | "exceptionLogging": "STACKDRIVER", 13 | "runtimeVersion": "V8" 14 | } 15 | -------------------------------------------------------------------------------- /snippets/docs/api_find_and_replace_named_ranges/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-doc", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/docs/create_footnote/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "enabledAdvancedServices": [ 5 | { 6 | "userSymbol": "Docs", 7 | "serviceId": "docs", 8 | "version": "v1" 9 | } 10 | ] 11 | }, 12 | "exceptionLogging": "STACKDRIVER", 13 | "runtimeVersion": "V8" 14 | } 15 | -------------------------------------------------------------------------------- /snippets/docs/create_footnote/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-doc", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/docs/create_footnote/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Create a footnote' 3 | date: '2021-02-17' 4 | description: 'Shows how to create new footnotes' 5 | tags: ['Docs advanced service'] 6 | categories: ['snippets'] 7 | --- 8 | 9 | ## Create footnote 10 | 11 | This snippet demonstrates the ability to create new footnotes by referencing the document body. Note, you will need to find the position index in the body before to insert a footnote. 12 | 13 | - {{< externalLink >}} 14 | - {{< commentLink >}} 15 | - {{< scrvizLink >}} 16 | 17 | {{< codeFromFile "index.js" >}} 18 | {{< codeFromFile "appsscript.json" >}} 19 | -------------------------------------------------------------------------------- /snippets/docs/docs_push_2D_array_to_table/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/documents"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER", 6 | "runtimeVersion": "V8" 7 | } 8 | -------------------------------------------------------------------------------- /snippets/docs/docs_push_2D_array_to_table/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-doc", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/docs/document-copy_and_replace/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/docs/document-copy_and_replace/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-doc", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/docs/document-copy_and_replace/copy_and_replace.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Copy the template and replace text 3 | * @url https://ru.stackoverflow.com/questions/1073978 4 | */ 5 | 6 | /** 7 | * Run the snippet 8 | */ 9 | function run() { 10 | var doc = DocumentApp.getActiveDocument(); 11 | var copy = copyAndReplace_(doc); 12 | Logger.log(copy); 13 | } 14 | 15 | /** 16 | * 17 | * @param {GoogleAppsScript.Document.Document} template 18 | * @return {GoogleAppsScript.Document.Document} 19 | */ 20 | function copyAndReplace_(template) { 21 | var copy = DriveApp.getFileById(template.getId()).makeCopy(); 22 | var newDoc = DocumentApp.openById(copy.getId()); 23 | newDoc.getBody().replaceText('a', ' '); 24 | newDoc.saveAndClose(); 25 | return newDoc; 26 | } 27 | -------------------------------------------------------------------------------- /snippets/docs/document_center-align-table-cell-content/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/documents"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/docs/document_center-align-table-cell-content/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-doc", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/docs/document_center-align-table-cell-content/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/docs/document_center-align-table-cell-content/screenshot.png -------------------------------------------------------------------------------- /snippets/docs/document_copy-inline-image/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": [ 4 | "https://www.googleapis.com/auth/documents", 5 | "https://www.googleapis.com/auth/drive", 6 | "https://www.googleapis.com/auth/script.external_request" 7 | ], 8 | "dependencies": { 9 | "enabledAdvancedServices": [], 10 | "libraries": [] 11 | }, 12 | "exceptionLogging": "STACKDRIVER" 13 | } 14 | -------------------------------------------------------------------------------- /snippets/docs/document_copy-inline-image/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": ["./shims/Array.find.js", "./shims/Array.findIndex.js"] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/docs/document_paste-data-to-selection/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/documents"], 4 | "dependencies": { 5 | "enabledAdvancedServices": [], 6 | "libraries": [] 7 | }, 8 | "exceptionLogging": "STACKDRIVER" 9 | } 10 | -------------------------------------------------------------------------------- /snippets/docs/document_paste-data-to-selection/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-doc", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/docs/document_paste-data-to-selection/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/docs/document_paste-data-to-selection/screenrecord.gif -------------------------------------------------------------------------------- /snippets/docs/document_paste-data-to-selection/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/docs/document_paste-data-to-selection/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/docs/find_and_replace_bulk/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "enabledAdvancedServices": [ 5 | { 6 | "userSymbol": "Docs", 7 | "serviceId": "docs", 8 | "version": "v1" 9 | } 10 | ] 11 | }, 12 | "exceptionLogging": "STACKDRIVER", 13 | "runtimeVersion": "V8" 14 | } 15 | -------------------------------------------------------------------------------- /snippets/docs/find_and_replace_bulk/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-doc", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/docs/find_and_replace_bulk/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Find and replace multiple pairs of occurrences' 3 | date: '2021-02-18' 4 | description: 'Sample article showcasing basic Markdown syntax and formatting for HTML elements.' 5 | tags: ['Docs advanced service'] 6 | categories: ['snippets'] 7 | --- 8 | 9 | ## Find and replace multiple pairs of occurrences 10 | 11 | This snippet shows how you can find and replace multiple data entries at once. For example, you want to replace the text "`{{datetime}}`" with the current time, and "`{{signature}}`" with the signature. You will need a settings object. See how it is written in code: 12 | 13 | - {{< externalLink >}} 14 | - {{< commentLink >}} 15 | - {{< scrvizLink >}} 16 | 17 | {{< codeFromFile "index.js" >}} 18 | {{< codeFromFile "appsscript.json" >}} 19 | -------------------------------------------------------------------------------- /snippets/docs/horizontal_align_samples/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "V8" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/docs/horizontal_align_samples/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-doc", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/docs/insert_image/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "V8" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/docs/insert_image/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-doc", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/docs/uncheck-checklist/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "enabledAdvancedServices": [ 5 | { 6 | "userSymbol": "Docs", 7 | "serviceId": "docs", 8 | "version": "v1" 9 | } 10 | ] 11 | }, 12 | "exceptionLogging": "STACKDRIVER", 13 | "runtimeVersion": "V8" 14 | } 15 | -------------------------------------------------------------------------------- /snippets/docs/uncheck-checklist/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-doc", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/docs/uncheck-checklist/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Check/uncheck the entire checklist in the Document 3 | * 4 | * @param {GoogleAppsScript.Document.Document} doc A Document 5 | * @param {string} index The checklist id 6 | */ 7 | function uncheckListById_(doc, id) { 8 | const body = doc.getBody(); 9 | const lists = body.getListItems().filter((l) => l.getListId() === id); 10 | const last = lists.splice(-1)[0]; 11 | lists.reverse().forEach((item) => { 12 | const copy = last.copy(); 13 | copy.asListItem().setText(item.asListItem().getText()); 14 | body.insertListItem(body.getChildIndex(item), copy); 15 | item.removeFromParent(); 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /snippets/docs/uncheck-checklist/run.js: -------------------------------------------------------------------------------- 1 | /* global uncheckListById_ */ 2 | 3 | /** 4 | * Run the snippet 5 | */ 6 | function run() { 7 | uncheckListById_(DocumentApp.getActiveDocument(), 'kix.yy1s6bgaip7h'); 8 | } 9 | 10 | /** 11 | * Prints ids of lists in the current Document 12 | */ 13 | function printListIds() { 14 | console.log(getListIds_(DocumentApp.getActiveDocument())); 15 | } 16 | 17 | /** 18 | * Gets ids of lists in the current Document 19 | * 20 | * @param {globalThis.DocumentApp.Document} doc 21 | */ 22 | function getListIds_(doc) { 23 | return doc 24 | .getBody() 25 | .getListItems() 26 | .reduce((a, c) => { 27 | const id = c.getListId(); 28 | if (a.indexOf(id) === -1) a.push(id); 29 | return a; 30 | }, []); 31 | } 32 | -------------------------------------------------------------------------------- /snippets/docs/uncheck-checklist/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/docs/uncheck-checklist/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/docs/uncheck-checklist/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/docs/uncheck-checklist/screenshot.png -------------------------------------------------------------------------------- /snippets/docs/uncheck-checklist/triggerActions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates the user menu for handy use. 3 | */ 4 | function onOpen() { 5 | DocumentApp.getUi().createMenu('Checklists').addItem('Mark the list as its last item', 'run').addToUi(); 6 | } 7 | -------------------------------------------------------------------------------- /snippets/drive/convert_file_to_drive_format/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "enabledAdvancedServices": [ 5 | { 6 | "userSymbol": "Drive", 7 | "version": "v2", 8 | "serviceId": "drive" 9 | } 10 | ] 11 | }, 12 | "exceptionLogging": "STACKDRIVER", 13 | "runtimeVersion": "V8" 14 | } 15 | -------------------------------------------------------------------------------- /snippets/drive/convert_file_to_drive_format/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/drive/convert_file_to_drive_format/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | function convert() { 5 | const blob = UrlFetchApp.fetch( 6 | 'https://file-examples-com.github.io/uploads/2017/02/file_example_XLS_10.xls' 7 | ).getBlob(); 8 | 9 | const file = DriveApp.createFile(blob); 10 | Drive.Files.copy( 11 | { 12 | title: 'New file', 13 | }, 14 | file.getId(), 15 | { convert: true } 16 | ); 17 | file.setTrashed(true); 18 | } 19 | -------------------------------------------------------------------------------- /snippets/drive/copying_access_rights_between_two_entities/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "V8", 5 | "dependencies": { 6 | "enabledAdvancedServices": [ 7 | { 8 | "userSymbol": "Drive", 9 | "serviceId": "drive", 10 | "version": "v2" 11 | } 12 | ], 13 | "libraries": [ 14 | { 15 | "userSymbol": "BatchRequest", 16 | "libraryId": "1HLv6tWz0oXFOJHerBTP8HsNmhpRqssijJatC92bv9Ym6HSN69_UuzcDk", 17 | "version": "5" 18 | } 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /snippets/drive/copying_access_rights_between_two_entities/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/drive/drive-upload_file_from_url/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/drive/drive-upload_file_from_url/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/drive/drive-upload_file_from_url/upload_file_from_url.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dowload a file from the url to Drive 3 | * @url https://developer.mozilla.org/en-US/docs/Web/API/URL 4 | */ 5 | 6 | /* exported userActionRun */ 7 | 8 | /** 9 | * User action. Runs the snippet 10 | */ 11 | function userActionRun() { 12 | var url = 'https://admin.singlaapparels.com/Main/fileurl/64F619B8-C2BE-4EDF-BF9B-01FD60C5D957/4/RakeshKumar.jpg'; 13 | var blob = UrlFetchApp.fetch(url).getBlob(); 14 | DriveApp.createFile(blob); 15 | } 16 | -------------------------------------------------------------------------------- /snippets/drive/drive_change_user_role/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "enabledAdvancedServices": [ 5 | { 6 | "userSymbol": "Drive", 7 | "serviceId": "drive", 8 | "version": "v2" 9 | } 10 | ], 11 | "libraries": [] 12 | }, 13 | "exceptionLogging": "STACKDRIVER" 14 | } 15 | -------------------------------------------------------------------------------- /snippets/drive/driveapp_change_owner_in_folder/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "libraries": [] 5 | }, 6 | "exceptionLogging": "STACKDRIVER" 7 | } 8 | -------------------------------------------------------------------------------- /snippets/drive/save_file_to_drive/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/drive/save_file_to_drive/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/drive/save_file_to_drive/index.js: -------------------------------------------------------------------------------- 1 | /* exported run */ 2 | 3 | /** 4 | * Runs the example 5 | * @ignore 6 | */ 7 | function run() { 8 | // https://people.sc.fsu.edu/~jburkardt/data/csv/csv.html 9 | const file = saveFileFromUrl_('https://people.sc.fsu.edu/~jburkardt/data/csv/addresses.csv'); 10 | console.log(file.getName()); 11 | } 12 | 13 | /** 14 | * 15 | * @param {string} url 16 | * @return {GoogleAppsScript.Drive.File} 17 | */ 18 | function saveFileFromUrl_(url) { 19 | const blob = UrlFetchApp.fetch(url).getBlob(); 20 | return DriveApp.createFile(blob); 21 | } 22 | -------------------------------------------------------------------------------- /snippets/drive/utf8_bom_to_utf8/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "V8" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/drive/utf8_bom_to_utf8/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/external/czech-national-bank-public-api/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/external/czech-national-bank-public-api/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/external/czech-national-bank-public-api/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @url https://qna.habr.com/q/779817 4 | */ 5 | 6 | /** 7 | * Get currencies by a date 8 | */ 9 | function run() { 10 | const httpResponse = UrlFetchApp.fetch( 11 | 'https://www.cnb.cz/cs/financni-trhy/devizovy-trh/kurzy-devizoveho-trhu/kurzy-devizoveho-trhu/denni_kurz.txt?date=20.05.2020' 12 | ); 13 | const data = Utilities.newBlob(httpResponse.getContent(), 'plain/text') 14 | .getDataAsString() 15 | .split('\n') 16 | .map((line) => line.split('|')) 17 | .slice(1); 18 | console.log(data); 19 | /* 20 | // Paste to a sheet 21 | sheet.getRange(1, 1, data.length, data[0].length).setValues(data); 22 | */ 23 | } 24 | -------------------------------------------------------------------------------- /snippets/external/external_forismatic_com/external_forismatic_com.js: -------------------------------------------------------------------------------- 1 | function forismatic() { 2 | return JSON.parse( 3 | UrlFetchApp.fetch( 4 | 'http://api.forismatic.com/api/1.0/?method=getQuote&key=457653&format=json&lang=ru' 5 | ).getContentText() 6 | )['quoteText']; 7 | } 8 | -------------------------------------------------------------------------------- /snippets/external/external_smartlabru/Code.gs: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @param param 4 | */ 5 | function getIO(param) { 6 | param = param || {}; 7 | var _ = {}; 8 | _.type = param.type || 'D'; 9 | _.url = param.url || ''; 10 | 11 | switch (_.type.toUpperCase()) { 12 | case 'D': 13 | _.url = 'http://smart-lab.ru/indeks-optimizma//download/'; 14 | break; 15 | case 'W': 16 | _.url = 'http://smart-lab.ru/indeks-optimizma//download_week/'; 17 | } 18 | var fetch = UrlFetchApp.fetch(_.url); 19 | var csv = fetch.getBlob().getDataAsString('Windows-1251'); 20 | csv = csv.replace(/(;\d+),(\d+;)/g, '$1.$2'); 21 | csv = csv.replace(/<.*>/g, ''); 22 | csv = csv.replace(/^\s*[\r\n]/gm, ''); 23 | var values = Utilities.parseCsv(csv, ';'); 24 | return values; 25 | } 26 | -------------------------------------------------------------------------------- /snippets/external/external_smartlabru/README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | - DOCS https://script.google.com/macros/library/versions/d/MUjQ0enKqP-RKxsvJNoWR8vVsbLCrn_6h 4 | - SUBJECT http://smart-lab.ru/indeks-optimizma/ 5 | - LIB KEY MUjQ0enKqP-RKxsvJNoWR8vVsbLCrn_6h 6 | -------------------------------------------------------------------------------- /snippets/extra/xml-js_demo/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/extra/xml-js_demo/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": ["shims/xml-js.js"] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/extra/xml-js_demo/init.js: -------------------------------------------------------------------------------- 1 | !(function (global) { 2 | const window = {}; 3 | global.window = window; 4 | global.convert = window; 5 | })(this); 6 | -------------------------------------------------------------------------------- /snippets/extra/xml-js_demo/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Sample for xml-js' 3 | date: '2021-08-02' 4 | description: 'Using xml-js for Apps Script' 5 | tags: ['extra'] 6 | categories: ['snippets'] 7 | --- 8 | 9 | ## Using xml-js for Apps Script 10 | 11 | {{< toc >}} 12 | 13 | ### Snippet 14 | 15 | - {{< externalLink >}} 16 | - {{< commentLink >}} 17 | - {{< scrvizLink >}} 18 | 19 | ### Run it 20 | 21 | {{< codeFromFile "run.js" >}} 22 | 23 | ### Init it before using 24 | 25 | {{< codeFromFile "init.js" >}} 26 | 27 | {{< clipboard >}} 28 | -------------------------------------------------------------------------------- /snippets/forms/arrange_list/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/forms/arrange_list/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/forms/create_file_upload_field/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/forms/create_file_upload_field/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/forms/get_pre_fill_entries_map/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/forms/get_pre_fill_entries_map/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/forms/on_form_submit_event/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": [], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/forms/on_form_submit_event/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-form", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/forms/on_form_submit_event/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @param {GoogleAppsScript.Events.FormsOnSubmit} e 4 | */ 5 | function omFormSubmit(e) { 6 | console.log(Object.keys(e), JSON.stringify(e.namedValues)); 7 | } 8 | -------------------------------------------------------------------------------- /snippets/forms/send_other_multiple_choice/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/forms/send_other_multiple_choice/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/forms/send_other_multiple_choice/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copies a template and builds a new Form 3 | */ 4 | function run() { 5 | const form = FormApp.openById('1JInxW42UFZPSADPPw-qU9qPMSXYwrchtjqAoQHO3-7I'); 6 | console.log(submitResponse_(form).getEditResponseUrl()); 7 | } 8 | 9 | /** 10 | * 11 | * @param {GoogleAppsScript.Forms.Form} form 12 | * @return {GoogleAppsScript.Forms.FormResponse} 13 | */ 14 | function submitResponse_(form) { 15 | const response = form.createResponse(); 16 | 17 | const text = form.getItems()[1].asTextItem(); 18 | 19 | const itemText = text.createResponse('asdfasdf'); 20 | 21 | const mch = form.getItems()[0].asMultipleChoiceItem(); 22 | 23 | const itemMch = mch.createResponse('Russia'); 24 | 25 | return response.withItemResponse(itemText).withItemResponse(itemMch).submit(); 26 | } 27 | -------------------------------------------------------------------------------- /snippets/gae/start_stop_instance/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8", 6 | "oauthScopes": [ 7 | "https://www.googleapis.com/auth/cloud-platform", 8 | "https://www.googleapis.com/auth/compute", 9 | "https://www.googleapis.com/auth/compute.readonly", 10 | "https://www.googleapis.com/auth/script.external_request" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /snippets/gae/start_stop_instance/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/gmail/answering_machine/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "1KfczoNvR_UTYHPhsIy6SCJe152BDurhhs-1HQLqqKLbUs5DUcO86oTCY", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/gmail/answering_machine/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/gmail/answering_machine/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/gmail/forward_without_attachments/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/gmail/forward_without_attachments/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/gpf/copy_paste_data_between_sheets/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "1AFFlipENpF9bn8XubPpDa71apZjjneOm5trnoUht98cQwugrZGC4_V9k", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/gpf/copy_paste_data_between_sheets/Code2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @see {@link https://support.google.com/docs/thread/38835811} 4 | */ 5 | 6 | /** 7 | * 8 | */ 9 | function copyData_() { 10 | const book = SpreadsheetApp.getActive(); 11 | const data = book 12 | .getRange('Sheet2!E:F') 13 | .getValues() 14 | .filter((row) => row.some((cell) => cell !== '')); 15 | const target = book.getSheetByName('Sheet1'); 16 | const targetData = target.getRange('A:B').getValues(); 17 | const lastRow = targetData.length - targetData.reverse().findIndex((row) => row.some((cell) => cell !== '')); 18 | if (data.length) target.getRange(lastRow + 1, 1, data.length, data[0].length).setValues(data); 19 | } 20 | -------------------------------------------------------------------------------- /snippets/gpf/copy_paste_data_between_sheets/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "America/New_York", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8", 6 | "sheets": { 7 | "macros": [ 8 | { 9 | "menuName": "Macro 1", 10 | "functionName": "Macro1" 11 | }, 12 | { 13 | "menuName": "Paste across sheets", 14 | "functionName": "Pasteacrosssheets" 15 | }, 16 | { 17 | "menuName": "Copy data", 18 | "functionName": "CopyDataMacro" 19 | } 20 | ] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /snippets/gpf/copy_paste_data_between_sheets/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "single", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/gpf/copy_paste_data_between_sheets/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/gpf/copy_paste_data_between_sheets/screenrecord.gif -------------------------------------------------------------------------------- /snippets/gpf/copy_paste_data_between_sheets/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/gpf/copy_paste_data_between_sheets/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/js/datesRangeIterator/1590513969504.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/js/datesRangeIterator/1590513969504.png -------------------------------------------------------------------------------- /snippets/js/datesRangeIterator/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/js/datesRangeIterator/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/patterns/bootstrap_jquery/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "1VpI6PRVsIQ08W6gIHs2y1UlIbGBOeQSHXxiUZxvODqRZ06Ziz_ylLyXp", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/patterns/bootstrap_jquery/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "webapp": { 5 | "access": "MYSELF", 6 | "executeAs": "USER_DEPLOYING" 7 | }, 8 | "exceptionLogging": "STACKDRIVER", 9 | "runtimeVersion": "V8" 10 | } 11 | -------------------------------------------------------------------------------- /snippets/patterns/bootstrap_jquery/bootstrap.html: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /snippets/patterns/bootstrap_jquery/client.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

Welcome

9 |

10 | 11 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /snippets/patterns/bootstrap_jquery/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "single" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/patterns/bootstrap_jquery/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @param {*} e 4 | */ 5 | function doGet(e) { 6 | var htmlTemplate = HtmlService.createTemplateFromFile('client'); 7 | return htmlTemplate.evaluate(); 8 | } 9 | -------------------------------------------------------------------------------- /snippets/patterns/bootstrap_jquery/jquery.html: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /snippets/patterns/bootstrap_jquery/tools.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @param {string} filename 4 | */ 5 | function include(filename) { 6 | return HtmlService.createHtmlOutputFromFile(filename).getContent(); 7 | } 8 | -------------------------------------------------------------------------------- /snippets/patterns/default_app/App/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | class App { 5 | /** 6 | * 7 | */ 8 | constructor() { 9 | if (!App._instance) { 10 | this.data = { 11 | someValue: 1, 12 | }; 13 | App._instance = this; 14 | } 15 | return App._instance; 16 | } 17 | /** 18 | * 19 | * @param {*} e 20 | */ 21 | onOpen(e) { 22 | const f = Object.assign({}, e); 23 | f.someValue = this.data.someValue; 24 | console.log(f); 25 | } 26 | /** 27 | * 28 | * @param {*} e 29 | */ 30 | onEdit(e) { 31 | console.log(e); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /snippets/patterns/default_app/Triggers/index.js: -------------------------------------------------------------------------------- 1 | /* global App */ 2 | 3 | const app = new App(); 4 | 5 | /** 6 | * 7 | * @param {*} e 8 | */ 9 | function onOpen(e) { 10 | app.onOpen(e); 11 | } 12 | 13 | /** 14 | * 15 | * @param {*} e 16 | */ 17 | function onEdit(e) { 18 | app.onEdit(e); 19 | } 20 | -------------------------------------------------------------------------------- /snippets/patterns/default_app/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/patterns/default_app/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/sheets/append_row_with_date_time/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8", 6 | "sheets": { 7 | "macros": [ 8 | { 9 | "menuName": "Форматирование активного листа по шаблону", 10 | "functionName": "formatActiveSheetByTemplate", 11 | "defaultShortcut": "Ctrl+Alt+Shift+1" 12 | } 13 | ] 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /snippets/sheets/append_row_with_date_time/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/append_row_with_date_time/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/append_row_with_date_time/screenrecord.gif -------------------------------------------------------------------------------- /snippets/sheets/append_row_with_date_time/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/append_row_with_date_time/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/sheets/append_values_from_sheet_to_one/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/append_values_from_sheet_to_one/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/append_values_from_sheet_to_one/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/append_values_from_sheet_to_one/screenrecord.gif -------------------------------------------------------------------------------- /snippets/sheets/append_values_from_sheet_to_one/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/append_values_from_sheet_to_one/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/sheets/autoid/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/autoid/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/autoid/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/autoid/screenrecord.gif -------------------------------------------------------------------------------- /snippets/sheets/autoid/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/autoid/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/sheets/clean_cells_by_find_result/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "V8" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/clean_cells_by_find_result/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/copy_format_between_sheets/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8", 6 | "sheets": { 7 | "macros": [ 8 | { 9 | "menuName": "Форматирование активного листа по шаблону", 10 | "functionName": "formatActiveSheetByTemplate", 11 | "defaultShortcut": "Ctrl+Alt+Shift+1" 12 | } 13 | ] 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /snippets/sheets/copy_format_between_sheets/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/copying_protected_ranges_between_two_entities/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "V8", 5 | "dependencies": { 6 | "enabledAdvancedServices": [ 7 | { 8 | "userSymbol": "Sheets", 9 | "version": "v4", 10 | "serviceId": "sheets" 11 | } 12 | ] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /snippets/sheets/copying_protected_ranges_between_two_entities/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/count_cells/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "1jlrJK1X8HG06M5hzmsFiAbAHBRAPy5fH-aSB_8FCn29w9vEMtqaIQqId", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/count_cells/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/London", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/count_cells/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "single", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/count_cells/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/count_cells/screenrecord.gif -------------------------------------------------------------------------------- /snippets/sheets/count_cells/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/count_cells/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/sheets/delete_move_rows_by_conditional/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/delete_move_rows_by_conditional/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/delete_move_rows_by_conditional/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/delete_move_rows_by_conditional/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/sheets/delete_move_rows_by_conditional/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/delete_move_rows_by_conditional/screenshot.png -------------------------------------------------------------------------------- /snippets/sheets/delete_move_rows_by_conditional/userActions.js: -------------------------------------------------------------------------------- 1 | /* global run2 */ 2 | 3 | /** 4 | * If you wish implement the snippet for EDIT event 5 | */ 6 | function onEdit() { 7 | run2(); 8 | } 9 | -------------------------------------------------------------------------------- /snippets/sheets/dynamic_meny/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "DEPRECATED_ES5" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/dynamic_meny/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/dynamic_meny/screenrecord22.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/dynamic_meny/screenrecord22.gif -------------------------------------------------------------------------------- /snippets/sheets/dynamic_meny/screenrecord22.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/dynamic_meny/screenrecord22.mp4 -------------------------------------------------------------------------------- /snippets/sheets/export-import-to-csv/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "enabledAdvancedServices": [ 5 | { 6 | "userSymbol": "Sheets", 7 | "serviceId": "sheets", 8 | "version": "v4" 9 | } 10 | ] 11 | }, 12 | "exceptionLogging": "STACKDRIVER" 13 | } 14 | -------------------------------------------------------------------------------- /snippets/sheets/export-import-to-csv/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/filters_samples/000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/filters_samples/000.png -------------------------------------------------------------------------------- /snippets/sheets/filters_samples/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "V8" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/filters_samples/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/find_and_replace_samples/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "V8" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/find_and_replace_samples/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/get_data_sheet_as_array_of_objects/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "enabledAdvancedServices": [ 5 | { 6 | "userSymbol": "Sheets", 7 | "serviceId": "sheets", 8 | "version": "v4" 9 | } 10 | ] 11 | }, 12 | "exceptionLogging": "STACKDRIVER", 13 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 14 | "runtimeVersion": "V8" 15 | } 16 | -------------------------------------------------------------------------------- /snippets/sheets/get_data_sheet_as_array_of_objects/code.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * 4 | */ 5 | function getData() { 6 | const values = SpreadsheetApp.getActiveSheet().getDataRange().getValues(); 7 | const headers = values.shift(); 8 | const data = values.reduce((p, c) => { 9 | const entry = c.reduce((o, v, j) => { 10 | if (headers[j]) o[headers[j]] = v; 11 | return o; 12 | }, {}); 13 | p.push(entry); 14 | return p; 15 | }, []); 16 | console.log(data); 17 | } 18 | -------------------------------------------------------------------------------- /snippets/sheets/get_data_sheet_as_array_of_objects/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/hide_empty_columns/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "enabledAdvancedServices": [ 5 | { 6 | "userSymbol": "Sheets", 7 | "serviceId": "sheets", 8 | "version": "v4" 9 | } 10 | ] 11 | }, 12 | "exceptionLogging": "STACKDRIVER", 13 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 14 | "runtimeVersion": "V8" 15 | } 16 | -------------------------------------------------------------------------------- /snippets/sheets/hide_empty_columns/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/hide_empty_columns/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/hide_empty_columns/screenrecord.gif -------------------------------------------------------------------------------- /snippets/sheets/hide_empty_columns/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/hide_empty_columns/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/sheets/hyperlinks/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/hyperlinks/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/hyperlinks/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | function getHyperlinks() { 5 | const runs = SpreadsheetApp.getCurrentCell().getRichTextValue().getRuns(); 6 | console.log( 7 | runs.reduce((c, run) => { 8 | const url = run.getLinkUrl(); 9 | if (url) c.push(url); 10 | return c; 11 | }, []) 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /snippets/sheets/insert_image_blob_to_cell/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "V8", 5 | "dependencies": { 6 | "libraries": [ 7 | { 8 | "userSymbol": "DocsServiceApp", 9 | "libraryId": "108j6x_ZX544wEhGkgddFYM6Ie09edDqXaFwnW3RVFQCLHw_mEueqUHTW", 10 | "version": "2" 11 | } 12 | ] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /snippets/sheets/insert_image_blob_to_cell/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/is_range_a_cell/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "V8" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/is_range_a_cell/code.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable camelcase */ 2 | 3 | /** 4 | * Checks if a range is a cell 5 | * @param {GoogleAppsScript.Spreadsheet.Range} range 6 | * @return {boolean} 7 | */ 8 | function isRangeACell_(range) { 9 | return !~range.getA1Notation().indexOf(':'); 10 | } 11 | 12 | /** 13 | * Run the snippet 14 | */ 15 | function run_test() { 16 | const cell = SpreadsheetApp.getActive().getRange('B3'); 17 | const range = SpreadsheetApp.getActive().getRange('B3:B4'); 18 | const active = SpreadsheetApp.getActiveRange(); 19 | console.log([cell, range, active].map(isRangeACell_)); 20 | } 21 | -------------------------------------------------------------------------------- /snippets/sheets/is_range_a_cell/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/join_rich-text-values/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/join_rich-text-values/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/join_rich-text-values/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Join of RichTextValues' 3 | date: '2022-08-01' 4 | description: 'The snippet demonstrates how to join/concatenation of RichTextValues in Google Sheets.' 5 | tags: ['SpreadsheetApp'] 6 | categories: ['snippets'] 7 | --- 8 | 9 | ## Open an dialog from the sidebar 10 | 11 | {{< toc >}} 12 | 13 | - {{< externalLink >}} 14 | - {{< commentLink >}} 15 | - {{< scrvizLink >}} 16 | 17 | ### The main code 18 | 19 | {{< codeFromFile "app/index.js" >}} 20 | 21 | ### Run it 22 | 23 | {{< codeFromFile "run.js" >}} 24 | 25 | {{< clipboard >}} 26 | -------------------------------------------------------------------------------- /snippets/sheets/join_rich-text-values/run.js: -------------------------------------------------------------------------------- 1 | function run() { 2 | const book = SpreadsheetApp.getActive(); 3 | const range1 = book.getRange('Лист1!B4'); 4 | const range2 = book.getRange('Лист1!B6'); 5 | 6 | const joinRichTextValue = new JoinRichTextValue(); 7 | joinRichTextValue.separator = { text: '\n' }; 8 | joinRichTextValue.push(range1.getRichTextValue()); 9 | joinRichTextValue.push(range2.getRichTextValue()); 10 | 11 | const range = book.getRange('Лист1!B16'); 12 | range.setRichTextValue(joinRichTextValue.build()); 13 | } 14 | -------------------------------------------------------------------------------- /snippets/sheets/on_change_trigger_sample/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "V8" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/on_change_trigger_sample/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/on_change_trigger_sample/index.js: -------------------------------------------------------------------------------- 1 | /* "runtimeVersion": "STABLE" */ 2 | 3 | /** 4 | * @param {GoogleAppsScript.Events.SheetsOnChange} e 5 | */ 6 | function onChange1(e) { 7 | const bookId = ScriptApp.getProjectTriggers() 8 | .find(function (trigger) { 9 | return trigger.getUniqueId() === e.triggerUid; 10 | })[0] 11 | .getTriggerSourceId(); 12 | var book = SpreadsheetApp.openById(bookId); 13 | console.log(book.getName()); 14 | } 15 | -------------------------------------------------------------------------------- /snippets/sheets/on_change_trigger_sample_DEPRECATED_ES5/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "STABLE" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/on_change_trigger_sample_DEPRECATED_ES5/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/on_change_trigger_sample_DEPRECATED_ES5/index.js: -------------------------------------------------------------------------------- 1 | /* "runtimeVersion": "STABLE" */ 2 | 3 | /** 4 | * @param {GoogleAppsScript.Events.SheetsOnChange} e 5 | */ 6 | function onChange1(e) { 7 | var bookId = ScriptApp.getProjectTriggers() 8 | .filter(function (trigger) { 9 | return trigger.getUniqueId() === e.triggerUid; 10 | })[0] 11 | .getTriggerSourceId(); 12 | var book = SpreadsheetApp.openById(bookId); 13 | console.log(book.getName()); 14 | } 15 | -------------------------------------------------------------------------------- /snippets/sheets/on_edit_active_user/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/on_edit_active_user/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/on_edit_sort/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "1eoaJMyrcsqfa1TW96xZNAMEMtBft3jHyAlHoaQmyZojONRohFT6rA3fd", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/on_edit_sort/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "America/New_York", 3 | "runtimeVersion": "V8", 4 | "exceptionLogging": "STACKDRIVER" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/on_edit_sort/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "single", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/on_edit_sort/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @param {GoogleAppsScript.Events.SheetsOnEdit} e 4 | */ 5 | function onEdit(e) { 6 | const sheetName = 'Sheet1'; // name of the sheet the script should work on 7 | const colToSort = 4; // name of the column should sort on 8 | 9 | if (e && e.range && e.range.getColumn() === colToSort && e.range.getRow() > 1) { 10 | const sheet = e.range.getSheet(); 11 | if (sheet.getName() == sheetName) sheet.sort(colToSort); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /snippets/sheets/on_edit_timestamp/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "11hm3AyJlQ-Z5js6A4RGODycpYOgdYHZuKKG68vBjX9mWr2C6uBcdgCEC", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/on_edit_timestamp/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "America/New_York", 3 | "runtimeVersion": "V8", 4 | "exceptionLogging": "STACKDRIVER" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/on_edit_timestamp/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "single", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/on_edit_timestamp/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @param {GoogleAppsScript.Events.SheetsOnEdit} e 4 | */ 5 | function onEdit(e) { 6 | const sheetName = 'Sheet6'; // name of the sheet the script should work on 7 | const colToStamp = 3; // timestamp in col C 8 | 9 | if (e && e.range && e.range.getRow() > 1) { 10 | const sheet = e.range.getSheet(); 11 | if (sheet.getName() == sheetName) { 12 | const writeVal = e.value && ('' & e.value) !== '' ? new Date() : ''; 13 | sheet.getRange(e.range.rowStart, colToStamp).setValue(writeVal); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /snippets/sheets/on_edit_timestamp_with_check/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "1I5VeJZIPgB-BjN-6RxQVXNoTmpGoTfyEb2B4ebbU0DngQgpFbH0z0HPt", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/on_edit_timestamp_with_check/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "America/New_York", 3 | "runtimeVersion": "V8", 4 | "exceptionLogging": "STACKDRIVER" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/on_edit_timestamp_with_check/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "single", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/on_edit_timestamp_with_check/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @param {GoogleAppsScript.Events.SheetsOnEdit} e 4 | */ 5 | function onEdit(e) { 6 | const sheetName = 'Sheet6'; // name of the sheet the script should work on 7 | const colToStamp = 3; // timestamp in col C 8 | 9 | if (e && e.range && e.range.getColumn() > 1 && e.range.getRow() > 1) { 10 | const sheet = e.range.getSheet(); 11 | if (sheet.getName() !== sheetName) { 12 | const writeVal = e.value && sheet.getRange(e.range.getRow(), 1).getValue() == true ? new Date() : ''; 13 | sheet.getRange(e.range.rowStart, colToStamp).setValue(writeVal); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /snippets/sheets/on_selection_change_simple_trigger/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "V8" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/on_selection_change_simple_trigger/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/on_selection_change_simple_trigger/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @param {Event} e The onSelectionChange event. 4 | */ 5 | function onSelectionChange(e) { 6 | try { 7 | var range = e.range; 8 | if (range.getNumRows() === 1 && range.getNumColumns() === 1 && range.getCell(1, 1).getValue() === '') { 9 | range.setBackground(randomColor_()); 10 | } 11 | } catch (error) { 12 | console.error(error.message, error); 13 | } 14 | } 15 | 16 | /** 17 | * @return {string} 18 | */ 19 | function randomColor_() { 20 | return '#' + (0x1000000 + Math.random() * 0xffffff).toString(16).substr(1, 6); 21 | } 22 | -------------------------------------------------------------------------------- /snippets/sheets/on_selection_change_simple_trigger/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/on_selection_change_simple_trigger/screenrecord.gif -------------------------------------------------------------------------------- /snippets/sheets/on_selection_change_simple_trigger/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/on_selection_change_simple_trigger/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/sheets/protection_multiple_sheets/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "V8" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/protection_multiple_sheets/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/protection_multiple_sheets/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Protection of multiple sheets' 3 | date: '2021-03-04' 4 | description: 'Protects the list of sheets' 5 | tags: ['SpreadsheetApp', 'Protection'] 6 | categories: ['snippets'] 7 | --- 8 | 9 | ## Protection of multiple sheets 10 | 11 | The snippet processes the list of sheets of the spreadsheet. It protects the sheets. It excludes ranges from protection if there is the specific list. 12 | 13 | - {{< externalLink >}} 14 | - {{< commentLink >}} 15 | - {{< scrvizLink >}} 16 | 17 | {{< codeFromFile "index.js" >}} 18 | {{< codeFromFile "appsscript.json" >}} 19 | -------------------------------------------------------------------------------- /snippets/sheets/rename_sheets_by_patt/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "enabledAdvancedServices": [ 5 | { 6 | "userSymbol": "Sheets", 7 | "serviceId": "sheets", 8 | "version": "v4" 9 | } 10 | ] 11 | }, 12 | "exceptionLogging": "STACKDRIVER", 13 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 14 | "runtimeVersion": "V8" 15 | } 16 | -------------------------------------------------------------------------------- /snippets/sheets/rename_sheets_by_patt/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/rename_sheets_by_patt/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/rename_sheets_by_patt/screenrecord.gif -------------------------------------------------------------------------------- /snippets/sheets/rename_sheets_by_patt/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/rename_sheets_by_patt/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/sheets/reset_sheet_data/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "1I8OHpfnjZsMsmz50UgBiFRt8RgQRCQkDfGACiBZVh_-7zdRWEQo4FpD0", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/reset_sheet_data/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "libraries": [] 5 | }, 6 | "exceptionLogging": "STACKDRIVER", 7 | "runtimeVersion": "V8" 8 | } 9 | -------------------------------------------------------------------------------- /snippets/sheets/reset_sheet_data/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "single", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/reset_sheet_data/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/reset_sheet_data/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/sheets/reset_sheet_data/screenrecord2.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/reset_sheet_data/screenrecord2.mp4 -------------------------------------------------------------------------------- /snippets/sheets/reset_sheet_data/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/reset_sheet_data/screenshot.png -------------------------------------------------------------------------------- /snippets/sheets/reset_sheet_data/triggerActions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates the user menu for handy use. 3 | */ 4 | function onOpen() { 5 | SpreadsheetApp.getUi() 6 | .createMenu('Reset sheet') 7 | .addItem('Reset active sheet (ContactPrice example)', 'userActionResetActiveSheetByRangesAddresses') 8 | .addItem('Reset ranges', 'userActionResetRangesByRangesAddresses') 9 | .addItem('Reset multiple sheets', 'userActionResetMultipleSheetsByRangesAddresses') 10 | .addItem('Reset "GSM" columns', 'userActionResetMultipleSheetsBySpecialColumns') 11 | .addItem('Reset to a specific value', 'userActionResetToSpecificValue') 12 | .addItem('Make a copy before reset', 'userActionMakeCopyBeforeReset') 13 | .addToUi(); 14 | } 15 | -------------------------------------------------------------------------------- /snippets/sheets/shuffle_some_data/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "1f-1yqCbZag_FTFWCmlnuHU8YEDAMnVh5UzUwQWU1ewZcQaDrfw_sP1JZ", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/shuffle_some_data/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/London", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/shuffle_some_data/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "single", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/shuffle_some_data/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/shuffle_some_data/screenrecord.gif -------------------------------------------------------------------------------- /snippets/sheets/shuffle_some_data/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/shuffle_some_data/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/sheets/shuffle_some_data/screenrecord1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/shuffle_some_data/screenrecord1.gif -------------------------------------------------------------------------------- /snippets/sheets/shuffle_some_data/screenrecord1.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/shuffle_some_data/screenrecord1.mp4 -------------------------------------------------------------------------------- /snippets/sheets/sort_book_sheets/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "1q6uooLGsK-sRinMPjKuUtF8QAYT46VBDYVGznGUY2yoeouoeBeNjKEVg", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/sort_book_sheets/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/sort_book_sheets/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "single", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/sort_sheet_when_form_submit/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/sort_sheet_when_form_submit/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/split_data_to_two_array_by_condition/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "1wsGgzWX7e4xVkmY3Prlkw4iz8ae7hKgZ0kYAYa4HL42Sm9qL4AmvAK_2", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/split_data_to_two_array_by_condition/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/split_data_to_two_array_by_condition/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "single", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/split_data_to_two_array_by_condition/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Split data to two array by condition' 3 | date: '2022-03-18' 4 | description: '' 5 | tags: ['sheets'] 6 | categories: ['snippets'] 7 | # images: ['./snippets/sheets/delete_move_rows_by_conditional/screenshot.png'] 8 | --- 9 | 10 | ## Split data to two array by condition 11 | 12 | {{< toc >}} 13 | 14 | ### Snippet 15 | 16 | - {{< externalLink >}} 17 | - {{< commentLink >}} 18 | - {{< scrvizLink >}} 19 | 20 | {{< codeFromFile "index.js" >}} 21 | 22 | {{< clipboard >}} 23 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-apply_format/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-apply_format/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-autoincrement/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-autoincrement/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-autoincrement/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/spreadsheet-autoincrement/screenrecord.gif -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-autoincrement/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/spreadsheet-autoincrement/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-charts_calendar/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-charts_calendar/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-charts_calendar/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/spreadsheet-charts_calendar/screenrecord.gif -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-charts_calendar/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/spreadsheet-charts_calendar/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-closest_match_analog/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-closest_match_analog/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-colored_cell_by_list_value/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-colored_cell_by_list_value/colored_cell_by_list_value.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Colored cell by list value 3 | * @see {@link https://stackoverflow.com/questions/60235521/change-cell-color-based-on-selection-from-dropdown-menu} 4 | */ 5 | 6 | /** 7 | * Run the snippet as a simple trigger 8 | */ 9 | /** 10 | * 11 | * @param {GoogleAppsScript.Events.SheetsOnEdit} e 12 | */ 13 | const onEdit = (e) => { 14 | const sheet = e.range.getSheet(); 15 | const value = e.range.getValue(); 16 | if (sheet.getName() == 'Sheet1' && e.range.getA1Notation() === 'C2') { 17 | const range = sheet.getRange(2, 1, sheet.getLastRow() - 1, 1); 18 | range.setBackgrounds(range.getValues().map((row) => [row[0] === value ? '#7986CB' : ''])); 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-colored_cell_by_list_value/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-colored_cell_by_list_value/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/spreadsheet-colored_cell_by_list_value/screenrecord.gif -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-colored_cell_by_list_value/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/spreadsheet-colored_cell_by_list_value/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-copy_active_rows_two_sheets/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-copy_active_rows_two_sheets/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-copy_active_rows_two_sheets/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/spreadsheet-copy_active_rows_two_sheets/screenrecord.gif -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-draft/Code.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable require-jsdoc */ 2 | function onEdit() { 3 | // Dowant you want here 4 | // ... 5 | 6 | SpreadsheetApp.getActive().getRangeByName('LAST_EDITS').setValue(new Date()); 7 | } 8 | 9 | function clearTrigger() { 10 | const BOOK_ID = '1YvGje4cbSwHQwsQFYVQGfaYG4fm0LLd1T2RTjvZ5i5c'; 11 | const lastEditsRange = SpreadsheetApp.openById(BOOK_ID).getRangeByName('LAST_EDITS'); 12 | const current = lastEditsRange.getValue(); 13 | if (current && current.getTime && new Date() - current > 5 * 60 * 1000) lastEditsRange.setValue(''); 14 | } 15 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-draft/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "America/New_York", 3 | "runtimeVersion": "V8", 4 | "exceptionLogging": "STACKDRIVER" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-draft/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-draft/spreadsheet-draft/Code.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable require-jsdoc */ 2 | function onEdit() { 3 | // Dowant you want here 4 | // ... 5 | 6 | SpreadsheetApp.getActive().getRangeByName('LAST_EDITS').setValue(new Date()); 7 | } 8 | 9 | function clearTrigger() { 10 | const BOOK_ID = '1YvGje4cbSwHQwsQFYVQGfaYG4fm0LLd1T2RTjvZ5i5c'; 11 | const lastEditsRange = SpreadsheetApp.openById(BOOK_ID).getRangeByName('LAST_EDITS'); 12 | const current = lastEditsRange.getValue(); 13 | if (current && current.getTime && new Date() - current > 5 * 60 * 1000) lastEditsRange.setValue(''); 14 | } 15 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-draft/spreadsheet-draft/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "America/New_York", 3 | "runtimeVersion": "V8", 4 | "exceptionLogging": "STACKDRIVER" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-draft/spreadsheet-draft/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-dragg_down_formulas/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "V8" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-dragg_down_formulas/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-get_error_value_formulas/Untitled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/spreadsheet-get_error_value_formulas/Untitled.png -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-get_error_value_formulas/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "enabledAdvancedServices": [ 5 | { 6 | "userSymbol": "Sheets", 7 | "serviceId": "sheets", 8 | "version": "v4" 9 | } 10 | ] 11 | }, 12 | "exceptionLogging": "STACKDRIVER", 13 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"] 14 | } 15 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-get_error_value_formulas/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-get_last_values/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-get_last_values/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-get_last_values/get_last_values.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | function getLastValueByFullColumnAddres() { 5 | var range = SpreadsheetApp.getActive().getRange('Ответы на форму (2)!B:B'); 6 | var values = range.getValues(); 7 | var lValue = ''; 8 | values.some(function (_, i, arr) { 9 | if (arr[arr.length - 1 - i][0] !== '') { 10 | lValue = arr[arr.length - 1 - i][0]; 11 | return true; 12 | } 13 | }); 14 | Logger.log(lValue); 15 | } 16 | 17 | /** 18 | * 19 | */ 20 | function getLastRowValuesOfSheet() { 21 | var sheet = SpreadsheetApp.getActiveSheet(); 22 | var dataValues = sheet.getDataRange().getValues(); 23 | var lastValues = dataValues[dataValues.length - 1].slice(); 24 | Logger.log(lastValues); 25 | } 26 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-images_simple/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-images_simple/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-images_simple/images_simple.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | function run() { 5 | var sheet = SpreadsheetApp.getActiveSheet(); 6 | var images = sheet.getImages(); 7 | images.forEach(function (image) { 8 | Logger.log(image); 9 | }); 10 | } 11 | 12 | /** 13 | * 14 | */ 15 | function run2() { 16 | var sheet = SpreadsheetApp.getActiveSheet(); 17 | var image = sheet.getRange('E5').getDisplayValue(); 18 | Logger.log(image); 19 | } 20 | 21 | /** 22 | * 23 | */ 24 | function run3() { 25 | // Sheets.Spreadsheets. 26 | } 27 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-lodasgs_sample/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "libraries": [ 5 | { 6 | "userSymbol": "LodashGS", 7 | "libraryId": "1SQ0PlSMwndIuOAgtVJdjxsuXueECtY9OGejVDS37ckSVbMll73EXf2PW", 8 | "version": "5" 9 | } 10 | ] 11 | }, 12 | "exceptionLogging": "STACKDRIVER", 13 | "runtimeVersion": "V8" 14 | } 15 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-lodasgs_sample/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-lodasgs_sample/lodasgs_sample.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | function run() { 5 | const dataRange = SpreadsheetApp.getActiveSheet().getDataRange(); 6 | dataRange.setValues(dataRange.getValues().map((row) => row.sort())); 7 | } 8 | 9 | /** 10 | * 11 | */ 12 | function shuffleActiveRange() { 13 | /** 14 | * @type {import("lodash").LoDashStatic} 15 | */ 16 | const _ = LodashGS.load(); 17 | 18 | const activeRange = SpreadsheetApp.getActiveRange(); 19 | activeRange.setValues(_.shuffle(activeRange.getValues().map((row) => _.shuffle(row)))); 20 | } 21 | 22 | const onOpen = () => 23 | SpreadsheetApp.getUi().createMenu('DoIt').addItem('Run', 'run').addItem('Shuffle', 'shuffleActiveRange').addToUi(); 24 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-lodasgs_sample/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/spreadsheet-lodasgs_sample/screenrecord.gif -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-lodasgs_sample/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/spreadsheet-lodasgs_sample/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-maps-check_streetview/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "1PaBjc1GOa2l4eldMDcFYLwt2hn9Z1v_j3pf6v4vhkUa5VdkFimHrTL0q", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-maps-check_streetview/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-maps-check_streetview/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "single", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-maps-check_streetview/strv.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-multiple_formats/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-multiple_formats/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-null_values/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-null_values/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-null_values/null_values.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Null values 3 | * @url 4 | */ 5 | 6 | /** 7 | * 8 | */ 9 | function run() { 10 | SpreadsheetApp.getActiveSheet() 11 | .getRange('A1:B2') 12 | .setValues([ 13 | [1, null], 14 | [null, 2], 15 | ]); 16 | } 17 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-onedit-check-value/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-onedit-check-value/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-onedit-check-value/onedit-check-value.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * {@link} 4 | */ 5 | 6 | /** 7 | * Runs the snippet. 8 | * 9 | * @param {GoogleAppsScript.Events.SheetsOnEdit} e 10 | */ 11 | function onEdit(e) { 12 | if (e.range.getSheet().getName() === 'Sheet1' && e.range.getColumn() === 4 && e.range.getValue() === true) 13 | e.range.getSheet().getParent().toast('Hi'); 14 | } 15 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-simple_search_engine/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-simple_search_engine/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-simple_search_engine/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/spreadsheet-simple_search_engine/screenrecord.gif -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-simple_search_engine/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/spreadsheet-simple_search_engine/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-split_data_on_each_row/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet-split_data_on_each_row/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_add-row-to-filtered-range/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_add-row-to-filtered-range/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_appndRow-formula-increment/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_appndRow-formula-increment/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_appndRow-formula-increment/spreadsheet_appndRow-formula-increment.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | function newRow() { 5 | var sheet = SpreadsheetApp.getActiveSheet(); 6 | var nextRow = sheet.getLastRow() + 1; 7 | var formula = '=B%s-A%s'.replace(/%s/g, nextRow); 8 | sheet.appendRow(['00:00:00', '00:00:00', formula]); 9 | } 10 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_autosort/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_autosort/autosort1.js: -------------------------------------------------------------------------------- 1 | /** 2 | * https://stackoverflow.com/questions/58723024/auto-sort-data-moved-by-script 3 | */ 4 | function autoSortOnEdit_() { 5 | var ss = SpreadsheetApp.getActiveSpreadsheet(); 6 | var sheet = ss.getSheetByName('Completed Returns'); 7 | if (!sheet) return; 8 | var range = sheet.getRange(4, 1, sheet.getLastRow() - 1, sheet.getLastColumn()); 9 | range.sort({ column: 2, ascending: true }); 10 | } 11 | 12 | /** 13 | * This is some additional function 14 | */ 15 | function copyData_() {} 16 | 17 | /** 18 | * 19 | */ 20 | function onEditAutosort1() { 21 | copyData_(); 22 | autoSortOnEdit_(); 23 | } 24 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_autosort/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_autosort/onEdit.js: -------------------------------------------------------------------------------- 1 | /* global onEditAutosort1, onEditAutosort2 */ 2 | /** 3 | * 4 | * @param {GoogleAppsScript.Events.SheetsOnEdit} e 5 | */ 6 | function onEdit(e) { 7 | onEditAutosort1(); 8 | onEditAutosort2(e); 9 | } 10 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_binding-notes/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_binding-notes/binding-notes.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Updates notes in the second column if there have been edits in the first one. 3 | * @url https://stackoverflow.com/questions/58685598/set-dependent-notes-in-google-sheets 4 | */ 5 | 6 | /** 7 | * @param {GoogleAppsScript.Events.SheetsOnEdit} e 8 | */ 9 | function onEdit(e) { 10 | if (e.range.getColumn() === 1) e.range.offset(0, 1).setNotes(e.range.getValues()); 11 | } 12 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_binding-notes/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_binding-notes/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/spreadsheet_binding-notes/screenrecord.gif -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_binding-notes/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/spreadsheet_binding-notes/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_change-basic-event/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_change-basic-event/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_change-basic-event/spreadsheet_change-basic-event.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * {@link } 4 | */ 5 | 6 | /** 7 | * Runs the snippet. 8 | * Please, register this function for CHANGE event 9 | * once from the owner of the Spreadsheet 10 | * 11 | * @param {GoogleAppsScript.Events.SheetsOnChange} e 12 | */ 13 | function onchange(e) { 14 | try { 15 | var log = e.source.getSheetByName('log') || e.source.insertSheet('log'); 16 | log.appendRow([new Date(), JSON.stringify(e, null, ' ')]); 17 | } catch (error) { 18 | console.error('error', error); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_change_user_role/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "libraries": [] 5 | }, 6 | "exceptionLogging": "STACKDRIVER" 7 | } 8 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_change_user_role/spreadsheet.users.js: -------------------------------------------------------------------------------- 1 | /* exported SPREADSHEET_ID, EDITOR_EMAIL, run */ 2 | 3 | /** ID Таблицы */ 4 | var SPREADSHEET_ID = '{{YOUR_SPREADSHEET_ID}}'; 5 | 6 | /** The user's email */ 7 | var EDITOR_EMAIL = '{{EDITOR_EMAIL}}'; 8 | 9 | /** 10 | * Runs the example 11 | * @ignore 12 | */ 13 | function run() { 14 | changeUserRole_(SpreadsheetApp.openById(SPREADSHEET_ID), EDITOR_EMAIL); 15 | } 16 | 17 | /** 18 | * 19 | * @param {GoogleAppsScript.Spreadsheet.Spreadsheet} spreadsheet 20 | * @param {string} email 21 | */ 22 | function changeUserRole_(spreadsheet, email) { 23 | spreadsheet.removeEditor(email); 24 | spreadsheet.addViewer(email); 25 | } 26 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_clear-bandings/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_clear-bandings/clear-bandings.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Clears all bandings 3 | * @url https://support.google.com/docs/thread/12818677?msgid=12818677 4 | * */ 5 | 6 | /** 7 | * User action. Runs the snippet 8 | */ 9 | function run() { 10 | var spreadsheet = SpreadsheetApp.getActive(); 11 | clearBandings_(spreadsheet); 12 | } 13 | 14 | /** 15 | * 16 | * @param {GoogleAppsScript.Spreadsheet.Spreadsheet} spreadsheet 17 | */ 18 | function clearBandings_(spreadsheet) { 19 | spreadsheet.getSheets().forEach(function (sheet) { 20 | sheet.getBandings().forEach(function (banding) { 21 | banding.remove(); 22 | }); 23 | }); 24 | } 25 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_clear-bandings/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_collect_data_from_multiple_sheets/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_collect_data_from_multiple_sheets/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_compare_dates/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_compare_dates/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_compare_dates/spreadsheet_compare_dates.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {Date} date 3 | */ 4 | function toTime(date, withoutTime) { 5 | var date_ = new Date(date); 6 | if (withoutTime === true) date_.setHours(0, 0, 0, 0); 7 | return date_.getTime(); 8 | } 9 | 10 | /** 11 | * comapre 12 | */ 13 | function compareDates() { 14 | var sheetDate = SpreadsheetApp.getActiveRange().getValue(); 15 | var currentDate = new Date(); 16 | Logger.log('%s < %s: %s', toTime(sheetDate), toTime(currentDate), toTime(sheetDate) < toTime(currentDate)); 17 | Logger.log( 18 | '%s === %s: %s', 19 | toTime(sheetDate, true), 20 | toTime(currentDate, true), 21 | toTime(sheetDate, true) === toTime(currentDate, true) 22 | ); 23 | } 24 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_copy-chart/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_copy-chart/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_copy-chart/spreadsheet_copy-chart.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | function myFunction() { 5 | var chart = SpreadsheetApp.getActiveSheet().getCharts()[0]; 6 | var ranges = chart.getRanges(); 7 | var builder = chart.modify(); 8 | var spreadsheet = SpreadsheetApp.openById('16WXWHS5OHtBERqhGhWyHvY1uyFA5Zc3SUm5B87DUSpo'); 9 | //asdfa sdf sdf 10 | builder.clearRanges(); 11 | ranges.forEach(function (range) { 12 | var sheetName = range.getSheet().getName(); 13 | var nota = range.getA1Notation(); 14 | var sheet = spreadsheet.getSheetByName(sheetName) || spreadsheet.insertSheet(sheetName); 15 | builder.addRange(sheet.getRange(nota)); 16 | }); 17 | 18 | var copyChart = builder.build(); 19 | spreadsheet.getSheets()[0].insertChart(copyChart); 20 | } 21 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_copy_formats_between_two_sheets/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_copy_formats_between_two_sheets/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_copy_values_between_two_sheets/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_copy_values_between_two_sheets/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_data_to_html_table/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "libraries": [] 5 | }, 6 | "exceptionLogging": "STACKDRIVER" 7 | } 8 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_insert-rows-before-by-condition/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_insert-rows-before-by-condition/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_insert-rows-before-by-condition/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/spreadsheet_insert-rows-before-by-condition/screenrecord.gif -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_insert-rows-before-by-condition/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/spreadsheet_insert-rows-before-by-condition/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_insert_rich_text_to_active_cell/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_insert_rich_text_to_active_cell/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_on-form-submit-event/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_on-form-submit-event/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_on-form-submit-event/on-form-submit-event.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @param {GoogleAppsScript.Events.FormsOnSubmit} e 4 | */ 5 | function onFormSubmit(e) { 6 | console.log(Object.keys(e), JSON.stringify(e.namedValues)); 7 | } 8 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_onedit-copy-row-if-edit/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_onedit-copy-row-if-edit/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_onedit-sample/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_onedit-sample/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_onedit-sample/onedit-sample.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * {@link} 4 | */ 5 | 6 | /** 7 | * Runs the snippet. 8 | * 9 | * @param {GoogleAppsScript.Events.SheetsOnEdit} e 10 | */ 11 | function onEdit(e) { 12 | e.range 13 | .getSheet() 14 | .getParent() 15 | .toast(Utilities.formatString("'%s'!%s", e.range.getSheet().getName(), e.range.getA1Notation()), '', -1); 16 | } 17 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_onedit-sample/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/spreadsheet_onedit-sample/screenrecord.gif -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_onedit-sample/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/spreadsheet_onedit-sample/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_painting-specific-characters/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_painting-specific-characters/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_painting-specific-characters/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/spreadsheet_painting-specific-characters/screenshot.png -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_rainbow_active_cell/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_rainbow_active_cell/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": ["./extra/hslToHex.js"] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_rainbow_active_cell/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/spreadsheet_rainbow_active_cell/screenshot.png -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_update-colored-notes/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], 4 | "dependencies": {}, 5 | "exceptionLogging": "STACKDRIVER" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_update-colored-notes/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/spreadsheet_update-colored-notes/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/spreadsheet_update-colored-notes/screenshot.png -------------------------------------------------------------------------------- /snippets/sheets/toc_generator/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "V8" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/toc_generator/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/toc_generator/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'TOC generator for Google Sheets' 3 | date: '2021-03-18' 4 | description: 'Generates a table of contents for a specific Spreadsheet' 5 | tags: ['sheets'] 6 | categories: ['snippets'] 7 | images: ['./snippets/sheets/toc_generator/screenrecord.gif'] 8 | --- 9 | 10 | {{< toc >}} 11 | 12 | ## TOC generator for Google Sheets 13 | 14 | ![Snippet of TOC generator for Google Sheets](./screenrecord.gif) 15 | 16 | ### Snippet 17 | 18 | - {{< externalLink >}} 19 | - {{< commentLink >}} 20 | - {{< scrvizLink >}} 21 | 22 | {{< codeFromFile "index.js" >}} 23 | 24 | ### Run it 25 | 26 | {{< codeFromFile "run.js" >}} 27 | 28 | {{< clipboard >}} 29 | -------------------------------------------------------------------------------- /snippets/sheets/toc_generator/run.js: -------------------------------------------------------------------------------- 1 | /* global tocBuilder_ tocUpdater_*/ 2 | 3 | /** 4 | * Runs the snippet. 5 | * Generates a TOC to 'Sheet27!B2' without 'Sheet27' item. 6 | */ 7 | function run() { 8 | const excludeSheetNames = ['Sheet27']; 9 | const book = SpreadsheetApp.getActive(); 10 | const tocBuild = tocBuilder_(book).filter((item) => excludeSheetNames.indexOf(item.name) === -1); 11 | const range = book.getRange('Sheet27!B2:B').clearContent(); 12 | tocUpdater_(tocBuild, range); 13 | range.activate(); 14 | } 15 | 16 | /** 17 | * Create menu for handy use 18 | */ 19 | function onOpen() { 20 | SpreadsheetApp.getUi().createMenu('Apps Script Snippets').addItem('Generate TOC', 'run').addToUi(); 21 | } 22 | -------------------------------------------------------------------------------- /snippets/sheets/toc_generator/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/toc_generator/screenrecord.gif -------------------------------------------------------------------------------- /snippets/sheets/unlink_urls/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "V8" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/sheets/unlink_urls/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/unlink_urls/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Removes all links from the range 3 | * 4 | * @param {GoogleAppsScript.Spreadsheet.Range} range A range 5 | * @return {GoogleAppsScript.Spreadsheet.RichTextValue[][]} 6 | */ 7 | function unlinkUrls_(range = SpreadsheetApp.getActiveRange()) { 8 | return range.setRichTextValues( 9 | range.getRichTextValues().map((rowRichTextValues) => 10 | rowRichTextValues.map((richTextValue) => { 11 | if (richTextValue.getRuns().some((ruin) => ruin.getLinkUrl())) { 12 | const copy = richTextValue.copy(); 13 | copy.setLinkUrl(undefined); 14 | return copy.build(); 15 | } 16 | return richTextValue; 17 | }) 18 | ) 19 | ); 20 | } 21 | -------------------------------------------------------------------------------- /snippets/sheets/unlink_urls/run.js: -------------------------------------------------------------------------------- 1 | /* global unlinkUrls_ */ 2 | 3 | /** 4 | * Runs the snippet. 5 | * Unlink URLs 6 | */ 7 | function run() { 8 | const sheet = SpreadsheetApp.getActiveSheet(); 9 | const range = sheet.getDataRange(); 10 | unlinkUrls_(range); 11 | } 12 | 13 | /** 14 | * Create menu for handy use 15 | */ 16 | function onOpen() { 17 | SpreadsheetApp.getUi().createMenu('Apps Script Snippets').addItem('Unlink all urls on the Sheet', 'run').addToUi(); 18 | } 19 | -------------------------------------------------------------------------------- /snippets/sheets/unlink_urls/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/sheets/unlink_urls/screenrecord.gif -------------------------------------------------------------------------------- /snippets/sheets/unset_checkbox_by_condition/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "15fIXKeDqFqmMemCg5rTaw2HMEy4pBVPgM1QswJQ7EGUFY1SNBnA5WPkx", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/sheets/unset_checkbox_by_condition/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8", 6 | "sheets": { 7 | "macros": [ 8 | { 9 | "menuName": "Форматирование активного листа по шаблону", 10 | "functionName": "formatActiveSheetByTemplate", 11 | "defaultShortcut": "Ctrl+Alt+Shift+1" 12 | } 13 | ] 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /snippets/sheets/unset_checkbox_by_condition/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "single", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/birthdays/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/standalone/birthdays/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/standalone/birthdays/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Return cantacts birthdays 3 | */ 4 | 5 | /** 6 | * 7 | */ 8 | function run() { 9 | console.log(ContactsApp.getContactsByDate(ContactsApp.Month.MAY, 8, ContactsApp.Field.BIRTHDAY)); 10 | } 11 | -------------------------------------------------------------------------------- /snippets/standalone/copy_protected_file/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8" 6 | } 7 | -------------------------------------------------------------------------------- /snippets/standalone/copy_protected_file/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/standalone/copy_protected_file/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Copy a shared file with copy protection 3 | */ 4 | 5 | const FILE_ID = ''; 6 | 7 | /** 8 | * 9 | */ 10 | function run() { 11 | DriveApp.getFileById(FILE_ID).makeCopy(); 12 | } 13 | -------------------------------------------------------------------------------- /snippets/standalone/export-document-to/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "enabledAdvancedServices": [ 5 | { 6 | "userSymbol": "Drive", 7 | "serviceId": "drive", 8 | "version": "v2" 9 | } 10 | ] 11 | }, 12 | "oauthScopes": [ 13 | "https://www.googleapis.com/auth/script.external_request", 14 | "https://www.googleapis.com/auth/drive", 15 | "https://www.googleapis.com/auth/spreadsheets" 16 | ], 17 | "exceptionLogging": "STACKDRIVER" 18 | } 19 | -------------------------------------------------------------------------------- /snippets/standalone/export-document-to/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/export_spreadsheet_to/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "enabledAdvancedServices": [ 5 | { 6 | "userSymbol": "Drive", 7 | "serviceId": "drive", 8 | "version": "v2" 9 | } 10 | ] 11 | }, 12 | "exceptionLogging": "STACKDRIVER", 13 | "runtimeVersion": "V8" 14 | } 15 | -------------------------------------------------------------------------------- /snippets/standalone/export_spreadsheet_to/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/google_cloud_print/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "runtimeVersion": "V8", 6 | "oauthScopes": [ 7 | "https://www.googleapis.com/auth/script.external_request", 8 | "https://www.googleapis.com/auth/cloudprint", 9 | "https://www.googleapis.com/auth/drive" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /snippets/standalone/google_cloud_print/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/standalone/parse_html/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "webapp": { 5 | "access": "ANYONE_ANONYMOUS", 6 | "executeAs": "USER_DEPLOYING" 7 | }, 8 | "exceptionLogging": "STACKDRIVER", 9 | "runtimeVersion": "V8" 10 | } 11 | -------------------------------------------------------------------------------- /snippets/standalone/parse_html/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/standalone/standalone-copy_image_as_string/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone-copy_image_as_string/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone-gmail_remove_forever/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "rootDir": "dist", 3 | "scriptId": "1r8DWiSMJSmeTMaVBdKG3aTuHVT3gKjM6I6gmAWDYUBxHuGyD2J1-p-3w" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone-gmail_remove_forever/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "enabledAdvancedServices": [ 5 | { 6 | "userSymbol": "Gmail", 7 | "serviceId": "gmail", 8 | "version": "v1" 9 | } 10 | ] 11 | }, 12 | "exceptionLogging": "STACKDRIVER", 13 | "runtimeVersion": "V8" 14 | } 15 | -------------------------------------------------------------------------------- /snippets/standalone/standalone-gmail_remove_forever/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "single", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone-gmail_remove_forever/gmail_remove_forever.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Удаляет цепочки навсегда 3 | * @url https://support.google.com/mail/thread/28210414?hl=ru 4 | */ 5 | 6 | const SPAMMEREMAIL = 'spammer@spam.block'; 7 | 8 | /** 9 | * 10 | */ 11 | function trigger() { 12 | if (SPAMMEREMAIL.length < 3) throw new Error('Danger of deleting all content!'); 13 | 14 | Gmail.Users.Threads.list('me', { 15 | q: `(from:${SPAMMEREMAIL})`, 16 | }).threads.forEach((thread) => Gmail.Users.Threads.remove('me', thread.id)); 17 | 18 | Gmail.Users.Threads.list('me', { 19 | q: `(from:${SPAMMEREMAIL}) is:trash`, 20 | }).threads.forEach((thread) => Gmail.Users.Threads.remove('me', thread.id)); 21 | } 22 | -------------------------------------------------------------------------------- /snippets/standalone/standalone-triggers_timebased_daily_exact_time/1576074760009.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/standalone/standalone-triggers_timebased_daily_exact_time/1576074760009.png -------------------------------------------------------------------------------- /snippets/standalone/standalone-triggers_timebased_daily_exact_time/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone-triggers_timebased_daily_exact_time/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_batch-create-calendar-events/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": [ 4 | "https://www.googleapis.com/auth/script.external_request", 5 | "https://www.googleapis.com/auth/calendar" 6 | ], 7 | "dependencies": { 8 | "enabledAdvancedServices": [ 9 | { 10 | "userSymbol": "Calendar", 11 | "serviceId": "calendar", 12 | "version": "v3" 13 | } 14 | ] 15 | }, 16 | "exceptionLogging": "STACKDRIVER" 17 | } 18 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_batch-create-calendar-events/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_content-server/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "webapp": { 5 | "access": "ANYONE_ANONYMOUS", 6 | "executeAs": "USER_DEPLOYING" 7 | }, 8 | "exceptionLogging": "STACKDRIVER" 9 | } 10 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_content-server/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": ["./shims/URL.js", "./shims/URLSearchParams.js"] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_create-file-from-url/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "oauthScopes": ["https://www.googleapis.com/auth/script.external_request", "https://www.googleapis.com/auth/drive"], 4 | "exceptionLogging": "STACKDRIVER" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_create-file-from-url/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_drive-changes/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "enabledAdvancedServices": [ 5 | { 6 | "userSymbol": "Drive", 7 | "serviceId": "drive", 8 | "version": "v2" 9 | } 10 | ] 11 | }, 12 | "webapp": { 13 | "access": "ANYONE_ANONYMOUS", 14 | "executeAs": "USER_DEPLOYING" 15 | }, 16 | "exceptionLogging": "STACKDRIVER", 17 | "oauthScopes": ["https://www.googleapis.com/auth/drive"] 18 | } 19 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_drive-changes/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_drive-changes/drive-changes.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Creates a copy of file and sets its title 3 | * @url https://support.google.com/docs/thread/12032976?msgid=12032976 4 | */ 5 | 6 | /** 7 | * User action. Runs the snippet 8 | */ 9 | function run() { 10 | var changes = Drive.Changes.list(); 11 | console.log(changes.items); 12 | } 13 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_driveapp-save-file-to-drive-from-web/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER" 5 | } 6 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_driveapp-save-file-to-drive-from-web/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_driveapp-save-file-to-drive-from-web/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/standalone/standalone_driveapp-save-file-to-drive-from-web/screenrecord.gif -------------------------------------------------------------------------------- /snippets/standalone/standalone_driveapp-save-file-to-drive-from-web/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/standalone/standalone_driveapp-save-file-to-drive-from-web/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/standalone/standalone_driveapp-save-file-to-drive-from-web/standalone_driveapp-save-file-to-drive-from-web.js: -------------------------------------------------------------------------------- 1 | /* exported run */ 2 | 3 | /** 4 | * Runs the example 5 | * @ignore 6 | */ 7 | function run() { 8 | var url = 9 | 'https://raw.githubusercontent.com/contributorpw/google-apps-script-snippets/master/snippets/standalone_driveapp-save-file-to-drive-from-web/standalone_driveapp-save-file-to-drive-from-web.js'; 10 | Logger.log(saveFileToDriveByUrl_(url).getId()); 11 | } 12 | 13 | /** 14 | * 15 | * @param {string} url The file source url 16 | * @return {GoogleAppsScript.Drive.File} 17 | */ 18 | function saveFileToDriveByUrl_(url) { 19 | var httpResponse = UrlFetchApp.fetch(url); 20 | var blob = httpResponse.getBlob(); 21 | var file = DriveApp.createFile(blob); 22 | return file; 23 | } 24 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_echo-server/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "webapp": { 5 | "access": "ANYONE_ANONYMOUS", 6 | "executeAs": "USER_DEPLOYING" 7 | }, 8 | "exceptionLogging": "STACKDRIVER" 9 | } 10 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_echo-server/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": ["./shims/URL.js", "./shims/URLSearchParams.js"] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_echo-server/echo-serverl.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | function doGet(e) { 5 | return ContentService.createTextOutput(JSON.stringify(e)); 6 | } 7 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_file-backuper/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_file-backuper/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_get-list-files-from-folder/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "enabledAdvancedServices": [ 5 | { 6 | "userSymbol": "Drive", 7 | "serviceId": "drive", 8 | "version": "v2" 9 | } 10 | ] 11 | }, 12 | "webapp": { 13 | "access": "ANYONE_ANONYMOUS", 14 | "executeAs": "USER_DEPLOYING" 15 | }, 16 | "exceptionLogging": "STACKDRIVER" 17 | } 18 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_get-list-files-from-folder/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_get-list-files-from-folder/get-list-files-from-folder.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file getting Videos from Youtube with IDs 3 | */ 4 | 5 | /* exported userActionRun */ 6 | 7 | /** 8 | * User action. Runs the snippet 9 | */ 10 | function userActionRun() { 11 | var list = getFilesListFromFolder_('ASDFSDFASFWERTF'); 12 | } 13 | 14 | /** 15 | * Returns a list of files 16 | * @param {string} id Folder's id 17 | * @return {Array.>} 18 | */ 19 | function getFilesListFromFolder_(id) { 20 | return Drive.Files.list({ q: Utilities.formatString('"%s" in parents', id) }).items; 21 | } 22 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_gmail-import-csv-to-sheet/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_gmail-import-csv-to-sheet/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_gmail-import-csv-to-sheet/gmail-import-csv-to-sheet.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_gmail-save-attachmets-content-to-spreadsheet/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "oauthScopes": [ 6 | "https://mail.google.com/", 7 | "https://www.googleapis.com/auth/drive", 8 | "https://www.googleapis.com/auth/spreadsheets" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_gmail-save-attachmets-content-to-spreadsheet/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_gmail-save-attachmets-to-drive/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "exceptionLogging": "STACKDRIVER", 5 | "oauthScopes": ["https://mail.google.com/", "https://www.googleapis.com/auth/drive"] 6 | } 7 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_gmail-save-attachmets-to-drive/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_parse-html-table/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_parse-html-table/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": ["./shims/String.repeat.js"] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_parse-html/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "oauthScopes": ["https://www.googleapis.com/auth/script.external_request"] 5 | } 6 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_parse-html/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_ramda-demo/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "enabledAdvancedServices": [ 5 | { 6 | "userSymbol": "Drive", 7 | "serviceId": "drive", 8 | "version": "v2" 9 | } 10 | ] 11 | }, 12 | "exceptionLogging": "STACKDRIVER", 13 | "oauthScopes": ["https://www.googleapis.com/auth/drive"] 14 | } 15 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_ramda-demo/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": ["shims/ramda.js"] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_ramda-demo/ramda-demo.js: -------------------------------------------------------------------------------- 1 | /* globals R */ 2 | /** 3 | * 4 | */ 5 | function run() { 6 | // `prop` takes two arguments. If I just give it one, I get a function back 7 | var moo = R.prop('moo'); 8 | // when I call that function with one argument, I get the result. 9 | var value = moo({ moo: 'cow' }); // => 'cow' 10 | Logger.log(value); 11 | } 12 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_simple-advanced-api-pagination/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "enabledAdvancedServices": [ 5 | { 6 | "userSymbol": "YouTube", 7 | "serviceId": "youtube", 8 | "version": "v3" 9 | } 10 | ] 11 | }, 12 | "webapp": { 13 | "access": "ANYONE_ANONYMOUS", 14 | "executeAs": "USER_DEPLOYING" 15 | }, 16 | "exceptionLogging": "STACKDRIVER" 17 | } 18 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_simple-advanced-api-pagination/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_simple-webapp/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "webapp": { 5 | "access": "ANYONE_ANONYMOUS", 6 | "executeAs": "USER_DEPLOYING" 7 | }, 8 | "exceptionLogging": "STACKDRIVER" 9 | } 10 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_simple-webapp/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone" 3 | } 4 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_simple-webapp/simple-webapp.js: -------------------------------------------------------------------------------- 1 | function doGet() { 2 | return HtmlService.createTemplateFromFile('app') 3 | .evaluate() 4 | .addMetaTag('viewport', 'width=device-width, initial-scale=1'); 5 | } 6 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_telegram-bot/.clasp.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptId": "1mk9OHnc4dUTriz5rt5iZg9VdJlokHnUaKrrjNsFJXKsY-eW581SgLWW2", 3 | "rootDir": "dist" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_telegram-bot/api.js: -------------------------------------------------------------------------------- 1 | function getScriptURL() { 2 | return ScriptApp.getService().getUrl(); 3 | } 4 | 5 | function setWebhook() { 6 | var uf = UrlFetchApp.fetch(api('setWebhook') + '?url=' + getScriptURL()); 7 | } 8 | 9 | function disableWebhook() { 10 | var uf = UrlFetchApp.fetch(api('setWebhook') + '?url='); 11 | } 12 | 13 | function getApiKey() { 14 | return PropertiesService.getScriptProperties().getProperty('apikey'); 15 | } 16 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_telegram-bot/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "webapp": { 5 | "access": "ANYONE_ANONYMOUS", 6 | "executeAs": "USER_DEPLOYING" 7 | }, 8 | "exceptionLogging": "STACKDRIVER" 9 | } 10 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_telegram-bot/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "single", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_telegram-bot/logic.js: -------------------------------------------------------------------------------- 1 | var SPRID = '128F4LovqmOV1E2LqXRBXj3HuDl4SCDpwUhJgj8Yzd1E'; 2 | 3 | function appendRow(data) { 4 | SpreadsheetApp.openById(SPRID).appendRow([new Date(), data]); 5 | } 6 | 7 | function readLastRow() { 8 | var data = SpreadsheetApp.openById(SPRID).getDataRange().getValues(); 9 | return JSON.stringify(data[data.length - 1], null, ' '); 10 | } 11 | 12 | function getValuesOfRange(a1Nota) { 13 | var data = SpreadsheetApp.openById(SPRID).getRange(a1Nota).getValues(); 14 | return JSON.stringify(data[data.length - 1], null, ' '); 15 | } 16 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_use-url-polyfill/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER" 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_use-url-polyfill/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": ["./shims/URL.js"] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_use-url-polyfill/use-url-polyfill.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file The URL constructor 3 | * @url https://developer.mozilla.org/en-US/docs/Web/API/URL 4 | */ 5 | 6 | /* globals URL */ 7 | /* exported userActionRun */ 8 | 9 | /** 10 | * User action. Runs the snippet 11 | */ 12 | function userActionRun() { 13 | // Base urls 14 | var m = 'https://developer.mozilla.org'; 15 | var a = new URL('/', m); // => 'https://developer.mozilla.org/' 16 | Logger.log(a.toString()); 17 | var b = new URL(m); // => 'https://developer.mozilla.org/' 18 | Logger.log(b.toString()); 19 | var d = new URL('/en-US/docs', b); // => 'https://developer.mozilla.org/en-US/docs' 20 | Logger.log(d.toString()); 21 | Logger.log(new URL('//foo.com', 'https://example.com').toString()); // => 'https://foo.com' (see relative URLs) 22 | } 23 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_use-urlsearchparams-polyfill copy/app.html: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_use-urlsearchparams-polyfill copy/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "webapp": { 5 | "access": "MYSELF", 6 | "executeAs": "USER_DEPLOYING" 7 | }, 8 | "exceptionLogging": "STACKDRIVER" 9 | } 10 | -------------------------------------------------------------------------------- /snippets/standalone/standalone_use-urlsearchparams-polyfill copy/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "standalone", 3 | "src": ["./shims/URL.js", "./shims/URLSearchParams.js"] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/webapp/form2Json/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": {}, 4 | "webapp": { 5 | "access": "ANYONE_ANONYMOUS", 6 | "executeAs": "USER_DEPLOYING" 7 | }, 8 | "exceptionLogging": "STACKDRIVER", 9 | "runtimeVersion": "V8" 10 | } 11 | -------------------------------------------------------------------------------- /snippets/webapp/form2Json/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "webapp", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/webapp/form2Json/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @file 4 | * {@link https://qna.habr.com/q/766259} 5 | */ 6 | 7 | /* global form2Json */ 8 | /* exported doPost */ 9 | /** 10 | * 11 | * @param {GoogleAppsScript.Events.DoPost} e 12 | */ 13 | function doPost(e) { 14 | // const payments = JSON.parse(e.parameter.payments); 15 | return ContentService.createTextOutput(JSON.stringify(form2Json(e.postData.contents), null, ' ')); 16 | } 17 | -------------------------------------------------------------------------------- /snippets/webapp/materializecss_form_to_sheet/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "America/New_York", 3 | "dependencies": {}, 4 | "webapp": { 5 | "access": "MYSELF", 6 | "executeAs": "USER_DEPLOYING" 7 | }, 8 | "exceptionLogging": "STACKDRIVER", 9 | "runtimeVersion": "V8" 10 | } 11 | -------------------------------------------------------------------------------- /snippets/webapp/materializecss_form_to_sheet/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "webapp", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/webapp/materializecss_form_to_sheet/page-css.html: -------------------------------------------------------------------------------- 1 | 30 | -------------------------------------------------------------------------------- /snippets/webapp/responsive-meta/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "webapp": { 3 | "executeAs": "USER_DEPLOYING", 4 | "access": "ANYONE_ANONYMOUS" 5 | }, 6 | "runtimeVersion": "V8" 7 | } 8 | -------------------------------------------------------------------------------- /snippets/webapp/responsive-meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "webapp", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/webapp/responsive-meta/index.js: -------------------------------------------------------------------------------- 1 | /* exported doGet */ 2 | /** 3 | * Using responsive meta tags for the webapp 4 | */ 5 | function doGet() { 6 | const htmlContent = 'Hello world!'; 7 | return HtmlService.createHtmlOutput(htmlContent).addMetaTag('viewport', 'width=device-width, initial-scale=1'); 8 | } 9 | -------------------------------------------------------------------------------- /snippets/webapp/responsive-meta/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/webapp/responsive-meta/screenshot.png -------------------------------------------------------------------------------- /snippets/webapp/spreadsheet_to_json/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "dependencies": { 4 | "enabledAdvancedServices": [ 5 | { 6 | "userSymbol": "Sheets", 7 | "serviceId": "sheets", 8 | "version": "v4" 9 | } 10 | ] 11 | }, 12 | "webapp": { 13 | "access": "ANYONE_ANONYMOUS", 14 | "executeAs": "USER_DEPLOYING" 15 | }, 16 | "exceptionLogging": "STACKDRIVER" 17 | } 18 | -------------------------------------------------------------------------------- /snippets/webapp/spreadsheet_to_json/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "webapp", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/webapp/spreadsheet_to_json/screenrecord.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/webapp/spreadsheet_to_json/screenrecord.gif -------------------------------------------------------------------------------- /snippets/webapp/spreadsheet_to_json/screenrecord.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oshliaer/google-apps-script-snippets/aa79e196c459f400ac95987df92b370f3f43c7ff/snippets/webapp/spreadsheet_to_json/screenrecord.mp4 -------------------------------------------------------------------------------- /snippets/webapp/webserver/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "webapp": { 4 | "access": "ANYONE_ANONYMOUS", 5 | "executeAs": "USER_DEPLOYING" 6 | }, 7 | "exceptionLogging": "STACKDRIVER" 8 | } 9 | -------------------------------------------------------------------------------- /snippets/webapp/webserver/client/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | Hi 10 | 11 | 12 | -------------------------------------------------------------------------------- /snippets/webapp/webserver/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "webapp", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /snippets/webapp/webserver/server/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @param {GoogleAppsScript.Events.DoGet} e 4 | */ 5 | function doGet(e) { 6 | return HtmlService.createHtmlOutputFromFile('client/index'); 7 | } 8 | 9 | /** 10 | * @param {GoogleAppsScript.Events.DoPost} 11 | */ 12 | function doPost(e) { 13 | return ContentService.createTextOutput(JSON.stringify({ date: new Date().toLocaleTimeString('ru') })); 14 | } 15 | -------------------------------------------------------------------------------- /templates/sheet_snippet/appsscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeZone": "Europe/Moscow", 3 | "exceptionLogging": "STACKDRIVER", 4 | "runtimeVersion": "V8" 5 | } 6 | -------------------------------------------------------------------------------- /templates/sheet_snippet/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "container-bound-sheet", 3 | "src": [] 4 | } 5 | -------------------------------------------------------------------------------- /templates/sheet_snippet/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Paints the active cell text in rainbow colors. 3 | * @return {undefined} 4 | */ 5 | -------------------------------------------------------------------------------- /templates/sheet_snippet/readme.md: -------------------------------------------------------------------------------- 1 | # Spreadsheet snippet 2 | -------------------------------------------------------------------------------- /tools/flat-polyfill/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const got = require('got'); 4 | const fs = require('fs').promises; 5 | 6 | const getOriginFile = async () => { 7 | const url = 'https://raw.githubusercontent.com/jonathantneal/array-flat-polyfill/master/src/polyfill-flat.js'; 8 | const { body } = await got(url); 9 | return body; 10 | }; 11 | 12 | const main = async () => { 13 | const content = await getOriginFile(); 14 | return fs.writeFile('./shims/Array.flat.js', content, 'utf8'); 15 | }; 16 | 17 | main().catch((err) => { 18 | console.error(err.message); 19 | process.exit(1); 20 | }); 21 | -------------------------------------------------------------------------------- /tools/jsonata/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const fs = require('fs').promises; 4 | 5 | const main = async () => { 6 | return fs.copyFile('node_modules/jsonata/jsonata-es5.js', 'shims/jsonata.js'); 7 | }; 8 | 9 | main().catch((err) => { 10 | console.error(err.message); 11 | process.exit(1); 12 | }); 13 | -------------------------------------------------------------------------------- /tools/ramda/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const got = require('got'); 4 | const fs = require('fs').promises; 5 | 6 | const getOriginFile = async () => { 7 | const url = 'https://raw.githubusercontent.com/ramda/ramda/master/dist/ramda.js'; 8 | const { body } = await got(url); 9 | return body; 10 | }; 11 | 12 | const main = async () => { 13 | const content = await getOriginFile(); 14 | return fs.writeFile('./shims/ramda.js', content, 'utf8'); 15 | }; 16 | 17 | main().catch((err) => { 18 | console.error(err.message); 19 | process.exit(1); 20 | }); 21 | -------------------------------------------------------------------------------- /tools/xml-js/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const fs = require('fs').promises; 4 | 5 | const main = async () => { 6 | return fs.copyFile('node_modules/xml-js/dist/xml-js.js', 'shims/xml-js.js'); 7 | }; 8 | 9 | main().catch((err) => { 10 | console.error(err.message); 11 | process.exit(1); 12 | }); 13 | --------------------------------------------------------------------------------