col.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package xlsx
  2. // Default column width in excel
  3. const ColWidth = 9.5
  4. type Col struct {
  5. Min int
  6. Max int
  7. Hidden bool
  8. Width float64
  9. BestFit bool
  10. Collapsed bool
  11. OutlineLevel uint8
  12. numFmt string
  13. parsedNumFmt *parsedNumberFormat
  14. style *Style
  15. }
  16. // SetType will set the format string of a column based on the type that you want to set it to.
  17. // This function does not really make a lot of sense.
  18. func (c *Col) SetType(cellType CellType) {
  19. switch cellType {
  20. case CellTypeString:
  21. c.numFmt = builtInNumFmt[builtInNumFmtIndex_STRING]
  22. case CellTypeNumeric:
  23. c.numFmt = builtInNumFmt[builtInNumFmtIndex_INT]
  24. case CellTypeBool:
  25. c.numFmt = builtInNumFmt[builtInNumFmtIndex_GENERAL] //TEMP
  26. case CellTypeInline:
  27. c.numFmt = builtInNumFmt[builtInNumFmtIndex_STRING]
  28. case CellTypeError:
  29. c.numFmt = builtInNumFmt[builtInNumFmtIndex_GENERAL] //TEMP
  30. case CellTypeDate:
  31. // Cells that are stored as dates are not properly supported in this library.
  32. // They should instead be stored as a Numeric with a date format.
  33. c.numFmt = builtInNumFmt[builtInNumFmtIndex_GENERAL]
  34. case CellTypeStringFormula:
  35. c.numFmt = builtInNumFmt[builtInNumFmtIndex_STRING]
  36. }
  37. }
  38. // GetStyle returns the Style associated with a Col
  39. func (c *Col) GetStyle() *Style {
  40. return c.style
  41. }
  42. // SetStyle sets the style of a Col
  43. func (c *Col) SetStyle(style *Style) {
  44. c.style = style
  45. }