Skip to content

04‐API

Teeraphat Kullanankanjana edited this page Oct 28, 2023 · 9 revisions

Import Library

from ggsheet import MicroGoogleSheet

Class Instance

MicroGoogleSheet(googleSheetURL, sheet_name, deploymentID)

Initializes the MicroGoogleSheet class with the Google Sheet URL, sheet name, and deployment ID.

Parameters

  • googleSheetURL(str): The URL of the Google Sheet.
  • sheet_name(str, optional): The name of the sheet within the Google Sheet. Default is "Sheet1".
  • deploymentID(str, optional): The deployment ID of the Google Apps Script web app. The default is an empty string, which can be added later with set_DeploymentID().
# Google Sheet Credential 
google_sheet_url = "https://docs.google.com/spreadsheets/d/xxxxxxxxx/edit#gid=0"
google_sheet_name = "Sheet1"
google_app_deployment_id = "xxxxxxxx"

# Create Instance 
ggsheet = MicroGoogleSheet(google_sheet_url,google_sheet_name,google_app_deployment_id)

Set Deployment ID

set_DeploymentID(deployment_id)

Sets the deployment ID for the Google Apps Script web app.

Parameters

  • deployment_id(str): The deployment ID to set.
# Google Sheet Credential 
google_sheet_url = "https://docs.google.com/spreadsheets/d/xxxxxxxxx/edit#gid=0"
google_sheet_name = "Sheet1"
google_app_deployment_id = "xxxxxxxx"

ggsheet = MicroGoogleSheet(google_sheet_url,google_sheet_name)
ggsheet.set_DeploymentID(google_app_deployment_id)

Set Sheet Name

set_SheetName(sheetName)

Sets the name of the sheet within the Google Sheet.

Parameters

  • sheetName (str): The sheet name to set.
# Google Sheet Credential 
google_sheet_url = "https://docs.google.com/spreadsheets/d/xxxxxxxxx/edit#gid=0"
google_sheet_name = "Sheet1"
google_app_deployment_id = "xxxxxxxx"

# Class Instance
ggsheet = MicroGoogleSheet(google_sheet_url,google_sheet_name)
# Set Deployment ID
ggsheet.set_DeploymentID(google_app_deployment_id)
# Set the sheet name from "Sheet1" to "Sheet2"
ggsheet.set_SheetName("Sheet2")

Generate Google Sheet Script

gen_scriptFile()

Generate a Google Apps Script file for Google Sheet operations.

# Google Sheet Credential 
google_sheet_url = "https://docs.google.com/spreadsheets/d/xxxxxxxxx/edit#gid=0"

# Class Instance
ggsheet = MicroGoogleSheet(google_sheet_url)

# Generate Google Script File
ggsheet.gen_scriptFile()

Update

The

updateCell()

Python Code

updateRow()

Python Code

updateColumn()

Python Code

Get

Python Code

getCell()

Python Code

getRow()

Python Code

getColumn()

Python Code

Delete

Python Code

deleteCell()

Python Code

deleteRow()

Python Code

deleteColumn()

Python Code

Append

Python Code

appendCell()

Python Code

appendRow()

Python Code

appendColumn()

Python Code

Clone this wiki locally