mirror of
https://github.com/unidoc/unioffice.git
synced 2025-04-29 13:49:10 +08:00
23 lines
467 B
Go
23 lines
467 B
Go
![]() |
package main
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
|
||
|
"baliance.com/gooxml/document"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
d, err := document.Open("mm.docx")
|
||
|
if err != nil {
|
||
|
log.Fatalf("error opening document: %s", err)
|
||
|
}
|
||
|
for _, v := range d.MergeFields() {
|
||
|
log.Println("replacing", v)
|
||
|
}
|
||
|
rep := map[string]string{}
|
||
|
rep["Title"] = "mr." // has a \* Upper attribute on the field
|
||
|
rep["FirstName"] = "JOHN" // has a \* Lower attribute on the field
|
||
|
d.MailMerge(rep)
|
||
|
d.SaveToFile("merged.docx")
|
||
|
}
|