Skip to main content
Glama
lubo3395
by lubo3395

读取 Excel Sheet 数据

xlsx_read
Read-onlyIdempotent

Read specific sheets from xlsx files, outputting data as JSON object arrays or two-dimensional arrays. Supports custom cell ranges and header rows.

Instructions

读取 xlsx 文件中指定 sheet 的数据,支持 JSON 对象数组和二维数组两种格式。

参数:

  • file_path (string, 必填): xlsx 文件路径

  • sheet (string|number, 必填): sheet 名称或索引 (从 0 开始)

  • format (string, 默认 "json"): 输出格式

    • "json": 返回对象数组 (第一行为表头)

    • "array": 返回二维数组

  • range (string, 可选): 单元格范围,如 "A1:C10"

  • header_row (number, 默认 0): 表头行号,仅 json 格式有效

返回:

  • sheet: 读取的 sheet 名称

  • rows: 数据行数

  • cols: 数据列数

  • data: 表格数据

  • format: 数据格式

示例:

  • "读取 test.xlsx 的 Sheet1" -> { file_path: "test.xlsx", sheet: "Sheet1" }

  • "读取 test.xlsx 第一个 sheet 的 A1 到 C10 范围" -> { file_path: "test.xlsx", sheet: 0, range: "A1:C10" }

  • "以二维数组格式读取" -> { file_path: "test.xlsx", sheet: "Sheet1", format: "array" }

错误处理:

  • sheet 不存在: "Sheet "名称" 不存在。可用的 sheet: ..."

  • sheet 索引无效: "Sheet 索引无效: ..."

  • 文件不存在: "文件不存在: <路径>"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesxlsx 文件路径
sheetYessheet 名称或索引 (从 0 开始)
formatNo输出格式: 'json' 返回对象数组 (第一行为表头), 'array' 返回二维数组json
rangeNo可选单元格范围, 如 'A1:C10'
header_rowNo表头行号 (仅 json 格式有效), 从 0 开始, 默认第一行为表头

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

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/lubo3395/mcp-xlsx-server'

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