设置工作表页边距

  1. func (f *File) SetPageMargins(sheet string, opts ...PageMarginsOptions) error

根据给定的工作表名称和页边距参数设置工作表的页边距。页边距可选参数:

参数数据类型
PageMarginBotomfloat64
PageMarginFooterfloat64
PageMarginHeaderfloat64
PageMarginLeftfloat64
PageMarginRightfloat64
PageMarginTopfloat64
  • 例如,设置名为 Sheet1 的工作表页边距:
  1. f := excelize.NewFile()
  2. const sheet = "Sheet1"
  3. if err := f.SetPageMargins(sheet,
  4. excelize.PageMarginBottom(1.0),
  5. excelize.PageMarginFooter(1.0),
  6. excelize.PageMarginHeader(1.0),
  7. excelize.PageMarginLeft(1.0),
  8. excelize.PageMarginRight(1.0),
  9. excelize.PageMarginTop(1.0),
  10. ); err != nil {
  11. panic(err)
  12. }