Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
ef63631
feat(table-scan-to-excel): add table scan to Excel UI plugin
ppppp2005-p Nov 25, 2026
de005b3
feat(table-scan-to-excel): add table scan to Excel UI plugin
ppppp2005-p Nov 25, 2026
2694f26
feat(table-scan-to-excel): add table scan to Excel UI plugin
ppppp2005-p Nov 25, 2026
5c10816
feat(table-scan-to-excel): add table scan to Excel UI plugin
ppppp2005-p Nov 25, 2026
47d2292
feat(table-scan-to-excel): add table scan to Excel UI plugin
ppppp2005-p Nov 25, 2026
0f74a66
feat(table-scan-to-excel): add table scan to Excel UI plugin
ppppp2005-p Nov 25, 2026
b2cc035
feat(table-scan-to-excel): add table scan to Excel UI plugin
ppppp2005-p Nov 25, 2026
2d5e638
feat(table-scan-to-excel): add table scan to Excel UI plugin
ppppp2005-p Nov 25, 2026
a5498e5
feat(table-scan-to-excel): add table scan to Excel UI plugin
ppppp2005-p Nov 25, 2026
6dc9fa8
feat(table-scan-to-excel): add table scan to Excel UI plugin
ppppp2005-p Nov 25, 2026
27d7fa6
feat(table-scan-to-excel): add table scan to Excel UI plugin
ppppp2005-p Nov 25, 2026
0639015
fix(table-scan-to-excel): check row-wise total columns and parse CJK …
ppppp2005-p Nov 25, 2026
79885e6
fix(table-scan-to-excel): check row-wise total columns and parse CJK …
ppppp2005-p Nov 25, 2026
4a7d95f
fix(table-scan-to-excel): keep workspace access inside the project; d…
ppppp2005-p Nov 25, 2026
713017b
fix(table-scan-to-excel): keep workspace access inside the project; d…
ppppp2005-p Nov 25, 2026
6ab3998
fix(table-scan-to-excel): keep workspace access inside the project; d…
ppppp2005-p Nov 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions external_plugins/table-scan-to-excel/.zcode-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "table-scan-to-excel",
"version": "0.1.0",
"description": "Turn a photo or scan of a table (invoice, statement, printed form) into an Excel file you can trust. The agent reads the image; the plugin checks every subtotal and total against the numbers above it, flags unreadable cells and text in number columns, and shows the image next to an editable table so you can fix and confirm cells. Exports .xlsx with merged cells, real numbers and highlighted comments, or CSV. Runs locally; no API keys.",
"description_i18n": {
"en": "Turn a photo or scan of a table (invoice, statement, printed form) into an Excel file you can trust. The agent reads the image; the plugin checks every subtotal and total against the numbers above it, flags unreadable cells and text in number columns, and shows the image next to an editable table so you can fix and confirm cells. Exports .xlsx with merged cells, real numbers and highlighted comments, or CSV. Runs locally; no API keys.",
"zh-CN": "把表格照片或扫描件(发票、对账单、纸质表单)变成可信的 Excel。由 Agent 看图识别;插件逐一核对小计、合计和上面的数字是否对得上,标出看不清的格子和数字列里的非数字,并把原图和可编辑表格并排显示,方便逐格修改、确认。导出的 .xlsx 保留合并单元格、数字为真正的数值,存疑格子带底色和批注;也可导出 CSV。全部本地处理,无需 API 密钥。"
},
"author": {
"name": "Penova",
"url": "https://github.com/ppppp2005-p"
},
"license": "MIT",
"keywords": [
"ocr",
"table",
"excel",
"xlsx",
"csv",
"scan",
"invoice",
"data-entry",
"表格识别",
"图片转表格",
"扫描件"
],
"skills": "skills",
"mcpServers": {
"table-scan-to-excel": {
"type": "stdio",
"command": "node",
"args": [
"${ZCODE_PLUGIN_ROOT}/dist/server.mjs"
],
"cwd": "${ZCODE_PROJECT_DIR}",
"timeoutMs": 900000,
"env": {
"ZCODE_WORKSPACE_ROOT": "${ZCODE_PROJECT_DIR}"
}
}
},
"ui": {
"surfaces": [
{
"id": "editor",
"title": {
"zh-CN": "扫描表格转 Excel",
"en-US": "Table Scan to Excel"
},
"icon": "table",
"server": "table-scan-to-excel",
"resourceUri": "ui://table-scan-to-excel/panel.html",
"availability": "session"
}
]
}
}
21 changes: 21 additions & 0 deletions external_plugins/table-scan-to-excel/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Penova

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
56 changes: 56 additions & 0 deletions external_plugins/table-scan-to-excel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Table Scan to Excel

Turn a photo or scan of a table (purchase list, invoice lines, bank statement, paper form) into an Excel file you can trust. The ZCode agent reads the image; the plugin **checks** and **exports**: totals that don't add up and cells that were hard to read are flagged, and you confirm them next to the original image before exporting.

## Features

- **Reading**: `table_scan_open` hands the image (scaled to ≤ 2000 px) to the agent with transcription rules — copy exactly, never calculate, how to write merged cells, list every doubtful cell. One image can hold several tables; each becomes a sheet.
- **Checks**:
- every subtotal row against the section above it, every total / grand total row against all detail rows (subtotals skipped), with the difference;
- text in number columns (e.g. `l0` for `10`);
- rows with a different number of cells (missing or shifted column);
- cells the agent marked as uncertain.
- Numbers understand thousands separators, full-width digits, bracketed negatives, minus signs, %, ¥/$/€ and 元.
- **Review panel**: the image on the left (zoomable; the selected cell is outlined approximately), an editable table on the right with merged cells and header rows; uncertain cells yellow, total mismatches red. Click an issue to jump to it, then "Looks right" or edit; or ask the agent to look again. Edits count as confirmed; confirmations survive a re-submission when the text is unchanged.
- **Export**:
- `.xlsx`: one sheet per table; bold, frozen header rows; merged cells; numbers stored as numbers with their original thousands/decimal/percent format; remaining flagged cells coloured with a comment.
- `.csv`: UTF-8 with BOM (opens cleanly in Excel), one file per table.
- The transcription is saved as `tables/<image>.tablescan.json` and reloaded next time.

## Usage

Ask the agent in ZCode Desktop:

- "Turn this photo of a purchase list (receipt.jpg) into an Excel file"
- "Check whether the totals in statement.png add up, then export it to xlsx"
- "Convert all the scanned tables in scans/ to CSV"

Or open **Table Scan to Excel** in the session side bar, pick an image and click "Ask the agent to read it".

## Tools

| Tool | Purpose |
|---|---|
| `table_scan_open` | Open an image, return it to the agent and open the panel; loads an earlier transcription if there is one |
| `table_submit` | The agent submits its transcription; checked, saved and shown in the panel |
| `table_export` | Write `.xlsx` and/or `.csv` (default `tables/<image>.xlsx`) |

## Scope (v0.1)

- PNG and JPG. Convert PDF scans or HEIC photos to images first.
- Recognition quality depends on the vision ability of the model you use in ZCode; the plugin ships no OCR engine and sends the image nowhere else.
- The outline on the image divides the table area evenly, so it is approximate for very tall header rows or tilted photos.
- Not in v0.1: deskew/cropping, formula reconstruction, adding/removing rows or columns in the panel (ask the agent to re-submit).

## Privacy, network and files

- The plugin itself makes **no network requests** and needs no API key or account. The image is returned as a tool result to the model you use in ZCode (just like attaching it to a message).
- It reads only the image you choose and writes only inside the workspace under `tables/` (or the export path you give). No commands, no hooks.

## Build and test (developers)

Source: `ui-plugins/table-scan-to-excel/`. Run `pnpm install --frozen-lockfile && pnpm build` at the repo root and add `dist/local-marketplace` as a local marketplace source in ZCode. Tests: `pnpm --filter @penova/plugin-table-scan-to-excel test` (number parsing, subtotal/total checks, padding, input validation, xlsx/csv content) and `test:e2e` (browser panel test: review, confirm, correct and export a photographed purchase list, plus a 1912 census scan).

## Third-party components and licenses

MIT licensed (author: Penova). Bundled: ExcelJS (MIT), pngjs (MIT), jpeg-js (BSD-3-Clause), MCP SDK and ext-apps (MIT); full list in `dist/THIRD_PARTY_NOTICES.txt`. Test images: see `ui-plugins/table-scan-to-excel/test/fixtures/SOURCES.md` (self-made purchase list, CC0; census scan from Wikimedia Commons, no known copyright restrictions); not included in the package.
56 changes: 56 additions & 0 deletions external_plugins/table-scan-to-excel/README_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# 扫描表格转 Excel

把表格照片或扫描件(采购单、发票明细、对账单、纸质登记表)变成可以放心使用的 Excel。识别由 ZCode 的 Agent 看图完成;插件负责**核对**和**导出**:合计对不上、看不清的格子都会被标出来,你在原图旁边逐格确认后再导出。

## 功能

- **看图识别**:`table_scan_open` 把图片(自动缩到 2000 像素以内)交给 Agent,并附上转写规则:照抄、不计算、合并单元格怎么写、没把握的格子要标出来。一张图里可以有多个表格,每个表格导出为一个工作表。
- **自动核对**:
- 每个“小计”行与它上面一段明细之和比对,“合计 / 总计 / Total”行与全部明细之和比对(跳过小计),差额写清楚;
- 数字列里混入的文字(比如把 10 认成 l0);
- 行的格子数不一致(漏列或错位);
- Agent 标为“没把握”的格子。
- 数字识别支持千分位、全角数字、括号负数、负号、百分号、¥/$/€ 和“元”。
- **核对面板**:左边原图(可放大,选中的格子在原图上用橙框大致标出),右边可编辑表格(保留合并单元格和表头),存疑格子黄色、合计不符红色。点问题列表跳到对应格子,“确认无误”或直接改;也可以一键让 Agent 再看一次。修改自动视为已确认,可保存,Agent 重新提交时保留你确认过且没变的格子。
- **导出**:
- `.xlsx`:每个表格一个工作表;表头加粗、冻结;合并单元格保留;数字存为真正的数值并保留原来的千分位、小数位、百分比格式;仍存疑的格子黄色、合计不符红色,并带批注说明。
- `.csv`:UTF-8(带 BOM,Excel 直接打开不乱码),每个表格一个文件。
- 识别结果保存在 `tables/<图片名>.tablescan.json`,下次打开同一张图直接载入,不用重新识别。

## 使用

在 ZCode Desktop 中对 Agent 说:

- “把这张采购单照片(采购单.jpg)转成 Excel”
- “看看 对账单.png 里的合计对不对,然后导出 xlsx”
- “把 scans 文件夹里的表格扫描件都转成 CSV”

也可以在会话侧栏打开“扫描表格转 Excel”,选一张图,点“让 Agent 识别”。

## 工具

| 工具 | 作用 |
|---|---|
| `table_scan_open` | 打开图片,返回给 Agent 看并打开面板;已识别过则载入结果 |
| `table_submit` | Agent 提交识别结果;核对并保存,显示在面板里 |
| `table_export` | 导出 `.xlsx` 和/或 `.csv`(默认 `tables/<图片名>.xlsx`) |

## 范围(v0.1)

- 支持 PNG、JPG。PDF 扫描件、HEIC 照片请先转成图片。
- 识别质量取决于 Agent 所用模型的看图能力;插件不自带 OCR 引擎,也不会把图片发到其他地方。
- 原图上的橙框按表格范围等分行列估算,表头特别高或照片倾斜时只是大致位置。
- v0.1 不包含:自动纠偏/裁边、公式还原、在面板里增删行列(可让 Agent 重新提交)。

## 隐私、网络与文件写入

- 插件本身**不联网**、不需要 API 密钥或账号。图片会作为工具结果交给你在 ZCode 中使用的模型(和你直接把图片发给 Agent 一样)。
- 只读取你指定的图片;只在工作区的 `tables/`(或你指定的导出路径)里写文件。不执行命令,没有 hooks。

## 构建与测试(开发者)

源码在 `ui-plugins/table-scan-to-excel/`。在仓库根目录运行 `pnpm install --frozen-lockfile && pnpm build`,把 `dist/local-marketplace` 添加为 ZCode 插件商店的本地来源后安装。测试:`pnpm --filter @penova/plugin-table-scan-to-excel test`(数字解析、小计/合计核对、补齐行、工具输入校验、导出 xlsx/csv 内容)和 `test:e2e`(浏览器面板测试:照片采购单的核对、确认、改错、导出,以及一张 1912 年人口普查扫描件)。

## 第三方组件与许可证

插件采用 MIT 许可证(作者:Penova)。打包的依赖:ExcelJS(MIT)、pngjs(MIT)、jpeg-js(BSD-3-Clause)、MCP SDK 与 ext-apps(MIT)。完整清单随包附带于 `dist/THIRD_PARTY_NOTICES.txt`。测试图片见 `ui-plugins/table-scan-to-excel/test/fixtures/SOURCES.md`(自制采购单 CC0;人口普查扫描件来自 Wikimedia Commons,无已知版权限制),不包含在安装包中。
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: table-scan-to-excel
description: 把表格照片或扫描件转成 Excel/CSV,并核对合计、标出看不清的格子。用户提到“图片转表格 / 扫描件转 Excel / 照片里的表格 / 发票明细录入 / 对账单转 Excel”时使用。
---

# 扫描表格转 Excel

识别由你(Agent)看图完成;插件负责核对、让用户确认和导出。插件不联网。

1. **打开**:`table_scan_open(image)`(PNG/JPG)。结果里有图片和转写规则;如果这张图以前识别过,会直接返回已保存的结果,不要重复识别,除非用户要求。
2. **转写并提交**:`table_submit(image, tables)`,每个表格:
- `rows`:从上到下、从左到右照抄(保留千分位、%、货币符号、括号、负号),**不要计算、不要更正、不要补数**;每行格子数相同。
- 合并单元格:文字写在左上格,被覆盖的格子写 `""`,并在 `merges` 里写 `{row, col, rowSpan, colSpan}`(从 0 开始)。
- `headerRows`:表头行数。`uncertain`:所有没把握的格子 `[行, 列]`(模糊、手写、被遮挡、易混的数字)。`bounds`:表格在原图中的像素范围(可选)。
- 图片很大或很密时,可以分块仔细看,但最终一次提交完整的表。
3. **处理核对结果**:插件返回小计/合计不符、数字列里的文字、行格数不一致和存疑格子。你能看清的就重新看图并再次 `table_submit`;合计不符时**不要擅自改数字让它对上**——原单据本身可能就是错的,告诉用户差额,让用户在面板里确认或修改。
4. **导出**:用户核对完(或直接要求导出)后 `table_export(image, format?: "xlsx" | "csv" | "both", output?)`。默认 `tables/<图片名>.xlsx`。告诉用户文件位置和仍存疑的格子数(这些格子在 Excel 里有底色和批注)。
5. 多张图片:逐张 `table_scan_open` → `table_submit` → `table_export`。
49 changes: 49 additions & 0 deletions marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,55 @@
"把上一个 Hi3D 任务生成的模型按角色拆分成部件"
]
}
},
{
"name": "table-scan-to-excel",
"componentTypes": [
"ui"
],
"source": "./external_plugins/table-scan-to-excel",
"displayName": "Table Scan to Excel",
"displayName_i18n": {
"en": "Table Scan to Excel",
"zh-CN": "扫描表格转 Excel"
},
"description": "Turn a photo or scan of a table (invoice, statement, printed form) into an Excel file you can trust. The agent reads the image; the plugin checks every subtotal and total against the numbers above it, flags unreadable cells and text in number columns, and shows the image next to an editable table so you can fix and confirm cells. Exports .xlsx with merged cells, real numbers and highlighted comments, or CSV. Runs locally; no API keys.",
"description_i18n": {
"en": "Turn a photo or scan of a table (invoice, statement, printed form) into an Excel file you can trust. The agent reads the image; the plugin checks every subtotal and total against the numbers above it, flags unreadable cells and text in number columns, and shows the image next to an editable table so you can fix and confirm cells. Exports .xlsx with merged cells, real numbers and highlighted comments, or CSV. Runs locally; no API keys.",
"zh-CN": "把表格照片或扫描件(发票、对账单、纸质表单)变成可信的 Excel。由 Agent 看图识别;插件逐一核对小计、合计和上面的数字是否对得上,标出看不清的格子和数字列里的非数字,并把原图和可编辑表格并排显示,方便逐格修改、确认。导出的 .xlsx 保留合并单元格、数字为真正的数值,存疑格子带底色和批注;也可导出 CSV。全部本地处理,无需 API 密钥。"
},
"version": "0.1.0",
"author": {
"name": "Penova",
"url": "https://github.com/ppppp2005-p"
},
"license": "MIT",
"category": "productivity",
"keywords": [
"ocr",
"table",
"excel",
"xlsx",
"csv",
"scan",
"invoice",
"data-entry",
"表格识别",
"图片转表格",
"扫描件"
],
"examplePrompts": [
"Turn this photo of a purchase list (receipt.jpg) into an Excel file",
"Check whether the totals in statement.png add up, then export it to xlsx",
"Convert all the scanned tables in scans/ to CSV"
],
"examplePrompts_i18n": {
"zh-CN": [
"把这张采购单照片(采购单.jpg)转成 Excel",
"看看 对账单.png 里的合计对不对,然后导出 xlsx",
"把 scans 文件夹里的表格扫描件都转成 CSV"
]
}
}
]
}
Loading