获取工作表属性

  1. func (f *File) GetSheetPrOptions(name string, opts ...SheetPrOptionPtr) error

根据给定的工作表名称(大小写敏感)和筛选项获取工作表属性。

可选属性类型
CodeNamestring
EnableFormatConditionsCalculationbool
Publishedbool
FitToPagebool
AutoPageBreaksbool
OutlineSummaryBelowbool

例如:

  1. f := excelize.NewFile()
  2. const sheet = "Sheet1"
  3. var (
  4. codeName excelize.CodeName
  5. enableFormatConditionsCalculation excelize.EnableFormatConditionsCalculation
  6. published excelize.Published
  7. fitToPage excelize.FitToPage
  8. autoPageBreaks excelize.AutoPageBreaks
  9. outlineSummaryBelow excelize.OutlineSummaryBelow
  10. )
  11. if err := f.GetSheetPrOptions(sheet,
  12. &codeName,
  13. &enableFormatConditionsCalculation,
  14. &published,
  15. &fitToPage,
  16. &autoPageBreaks,
  17. &outlineSummaryBelow,
  18. ); err != nil {
  19. panic(err)
  20. }
  21. fmt.Println("Defaults:")
  22. fmt.Printf("- codeName: %q\n", codeName)
  23. fmt.Println("- enableFormatConditionsCalculation:", enableFormatConditionsCalculation)
  24. fmt.Println("- published:", published)
  25. fmt.Println("- fitToPage:", fitToPage)
  26. fmt.Println("- autoPageBreaks:", autoPageBreaks)
  27. fmt.Println("- outlineSummaryBelow:", outlineSummaryBelow)

输出:

  1. Defaults:
  2. - codeName: ""
  3. - enableFormatConditionsCalculation: true
  4. - published: true
  5. - fitToPage: false
  6. - autoPageBreaks: false
  7. - outlineSummaryBelow: true