Row.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheet\Worksheet;
  3. class Row
  4. {
  5. /**
  6. * \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet.
  7. *
  8. * @var Worksheet
  9. */
  10. private $worksheet;
  11. /**
  12. * Row index.
  13. *
  14. * @var int
  15. */
  16. private $rowIndex = 0;
  17. /**
  18. * Create a new row.
  19. *
  20. * @param Worksheet $worksheet
  21. * @param int $rowIndex
  22. */
  23. public function __construct(Worksheet $worksheet = null, $rowIndex = 1)
  24. {
  25. // Set parent and row index
  26. $this->worksheet = $worksheet;
  27. $this->rowIndex = $rowIndex;
  28. }
  29. /**
  30. * Destructor.
  31. */
  32. public function __destruct()
  33. {
  34. unset($this->worksheet);
  35. }
  36. /**
  37. * Get row index.
  38. *
  39. * @return int
  40. */
  41. public function getRowIndex()
  42. {
  43. return $this->rowIndex;
  44. }
  45. /**
  46. * Get cell iterator.
  47. *
  48. * @param string $startColumn The column address at which to start iterating
  49. * @param string $endColumn Optionally, the column address at which to stop iterating
  50. *
  51. * @return RowCellIterator
  52. */
  53. public function getCellIterator($startColumn = 'A', $endColumn = null)
  54. {
  55. return new RowCellIterator($this->worksheet, $this->rowIndex, $startColumn, $endColumn);
  56. }
  57. /**
  58. * Returns bound worksheet.
  59. *
  60. * @return Worksheet
  61. */
  62. public function getWorksheet()
  63. {
  64. return $this->worksheet;
  65. }
  66. }