Skip to main content
Glama
marekrost

mcp-server-spreadsheet

write_range

Write a 2D array of values into a spreadsheet region starting from a specified cell, replacing multiple individual cell writes with a single efficient operation.

Instructions

Write a 2D array of values into a rectangular region.

Writing starts at start_cell and expands right and down to fit the data. Prefer this over multiple write_cell calls for efficiency.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYesPath to the spreadsheet file
start_cellYesTop-left cell where writing begins, e.g. 'B2'
dataYes2D array of values (list of rows), e.g. [[1, 2, 3], ['a', 'b', 'c']]. Numeric strings are coerced to numbers.
sheetNoSheet name. Defaults to the first sheet if omitted.

Implementation Reference

  • Implementation of the write_range MCP tool which writes a 2D array of values into a spreadsheet at a specified starting cell.
    def write_range(
        file: Annotated[str, Field(description="Path to the spreadsheet file")],
        start_cell: Annotated[str, Field(description="Top-left cell where writing begins, e.g. 'B2'")],
        data: Annotated[list[list], Field(description="2D array of values (list of rows), e.g. [[1, 2, 3], ['a', 'b', 'c']]. Numeric strings are coerced to numbers.")],
        sheet: Annotated[str | None, Field(description="Sheet name. Defaults to the first sheet if omitted.")] = None,
    ) -> str:
        """Write a 2D array of values into a rectangular region.
    
        Writing starts at start_cell and expands right and down to fit the
        data. Prefer this over multiple write_cell calls for efficiency.
        """
        wb = load_workbook(file)
        ws = _resolve_sheet(wb, sheet)
        row_off, col_off = parse_cell(start_cell)
        for r_idx, row in enumerate(data):
            for c_idx, val in enumerate(row):
                ws.set_cell(row_off + r_idx, col_off + c_idx, coerce_value(val))
        wb.save(file)
        return f"Wrote {len(data)} rows starting at {start_cell}"

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/marekrost/mcp-server-spreadsheet'

If you have feedback or need assistance with the MCP directory API, please join our Discord server