1 Star 0 Fork 162

qingmk/excelize

forked from xuri/excelize 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
workbook_test.go 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
package excelize
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestWorkbookProps(t *testing.T) {
f := NewFile()
assert.NoError(t, f.SetWorkbookProps(nil))
wb, err := f.workbookReader()
assert.NoError(t, err)
wb.WorkbookPr = nil
expected := WorkbookPropsOptions{
Date1904: boolPtr(true),
FilterPrivacy: boolPtr(true),
CodeName: stringPtr("code"),
}
assert.NoError(t, f.SetWorkbookProps(&expected))
opts, err := f.GetWorkbookProps()
assert.NoError(t, err)
assert.Equal(t, expected, opts)
// Test set workbook properties with unsupported charset workbook
f.WorkBook = nil
f.Pkg.Store(defaultXMLPathWorkbook, MacintoshCyrillicCharset)
assert.EqualError(t, f.SetWorkbookProps(&expected), "XML syntax error on line 1: invalid UTF-8")
// Test get workbook properties with unsupported charset workbook
f.WorkBook = nil
f.Pkg.Store(defaultXMLPathWorkbook, MacintoshCyrillicCharset)
_, err = f.GetWorkbookProps()
assert.EqualError(t, err, "XML syntax error on line 1: invalid UTF-8")
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/qingmk/excelize.git
git@gitee.com:qingmk/excelize.git
qingmk
excelize
excelize
master

搜索帮助