04f 导出流程

状态:🟡 Excel 导出已实现;🟡 Access 导出平台受限

1. 操作入口

方式

入口

GUI

导航「输出」→ OutputView(Excel 导出)

CLI

certflow export-excel [options](Excel)

CLI

certflow export-access [options](Access,仅 Windows)

2. 涉及配置

配置文件

关键字段

说明

config/export.yaml

导出参数

字段映射、样式

config/output.yaml

输出目录

导出文件存放位置

3. 涉及代码文件

文件

职责

View

views/output_view.py

输出页面

Controller

controllers/output_controller.py

导出编排

Service

services/cert_export_service.py

合格证导出

Service

services/output_guard.py

输出保护(防误覆盖)

Handler

handlers/csv_export.py

CSV 导出

Handler

handlers/excel_handler.py

Excel 写入

Handler

handlers/excel_styler.py

Excel 样式

Handler

handlers/shipped_export_handler.py

发货导出

Handler

services/report_output_service.py

报告输出

CLI

cli/commands/export_excel.py

Excel CLI

CLI

cli/commands/export_access.py

Access CLI(🟡 平台受限)

4. 逐步流程

4.1 Excel 导出

  1. 在查询页选择记录 → 右键「导出选中」→ action export_selected_export_selected 或导航「输出」→ OutputView 设置条件

  2. OutputController 调用 CertExportService / ExcelHandler

  3. ExcelStyler 应用样式(表头/边框/列宽)

  4. OutputGuard 检查目标文件是否已存在,防误覆盖

  5. 文件写入 output.yaml 指定的输出目录

CLI:

certflow export-excel --filter "status=已发货" --out ./output/plan_202608.xlsx

4.2 Access 导出(🟡 仅 Windows)

导出到 SignDB.mdb(Access 数据库):

certflow export-access --out ./SignDB.mdb

限制:依赖 Windows Access ODBC 驱动。pyproject.toml:29 已注释 pyodbc("不支持 access 数据库");当前依赖 pyscape(已在依赖列表)。仅 Windows 环境可用。详见 08-todo.md T2-1。

4.3 发货导出

certflow mark-shipped --plan-no CF2026080001
certflow record-shipment --plan-no CF2026080001 --date 2026-08-04

对应 GUI 的 shipped_archive / shipped_export_delete action。详见 04i-history-archive.md

5. 输出保护

OutputGuard 在执行写入前检查目标路径,避免意外覆盖已存在的导出文件。

6. 常见问题

  • Access 导出失败:确认 Windows + Access 驱动;非 Windows 环境不支持

  • 样式丢失:检查 export.yaml 样式配置

  • 导出被拦截OutputGuard 拦截覆盖,修改文件名或确认覆盖