SheetsUpdateValuesTool()Create a tool from an API key.
Tool for updating values in a single range of Google Sheets.
Inherits from
SheetsBaseTool.
Updates cell values in a specified range, overwriting existing data.
Requires OAuth2 authentication. Use api_resource parameter with
authenticated Google Sheets service.
Tool Output:
success (bool): Whether operation succeeded. spreadsheet_id (str): The spreadsheet ID. updated_range (str): The A1 notation of updated range. updated_rows (int): Number of rows updated. updated_columns (int): Number of columns updated. updated_cells (int): Total number of cells updated.
Update a range with data:
from langchain_google_community.sheets import SheetsUpdateValuesTool
tool = SheetsUpdateValuesTool(api_resource=service)
result = tool.run(
{
"spreadsheet_id": "1TI6vO9eGsAeXcfgEjoEYcu4RgSZCUF4vdWGLBpg9-fg",
"range": "Sheet1!A1:C3",
"values": [
["Name", "Age", "City"],
["Alice", "25", "New York"],
["Bob", "30", "San Francisco"],
],
}
)Update cells with formulas using USER_ENTERED:
result = tool.run(
{
"spreadsheet_id": "1TI6vO9eGsAeXcfgEjoEYcu4RgSZCUF4vdWGLBpg9-fg",
"range": "Sheet1!D2:D3",
"values": [["=SUM(B2:C2)"], ["=SUM(B3:C3)"]],
"value_input_option": "USER_ENTERED",
}
)