audit-e2w 0.0.0-stage → 1.11.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +152 -3
- package/cordis.patch.yml +3 -0
- package/dsh_plugins/audit-e2w/lib/engine.mjs +174 -0
- package/dsh_plugins/audit-e2w/lib/index.js +122 -0
- package/dsh_plugins/audit-e2w/lib/skill.js +42 -0
- package/excel_word/README.md +388 -0
- package/excel_word/qoder_engine.py +437 -0
- package/excel_word/requirements.txt +4 -0
- package/excel_word/wesync/__init__.py +19 -0
- package/excel_word/wesync/__main__.py +6 -0
- package/excel_word/wesync/ai/__init__.py +52 -0
- package/excel_word/wesync/ai/actions.py +369 -0
- package/excel_word/wesync/ai/client.py +340 -0
- package/excel_word/wesync/ai/config.py +291 -0
- package/excel_word/wesync/ai/docs.py +177 -0
- package/excel_word/wesync/ai/prompts.py +288 -0
- package/excel_word/wesync/ai/tasks/__init__.py +26 -0
- package/excel_word/wesync/ai/tasks/actions_task.py +97 -0
- package/excel_word/wesync/ai/tasks/combined.py +123 -0
- package/excel_word/wesync/ai/tasks/diff_note.py +61 -0
- package/excel_word/wesync/ai/tasks/headings.py +119 -0
- package/excel_word/wesync/ai/tasks/help_task.py +69 -0
- package/excel_word/wesync/ai/tasks/roles.py +128 -0
- package/excel_word/wesync/align.py +155 -0
- package/excel_word/wesync/api.py +1292 -0
- package/excel_word/wesync/backup_history.py +100 -0
- package/excel_word/wesync/changelog.py +58 -0
- package/excel_word/wesync/cli.py +191 -0
- package/excel_word/wesync/commands/__init__.py +8 -0
- package/excel_word/wesync/commands/blank_cmd.py +279 -0
- package/excel_word/wesync/commands/bookmark_cmd.py +146 -0
- package/excel_word/wesync/commands/clear_cmd.py +50 -0
- package/excel_word/wesync/commands/export_cmd.py +270 -0
- package/excel_word/wesync/commands/incremental_cmd.py +157 -0
- package/excel_word/wesync/commands/marks_cmd.py +160 -0
- package/excel_word/wesync/commands/placeholders_cmd.py +92 -0
- package/excel_word/wesync/commands/writeback_cmd.py +469 -0
- package/excel_word/wesync/config.py +97 -0
- package/excel_word/wesync/console.py +85 -0
- package/excel_word/wesync/docx_blank.py +156 -0
- package/excel_word/wesync/docx_bookmarks.py +294 -0
- package/excel_word/wesync/docx_columns.py +257 -0
- package/excel_word/wesync/docx_edit.py +77 -0
- package/excel_word/wesync/docx_grid.py +212 -0
- package/excel_word/wesync/docx_marks.py +399 -0
- package/excel_word/wesync/docx_meta.py +157 -0
- package/excel_word/wesync/docx_newtable.py +220 -0
- package/excel_word/wesync/docx_placeholders.py +200 -0
- package/excel_word/wesync/docx_rows.py +67 -0
- package/excel_word/wesync/errors.py +5 -0
- package/excel_word/wesync/excel_blocks.py +502 -0
- package/excel_word/wesync/excel_export.py +143 -0
- package/excel_word/wesync/excel_marks.py +265 -0
- package/excel_word/wesync/excel_totals.py +53 -0
- package/excel_word/wesync/fsops.py +219 -0
- package/excel_word/wesync/gui/__init__.py +53 -0
- package/excel_word/wesync/gui/__main__.py +6 -0
- package/excel_word/wesync/gui/app.py +613 -0
- package/excel_word/wesync/gui/manual.py +70 -0
- package/excel_word/wesync/gui/pages/__init__.py +80 -0
- package/excel_word/wesync/gui/pages/_page.py +211 -0
- package/excel_word/wesync/gui/pages/ai_page.py +854 -0
- package/excel_word/wesync/gui/pages/batch_page.py +456 -0
- package/excel_word/wesync/gui/pages/blank_page.py +530 -0
- package/excel_word/wesync/gui/pages/bookmark_page.py +97 -0
- package/excel_word/wesync/gui/pages/export_page.py +141 -0
- package/excel_word/wesync/gui/pages/feedback_page.py +196 -0
- package/excel_word/wesync/gui/pages/format_page.py +551 -0
- package/excel_word/wesync/gui/pages/help_page.py +158 -0
- package/excel_word/wesync/gui/pages/history_page.py +168 -0
- package/excel_word/wesync/gui/pages/marks_page.py +211 -0
- package/excel_word/wesync/gui/pages/settings_page.py +450 -0
- package/excel_word/wesync/gui/pages/writeback_page.py +473 -0
- package/excel_word/wesync/gui/resources.py +22 -0
- package/excel_word/wesync/gui/runner.py +90 -0
- package/excel_word/wesync/gui/store.py +50 -0
- package/excel_word/wesync/gui/theme.py +271 -0
- package/excel_word/wesync/gui/widgets/__init__.py +8 -0
- package/excel_word/wesync/gui/widgets/ai_config.py +362 -0
- package/excel_word/wesync/gui/widgets/cards.py +139 -0
- package/excel_word/wesync/gui/widgets/chips.py +565 -0
- package/excel_word/wesync/gui/widgets/filebar.py +58 -0
- package/excel_word/wesync/gui/widgets/logpane.py +126 -0
- package/excel_word/wesync/gui/widgets/nav.py +294 -0
- package/excel_word/wesync/gui/widgets/theme_choice.py +93 -0
- package/excel_word/wesync/report_format.py +1585 -0
- package/excel_word/wesync/settings.py +35 -0
- package/excel_word/wesync/sort_rules.py +293 -0
- package/excel_word/wesync/valuefmt.py +485 -0
- package/package.json +53 -6
- package/packaging//344/275/277/347/224/250/350/257/264/346/230/216.txt +247 -0
- package/qoder_plugins/audit-toolbox/README.md +159 -0
- package/qoder_plugins/audit-toolbox/catalog.mjs +265 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"""bookmark 子命令:按内容把书签重新对齐到正确的表格,并把书签整表锚定。
|
|
2
|
+
|
|
3
|
+
用法要点:
|
|
4
|
+
* 默认**修复**:用「列数+行数+首行+首列」内容签名把工作簿表块与 Word 表格 1:1 配对,
|
|
5
|
+
然后把书签重建到对应表格内部(覆盖整张表),Excel 里点“→定位Word表”会选中整张表。
|
|
6
|
+
* 只接受完全一致的签名,不做模糊猜测;对不上的表会列为“未对齐”。
|
|
7
|
+
* 只删除“本工具自己的书签”(名字记录在工作簿 C 列里的,以及早期的 TBL_*),
|
|
8
|
+
审计软件的书签与 `_Toc…` 一律不动。
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import docx
|
|
12
|
+
from openpyxl import load_workbook
|
|
13
|
+
|
|
14
|
+
from ..align import apply_table_bookmarks, plan_table_bookmarks, split_bookmark_updates
|
|
15
|
+
from ..config import EXCEL_LINK_TEXT, SHEET_NAME, SHEET_NEW_TABLES
|
|
16
|
+
from ..console import log
|
|
17
|
+
from ..docx_bookmarks import cleanup_excel_markers
|
|
18
|
+
from ..docx_grid import body_items
|
|
19
|
+
from ..docx_meta import collect_table_info, dedupe_table_names
|
|
20
|
+
from ..errors import SyncError
|
|
21
|
+
from ..excel_blocks import parse_blocks, read_recorded_bookmarks, refresh_workbook_metadata, repair_workbook_links
|
|
22
|
+
from ..fsops import check_file_free, resolve_docx, resolve_xlsx, save_docx_xlsx_transaction
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _short_list(codes: list[str], limit: int = 12) -> str:
|
|
26
|
+
shown = "、".join(codes[:limit])
|
|
27
|
+
return shown + ("…" if len(codes) > limit else "")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def cmd_repair_links(args) -> int:
|
|
31
|
+
"""修复 Excel 中表格与标注指向 Word 的定位链接,不改 Word 和数据。"""
|
|
32
|
+
docx_path = resolve_docx(args.docx)
|
|
33
|
+
xlsx_path = resolve_xlsx(docx_path, args.excel)
|
|
34
|
+
if not xlsx_path.exists():
|
|
35
|
+
raise SyncError(
|
|
36
|
+
f"找不到工作簿:{xlsx_path}\n请先执行「导出表格到 Excel」或「增量导出」。"
|
|
37
|
+
)
|
|
38
|
+
if not args.dry_run:
|
|
39
|
+
check_file_free(xlsx_path, args.force)
|
|
40
|
+
|
|
41
|
+
log(f"读取 Word:{docx_path.name}")
|
|
42
|
+
log(f"读取 Excel:{xlsx_path.name}")
|
|
43
|
+
changed = repair_workbook_links(
|
|
44
|
+
xlsx_path, docx_path, dry_run=args.dry_run, backup=getattr(args, "backup", True)
|
|
45
|
+
)
|
|
46
|
+
if args.dry_run:
|
|
47
|
+
log(f"预演结束:发现 {changed} 个需要修复的链接,未写入任何文件。")
|
|
48
|
+
return 0
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def cmd_bookmark(args) -> int:
|
|
52
|
+
docx_path = resolve_docx(args.docx)
|
|
53
|
+
xlsx_path = resolve_xlsx(docx_path, args.excel)
|
|
54
|
+
if not args.dry_run:
|
|
55
|
+
check_file_free(docx_path, args.force)
|
|
56
|
+
if xlsx_path.exists():
|
|
57
|
+
check_file_free(xlsx_path, args.force)
|
|
58
|
+
|
|
59
|
+
doc = docx.Document(str(docx_path))
|
|
60
|
+
if not doc.tables:
|
|
61
|
+
raise SyncError("Word 文档中没有任何表格,无需处理")
|
|
62
|
+
items = body_items(doc)
|
|
63
|
+
infos = [collect_table_info(doc, items, idx, tab) for idx, tab in enumerate(doc.tables)]
|
|
64
|
+
dedupe_table_names(infos)
|
|
65
|
+
recorded = read_recorded_bookmarks(xlsx_path)
|
|
66
|
+
|
|
67
|
+
ws = None
|
|
68
|
+
blocks: dict = {}
|
|
69
|
+
if xlsx_path.exists():
|
|
70
|
+
workbook = load_workbook(str(xlsx_path))
|
|
71
|
+
if SHEET_NAME in workbook.sheetnames or SHEET_NEW_TABLES in workbook.sheetnames:
|
|
72
|
+
for sheet_name in (SHEET_NAME, SHEET_NEW_TABLES):
|
|
73
|
+
if sheet_name not in workbook.sheetnames:
|
|
74
|
+
continue
|
|
75
|
+
sheet = workbook[sheet_name]
|
|
76
|
+
_, sheet_blocks = parse_blocks(sheet)
|
|
77
|
+
for code, block in sheet_blocks.items():
|
|
78
|
+
block["sheet_name"] = sheet_name
|
|
79
|
+
block["_ws"] = sheet
|
|
80
|
+
blocks[code] = block
|
|
81
|
+
|
|
82
|
+
plan = plan_table_bookmarks(doc, ws, blocks, recorded, name_unmatched=not blocks)
|
|
83
|
+
code_by_index = {index: code for code, index in plan["mapping"].items()}
|
|
84
|
+
|
|
85
|
+
log(f"读取 Word:{docx_path.name}({len(doc.tables)} 张表)")
|
|
86
|
+
if blocks:
|
|
87
|
+
log(f"读取 Excel:{xlsx_path.name}({len(blocks)} 个表块)")
|
|
88
|
+
else:
|
|
89
|
+
log("未找到可用工作簿:将为每张表新建书签。")
|
|
90
|
+
|
|
91
|
+
for index, name in sorted(plan["assignments"]):
|
|
92
|
+
code = code_by_index.get(index, "(新表)")
|
|
93
|
+
log(f"[对齐] 第 {index + 1} 张表 ↔ {code}(书签 {name})")
|
|
94
|
+
for index in plan["unmatched_tables"]:
|
|
95
|
+
if code_by_index: # 有工作簿时才提示“未对齐”
|
|
96
|
+
log(f"[未对齐] 第 {index + 1} 张表:内容与任何表块都不匹配(建议重新导出工作簿)")
|
|
97
|
+
if plan["unmatched_codes"]:
|
|
98
|
+
log(
|
|
99
|
+
f"[提示] {len(plan['unmatched_codes'])} 个表块在 Word 中已删除,不会被同步:"
|
|
100
|
+
f"{_short_list(plan['unmatched_codes'])}"
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
if args.dry_run:
|
|
104
|
+
log("预演模式(--dry-run):以上为将执行的书签对齐,未写入任何文件。")
|
|
105
|
+
return 0
|
|
106
|
+
|
|
107
|
+
# 已经正确锚定在目标表内的书签不必重建(保证重复运行幂等)
|
|
108
|
+
assignments, remove_names = split_bookmark_updates(doc, plan["assignments"], recorded)
|
|
109
|
+
result = apply_table_bookmarks(doc, assignments, remove_names)
|
|
110
|
+
if result["removed"]:
|
|
111
|
+
log(f"[书签] 已移除旧的/锚错的工具书签 {result['removed']} 个")
|
|
112
|
+
if result["inserted"]:
|
|
113
|
+
log(f"[书签] 已把 {result['inserted']} 个书签整表锚定(点击可选中整张表格)")
|
|
114
|
+
if not result["removed"] and not result["inserted"]:
|
|
115
|
+
log("[书签] 书签已全部正确锚定,无需重建")
|
|
116
|
+
|
|
117
|
+
markers = cleanup_excel_markers(doc)
|
|
118
|
+
if markers:
|
|
119
|
+
log(f"[清理] 已删除 Word 正文中遗留的 {markers} 处 {EXCEL_LINK_TEXT} 文字/断链")
|
|
120
|
+
|
|
121
|
+
if result["removed"] or result["inserted"] or markers:
|
|
122
|
+
backups = save_docx_xlsx_transaction(
|
|
123
|
+
docx_path=docx_path, doc=doc, backup=getattr(args, "backup", True),
|
|
124
|
+
)
|
|
125
|
+
backup = backups.get(docx_path)
|
|
126
|
+
log(f"[书签] 已保存 {docx_path.name}" + (f"(原文件已备份:{backup.name})" if backup else ""))
|
|
127
|
+
else:
|
|
128
|
+
log("[书签] Word 已是目标状态,无需保存")
|
|
129
|
+
|
|
130
|
+
if blocks:
|
|
131
|
+
name_by_index = {index: name for index, name in plan["assignments"]}
|
|
132
|
+
infos_by_code: dict[str, dict] = {}
|
|
133
|
+
for code, index in plan["mapping"].items():
|
|
134
|
+
info = dict(infos[index]) if index < len(infos) else None
|
|
135
|
+
if info is None:
|
|
136
|
+
continue
|
|
137
|
+
info["bookmark"] = name_by_index.get(index, "")
|
|
138
|
+
infos_by_code[code] = info
|
|
139
|
+
refresh_workbook_metadata(
|
|
140
|
+
xlsx_path,
|
|
141
|
+
docx_path.name,
|
|
142
|
+
infos_by_code,
|
|
143
|
+
with_links=not getattr(args, "no_excel_links", False),
|
|
144
|
+
backup=getattr(args, "backup", True), docx_path=docx_path,
|
|
145
|
+
)
|
|
146
|
+
return 0
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""clear-bookmarks 子命令:删除 Word 里所有本工具写入的书签(CPAH_/TBL_/MRK_)。
|
|
2
|
+
|
|
3
|
+
只清本工具自己创建的定位/标注书签;Word 自带书签(如 _Toc 目录)一律保留。
|
|
4
|
+
正式执行前自动备份原文件到 _backup。
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import docx
|
|
10
|
+
|
|
11
|
+
from ..console import log
|
|
12
|
+
from ..docx_bookmarks import clear_tool_bookmarks
|
|
13
|
+
from ..fsops import check_file_free, resolve_docx, save_docx_xlsx_transaction
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def cmd_clear_bookmarks(args) -> int:
|
|
17
|
+
docx_path = resolve_docx(args.docx)
|
|
18
|
+
if not args.dry_run:
|
|
19
|
+
check_file_free(docx_path, args.force)
|
|
20
|
+
|
|
21
|
+
doc = docx.Document(str(docx_path))
|
|
22
|
+
result = clear_tool_bookmarks(doc)
|
|
23
|
+
|
|
24
|
+
log(f"读取 Word:{docx_path.name}")
|
|
25
|
+
log(f"[清理] 发现本工具书签(CPAH_/TBL_/MRK_):{result['removed']} 个")
|
|
26
|
+
if result["names"]:
|
|
27
|
+
shown = "、".join(result["names"][:12])
|
|
28
|
+
if len(result["names"]) > 12:
|
|
29
|
+
shown += f" …(共 {len(result['names'])} 个)"
|
|
30
|
+
log(f"[清理] 将删除:{shown}")
|
|
31
|
+
if result["kept"]:
|
|
32
|
+
log(f"[清理] 保留 Word 自带书签 {result['kept']} 个(如 _Toc 目录书签),未改动")
|
|
33
|
+
|
|
34
|
+
if not result["removed"]:
|
|
35
|
+
log("[清理] 没有发现本工具书签,无需处理")
|
|
36
|
+
return 0
|
|
37
|
+
|
|
38
|
+
if args.dry_run:
|
|
39
|
+
log("预演模式(--dry-run):未写入任何文件。")
|
|
40
|
+
return 0
|
|
41
|
+
|
|
42
|
+
backups = save_docx_xlsx_transaction(
|
|
43
|
+
docx_path=docx_path, doc=doc, backup=getattr(args, "backup", True),
|
|
44
|
+
)
|
|
45
|
+
backup = backups.get(docx_path)
|
|
46
|
+
log(
|
|
47
|
+
f"[清理] 已从 {docx_path.name} 删除 {result['removed']} 个书签"
|
|
48
|
+
+ (f"(原文件已备份:{backup.name})" if backup else "")
|
|
49
|
+
)
|
|
50
|
+
return 0
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"""export 子命令:按当前 Word 重新生成工作簿,并把书签整表锚定。
|
|
2
|
+
|
|
3
|
+
导出时会先按内容把现有工作簿的表块与当前 Word 表格对齐,沿用原有的书签名
|
|
4
|
+
(对不上的块/表会自动报告),然后把书签重建到表格内部(覆盖整张表)。
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import docx
|
|
8
|
+
from openpyxl import Workbook, load_workbook
|
|
9
|
+
|
|
10
|
+
from ..align import apply_table_bookmarks, plan_table_bookmarks, split_bookmark_updates
|
|
11
|
+
from ..config import DELETED_BOOKMARK, EXCEL_LINK_TEXT, NEW_BOOKMARK, SHEET_NAME, SHEET_NEW_TABLES
|
|
12
|
+
from ..console import log
|
|
13
|
+
from ..docx_bookmarks import cleanup_excel_markers
|
|
14
|
+
from ..docx_grid import body_items
|
|
15
|
+
from ..docx_marks import ensure_mark_bookmarks, find_marks, processed_marks
|
|
16
|
+
from ..docx_meta import collect_table_info, dedupe_table_names
|
|
17
|
+
from ..docx_placeholders import VALUES_SHEET, init_placeholder_sheet, read_placeholder_values, scan_placeholders
|
|
18
|
+
from ..errors import SyncError
|
|
19
|
+
from ..excel_blocks import carry_over_deleted_blocks, parse_blocks, read_recorded_bookmarks, rejudge_marks
|
|
20
|
+
from ..excel_export import export_workbook
|
|
21
|
+
from ..excel_marks import SHEET_MARKS, build_marks_sheet, read_previous_marks
|
|
22
|
+
from ..fsops import check_file_free, load_workbook_for_save, resolve_docx, resolve_xlsx, save_docx_xlsx_transaction
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _code_number(code: str) -> int:
|
|
26
|
+
try:
|
|
27
|
+
return int(code[1:])
|
|
28
|
+
except ValueError:
|
|
29
|
+
return 0
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _removed_block_hints(xlsx_path, recorded: dict[str, str], blocks_old: dict, plan: dict) -> list[str]:
|
|
33
|
+
"""导出前提醒:现有工作簿里有块在 Word 中已找不到对应表格(按实际对齐结果判断)。"""
|
|
34
|
+
if not recorded:
|
|
35
|
+
if xlsx_path.exists():
|
|
36
|
+
return ["[提醒] 现有工作簿没有书签记录,本次导出将按当前 Word 重建并重新登记书签。"]
|
|
37
|
+
return []
|
|
38
|
+
missing = sorted(
|
|
39
|
+
(
|
|
40
|
+
code for code in plan["unmatched_codes"]
|
|
41
|
+
if (blocks_old.get(code) or {}).get("bookmark") != DELETED_BOOKMARK
|
|
42
|
+
),
|
|
43
|
+
key=_code_number,
|
|
44
|
+
)
|
|
45
|
+
unnamed = sorted((code for code, name in recorded.items() if not name), key=_code_number)
|
|
46
|
+
hints: list[str] = []
|
|
47
|
+
if missing:
|
|
48
|
+
shown = "、".join(missing[:8]) + ("…" if len(missing) > 8 else "")
|
|
49
|
+
hints.append(
|
|
50
|
+
f"[提醒] 现有工作簿中有 {len(missing)} 个表块在 Word 中已找不到对应表格"
|
|
51
|
+
f"(可能是已删除的表:{shown});导出将按当前 Word 重建,这些块会消失。"
|
|
52
|
+
)
|
|
53
|
+
if unnamed:
|
|
54
|
+
hints.append(f"[提醒] 现有工作簿中有 {len(unnamed)} 个表块没有书签记录,导出后将重新登记书签。")
|
|
55
|
+
return hints
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _load_previous_workbook(xlsx_path):
|
|
59
|
+
"""读取现有工作簿(表块 + 工作表),用于沿用书签名;不存在或读不了时返回 (None, {})。"""
|
|
60
|
+
if not xlsx_path.exists():
|
|
61
|
+
return None, {}
|
|
62
|
+
try:
|
|
63
|
+
workbook = load_workbook(str(xlsx_path))
|
|
64
|
+
except Exception as exc: # 文件被占用或损坏时不阻断导出
|
|
65
|
+
log(f"[提醒] 读取现有工作簿失败({exc}),本次不沿用旧书签名。")
|
|
66
|
+
return None, {}
|
|
67
|
+
if SHEET_NAME not in workbook.sheetnames:
|
|
68
|
+
return None, {}
|
|
69
|
+
blocks: dict[str, dict] = {}
|
|
70
|
+
for sheet_name in (SHEET_NAME, SHEET_NEW_TABLES):
|
|
71
|
+
if sheet_name not in workbook.sheetnames:
|
|
72
|
+
continue
|
|
73
|
+
ws = workbook[sheet_name]
|
|
74
|
+
_, sheet_blocks = parse_blocks(ws)
|
|
75
|
+
duplicate = set(sheet_blocks) & set(blocks)
|
|
76
|
+
if duplicate:
|
|
77
|
+
raise SyncError(f"工作簿中表编号重复:{'、'.join(sorted(duplicate))}。请修正后再导出。")
|
|
78
|
+
for code, block in sheet_blocks.items():
|
|
79
|
+
block["_ws"] = ws
|
|
80
|
+
blocks[code] = block
|
|
81
|
+
return workbook[SHEET_NAME], blocks
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _empty_export_workbook(xlsx_path):
|
|
85
|
+
"""全量导出仍清空重建;仅原 XLSM 额外载入并保留 VBA 包。"""
|
|
86
|
+
if not xlsx_path.exists() or xlsx_path.suffix.lower() != ".xlsm":
|
|
87
|
+
return Workbook()
|
|
88
|
+
try:
|
|
89
|
+
workbook = load_workbook_for_save(xlsx_path, keep_links=False)
|
|
90
|
+
except Exception as exc:
|
|
91
|
+
raise SyncError(f"无法读取原 XLSM 的 VBA,已中止导出以避免丢失宏:{exc}") from exc
|
|
92
|
+
try:
|
|
93
|
+
if "xl/vbaProject.bin" not in workbook.vba_archive.namelist():
|
|
94
|
+
raise SyncError("原 XLSM 中未找到 VBA 工程,无法确认宏可保留,已中止导出。")
|
|
95
|
+
for worksheet in list(workbook._sheets):
|
|
96
|
+
workbook.remove(worksheet)
|
|
97
|
+
workbook.create_sheet()
|
|
98
|
+
workbook.defined_names.clear()
|
|
99
|
+
return workbook
|
|
100
|
+
except Exception:
|
|
101
|
+
workbook.close()
|
|
102
|
+
workbook.vba_archive.close()
|
|
103
|
+
raise
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def cmd_export(args) -> int:
|
|
107
|
+
docx_path = resolve_docx(args.docx)
|
|
108
|
+
xlsx_path = resolve_xlsx(docx_path, args.excel)
|
|
109
|
+
if not args.dry_run:
|
|
110
|
+
check_file_free(docx_path, args.force)
|
|
111
|
+
check_file_free(xlsx_path, args.force)
|
|
112
|
+
|
|
113
|
+
doc = docx.Document(str(docx_path))
|
|
114
|
+
items = body_items(doc)
|
|
115
|
+
infos = [collect_table_info(doc, items, idx, tab) for idx, tab in enumerate(doc.tables)]
|
|
116
|
+
dedupe_table_names(infos)
|
|
117
|
+
recorded = {
|
|
118
|
+
code: name
|
|
119
|
+
for code, name in read_recorded_bookmarks(xlsx_path).items()
|
|
120
|
+
if name not in (NEW_BOOKMARK, DELETED_BOOKMARK)
|
|
121
|
+
}
|
|
122
|
+
ws_old, blocks_old = _load_previous_workbook(xlsx_path)
|
|
123
|
+
previous_marks = read_previous_marks(xlsx_path)
|
|
124
|
+
marks = find_marks(doc)
|
|
125
|
+
processed = processed_marks(doc, {mark.bookmark for mark in marks if mark.bookmark})
|
|
126
|
+
ph_fields = scan_placeholders(doc)
|
|
127
|
+
ph_values_old = {}
|
|
128
|
+
if ph_fields and xlsx_path.exists():
|
|
129
|
+
try:
|
|
130
|
+
ph_values_old = read_placeholder_values(xlsx_path, resolve_formulas=False)
|
|
131
|
+
except Exception as exc: # 旧工作簿读不了时不影响导出,只是带不过来已填值
|
|
132
|
+
log(f"[提醒] 读取原「{VALUES_SHEET}」表失败({exc}),本次无法保留已填值。")
|
|
133
|
+
|
|
134
|
+
plan = plan_table_bookmarks(doc, ws_old, blocks_old, recorded, name_unmatched=True)
|
|
135
|
+
name_by_index = {index: name for index, name in plan["assignments"]}
|
|
136
|
+
for info in infos:
|
|
137
|
+
info["bookmark"] = name_by_index.get(info["index"], "")
|
|
138
|
+
|
|
139
|
+
log(f"读取 Word:{docx_path.name}")
|
|
140
|
+
log(f"发现表格:{len(infos)} 张" + ("(无表格,工作表「" + SHEET_NAME + "」将为空)" if not infos else ""))
|
|
141
|
+
with_links = not getattr(args, "no_excel_links", False)
|
|
142
|
+
for info in infos:
|
|
143
|
+
log(
|
|
144
|
+
f" {info['code']} {info['name']}({info['nrows']} 行 × {info['ncols']} 列,"
|
|
145
|
+
f"合并区 {sum(1 for m in info['merges'] if m[2] > 1 or m[3] > 1)} 处,书签 {info['bookmark']})"
|
|
146
|
+
)
|
|
147
|
+
log(f"目标工作簿:{xlsx_path.name}(工作表:{SHEET_NAME})")
|
|
148
|
+
log(f"高亮标记:{len(marks)} 处(将写入工作表「{SHEET_MARKS}」)")
|
|
149
|
+
if ph_fields:
|
|
150
|
+
log(f"正文占位符:{len(ph_fields)} 个(将写入工作表「{VALUES_SHEET}」)")
|
|
151
|
+
else:
|
|
152
|
+
log(f"正文占位符:未发现(工作表「{VALUES_SHEET}」将为空)")
|
|
153
|
+
for hint in _removed_block_hints(xlsx_path, recorded, blocks_old, plan):
|
|
154
|
+
log(hint)
|
|
155
|
+
|
|
156
|
+
if args.dry_run:
|
|
157
|
+
log("预演模式(--dry-run):以上为将导出的内容,未写入任何文件。")
|
|
158
|
+
return 0
|
|
159
|
+
|
|
160
|
+
assignments, remove_names = split_bookmark_updates(doc, plan["assignments"], recorded)
|
|
161
|
+
result = apply_table_bookmarks(doc, assignments, remove_names)
|
|
162
|
+
if result["inserted"]:
|
|
163
|
+
log(f"[书签] 已把 {result['inserted']} 个书签整表锚定(点击可选中整张表格)")
|
|
164
|
+
created_marks = ensure_mark_bookmarks(doc, marks)
|
|
165
|
+
if created_marks:
|
|
166
|
+
log(f"[标记] 已为 {created_marks} 处高亮标记插入定位书签(MRK_xxxx,正文外观不变)")
|
|
167
|
+
removed_markers = cleanup_excel_markers(doc)
|
|
168
|
+
if removed_markers:
|
|
169
|
+
log(f"[清理] 已删除 Word 正文中遗留的 {removed_markers} 处 {EXCEL_LINK_TEXT} 文字/断链")
|
|
170
|
+
|
|
171
|
+
workbook = export_workbook(
|
|
172
|
+
infos, docx_path.name, with_links=with_links,
|
|
173
|
+
totals_formula=not getattr(args, "no_total_formulas", False),
|
|
174
|
+
wb=_empty_export_workbook(xlsx_path),
|
|
175
|
+
)
|
|
176
|
+
if ws_old is not None:
|
|
177
|
+
carried = carry_over_deleted_blocks(workbook, ws_old, blocks_old)
|
|
178
|
+
if carried:
|
|
179
|
+
log(f"[保留] 已可逆删除的 {len(carried)} 个表块原样保留({'、'.join(carried)}),可在「删除空白表格」页恢复。")
|
|
180
|
+
from ..sort_rules import carry_over_sort_settings
|
|
181
|
+
|
|
182
|
+
sort_carried = carry_over_sort_settings(workbook, ws_old, blocks_old)
|
|
183
|
+
if sort_carried:
|
|
184
|
+
log(f"[保留] {len(sort_carried)} 个表块的排序设置已按书签沿用({'、'.join(sort_carried)})。")
|
|
185
|
+
mark_stats = build_marks_sheet(workbook, docx_path.name, marks, previous_marks, processed)
|
|
186
|
+
log(
|
|
187
|
+
f"[标记] 工作表「{SHEET_MARKS}」已写入 {mark_stats['marks']} 行"
|
|
188
|
+
+ (f",{mark_stats['processed']} 行已处理" if mark_stats.get("processed") else "")
|
|
189
|
+
+ (f",另有 {mark_stats['orphans']} 行已删除记录" if mark_stats["orphans"] else "")
|
|
190
|
+
)
|
|
191
|
+
if ph_fields:
|
|
192
|
+
ws_ph = init_placeholder_sheet(workbook)
|
|
193
|
+
for field in ph_fields:
|
|
194
|
+
ws_ph.append([field, ph_values_old.get(field, ""), "全量"])
|
|
195
|
+
kept = sum(1 for f in ph_fields if ph_values_old.get(f))
|
|
196
|
+
log(
|
|
197
|
+
f"[占位符] 工作表「{VALUES_SHEET}」已写入 {len(ph_fields)} 个字段"
|
|
198
|
+
+ (f",保留已填值 {kept} 个" if kept else "(待填写)")
|
|
199
|
+
)
|
|
200
|
+
else:
|
|
201
|
+
init_placeholder_sheet(workbook)
|
|
202
|
+
log(f"[占位符] 正文无 {{字段名}},工作表「{VALUES_SHEET}」已创建为空表。")
|
|
203
|
+
backup = getattr(args, "backup", True)
|
|
204
|
+
if not backup:
|
|
205
|
+
log("[导出] 按选项不备份原文件(--no-backup / 界面取消勾选),直接覆盖。")
|
|
206
|
+
update_docx = bool(result["removed"] or result["inserted"] or created_marks or removed_markers)
|
|
207
|
+
try:
|
|
208
|
+
backups = save_docx_xlsx_transaction(
|
|
209
|
+
docx_path=docx_path if update_docx else None,
|
|
210
|
+
doc=doc if update_docx else None,
|
|
211
|
+
xlsx_path=xlsx_path, wb=workbook, backup=backup,
|
|
212
|
+
)
|
|
213
|
+
finally:
|
|
214
|
+
workbook.close()
|
|
215
|
+
if getattr(workbook, "vba_archive", None):
|
|
216
|
+
workbook.vba_archive.close()
|
|
217
|
+
xlsx_backup = backups.get(xlsx_path)
|
|
218
|
+
log(f"[导出] 已写入 {xlsx_path.name}" + (f"(原文件已备份:{xlsx_backup.name})" if xlsx_backup else ""))
|
|
219
|
+
if update_docx:
|
|
220
|
+
docx_backup = backups.get(docx_path)
|
|
221
|
+
log(f"[导出] 已更新 {docx_path.name}" + (f"(原文件已备份:{docx_backup.name})" if docx_backup else ""))
|
|
222
|
+
else:
|
|
223
|
+
log("[导出] Word 中的书签已是目标状态,无需改动。")
|
|
224
|
+
return 0
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def cmd_rejudge(args) -> int:
|
|
228
|
+
"""按工作簿当前内容重新判定 B 列表头/✓/✕(只改标记,不改数据、不改 Word)。"""
|
|
229
|
+
docx_path = resolve_docx(args.docx)
|
|
230
|
+
xlsx_path = resolve_xlsx(docx_path, args.excel)
|
|
231
|
+
if not xlsx_path.exists():
|
|
232
|
+
raise SyncError(f"找不到工作簿:{xlsx_path}\n请先执行「导出表格到 Excel」。")
|
|
233
|
+
if not args.dry_run:
|
|
234
|
+
check_file_free(xlsx_path, args.force)
|
|
235
|
+
workbook = load_workbook_for_save(xlsx_path)
|
|
236
|
+
sheets = [(name, workbook[name]) for name in (SHEET_NAME, SHEET_NEW_TABLES) if name in workbook.sheetnames]
|
|
237
|
+
if not sheets:
|
|
238
|
+
raise SyncError(f"工作簿中找不到工作表“{SHEET_NAME}”,请确认该文件由本工具导出")
|
|
239
|
+
total_changed = total_rows = total_blocks = 0
|
|
240
|
+
old_codes: list[str] = []
|
|
241
|
+
for sheet_name, ws in sheets:
|
|
242
|
+
_, sheet_blocks = parse_blocks(ws)
|
|
243
|
+
total_blocks += len(sheet_blocks)
|
|
244
|
+
if sheet_blocks:
|
|
245
|
+
stats = rejudge_marks(ws, sheet_blocks)
|
|
246
|
+
total_changed += stats["changed"]
|
|
247
|
+
total_rows += stats["rows"]
|
|
248
|
+
old_codes.extend(stats["old"])
|
|
249
|
+
if not total_blocks:
|
|
250
|
+
raise SyncError("工作簿中没有表块,请先执行「导出表格到 Excel」")
|
|
251
|
+
log(f"读取工作簿:{xlsx_path.name}({len(sheets)} 个表格工作表,{total_rows} 行)")
|
|
252
|
+
if old_codes:
|
|
253
|
+
log(
|
|
254
|
+
f"[提醒] {'、'.join(old_codes)} 为旧布局(没有标记列),无法重新判定;"
|
|
255
|
+
"请执行一次「导出表格到 Excel」升级为新布局。"
|
|
256
|
+
)
|
|
257
|
+
prefix = "[判定·预演]" if args.dry_run else "[判定]"
|
|
258
|
+
log(f"{prefix} 重新判定 {total_rows} 行,标记变化 {total_changed} 行(表头/✓/✕;「已删」行保持原样)")
|
|
259
|
+
if args.dry_run:
|
|
260
|
+
log("预演模式(--dry-run):未写入任何文件。")
|
|
261
|
+
return 0
|
|
262
|
+
if not total_changed:
|
|
263
|
+
log("标记与当前内容一致,工作簿无需写入。")
|
|
264
|
+
return 0
|
|
265
|
+
backups = save_docx_xlsx_transaction(
|
|
266
|
+
xlsx_path=xlsx_path, wb=workbook, backup=getattr(args, "backup", True),
|
|
267
|
+
)
|
|
268
|
+
xlsx_backup = backups.get(xlsx_path)
|
|
269
|
+
log(f"[判定] 已保存 {xlsx_path.name}" + (f"(原文件已备份:{xlsx_backup.name})" if xlsx_backup else ""))
|
|
270
|
+
return 0
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"""增量导出:只登记 Word 中尚未锚定的表格、标注与占位符。"""
|
|
2
|
+
|
|
3
|
+
from collections import Counter
|
|
4
|
+
|
|
5
|
+
import docx
|
|
6
|
+
|
|
7
|
+
from ..config import BOOKMARK_PREFIX, SHEET_NAME, SHEET_NEW_TABLES
|
|
8
|
+
from ..console import log
|
|
9
|
+
from ..docx_bookmarks import bookmark_names, insert_table_bookmark, new_cpah_name, next_bookmark_id, table_index_map_by_bookmark
|
|
10
|
+
from ..docx_grid import body_items
|
|
11
|
+
from ..docx_marks import _duplicate_mark_bookmarks, ensure_mark_bookmarks, find_marks
|
|
12
|
+
from ..docx_meta import collect_table_info, dedupe_table_names
|
|
13
|
+
from ..docx_placeholders import append_placeholder_sheet, scan_placeholders
|
|
14
|
+
from ..errors import SyncError
|
|
15
|
+
from ..excel_blocks import parse_blocks
|
|
16
|
+
from ..excel_export import export_workbook
|
|
17
|
+
from ..excel_marks import append_marks_sheet, read_previous_marks
|
|
18
|
+
from ..fsops import check_file_free, load_workbook_for_save, resolve_docx, resolve_xlsx, save_docx_xlsx_transaction
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _load_blocks(wb):
|
|
22
|
+
order: list[str] = []
|
|
23
|
+
blocks: dict[str, dict] = {}
|
|
24
|
+
for sheet_name in (SHEET_NAME, SHEET_NEW_TABLES):
|
|
25
|
+
if sheet_name not in wb.sheetnames:
|
|
26
|
+
continue
|
|
27
|
+
sheet_order, sheet_blocks = parse_blocks(wb[sheet_name])
|
|
28
|
+
duplicate = set(sheet_order) & set(blocks)
|
|
29
|
+
if duplicate:
|
|
30
|
+
raise SyncError(f"工作簿中表编号重复:{'、'.join(sorted(duplicate))}。请修正后再增量导出。")
|
|
31
|
+
for code, block in sheet_blocks.items():
|
|
32
|
+
block["sheet_name"] = sheet_name
|
|
33
|
+
block["_ws"] = wb[sheet_name]
|
|
34
|
+
order.extend(sheet_order)
|
|
35
|
+
blocks.update(sheet_blocks)
|
|
36
|
+
return order, blocks
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _ignored_table_content(doc) -> tuple[int, int]:
|
|
40
|
+
from ..docx_marks import _paragraph_mark_highlighted, run_highlighted
|
|
41
|
+
from ..docx_placeholders import PLACEHOLDER_RE
|
|
42
|
+
|
|
43
|
+
marks = placeholders = 0
|
|
44
|
+
roots = [doc.element.body]
|
|
45
|
+
for section in doc.sections:
|
|
46
|
+
roots.extend(part._element for part in (
|
|
47
|
+
section.header, section.footer, section.first_page_header, section.first_page_footer,
|
|
48
|
+
section.even_page_header, section.even_page_footer,
|
|
49
|
+
) if part is not None)
|
|
50
|
+
for root in roots:
|
|
51
|
+
for tc in root.iter(docx.oxml.ns.qn("w:tc")):
|
|
52
|
+
for p_el in tc.iter(docx.oxml.ns.qn("w:p")):
|
|
53
|
+
if _paragraph_mark_highlighted(p_el) or any(run_highlighted(r, doc) for r in p_el.iter(docx.oxml.ns.qn("w:r"))):
|
|
54
|
+
marks += 1
|
|
55
|
+
placeholders += len(PLACEHOLDER_RE.findall("".join(t.text or "" for t in p_el.iter(docx.oxml.ns.qn("w:t")))))
|
|
56
|
+
return marks, placeholders
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def cmd_incremental_export(args) -> int:
|
|
60
|
+
docx_path = resolve_docx(args.docx)
|
|
61
|
+
xlsx_path = resolve_xlsx(docx_path, args.excel)
|
|
62
|
+
if not xlsx_path.exists():
|
|
63
|
+
raise SyncError(f"找不到工作簿:{xlsx_path}\n请先执行一次全量「导出表格到 Excel」。")
|
|
64
|
+
if not args.dry_run:
|
|
65
|
+
check_file_free(docx_path, args.force)
|
|
66
|
+
check_file_free(xlsx_path, args.force)
|
|
67
|
+
|
|
68
|
+
doc = docx.Document(str(docx_path))
|
|
69
|
+
wb = load_workbook_for_save(xlsx_path)
|
|
70
|
+
if SHEET_NAME not in wb.sheetnames:
|
|
71
|
+
raise SyncError(f"工作簿中找不到工作表“{SHEET_NAME}”,请确认该文件由本工具导出")
|
|
72
|
+
order, blocks = _load_blocks(wb)
|
|
73
|
+
previous_marks = read_previous_marks(xlsx_path)
|
|
74
|
+
known_mark_bookmarks = {row.get("bookmark") for row in previous_marks if row.get("bookmark")}
|
|
75
|
+
|
|
76
|
+
recorded = {code: (block.get("bookmark") or "").strip() for code, block in blocks.items()}
|
|
77
|
+
candidates = {name for name in recorded.values() if name}
|
|
78
|
+
table_index = table_index_map_by_bookmark(doc, candidates, include_anchors=True)
|
|
79
|
+
counts = Counter(bookmark_names(doc.element.body))
|
|
80
|
+
duplicates = [name for name in counts if name.startswith(BOOKMARK_PREFIX) and counts[name] > 1]
|
|
81
|
+
if duplicates:
|
|
82
|
+
raise SyncError(f"Word 中存在重复的表格书签:{'、'.join(sorted(duplicates))}。请先清理重复书签。")
|
|
83
|
+
_duplicate_mark_bookmarks(doc)
|
|
84
|
+
|
|
85
|
+
items = body_items(doc)
|
|
86
|
+
new_indices = [index for index in range(len(doc.tables)) if index not in set(table_index.values())]
|
|
87
|
+
all_infos = [collect_table_info(doc, items, index, tab) for index, tab in enumerate(doc.tables)]
|
|
88
|
+
dedupe_table_names(all_infos)
|
|
89
|
+
existing_names = bookmark_names(doc.element.body)
|
|
90
|
+
bookmark_id = next_bookmark_id(doc)
|
|
91
|
+
new_infos = []
|
|
92
|
+
next_number = max([int(code[2:]) for code in order if code.startswith("XT") and code[2:].isdigit()] + [0]) + 1
|
|
93
|
+
for offset, index in enumerate(new_indices):
|
|
94
|
+
info = dict(all_infos[index])
|
|
95
|
+
name = new_cpah_name(existing_names)
|
|
96
|
+
info["bookmark"] = name
|
|
97
|
+
info["code"] = f"XT{next_number + offset:02d}"
|
|
98
|
+
new_infos.append(info)
|
|
99
|
+
|
|
100
|
+
marks = [mark for mark in find_marks(doc) if not mark.bookmark or mark.bookmark not in known_mark_bookmarks]
|
|
101
|
+
fields = scan_placeholders(doc)
|
|
102
|
+
existing_fields = set()
|
|
103
|
+
from ..docx_placeholders import VALUES_SHEET
|
|
104
|
+
if VALUES_SHEET in wb.sheetnames:
|
|
105
|
+
existing_fields = {str(wb[VALUES_SHEET].cell(r, 1).value or "").strip() for r in range(2, (wb[VALUES_SHEET].max_row or 1) + 1)}
|
|
106
|
+
new_fields = [field for field in fields if field not in existing_fields]
|
|
107
|
+
ignored_marks, ignored_placeholders = _ignored_table_content(doc)
|
|
108
|
+
|
|
109
|
+
log(f"读取 Word:{docx_path.name}")
|
|
110
|
+
log(f"增量预演:新增表格 {len(new_infos)} 张、新增标注 {len(marks)} 处、新增占位符 {len(new_fields)} 个。")
|
|
111
|
+
for info in new_infos:
|
|
112
|
+
log(f" {info['code']} {info['name']}({info['nrows']}行×{info['ncols']}列,书签 {info['bookmark']})")
|
|
113
|
+
for mark in marks:
|
|
114
|
+
log(f" {mark.location}:{mark.text[:40]}")
|
|
115
|
+
if new_fields:
|
|
116
|
+
log(f" 新字段:{'、'.join(new_fields)}")
|
|
117
|
+
if ignored_marks or ignored_placeholders:
|
|
118
|
+
log(f"[忽略] 表格内高亮 {ignored_marks} 处、占位符 {ignored_placeholders} 个不导出,避免与表格同步冲突。")
|
|
119
|
+
if args.dry_run:
|
|
120
|
+
log("预演模式:未写入任何文件。")
|
|
121
|
+
wb.close()
|
|
122
|
+
if getattr(wb, "vba_archive", None):
|
|
123
|
+
wb.vba_archive.close()
|
|
124
|
+
return 0
|
|
125
|
+
|
|
126
|
+
if not new_infos and not marks and not new_fields:
|
|
127
|
+
log("增量预演:没有新增表格、标注或占位符,未修改任何文件。")
|
|
128
|
+
wb.close()
|
|
129
|
+
if getattr(wb, "vba_archive", None):
|
|
130
|
+
wb.vba_archive.close()
|
|
131
|
+
return 0
|
|
132
|
+
|
|
133
|
+
for info in new_infos:
|
|
134
|
+
insert_table_bookmark(doc.tables[info["index"]]._tbl, info["bookmark"], bookmark_id)
|
|
135
|
+
bookmark_id += 1
|
|
136
|
+
created_marks = ensure_mark_bookmarks(doc, marks)
|
|
137
|
+
if new_infos:
|
|
138
|
+
export_workbook(
|
|
139
|
+
new_infos, docx_path.name, with_links=not getattr(args, "no_excel_links", False),
|
|
140
|
+
totals_formula=not getattr(args, "no_total_formulas", False), wb=wb, sheet_name=SHEET_NEW_TABLES,
|
|
141
|
+
)
|
|
142
|
+
mark_stats = append_marks_sheet(wb, docx_path.name, marks, previous_marks) if marks else {"marks": 0}
|
|
143
|
+
added_fields = append_placeholder_sheet(wb, new_fields, source="增量") if new_fields else []
|
|
144
|
+
backups = save_docx_xlsx_transaction(
|
|
145
|
+
docx_path=docx_path if new_infos or created_marks else None,
|
|
146
|
+
doc=doc if new_infos or created_marks else None,
|
|
147
|
+
xlsx_path=xlsx_path, wb=wb, backup=getattr(args, "backup", True),
|
|
148
|
+
)
|
|
149
|
+
log(
|
|
150
|
+
f"[增量导出] 已登记表格 {len(new_infos)} 张、标注 {mark_stats['marks']} 处、占位符 {len(added_fields)} 个;"
|
|
151
|
+
"既有工作簿行与公式位置未改动。"
|
|
152
|
+
)
|
|
153
|
+
if backups.get(docx_path):
|
|
154
|
+
log(f"[增量导出] Word 已备份:{backups[docx_path].name}")
|
|
155
|
+
if backups.get(xlsx_path):
|
|
156
|
+
log(f"[增量导出] Excel 已备份:{backups[xlsx_path].name}")
|
|
157
|
+
return 0
|