chore: prepare docfill project for gitea

This commit is contained in:
赵义仑
2026-06-24 09:45:35 +08:00
parent ca444bd5d0
commit 32e74d0f43
38 changed files with 2915 additions and 162 deletions

View File

@@ -25,6 +25,10 @@ func main() {
fmt.Fprintf(os.Stderr, "write excel-to-word fixtures: %v\n", err)
os.Exit(1)
}
if err := writeExcelFilterToWord(filepath.Join(*base, "excel-filter-to-word")); err != nil {
fmt.Fprintf(os.Stderr, "write excel-filter-to-word fixtures: %v\n", err)
os.Exit(1)
}
if err := writeSQLiteToExcel(filepath.Join(*base, "sqlite-to-excel")); err != nil {
fmt.Fprintf(os.Stderr, "write sqlite-to-excel fixtures: %v\n", err)
os.Exit(1)
@@ -45,6 +49,21 @@ func writeExcelToWord(dir string) error {
return writeDocx(filepath.Join(dir, "template.docx"), `<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:body><w:p><w:r><w:t>员工:{{na</w:t></w:r><w:r><w:t>me}}</w:t></w:r></w:p><w:p><w:r><w:t>日期:{{date}}</w:t></w:r></w:p><w:p><w:r><w:t>完成:{{done}}</w:t></w:r></w:p><w:p><w:r><w:t>计划:{{plan}}</w:t></w:r></w:p></w:body></w:document>`)
}
func writeExcelFilterToWord(dir string) error {
if err := os.MkdirAll(dir, 0o755); err != nil {
return err
}
if err := writeWorkbook(filepath.Join(dir, "data.xlsx"), "Tickets", [][]string{
{"date", "ticket_no", "customer", "result"},
{"2026-06-18", "GD-001", "A 公司", "已派单"},
{"2026-06-18", "GD-002", "B 公司", "已完成"},
{"2026-06-19", "GD-001", "C 公司", "待复核"},
}); err != nil {
return err
}
return writeDocx(filepath.Join(dir, "template.docx"), `<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:body><w:p><w:r><w:t>工单:{{ticket_no}}</w:t></w:r></w:p><w:p><w:r><w:t>日期:{{date}}</w:t></w:r></w:p><w:p><w:r><w:t>客户:{{customer}}</w:t></w:r></w:p><w:p><w:r><w:t>结果:{{result}}</w:t></w:r></w:p></w:body></w:document>`)
}
func writeSQLiteToExcel(dir string) error {
if err := os.MkdirAll(dir, 0o755); err != nil {
return err