uhf-report-fill
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "uhf-report-fill" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-bbc17342e330e24167794afbb43e05b2148e028480cae60e5bc42dc5eeb0b7ac. Verify the upstream source and version against https://skillhub.cn/skills/user_bef44692/utf-fill before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Automated test-report generation skill based on docx raw records and a docx test-report template: use this when a user supplies a raw-record/test-result docx and a test-report docx template and wants a specific data section (e.g., “3. UHF test data”) filled row-by-row into the template table, PRPS/plot images embedded, rows sorted by test-location similarity, and cells set to center alignment with SimSun font. Applicable to batch form-filling for UHF, ultrasonic and similar live electrical equipment test reports. Trigger phrases include: “fill report”, “generate report”, “put data into template”, “raw record into test report”.
Introduction source: third_party · user_bef44692 · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Audience
- Translation pending; see source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: uhf-report-fill
description: "根据 docx 原始记录与 docx 试验报告模板,自动生成完整的检测报告。当用户的输入是一份“原始记录/检测结果”docx 和一份“试验报告”docx 模板,并希望把前者某个数据板块(如“3、特高频检测数据”)逐行填入后者的表格、嵌入 PRPS/图谱图片、按检测位置相似度排序、并将单元格设置为上下左右居中 + 宋体时,应使用本技能。适用于特高频、超声波等电力设备带电检测报告的批量填表场景。触发词:“填报告”“出报告”“生成检测报告”“把数据填入模板”“原始记录填入试验报告”。"
version: 1.0.0
agent_created: true检测报告自动填表(docx)
Overview
本技能解决一类固定模式的 docx 处理任务:从原始记录文档的某一数据板块提取逐行数据 (含内嵌的图片,如 PRPS/PRPD 图谱),填入试验报告模板文档的对应表格,嵌入图片, 按检测位置相似度重新排序,并施加单元格居中 + 宋体格式,最终输出一个全新 docx。
核心实现用 zipfile + lxml 对 OOXML 做低层手术(不依赖 python-docx 高层 API),
以保证图片、命名空间、单元格格式都正确。详细坑点见 references/ooxml_gotchas.md。
When to use
满足以下特征时使用:
- 输入两个 docx:一份“原始记录/检测数据”,一份“试验报告/报告模板”。
- 需求是把原始记录里某个表格板块的数据,逐行填进报告模板的某个表格段。
- 涉及图片(图谱/照片)嵌入单元格,且要求单元格内上下左右居中、指定字体字号。
- 要求对所有行按某种规则(检测位置相似度/间隔号)重排序。
若输入是单个文档的局部编辑、或无需图片嵌入,可直接用通用文档工具,不必启用本技能。
处理流程(Workflow)
1. 解析两份文档,定位板块
- 用
zipfile读word/document.xml+word/_rels/document.xml.rels,lxml解析。 - 在原始记录里用板块标题文本(如
3、特高频检测数据)定位数据段起始行,其下一行是表头, 再往下是数据行,直到首个非数字序号行即结束。 - 在报告模板里用表头文本签名(如
['序号','检测位置','负荷电流( A)','图谱文件','是否异常']) 定位目标表格与表头行;数据段结束用下一个板块标记(如特征分析/仪器/四、)判定。
2. 提取每行的“文本 + 图片字节”
- 文本列(如
检测位置)直接cell_text。 - 图片列(如
PRPS图谱):从单元格find('.//a:blip')取r:embed,经 rels 解析成media/imageX.png,zip.read取字节。不要靠行号推算图片文件名(见 gotchas §1)。
3. 排序:按检测位置相似度
实现 sort_key(loc),把同类设备聚到一起,例如:
背景 → 各 X母 母线 → 互XX 互联 → GIS 间隔号(取前 3 位,2041→204,使 2041/204CT/204开关 相邻)。
排序后重新编号 1..N。具体规则按报告要求调整,可让用户三选一:间隔号分组 / 字典序 / 模糊聚类。
4. 以模板行为样板,生成新行并写入
- 深拷贝模板里的一个占位样本行作为新行骨架(保留
gridSpan/tcW/tcBorders等样式)。 - 逐列写入:
序号、检测位置、空白列(负荷电流/是否异常)、图片列。 - 图片列用
make_drawing(rid, imgid)构造 inline drawing,嵌入单元格。 - 单元格格式:每个单元格
set_cell_vcenter(垂直居中)+set_para_center(水平居中);检测位置单元格set_run_font('宋体', 17)(8.5pt=17 半磅)。 - 图片单元格必须重置 pPr(清掉模板继承的缩进/段间距/样式,仅留
jc=center), 否则居中在 Word 里不生效(见 gotchas §2)。
5. 替换占位行、补 rels 与 content-types、重新打包
- 删除模板里 N 个空白占位行,在表头之后、段末标记之前插入新生成的行。
- 为每个新图片追加
<Relationship>(type=image)到word/_rels/document.xml.rels; 若[Content_Types].xml无 png 的 Default,补一条。 - 序列化用原始
<w:document>根标签替换(保住mc:Ignorable命名空间,见 gotchas §3), 然后重新 zip 写出。
6. 验证(生成后自检,不必每次开 Word)
按 gotchas §7 清单:行数、空值、drawing 与 r:embed、图片字节、居中属性、排序连续性、 XML 可解析。
Resources
scripts/uhf_fill.py
可直接运行的端到端生成器。顶部 CONFIG 区集中了所有可按模板调整的参数
(文件路径、板块标题、列名、结束标记、字体字号、图片尺寸、占位行数等),并在
注释里标注了关键的 OOXML 手术函数:extract_records、sort_key、
set_cell_text、make_drawing、set_cell_image(含 pPr 重置)、
set_cell_vcenter、set_para_center、set_run_font、insert_in_order。
依赖 lxml(装到受管 venv:python -m venv <venv>; <venv>/Scripts/pip install lxml)。
适配其它同类报告(如超声波)时,优先改 CONFIG 与 sort_key,必要时调整列映射。
references/ooxml_gotchas.md
低层 OOXML 处理的非显然经验:图片提取读 r:embed、插入图片后重置 pPr、保留根命名空间、 有序插入子元素、字号半磅单位、EMU 尺寸、验证清单。排错时优先查阅。
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 解决电力设备检测报告批量填表的高频刚需,具备完整数据提取、图片嵌入、排序、格式控制闭环
Highlights
- 触发词覆盖全面(填报告/出报告/生成检测报告等),边界清晰,不易误触
Areas to improve
-
description 重复 Reported severity: Minor
顶层 frontmatter 和 skill_body 内均包含完整 description,存在冗余
Recommendation: 建议仅保留一处,避免维护不一致
Highlights
- 处理流程分 6 个清晰步骤,含端到端示例与关键函数说明,结构完整
Areas to improve
-
When to Use 章节标题层级 Reported severity: Minor
When to use 内容存在但使用二级标题,建议提升为一级标题以符合规范
Recommendation: 将 '## When to use' 改为 '# When to use' 以匹配其他一级章节
Highlights
- 工具链明确(zipfile+lxml),配置集中,覆盖图片处理、rels 更新、自检等关键异常点
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Install or fetch external dependencies
Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.
Mentioned in main document · lines 76
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.