-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstyle.go
More file actions
45 lines (42 loc) · 1.05 KB
/
style.go
File metadata and controls
45 lines (42 loc) · 1.05 KB
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
package xlsxtra
import "github.com/tealeg/xlsx"
// NewStyle creates a new style with color and boldness
func NewStyle(color string, font *xlsx.Font,
border *xlsx.Border, align *xlsx.Alignment) *xlsx.Style {
style := xlsx.NewStyle()
if color != "" {
style.Fill = *xlsx.NewFill("solid", color, color)
style.ApplyFill = true
} else {
style.Fill = *xlsx.DefaultFill()
}
if font != nil {
style.Font = *font
style.ApplyFont = true
} else {
style.Font = *xlsx.DefaultFont()
}
if border != nil {
style.Border = *border
style.ApplyBorder = true
} else {
style.Border = *xlsx.DefaultBorder()
}
if align != nil {
style.Alignment = *align
style.ApplyAlignment = true
} else {
style.Alignment = *xlsx.DefaultAlignment()
}
return style
}
// NewStyles creates styles with color and boldness
func NewStyles(colors []string, font *xlsx.Font,
border *xlsx.Border,
align *xlsx.Alignment) []*xlsx.Style {
styles := make([]*xlsx.Style, len(colors))
for i, color := range colors {
styles[i] = NewStyle(color, font, border, align)
}
return styles
}