stream_cell.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package xlsx
  2. import "strconv"
  3. // StreamCell holds the data, style and type of cell for streaming
  4. type StreamCell struct {
  5. cellData string
  6. cellStyle StreamStyle
  7. cellType CellType
  8. }
  9. // NewStreamCell creates a new StreamCell
  10. func NewStreamCell(cellData string, cellStyle StreamStyle, cellType CellType) StreamCell{
  11. return StreamCell{
  12. cellData: cellData,
  13. cellStyle: cellStyle,
  14. cellType: cellType,
  15. }
  16. }
  17. // MakeStringStreamCell creates a new cell that holds string data, is of type string and uses general formatting
  18. func MakeStringStreamCell(cellData string) StreamCell{
  19. return NewStreamCell(cellData, Strings, CellTypeString)
  20. }
  21. // MakeStyledStringStreamCell creates a new cell that holds a string and is styled according to the given style
  22. func MakeStyledStringStreamCell(cellData string, cellStyle StreamStyle) StreamCell {
  23. return NewStreamCell(cellData, cellStyle, CellTypeString)
  24. }
  25. // MakeIntegerStreamCell creates a new cell that holds an integer value (represented as string),
  26. // is formatted as a standard integer and is of type numeric.
  27. func MakeIntegerStreamCell(cellData int) StreamCell {
  28. return NewStreamCell(strconv.Itoa(cellData), Integers, CellTypeNumeric)
  29. }
  30. // MakeStyledIntegerStreamCell created a new cell that holds an integer value (represented as string)
  31. // and is styled according to the given style.
  32. func MakeStyledIntegerStreamCell(cellData int, cellStyle StreamStyle) StreamCell {
  33. return NewStreamCell(strconv.Itoa(cellData), cellStyle, CellTypeNumeric)
  34. }