worksheet.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package xlsx
  2. // xlsxWorksheet directly maps the worksheet element in the namespace
  3. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  4. // currently I have not checked it for completeness - it does as much
  5. // as I need.
  6. type xlsxWorksheet struct {
  7. Dimension xlsxDimension `xml:"dimension"`
  8. SheetData xlsxSheetData `xml:"sheetData"`
  9. }
  10. // xlsxDimension directly maps the dimension element in the namespace
  11. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  12. // currently I have not checked it for completeness - it does as much
  13. // as I need.
  14. type xlsxDimension struct {
  15. Ref string `xml:"ref,attr"`
  16. }
  17. // xlsxSheetData directly maps the sheetData element in the namespace
  18. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  19. // currently I have not checked it for completeness - it does as much
  20. // as I need.
  21. type xlsxSheetData struct {
  22. Row []xlsxRow `xml:"row"`
  23. }
  24. // xlsxRow directly maps the row element in the namespace
  25. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  26. // currently I have not checked it for completeness - it does as much
  27. // as I need.
  28. type xlsxRow struct {
  29. R int `xml:"r,attr"`
  30. Spans string `xml:"spans,attr"`
  31. C []xlsxC `xml:"c"`
  32. }
  33. // xlsxC directly maps the c element in the namespace
  34. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  35. // currently I have not checked it for completeness - it does as much
  36. // as I need.
  37. type xlsxC struct {
  38. R string `xml:"r,attr"`
  39. S int `xml:"s,attr"`
  40. T string `xml:"t,attr"`
  41. V string `xml:"v"`
  42. }
  43. // get cell
  44. func (sh *Sheet) Cell(row, col int) *Cell {
  45. if len(sh.Rows) > row && sh.Rows[row] != nil && len(sh.Rows[row].Cells) > col {
  46. return sh.Rows[row].Cells[col]
  47. }
  48. return new(Cell)
  49. }