docx
docx copied to clipboard
panic: zip: not a valid zip file
package main
import ( "fmt"
"github.com/nguyenthenguyen/docx"
)
func main() {
// Read from docx file
r, err := docx.ReadDocxFile("./a.docx")
// Or read from memory
// r, err := docx.ReadDocxFromMemory(data io.ReaderAt, size int64)
// Or read from a filesystem object:
// r, err := docx.ReadDocxFromFS(file string, fs fs.FS)
if err != nil {
fmt.Println("----")
panic(err)
fmt.Println("====")
}
docx1 := r.Editable()
// Replace like https://golang.org/pkg/strings/#Replace
docx1.Replace("OS_CPU", "OK", -1)
docx1.WriteToFile("./a.docx")
r.Close()
}
PS D:\Go\src\testdoc> go run .\testdoc.go
panic: zip: not a valid zip file
goroutine 1 [running]: main.main() D:/Go/src/testdoc/testdoc.go:21 +0x1a5 exit status 2