-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
sheet_info_test.go
50 lines (41 loc) · 1.55 KB
/
sheet_info_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
// 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/internal/ml"
"github.com/plandem/xlsx/internal/ml/primitives"
"github.com/plandem/xlsx/types/options/sheet"
"github.com/stretchr/testify/require"
"testing"
)
func TestSheetInfo(t *testing.T) {
require.Equal(t, true, isCellEmpty(nil))
require.Equal(t, true, isCellEmpty(&ml.Cell{}))
require.Equal(t, true, isCellEmpty(&ml.Cell{Ref: "A10"}))
require.Equal(t, false, isCellEmpty(&ml.Cell{Ref: "A10", Value: "1"}))
require.Equal(t, true, isRowEmpty(nil))
require.Equal(t, true, isRowEmpty(&ml.Row{}))
require.Equal(t, true, isRowEmpty(&ml.Row{Ref: 1}))
require.Equal(t, true, isRowEmpty(&ml.Row{Ref: 1, Cells: []*ml.Cell{}}))
require.Equal(t, false, isRowEmpty(&ml.Row{Cells: []*ml.Cell{{}}}))
require.Equal(t, false, isRowEmpty(&ml.Row{CustomHeight: true}))
xl, err := Open("./test_files/example_simple.xlsx")
if err != nil {
panic(err)
}
defer xl.Close()
sheet := xl.Sheet(0)
//test options
o := options.New(
options.Visibility(options.VisibilityVeryHidden),
)
require.Equal(t, primitives.VisibilityType(0), xl.workbook.ml.Sheets[0].State)
sheet.SetOptions(o)
require.Equal(t, options.VisibilityVeryHidden, xl.workbook.ml.Sheets[0].State)
//test set active
require.Equal(t, 0, xl.workbook.ml.BookViews.Items[0].ActiveTab)
sheet = xl.AddSheet("test")
sheet.SetActive()
require.Equal(t, 1, xl.workbook.ml.BookViews.Items[0].ActiveTab)
}