diff --git a/examples/README.md b/examples/README.md index 8529e7d..6c126e2 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,146 +1,232 @@ # Google Sheets Examples -* [X] Creating a Google API service account - [1](https://www.youtube.com/watch?v=sAgWCbGMzTo&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=1) - [2](https://www.youtube.com/watch?v=sVURhxyc6jE&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=43) +* [✅︎ Creating a Google API service account](#︎-creating-a-google-api-service-account) +* [✅︎ Create a SheetsService instance](#︎-create-a-sheetsservice-instance) +* [✅︎ Set background color](#︎-set-background-color) +* [Creating Google Sheets files](#creating-google-sheets-files) +* [Writing data to a sheet](#writing-data-to-a-sheet) +* [Reading data from a sheet](#reading-data-from-a-sheet) +* [Data formatting basics](#data-formatting-basics) +* [Creating charts](#creating-charts) +* [Data validation](#data-validation) +* [Cut, copy, and paste](#cut-copy-and-paste) +* [Duplicate sheets](#duplicate-sheets) +* [List sheets in a spreadsheet](#list-sheets-in-a-spreadsheet) +* [Set column width and row height](#set-column-width-and-row-height) +* [Append rows and columns](#append-rows-and-columns) +* [Delete rows and columns](#delete-rows-and-columns) +* [Insert rows and columns](#insert-rows-and-columns) +* [Move rows and columns](#move-rows-and-columns) +* [Clear data](#clear-data) +* [Add and delete sheets](#add-and-delete-sheets) +* [Copy sheet from one spreadsheet to another](#copy-sheet-from-one-spreadsheet-to-another) +* [Add a new sheet to an existing spreadsheet](#add-a-new-sheet-to-an-existing-spreadsheet) +* [Export a sheet to a CSV file](#export-a-sheet-to-a-csv-file) +* [Sort sheets](#sort-sheets) +* [Add calculated fields into a pivot table](#add-calculated-fields-into-a-pivot-table) +* [Named ranges](#named-ranges) +* [Create a pivot table](#create-a-pivot-table) +* [Calculated pivot fields](#calculated-pivot-fields) +* [Delete a pivot table](#delete-a-pivot-table) +* [Add pivot fields](#add-pivot-fields) +* [Add pivot filters](#add-pivot-filters) +* [Collapse/expand pivot table groups](#collapseexpand-pivot-table-groups) +* [Extract pivot table metadata](#extract-pivot-table-metadata) +* [Filter views](#filter-views) +* [Locate the last row in a column](#locate-the-last-row-in-a-column) +* [Autofill](#autofill) +* [Rename a sheet](#rename-a-sheet) +* [Find and replace](#find-and-replace) +* [Add and delete sheets](#add-and-delete-sheets-1) +* [Sum across sheets](#sum-across-sheets) +* [Freeze rows / columns](#freeze-rows--columns) +* [Protected ranges](#protected-ranges) +* [Resize a sheet](#resize-a-sheet) +* [Retrying on error](#retrying-on-error) +* [Set a custom datetime or decimal format for a range](#set-a-custom-datetime-or-decimal-format-for-a-range) - * See the [Getting started](https://github.com/main-branch/sheets_v4#getting-started) - section in the project README.md +Annotated examples written in Ruby. -* [X] Create a SheetsService instance +Checked (✅︎) topics are completed. Topics without a check still need to be added. - * See the [Usage](https://github.com/main-branch/sheets_v4#usage) section in the - project README.md +### ✅︎ Creating a Google API service account -* [X] Set background color +[1](https://www.youtube.com/watch?v=sAgWCbGMzTo&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=1) - * [examples/set_background_color1](https://github.com/main-branch/sheets_v4/blob/main/examples/set_background_color1): - set background colors building requests using `Google::Apis::SheetsV4::*` objects. - See the [Building a request](https://github.com/main-branch/sheets_v4/blob/main/README.md#building-a-request) - section in the project README.md. +[2](https://www.youtube.com/watch?v=sVURhxyc6jE&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=43) - * [examples/set_background_color2](https://github.com/main-branch/sheets_v4/blob/main/examples/set_background_color2): - set background colors building requests using `Hash` objects. - See the [Building a request](https://github.com/main-branch/sheets_v4/blob/main/README.md#building-a-request) - section in the project README.md. +See the [Getting started](https://github.com/main-branch/sheets_v4#getting-started) +section in the project README.md -* [ ] Creating Google Sheets files - [1](https://www.youtube.com/watch?v=JRUxeQ6ZCy0&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=2) +### ✅︎ Create a SheetsService instance -* [ ] Writing data to a sheet - [1](https://www.youtube.com/watch?v=YF7Ad-7pvks&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=3) +See [Obtaining an authenticated SheetsService](https://github.com/main-branch/sheets_v4#obtaining-an-authenticated-sheetsservice) +section in the project README.md -* [ ] Reading data from a sheet - [1](https://www.youtube.com/watch?v=gkglr8GID5E&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=4) +### ✅︎ Set background color - * Reading data +[examples/set_background_color1](https://github.com/main-branch/sheets_v4/blob/main/examples/set_background_color1): +set background colors building requests using `Google::Apis::SheetsV4::*` objects. +See the [Building a request](https://github.com/main-branch/sheets_v4/blob/main/README.md#building-a-request) +section in the project README.md. - * Reading formulas +[examples/set_background_color2](https://github.com/main-branch/sheets_v4/blob/main/examples/set_background_color2): +set background colors building requests using `Hash` objects. +See the [Building a request](https://github.com/main-branch/sheets_v4/blob/main/README.md#building-a-request) +section in the project README.md. -* [ ] Data formatting basics - [1](https://www.youtube.com/watch?v=R4EN3iPRris&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=5) +### Creating Google Sheets files -* [ ] Creating charts - [1](https://www.youtube.com/watch?v=xt3p5I8mNWE&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=6) +[1](https://www.youtube.com/watch?v=JRUxeQ6ZCy0&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=2) -* [ ] Data validation - [1](https://www.youtube.com/watch?v=n_Z2565gu6Y&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=7) +### Writing data to a sheet -* [ ] Cut, copy, and paste - [1](https://www.youtube.com/watch?v=r8GWH2E_ehw&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=8) +[1](https://www.youtube.com/watch?v=YF7Ad-7pvks&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=3) -* [ ] Duplicate sheets - [1](https://www.youtube.com/watch?v=BgQoPcoOiGY&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=9) +### Reading data from a sheet -* [ ] List sheets in a spreadsheet - [1](https://www.youtube.com/watch?v=BgQoPcoOiGY&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=9) +[1](https://www.youtube.com/watch?v=gkglr8GID5E&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=4) -* [ ] Set column width and row height - [1](https://www.youtube.com/watch?v=H3uMEaPqTVE&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=11) +Reading data -* [ ] Append rows and columns - [1](https://www.youtube.com/watch?v=txfiwEjb7sk&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=12) +Reading formulas -* [ ] Delete rows and columns - [1](https://www.youtube.com/watch?v=w1jrCxWx7Tc&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=13) +### Data formatting basics -* [ ] Insert rows and columns - [1](https://www.youtube.com/watch?v=FL7WSsO5EVs&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=14) +[1](https://www.youtube.com/watch?v=R4EN3iPRris&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=5) -* [ ] Move rows and columns - [1](https://www.youtube.com/watch?v=YHk3305dkOc&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=15) +### Creating charts -* [ ] Clear data - [1](https://www.youtube.com/watch?v=mvbnhfdDrro&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=16) +[1](https://www.youtube.com/watch?v=xt3p5I8mNWE&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=6) -* [ ] Add and delete sheets - [1](https://www.youtube.com/watch?v=X9PVQQVoJFc&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=17) +### Data validation -* [ ] Copy sheet from one spreadsheet to another - [1](https://www.youtube.com/watch?v=aIEM7Ts4n-c&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=18) +[1](https://www.youtube.com/watch?v=n_Z2565gu6Y&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=7) -* [ ] Add a new sheet to an existing spreadsheet +### Cut, copy, and paste -* [ ] Export a sheet to a CSV file - [1](https://www.youtube.com/watch?v=Dz22fsWsLhI&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=25) +[1](https://www.youtube.com/watch?v=r8GWH2E_ehw&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=8) -* [ ] Sort sheets - [1](https://www.youtube.com/watch?v=qbBZX7uBM1M&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=27) +### Duplicate sheets -* [ ] Add calculated fields into a pivot table - [1](https://www.youtube.com/watch?v=VR8zOz5ATLU&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=32) +[1](https://www.youtube.com/watch?v=BgQoPcoOiGY&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=9) -* [ ] Named ranges - [1](https://www.youtube.com/watch?v=LTPdfXS_LHA&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=42) +### List sheets in a spreadsheet -* [ ] Create a pivot table - [1](https://www.youtube.com/watch?v=preFnuL7ua0&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=28) +[1](https://www.youtube.com/watch?v=BgQoPcoOiGY&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=9) -* [ ] Calculated pivot fields - [1](https://www.youtube.com/watch?v=QLssI4uvjk4&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=33) +### Set column width and row height -* [ ] Delete a pivot table +[1](https://www.youtube.com/watch?v=H3uMEaPqTVE&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=11) -* [ ] Add pivot fields - [1](https://www.youtube.com/watch?v=VR8zOz5ATLU&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=32) +### Append rows and columns -* [ ] Add pivot filters - [1](https://www.youtube.com/watch?v=EKikw-eIcbY&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=29) +[1](https://www.youtube.com/watch?v=txfiwEjb7sk&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=12) -* [ ] Collapse/expand pivot table groups - [1](https://www.youtube.com/watch?v=-S9bs5-ZJ5E&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=31) +### Delete rows and columns -* [ ] Extract pivot table metadata - [1](https://www.youtube.com/watch?v=H1SGdqbaL4w&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=30) +[1](https://www.youtube.com/watch?v=w1jrCxWx7Tc&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=13) -* [ ] Filter views - [1](https://www.youtube.com/watch?v=GyRxsSlx0GU&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=34) +### Insert rows and columns -* [ ] Locate the last row in a column - [1](https://www.youtube.com/watch?v=NWWHleJll28&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=35) +[1](https://www.youtube.com/watch?v=FL7WSsO5EVs&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=14) -* [ ] Autofill - [1](https://www.youtube.com/watch?v=guHGNmODdpM&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=36) +### Move rows and columns -* [ ] Rename a sheet - [1](https://www.youtube.com/watch?v=iuiDUJ4NrQI&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=37) +[1](https://www.youtube.com/watch?v=YHk3305dkOc&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=15) -* [ ] Find and replace - [1](https://www.youtube.com/watch?v=YaFR0bu5CrY&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=39) +### Clear data -* [ ] Add and delete sheets - [1](https://www.youtube.com/watch?v=gMD4v8F8vlc&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=38) +[1](https://www.youtube.com/watch?v=mvbnhfdDrro&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=16) -* [ ] Sum across sheets - [1](https://www.youtube.com/watch?v=7QNk-MXkPC4&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=44) +### Add and delete sheets -* [ ] Freeze rows / columns +[1](https://www.youtube.com/watch?v=X9PVQQVoJFc&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=17) -* [ ] Protected ranges +### Copy sheet from one spreadsheet to another -* [ ] Resize a sheet +[1](https://www.youtube.com/watch?v=aIEM7Ts4n-c&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=18) -* [ ] Retrying on error +### Add a new sheet to an existing spreadsheet -* [ ] Set a custom datetime or decimal format for a range - [1](https://developers.google.com/sheets/api/samples/formatting#set_a_custom_datetime_or_decimal_format_for_a_range) +### Export a sheet to a CSV file + +[1](https://www.youtube.com/watch?v=Dz22fsWsLhI&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=25) + +### Sort sheets + +[1](https://www.youtube.com/watch?v=qbBZX7uBM1M&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=27) + +### Add calculated fields into a pivot table + +[1](https://www.youtube.com/watch?v=VR8zOz5ATLU&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=32) + +### Named ranges + +[1](https://www.youtube.com/watch?v=LTPdfXS_LHA&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=42) + +### Create a pivot table + +[1](https://www.youtube.com/watch?v=preFnuL7ua0&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=28) + +### Calculated pivot fields + +[1](https://www.youtube.com/watch?v=QLssI4uvjk4&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=33) + +### Delete a pivot table + +### Add pivot fields + +[1](https://www.youtube.com/watch?v=VR8zOz5ATLU&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=32) + +### Add pivot filters + +[1](https://www.youtube.com/watch?v=EKikw-eIcbY&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=29) + +### Collapse/expand pivot table groups + +[1](https://www.youtube.com/watch?v=-S9bs5-ZJ5E&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=31) + +### Extract pivot table metadata + +[1](https://www.youtube.com/watch?v=H1SGdqbaL4w&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=30) + +### Filter views + +[1](https://www.youtube.com/watch?v=GyRxsSlx0GU&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=34) + +### Locate the last row in a column + +[1](https://www.youtube.com/watch?v=NWWHleJll28&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=35) + +### Autofill + +[1](https://www.youtube.com/watch?v=guHGNmODdpM&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=36) + +### Rename a sheet + +[1](https://www.youtube.com/watch?v=iuiDUJ4NrQI&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=37) + +### Find and replace + +[1](https://www.youtube.com/watch?v=YaFR0bu5CrY&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=39) + +### Add and delete sheets + +[1](https://www.youtube.com/watch?v=gMD4v8F8vlc&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=38) + +### Sum across sheets + +[1](https://www.youtube.com/watch?v=7QNk-MXkPC4&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=44) + +### Freeze rows / columns + +### Protected ranges + +### Resize a sheet + +### Retrying on error + +### Set a custom datetime or decimal format for a range + +[1](https://developers.google.com/sheets/api/samples/formatting#set_a_custom_datetime_or_decimal_format_for_a_range) diff --git a/examples/create_spreadsheet b/examples/create_spreadsheet new file mode 100755 index 0000000..7554c17 --- /dev/null +++ b/examples/create_spreadsheet @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require 'sheets_v4' + +# Requires one of the following Auth scopes: +# * https://www.googleapis.com/auth/drive +# * https://www.googleapis.com/auth/drive.file +# * https://www.googleapis.com/auth/spreadsheets + +SheetsV4.sheets_service.create_spreadsheet