SheetsCreateSpreadsheetTool()Create a tool from an API key.
Tool for creating new Google Spreadsheets.
Inherits from
SheetsBaseTool.
Creates spreadsheets with configurable properties and optional initial data.
Requires OAuth2 authentication. Use api_resource parameter with
authenticated Google Sheets service.
Tool Output:
success (bool): Whether operation succeeded. spreadsheet_id (str): Unique ID of the created spreadsheet. spreadsheet_url (str): Direct URL to open the spreadsheet. title (str): The spreadsheet title. locale (str): The locale setting. time_zone (str): The timezone setting. auto_recalc (str): The recalculation setting. created (bool): Whether creation succeeded. initial_data_added (bool): Whether initial data was added (if provided). initial_data_cells_updated (int): Number of cells updated (if data added). initial_data_range (str): Range where data was placed (if data added).
Create a simple spreadsheet:
from langchain_google_community.sheets import SheetsCreateSpreadsheetTool
tool = SheetsCreateSpreadsheetTool(api_resource=service)
result = tool.run({"title": "My New Spreadsheet"})
print(f"Created: {result['spreadsheet_url']}")Create spreadsheet with pre-populated data:
result = tool.run(
{
"title": "Sales Report",
"initial_data": [
["Name", "Region", "Sales"],
["Alice", "East", "95000"],
["Bob", "West", "87000"],
],
"initial_range": "A1",
}
)Create with locale and timezone settings:
result = tool.run(
{
"title": "European Report",
"locale": "fr_FR",
"time_zone": "Europe/Paris",
"auto_recalc": "HOUR",
}
)