col.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. Collapsed bool
  10. OutlineLevel uint8
  11. numFmt string
  12. parsedNumFmt *parsedNumberFormat
  13. style *Style
  14. }
  15. // SetType will set the format string of a column based on the type that you want to set it to.
  16. // This function does not really make a lot of sense.
  17. func (c *Col) SetType(cellType CellType) {
  18. switch cellType {
  19. case CellTypeString:
  20. c.numFmt = builtInNumFmt[builtInNumFmtIndex_STRING]
  21. case CellTypeNumeric:
  22. c.numFmt = builtInNumFmt[builtInNumFmtIndex_INT]
  23. case CellTypeBool:
  24. c.numFmt = builtInNumFmt[builtInNumFmtIndex_GENERAL] //TEMP
  25. case CellTypeInline:
  26. c.numFmt = builtInNumFmt[builtInNumFmtIndex_STRING]
  27. case CellTypeError:
  28. c.numFmt = builtInNumFmt[builtInNumFmtIndex_GENERAL] //TEMP
  29. case CellTypeDate:
  30. // Cells that are stored as dates are not properly supported in this library.
  31. // They should instead be stored as a Numeric with a date format.
  32. c.numFmt = builtInNumFmt[builtInNumFmtIndex_GENERAL]
  33. case CellTypeStringFormula:
  34. c.numFmt = builtInNumFmt[builtInNumFmtIndex_STRING]
  35. }
  36. }
  37. // GetStyle returns the Style associated with a Col
  38. func (c *Col) GetStyle() *Style {
  39. return c.style
  40. }
  41. // SetStyle sets the style of a Col
  42. func (c *Col) SetStyle(style *Style) {
  43. c.style = style
  44. }