> ## Documentation Index
> Fetch the complete documentation index at: https://docs.narada.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# write_google_sheet

> Write data to Google Sheets using the Narada Python SDK

The `write_google_sheet` method writes data to a specified range of cells in a Google Sheet. This method requires that the user has the appropriate Google Sheets permissions configured in their Narada extension.

<Note>
  This method requires Google Sheets access to be configured in the Narada extension. If this is your first time using Google Sheets methods, the Narada extension will prompt you to authorize access. The user must have write permissions for the specified spreadsheet.
</Note>

## Method Signature

```python theme={null}
async def write_google_sheet(
    self,
    *,
    spreadsheet_id: str,
    range: str,
    values: list[list[str]],
    timeout: int | None = None,
) -> None
```

## Parameters

<ParamField query="spreadsheet_id" type="str" required>
  The ID of the Google Sheet. This is the long string in the Google Sheets URL.

  ```python theme={null}
  # From URL: https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit
  spreadsheet_id="1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"
  ```
</ParamField>

<ParamField query="range" type="str" required>
  The range of cells to write to in A1 notation. Can include sheet name.

  ```python theme={null}
  range="A1:C3"            # Range on default sheet
  range="Sheet1!A1:C3"     # Range on specific sheet
  range="Data!B2:E5"       # Named sheet with range
  ```
</ParamField>

<ParamField query="values" type="list[list[str]]" required>
  A 2D array containing the data to write. Each inner list represents a row of data.

  ```python theme={null}
  values=[
      ["Name", "Age", "City"],
      ["Alice", "25", "New York"],
      ["Bob", "30", "San Francisco"]
  ]
  ```
</ParamField>

<ParamField query="timeout" type="int | None" default="None">
  Maximum time in seconds to wait for the operation to complete.

  ```python theme={null}
  timeout=30     # Wait up to 30 seconds
  timeout=None   # Use default timeout
  ```
</ParamField>

## Return Value

This method returns `None` and completes when the data has been written to the sheet.

## Example

```python theme={null}
import asyncio

from narada import Agent, BrowserEnvironment

async def main():
    env = BrowserEnvironment()
    agent = Agent(environment=env)

    try:
        # Write data to a Google Sheet
        await agent.write_google_sheet(
            spreadsheet_id="1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms",
            range="Sheet1!A1:C3",
            values=[
                ["Product", "Price", "Stock"],
                ["Laptop", "999", "15"],
                ["Mouse", "25", "50"]
            ]
        )

        print("Data written successfully!")
    finally:
        await env.close()

if __name__ == "__main__":
    asyncio.run(main())
```
