获取工作表格式属性

  1. func (f *File) GetSheetFormatPr(sheet string, opts ...SheetFormatPrOptionsPtr) error

根据给定的工作表名称获取格式属性。

可选格式参数数据类型
BaseColWidthuint8
DefaultColWidthfloat64
DefaultRowHeightfloat64
CustomHeightbool
ZeroHeightbool
ThickTopbool
ThickBottombool

例子:

  1. f := excelize.NewFile()
  2. const sheet = "Sheet1"
  3. var (
  4. baseColWidth excelize.BaseColWidth
  5. defaultColWidth excelize.DefaultColWidth
  6. defaultRowHeight excelize.DefaultRowHeight
  7. customHeight excelize.CustomHeight
  8. zeroHeight excelize.ZeroHeight
  9. thickTop excelize.ThickTop
  10. thickBottom excelize.ThickBottom
  11. )
  12. if err := f.GetSheetFormatPr(sheet,
  13. &baseColWidth,
  14. &defaultColWidth,
  15. &defaultRowHeight,
  16. &customHeight,
  17. &zeroHeight,
  18. &thickTop,
  19. &thickBottom,
  20. ); err != nil {
  21. fmt.Println(err)
  22. }
  23. fmt.Println("Defaults:")
  24. fmt.Println("- baseColWidth:", baseColWidth)
  25. fmt.Println("- defaultColWidth:", defaultColWidth)
  26. fmt.Println("- defaultRowHeight:", defaultRowHeight)
  27. fmt.Println("- customHeight:", customHeight)
  28. fmt.Println("- zeroHeight:", zeroHeight)
  29. fmt.Println("- thickTop:", thickTop)
  30. fmt.Println("- thickBottom:", thickBottom)

得到输出:

  1. Defaults:
  2. - baseColWidth: 0
  3. - defaultColWidth: 0
  4. - defaultRowHeight: 15
  5. - customHeight: false
  6. - zeroHeight: false
  7. - thickTop: false
  8. - thickBottom: false