All docs This doc

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Copy-edit

...

This method allows you to creates create a new spreadsheet by optionally add sheets to spreadsheet, set specifying the spreadsheet id and , sheet properties, and add named ranges.

...

  • spreadsheetId [Optional] :- Unique value of the spreadsheet
  • properties [Optional] :- Properties of the spreadsheet.
  • sheets [Optional] :- List of sheets and their properties that you want to add into the spread sheetspreadsheet. You can add multiple sheets.
  • namedRanges [Optional] :- Create names that refer to a single cell or a group of cells on the sheet. Following sample request will create name range with the name "Name" for  the range A1:A6.
  • fields [Optional] :- Specifying which fields to include in a partial response. For the following request only the "spreadsheetId" will be included in the response.
Sample request

Following is a The sample request that can be used for createSpreadsheet given below calls the createSpreadsheet operation. With the following request we can specify spreadsheet details such as spreadsheet name ("Company"), sheets details such as sheet name ("Employees") as an array. So the spreadsheet will be created inside Google Sheets with the name "Company" and the sheet will be created with the name "Employees". Here we specify "fields" property to get a partial response. As per the following request, only the "spreadsheetId" will be included in the response.

...

https://developers.google.com/sheets/reference/rest/v4/spreadsheets#Spreadsheet

Sample configuration

Following The following example illustrates how to connect to Google Spreadsheet with the init operation and createSpreadsheet operation.

...

3. Replace Your_clientId, Your_clientSecret, Your_refreshToken, Your_accessToken with your values.

4. Execute the following cURL curl command:

Code Block
titleCURL command
curl http://localhost:8280/services/createSpreadsheet -H "Content-Type: application/json" -d @createSpreadsheet.json

5. Spreadsheet will returns an json Spreadsheet returns a JSON response as shown below :

Code Block
titleResponse
{
  "spreadsheetId": "16mEgWpzuoXczkLUA4PDDjGHzVmAI3D_QVQ9kguv2EC8",
  "properties": {
    "title": "Company",
    "locale": "en_US",
    "autoRecalc": "ON_CHANGE",
    "timeZone": "Etc/GMT",
    "defaultFormat": {
      "backgroundColor": {
        "red": 1,
        "green": 1,
        "blue": 1
      },
      "padding": {
        "top": 2,
        "right": 3,
        "bottom": 2,
        "left": 3
      },
      "verticalAlignment": "BOTTOM",
      "wrapStrategy": "OVERFLOW_CELL",
      "textFormat": {
        "foregroundColor": {},
        "fontFamily": "arial,sans,sans-serif",
        "fontSize": 10,
        "bold": false,
        "italic": false,
        "strikethrough": false,
        "underline": false
      }
    }
  },
  "sheets": [
    {
      "properties": {
        "sheetId": 67204741,
        "title": "Employees",
        "index": 0,
        "sheetType": "GRID",
        "gridProperties": {
          "rowCount": 1000,
          "columnCount": 26
        }
      }
    }
  ],
  "spreadsheetUrl": "https://docs.google.com/spreadsheets/d/16mEgWpzuoXczkLUA4PDDjGHzVmAI3D_QVQ9kguv2EC8/edit"
}