-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
row_test.go
67 lines (55 loc) · 1.69 KB
/
row_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
65
66
67
// Copyright (c) 2017 Andrey Gayvoronsky <plandem@gmail.com>
// 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/row"
"github.com/stretchr/testify/require"
"testing"
)
func TestRow(t *testing.T) {
xl, err := Open("./test_files/example_simple.xlsx")
if err != nil {
panic(err)
}
defer xl.Close()
sheet := xl.Sheet(0)
r := sheet.Row(5)
o := options.New(
options.Height(0),
options.OutlineLevel(10),
options.Hidden(true),
options.Phonetic(true),
options.Collapsed(true),
)
r.SetOptions(o)
require.Equal(t, r.ml.OutlineLevel, o.OutlineLevel)
require.Equal(t, r.ml.Hidden, o.Hidden)
require.Equal(t, r.ml.Phonetic, o.Phonetic)
require.Equal(t, r.ml.Collapsed, o.Collapsed)
require.Equal(t, r.ml.Height, float32(0.0))
require.Equal(t, r.ml.CustomHeight, false)
require.Equal(t, r.ml.CustomFormat, false)
require.Equal(t, r.ml.Style, styles.DirectStyleID(0))
o = options.New(
options.Height(100.0),
)
r.SetOptions(o)
require.Equal(t, r.ml.OutlineLevel, o.OutlineLevel)
require.Equal(t, r.ml.Hidden, o.Hidden)
require.Equal(t, r.ml.Phonetic, o.Phonetic)
require.Equal(t, r.ml.Collapsed, o.Collapsed)
require.Equal(t, r.ml.Height, float32(100.0))
require.Equal(t, r.ml.CustomHeight, true)
require.Equal(t, r.ml.CustomFormat, false)
require.Equal(t, r.ml.Style, styles.DirectStyleID(0))
style := styles.New(
styles.Font.Name("Calibri"),
styles.Font.Size(12),
)
styleRef := xl.AddStyles(style)
r.SetStyles(styleRef)
require.Equal(t, r.ml.CustomFormat, true)
require.Equal(t, r.ml.Style, styles.DirectStyleID(styleRef))
}