xlq
jq for Excel -流式xlsx CLI工具和MCP服务器。
xlq为Excel文件提供了高效、内存受限的操作。它可以处理数百万行电子表格,而无需将其完全加载到内存中。
特性
- 流媒体架构:处理内存小于100MB的任何大小的文件
- 双模式:CLI用于人类,MCP服务器用于AI代理
- 多种格式:JSON(默认)、CSV、TSV输出
- Unix哲学:简单、可组合的命令
安装
家酿
brew tap Fuabioo/tap
brew install xlq从源头构建
git clone https://github.com/fuabioo/xlq.git
cd xlq
just build
just install # Installs to $GOPATH/bin预构建二进制文件
# Linux amd64
curl -L https://github.com/fuabioo/xlq/releases/latest/download/xlq-linux-amd64 -o xlq
chmod +x xlq
# macOS arm64 (Apple Silicon)
curl -L https://github.com/fuabioo/xlq/releases/latest/download/xlq-darwin-arm64 -o xlq
chmod +x xlqCLI使用情况
# List all sheets in workbook
xlq sheets data.xlsx
# Get sheet metadata (rows, columns, headers)
xlq info data.xlsx
xlq info data.xlsx "Sheet Name"
# Read first/last N rows
xlq head data.xlsx -n 20
xlq tail data.xlsx -n 20
# Read specific range
xlq read data.xlsx A1:D100
xlq read data.xlsx Sheet2 B5:E50
# Get single cell
xlq cell data.xlsx A1
xlq cell data.xlsx Sheet2 C5
# Search for pattern
xlq search data.xlsx "error"
xlq search data.xlsx -i "ERROR" # case-insensitive
xlq search data.xlsx -r "ERR-[0-9]+" # regex
xlq search data.xlsx -s Sheet1 "value" # search single sheet输出格式
# Default: JSON (compact, token-efficient)
xlq head data.xlsx -n 5
# CSV format
xlq head data.xlsx -n 5 --format csv
# TSV format
xlq head data.xlsx -n 5 --format tsvMCP服务器模式
xlq可以作为MCP(模型上下文协议)服务器运行,用于AI代理集成:
xlq mcpClaude桌面配置
claude mcp add --scope user --transport stdio excel xlq mcpclaude mcp remove excel可用的MCP工具
| 工具 | 说明 |
|---|---|
sheets | 列出工作簿中的所有工作表 |
info | 获取工作表元数据 |
read | 读取单元格范围 |
head | 获取前N行 |
tail | 获取最后N行 |
search | 搜索图案 |
cell | 获取单个单元格值 |
例子
管道到jq进行加工
# Get all product names
xlq read products.xlsx A:A | jq -r '.[][]'
# Count rows
xlq info data.xlsx | jq '.rows'
# Filter search results
xlq search data.xlsx "error" | jq '.results[] | select(.row > 100)'导出到CSV
xlq read data.xlsx --format csv > export.csv快速数据检查
# What sheets exist?
xlq sheets report.xlsx
# What's in the first sheet?
xlq head report.xlsx -n 5
# What does row 1000 look like?
xlq read report.xlsx A1000:Z1000演出
xlq使用流式架构,从不将整个文件加载到内存中:
| 文件大小 | 行数 | 内存使用情况 | 时间 |
|---|---|---|---|
| 10 MB | 50K | ~30 MB | \<1s |
| 100 MB | 500K | 约50 MB | 约3秒 |
| 1 GB | 500万 | 约80 MB | 约30秒 |
无论文件大小如何,内存使用量都保持不变。
建筑
需要 仅仅 命令运行器。
$ just --list
Available recipes:
build # Build all platforms (cross-compile with goreleaser)
clean # Remove build artifacts
coverage # Run tests with coverage
install # Install to GOBIN (like go install)
lint # Run linter
mcp # Run MCP server mode
run *args # Run directly (development)
test # Run all tests许可证
MIT许可证-有关详细信息,请参阅许可证文件。
