-
Notifications
You must be signed in to change notification settings - Fork 61
/
main.go
39 lines (33 loc) · 949 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2017 Baliance. All rights reserved.
package main
import (
"fmt"
"log"
"time"
"github.com/carmel/gooxml/document"
)
func main() {
doc, err := document.Open("document.docx")
if err != nil {
log.Fatalf("error opening document: %s", err)
}
cp := doc.CoreProperties
// You can read properties from the document
fmt.Println("Title:", cp.Title())
fmt.Println("Author:", cp.Author())
fmt.Println("Description:", cp.Description())
fmt.Println("Last Modified By:", cp.LastModifiedBy())
fmt.Println("Category:", cp.Category())
fmt.Println("Content Status:", cp.ContentStatus())
fmt.Println("Created:", cp.Created())
fmt.Println("Modified:", cp.Modified())
// And change them as well
cp.SetTitle("CP Invoices")
cp.SetAuthor("John Doe")
cp.SetCategory("Invoices")
cp.SetContentStatus("Draft")
cp.SetLastModifiedBy("Jane Smith")
cp.SetCreated(time.Now())
cp.SetModified(time.Now())
doc.SaveToFile("document.docx")
}