Skip to main content
Glama
marekrost

mcp-server-spreadsheet

clear_range

Clear cell values in a spreadsheet range while preserving row and column structure. Use this tool to remove data from specific cells without deleting rows or columns.

Instructions

Clear all cell values in a range without removing rows or columns.

Sets every cell in the range to null. Row/column structure is preserved.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYesPath to the spreadsheet file
range_strYesRange to clear in A1 notation, e.g. 'A1:D10'. Only values are removed.
sheetNoSheet name. Defaults to the first sheet if omitted.

Implementation Reference

  • The clear_range tool handler, which clears cell values in a specified range and saves the spreadsheet.
    @mcp.tool()
    def clear_range(
        file: Annotated[str, Field(description="Path to the spreadsheet file")],
        range_str: Annotated[str, Field(description="Range to clear in A1 notation, e.g. 'A1:D10'. Only values are removed.")],
        sheet: Annotated[str | None, Field(description="Sheet name. Defaults to the first sheet if omitted.")] = None,
    ) -> str:
        """Clear all cell values in a range without removing rows or columns.
    
        Sets every cell in the range to null. Row/column structure is preserved.
        """
        wb = load_workbook(file)
        ws = _resolve_sheet(wb, sheet)
        min_col, min_row, max_col, max_row = parse_range(range_str)
        for r in range(min_row, max_row + 1):
            for c in range(min_col, max_col + 1):
                ws.set_cell(r, c, None)
        wb.save(file)
        return f"Cleared range {range_str}"

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