-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcell_core_xml.go
69 lines (51 loc) · 1.15 KB
/
cell_core_xml.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package xlripper
import (
"encoding/json"
"encoding/xml"
"github.com/bitflip-software/xlripper/xmlprivate"
)
type cellCoreXML struct {
x xmlprivate.CellXML
}
func (c *cellCoreXML) cellReference() string {
return c.x.R
}
func (c *cellCoreXML) cellReferenceRunes() []rune {
return []rune(c.cellReference())
}
func (c *cellCoreXML) typeInfo() cellTypeInfo {
if c.x.T == "" {
return ctNone
} else if c.x.T == "inlineStr" {
return ctInlineString
} else if c.x.T == "s" {
return ctSharedString
}
return ctUnknown
}
func (c *cellCoreXML) value() *string {
t := c.typeInfo()
if t == ctInlineString {
return &c.x.InlineString.Str
}
return &c.x.V
}
func (c *cellCoreXML) valueRunes() []rune {
return []rune(*c.value())
}
func (c cellCoreXML) MarshalJSON() ([]byte, error) {
return json.Marshal(c.x)
}
func (c *cellCoreXML) UnmarshalJSON(b []byte) error {
return json.Unmarshal(b, &c.x)
}
func (c *cellCoreXML) parseXML(runes []rune) error {
return xml.Unmarshal([]byte(string(runes)), &c.x)
}
func (c *cellCoreXML) toXML() ([]rune, error) {
b, err := xml.Marshal(c.x)
if err != nil {
return nil, err
}
return []rune(string(b)), nil
}