获取工作表页边距
根据给定的工作表名称和页边距参数获取工作表的页边距。页边距可选参数:
参数 | 数据类型 |
---|---|
PageMarginBotom | float64 |
PageMarginFooter | float64 |
PageMarginHeader | float64 |
PageMarginLeft | float64 |
PageMarginRight | float64 |
PageMarginTop | float64 |
- 例如,获取名为
Sheet1
的工作表页边距:
f := excelize.NewFile()
const sheet = "Sheet1"
var (
marginBottom excelize.PageMarginBottom
marginFooter excelize.PageMarginFooter
marginHeader excelize.PageMarginHeader
marginLeft excelize.PageMarginLeft
marginRight excelize.PageMarginRight
marginTop excelize.PageMarginTop
)
if err := f.GetPageMargins(sheet,
&marginBottom,
&marginFooter,
&marginHeader,
&marginLeft,
&marginRight,
&marginTop,
); err != nil {
fmt.Println(err)
}
fmt.Println("Defaults:")
fmt.Println("- marginBottom:", marginBottom)
fmt.Println("- marginFooter:", marginFooter)
fmt.Println("- marginHeader:", marginHeader)
fmt.Println("- marginLeft:", marginLeft)
fmt.Println("- marginRight:", marginRight)
fmt.Println("- marginTop:", marginTop)
得到输出:
Defaults:
- marginBottom: 0.75
- marginFooter: 0.3
- marginHeader: 0.3
- marginLeft: 0.7
- marginRight: 0.7
- marginTop: 0.75