获取工作表属性

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

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

可选属性类型
CodeNamestring
EnableFormatConditionsCalculationbool
Publishedbool
FitToPagebool
TabColorstring
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. tabColor excelize.TabColor
  9. autoPageBreaks excelize.AutoPageBreaks
  10. outlineSummaryBelow excelize.OutlineSummaryBelow
  11. )
  12. if err := f.GetSheetPrOptions(sheet,
  13. &codeName,
  14. &enableFormatConditionsCalculation,
  15. &published,
  16. &fitToPage,
  17. &tabColor,
  18. &autoPageBreaks,
  19. &outlineSummaryBelow,
  20. ); err != nil {
  21. fmt.Println(err)
  22. }
  23. fmt.Println("Defaults:")
  24. fmt.Printf("- codeName: %q\n", codeName)
  25. fmt.Println("- enableFormatConditionsCalculation:", enableFormatConditionsCalculation)
  26. fmt.Println("- published:", published)
  27. fmt.Println("- fitToPage:", fitToPage)
  28. fmt.Printf("- tabColor: %q\n", tabColor)
  29. fmt.Println("- autoPageBreaks:", autoPageBreaks)
  30. fmt.Println("- outlineSummaryBelow:", outlineSummaryBelow)

输出:

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