forked from plandem/xlsx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
workbook.go
37 lines (29 loc) · 905 Bytes
/
workbook.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
// Copyright (c) 2017 Andrey Gayvoronsky <[email protected]>
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package xlsx
import (
"github.com/plandem/ooxml"
"github.com/plandem/xlsx/internal"
"github.com/plandem/xlsx/internal/ml"
)
//workbook is a higher level object that wraps ml.Workbook with functionality
type workbook struct {
ml ml.Workbook
doc *Spreadsheet
file *ooxml.PackageFile
}
func newWorkbook(f interface{}, doc *Spreadsheet) *workbook {
wb := &workbook{
doc: doc,
}
doc.workbook = wb
wb.file = ooxml.NewPackageFile(doc.pkg, f, &wb.ml, nil)
wb.file.LoadIfRequired(nil)
if wb.file.IsNew() {
doc.pkg.ContentTypes().RegisterContent(wb.file.FileName(), internal.ContentTypeWorkbook)
doc.pkg.Relationships().AddFile(internal.RelationTypeWorkbook, wb.file.FileName())
wb.file.MarkAsUpdated()
}
return wb
}