添加过滤

main
还不如一只猪威武 1 week ago
parent fb4514e91d
commit df9f122399

5
.gitignore vendored

@ -1,4 +1,7 @@
/build/ /build/
/dist/ /dist/
.idea .idea
*.spec *.spec
.venv
*.docx
!template.docx

@ -26,12 +26,12 @@
}, },
{ {
"key": "{Test1}", "key": "{Test1}",
"value": "2025年11月26日", "value": "2TEst1打赏",
"type": "text" "type": "text"
}, },
{ {
"key": "{Test2}", "key": "{Test2}",
"value": "2025年11月26日", "value": "20TEst2打赏萨格",
"type": "text" "type": "text"
}, },
{ {

Binary file not shown.

@ -119,10 +119,11 @@ def replace(template_path, filename_path, data_json):
repeat = True repeat = True
else: else:
for paragraph in cell.paragraphs: for paragraph in cell.paragraphs:
paragraph.text = paragraph.text.replace(" ", "")
for run in paragraph.runs: for run in paragraph.runs:
find = False find = False
for datum in data_json: for datum in data_json:
if datum["key"] in cell.text: if datum["key"] in run.text:
find = True find = True
if "text" == datum["type"]: if "text" == datum["type"]:
run.text = run.text.replace(datum["key"], datum["value"]) run.text = run.text.replace(datum["key"], datum["value"])

Binary file not shown.
Loading…
Cancel
Save