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 开始, 默认第一行为表头
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

注解已声明只读等特性,描述额外提供了错误处理细节和返回结构,增加价值。无矛盾。

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

描述较长但结构清晰,包含参数、返回值、示例和错误处理,无冗余,适合复杂工具。

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

对于只读工具,描述了所有参数、返回结构和错误处理,无需输出模式,非常完整。

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

模式覆盖率100%,描述在基线之上提供了示例和默认值解释,但未添加大量新信息。略微超出基线。

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

描述明确说明工具用于读取xlsx文件指定sheet的数据,支持两种格式,与兄弟工具(添加、创建、列出、更新)区分明显。

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

描述通过示例隐含使用场景,但未显式说明何时不使用或替代工具。上下文清晰,但缺乏明确排除项。

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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