forked from plandem/xlsx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcol_test.go
64 lines (52 loc) · 1.56 KB
/
col_test.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
// 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/xlsx/format/styles"
"github.com/plandem/xlsx/types/options/column"
"github.com/stretchr/testify/require"
"testing"
)
func TestCol(t *testing.T) {
xl, err := Open("./test_files/example_simple.xlsx")
if err != nil {
panic(err)
}
defer xl.Close()
sheet := xl.Sheet(0)
c := sheet.Col(5)
o := options.New(
options.Width(0),
options.OutlineLevel(10),
options.Hidden(true),
options.Phonetic(true),
options.Collapsed(true),
)
c.SetOptions(o)
require.Equal(t, c.ml.OutlineLevel, o.OutlineLevel)
require.Equal(t, c.ml.Hidden, o.Hidden)
require.Equal(t, c.ml.Phonetic, o.Phonetic)
require.Equal(t, c.ml.Collapsed, o.Collapsed)
require.Equal(t, c.ml.Width, float32(0.0))
require.Equal(t, c.ml.CustomWidth, false)
require.Equal(t, c.ml.Style, styles.DirectStyleID(0))
o = options.New(
options.Width(100.0),
)
c.SetOptions(o)
require.Equal(t, c.ml.OutlineLevel, o.OutlineLevel)
require.Equal(t, c.ml.Hidden, o.Hidden)
require.Equal(t, c.ml.Phonetic, o.Phonetic)
require.Equal(t, c.ml.Collapsed, o.Collapsed)
require.Equal(t, c.ml.Width, float32(100.0))
require.Equal(t, c.ml.CustomWidth, true)
require.Equal(t, c.ml.Style, styles.DirectStyleID(0))
style := styles.New(
styles.Font.Name("Calibri"),
styles.Font.Size(12),
)
styleRef := xl.AddStyles(style)
c.SetStyles(styleRef)
require.Equal(t, c.ml.Style, styles.DirectStyleID(styleRef))
}