代码拉取完成,页面将自动刷新
同步操作将从 xuri/excelize 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package excelize_test
import (
"fmt"
"testing"
"github.com/360EntSecGroup-Skylar/excelize"
)
var _ = []excelize.SheetViewOption{
excelize.DefaultGridColor(true),
excelize.RightToLeft(false),
excelize.ShowFormulas(false),
excelize.ShowGridLines(true),
excelize.ShowRowColHeaders(true),
// SheetViewOptionPtr are also SheetViewOption
new(excelize.DefaultGridColor),
new(excelize.RightToLeft),
new(excelize.ShowFormulas),
new(excelize.ShowGridLines),
new(excelize.ShowRowColHeaders),
}
var _ = []excelize.SheetViewOptionPtr{
(*excelize.DefaultGridColor)(nil),
(*excelize.RightToLeft)(nil),
(*excelize.ShowFormulas)(nil),
(*excelize.ShowGridLines)(nil),
(*excelize.ShowRowColHeaders)(nil),
}
func ExampleFile_SetSheetViewOptions() {
xl := excelize.NewFile()
const sheet = "Sheet1"
if err := xl.SetSheetViewOptions(sheet, 0,
excelize.DefaultGridColor(false),
excelize.RightToLeft(false),
excelize.ShowFormulas(true),
excelize.ShowGridLines(true),
excelize.ShowRowColHeaders(true),
excelize.ZoomScale(80),
); err != nil {
panic(err)
}
var zoomScale excelize.ZoomScale
fmt.Println("Default:")
fmt.Println("- zoomScale: 80")
if err := xl.SetSheetViewOptions(sheet, 0, excelize.ZoomScale(500)); err != nil {
panic(err)
}
if err := xl.GetSheetViewOptions(sheet, 0, &zoomScale); err != nil {
panic(err)
}
fmt.Println("Used out of range value:")
fmt.Println("- zoomScale:", zoomScale)
if err := xl.SetSheetViewOptions(sheet, 0, excelize.ZoomScale(123)); err != nil {
panic(err)
}
if err := xl.GetSheetViewOptions(sheet, 0, &zoomScale); err != nil {
panic(err)
}
fmt.Println("Used correct value:")
fmt.Println("- zoomScale:", zoomScale)
// Output:
// Default:
// - zoomScale: 80
// Used out of range value:
// - zoomScale: 80
// Used correct value:
// - zoomScale: 123
}
func ExampleFile_GetSheetViewOptions() {
xl := excelize.NewFile()
const sheet = "Sheet1"
var (
defaultGridColor excelize.DefaultGridColor
rightToLeft excelize.RightToLeft
showFormulas excelize.ShowFormulas
showGridLines excelize.ShowGridLines
showRowColHeaders excelize.ShowRowColHeaders
zoomScale excelize.ZoomScale
)
if err := xl.GetSheetViewOptions(sheet, 0,
&defaultGridColor,
&rightToLeft,
&showFormulas,
&showGridLines,
&showRowColHeaders,
&zoomScale,
); err != nil {
panic(err)
}
fmt.Println("Default:")
fmt.Println("- defaultGridColor:", defaultGridColor)
fmt.Println("- rightToLeft:", rightToLeft)
fmt.Println("- showFormulas:", showFormulas)
fmt.Println("- showGridLines:", showGridLines)
fmt.Println("- showRowColHeaders:", showRowColHeaders)
fmt.Println("- zoomScale:", zoomScale)
if err := xl.SetSheetViewOptions(sheet, 0, excelize.ShowGridLines(false)); err != nil {
panic(err)
}
if err := xl.GetSheetViewOptions(sheet, 0, &showGridLines); err != nil {
panic(err)
}
fmt.Println("After change:")
fmt.Println("- showGridLines:", showGridLines)
// Output:
// Default:
// - defaultGridColor: true
// - rightToLeft: false
// - showFormulas: false
// - showGridLines: true
// - showRowColHeaders: true
// - zoomScale: 0
// After change:
// - showGridLines: false
}
func TestSheetViewOptionsErrors(t *testing.T) {
xl := excelize.NewFile()
const sheet = "Sheet1"
if err := xl.GetSheetViewOptions(sheet, 0); err != nil {
t.Errorf("Unexpected error: %s", err)
}
if err := xl.GetSheetViewOptions(sheet, -1); err != nil {
t.Errorf("Unexpected error: %s", err)
}
if err := xl.GetSheetViewOptions(sheet, 1); err == nil {
t.Error("Error expected but got nil")
}
if err := xl.GetSheetViewOptions(sheet, -2); err == nil {
t.Error("Error expected but got nil")
}
if err := xl.SetSheetViewOptions(sheet, 0); err != nil {
t.Errorf("Unexpected error: %s", err)
}
if err := xl.SetSheetViewOptions(sheet, -1); err != nil {
t.Errorf("Unexpected error: %s", err)
}
if err := xl.SetSheetViewOptions(sheet, 1); err == nil {
t.Error("Error expected but got nil")
}
if err := xl.SetSheetViewOptions(sheet, -2); err == nil {
t.Error("Error expected but got nil")
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。