| name | docx-template-weekly-report |
| description | Preserve and fill institutional Word weekly-report, project-practice, and course-report templates. Use when a user provides a .doc/.docx school or institution template and wants generated DOCX output while keeping the original page size, margins, cover underlines, tables, row heights, merged cells, fonts, alignment, reflection sections, teacher-review/score areas, and signature/date blocks. |
DOCX Template Weekly Report
Core Rule
Treat the user's Word template as the formatting authority. Do not rebuild tables, cover pages, review areas, or score areas from scratch unless the template is unusable. Clone or preserve the original XML and replace or insert only the visible text that must change.
Workflow
- Create a task folder in the project root for intermediate files.
- If the source is
.doc, convert it to .docx with Word COM first.
- Inspect page size, margins, paragraph runs, underlined blanks, table dimensions, row heights, merged cells, and alignment.
- Draft content separately in Markdown/JSON before filling Word.
- Generate the filled DOCX by preserving/cloning template XML and replacing text inside existing paragraphs/cells.
- Export to PDF and render preview pages for visual QA.
- Fix mappings or insertion points when layout differs; avoid rebuilding the document.
Read references/workflow.md for detailed patterns before working on fragile templates.
Template Patterns
- Weekly journal templates: Use
scripts/fill_weekly_report_template.py when the document repeats one template page/table for many weeks.
- Project/course report templates: Use
scripts/fill_project_practice_report_template.py as a starting point when the document has a cover page, one large report-outline table, a reflection/summary section, and a final teacher-review or score area.
Important Rules
- Preserve cover underlines. Many templates use underlined space runs as blanks; do not replace them with plain text.
- Center values inside underlined blanks when the original form expects centered personal information.
- Preserve body outline tables. Insert content after existing headings instead of clearing the whole cell.
- Insert section content from bottom to top when using paragraph indexes, because new paragraphs shift later indexes.
- Preserve reflection headings such as
Summary and Reflection, Reflection, ๅฟๅพไฝไผ, or ๆป็ปไธๆๆ.
- Preserve teacher-review, score, signature, and date areas. Do not fill or delete them unless the user explicitly asks.
- Set final teacher-review/score rows to not split across pages when Word pagination breaks the block.
Visual QA
Always inspect a PDF preview, not only DOCX text:
- First page: logo/title positions, underlines, centered field values, and empty fields.
- Body pages: original table frame, section headings, and body content inside the template area.
- Reflection page: reflection/summary heading still exists.
- Final page: teacher review, score table, signature, and date block are preserved and not awkwardly split.
- Page count: no blank trailing page unless the template itself has one.