设置工作表属性

  1. func (f *File) SetSheetPrOptions(sheet string, opts ...SheetPrOption) error

根据给定的工作表名称和筛选项设置工作表属性。

可选属性列表:

可选属性类型
CodeNamestring
EnableFormatConditionsCalculationbool
Publishedbool
FitToPagebool
TabColorIndexedint
TabColorRGBstring
TabColorThemeint
TabColorTintfloat64
AutoPageBreaksbool
OutlineSummaryBelowbool

例如:

  1. f := excelize.NewFile()
  2. const sheet = "Sheet1"
  3. if err := f.SetSheetPrOptions(sheet,
  4. excelize.CodeName("code"),
  5. excelize.EnableFormatConditionsCalculation(false),
  6. excelize.Published(false),
  7. excelize.FitToPage(true),
  8. excelize.TabColorIndexed(42),
  9. excelize.TabColorRGB("#FFFF00"),
  10. excelize.TabColorTheme(ColorMappingTypeLight2),
  11. excelize.TabColorTint(0.5),
  12. excelize.AutoPageBreaks(true),
  13. excelize.OutlineSummaryBelow(false),
  14. ); err != nil {
  15. fmt.Println(err)
  16. }