worksheet.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. SheetViews xlsxSheetViews `xml:"sheetViews"`
  9. SheetFormatPr xlsxSheetFormatPr `xml:"sheetFormatPr"`
  10. SheetData xlsxSheetData `xml:"sheetData"`
  11. }
  12. // xlsxDimension directly maps the dimension element in the namespace
  13. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  14. // currently I have not checked it for completeness - it does as much
  15. // as I need.
  16. type xlsxDimension struct {
  17. Ref string `xml:"ref,attr"`
  18. }
  19. // xlsxSheetViews directly maps the sheetViews element in the namespace
  20. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  21. // currently I have not checked it for completeness - it does as much
  22. // as I need.
  23. type xlsxSheetViews struct {
  24. SheetView []xlsxSheetView `xml:"sheetView"`
  25. }
  26. // xlsxSheetView directly maps the sheetView element in the namespace
  27. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  28. // currently I have not checked it for completeness - it does as much
  29. // as I need.
  30. type xlsxSheetView struct {
  31. TabSelected string `xml:"tabSelected,attr"`
  32. WorkbookViewID string `xml:"workbookViewId,attr"`
  33. Selection xlsxSelection `xml:"selection"`
  34. }
  35. // xlsxSelection directly maps the selection element in the namespace
  36. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  37. // currently I have not checked it for completeness - it does as much
  38. // as I need.
  39. type xlsxSelection struct {
  40. ActiveCell string `xml:"activeCell,attr"`
  41. SQRef string `xml:"sqref,attr"`
  42. }
  43. // xlsxSheetFormatPr directly maps the sheetFormatPr element in the namespace
  44. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  45. // currently I have not checked it for completeness - it does as much
  46. // as I need.
  47. type xlsxSheetFormatPr struct {
  48. BaseColWidth string `xml:"baseColWidth,attr"`
  49. DefaultRowHeight string `xml:"defaultRowHeight,attr"`
  50. }
  51. // xlsxSheetData directly maps the sheetData element in the namespace
  52. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  53. // currently I have not checked it for completeness - it does as much
  54. // as I need.
  55. type xlsxSheetData struct {
  56. Row []xlsxRow `xml:"row"`
  57. }
  58. // xlsxRow directly maps the row element in the namespace
  59. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  60. // currently I have not checked it for completeness - it does as much
  61. // as I need.
  62. type xlsxRow struct {
  63. R string `xml:"r,attr"`
  64. Spans string `xml:"spans,attr"`
  65. C []xlsxC `xml:"c"`
  66. }
  67. // xlsxC directly maps the c element in the namespace
  68. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  69. // currently I have not checked it for completeness - it does as much
  70. // as I need.
  71. type xlsxC struct {
  72. R string `xml:"r,attr"`
  73. T string `xml:"t,attr"`
  74. V string `xml:"v"`
  75. }
  76. // xlsxV directly maps the v element in the namespace
  77. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  78. // currently I have not checked it for completeness - it does as much
  79. // as I need.
  80. // type xlsxV struct {
  81. // Data string `xml:"chardata"`
  82. // }
  83. // get cell
  84. func (sh *Sheet) Cell(row,col int) *Cell {
  85. if len(sh.Rows) > row && len(sh.Rows[row].Cells) > col {
  86. return sh.Rows[row].Cells[col]
  87. }
  88. return new(Cell)
  89. }