Column.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheet\Worksheet;
  3. class Column
  4. {
  5. /**
  6. * \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet.
  7. *
  8. * @var Worksheet
  9. */
  10. private $parent;
  11. /**
  12. * Column index.
  13. *
  14. * @var string
  15. */
  16. private $columnIndex;
  17. /**
  18. * Create a new column.
  19. *
  20. * @param Worksheet $parent
  21. * @param string $columnIndex
  22. */
  23. public function __construct(Worksheet $parent = null, $columnIndex = 'A')
  24. {
  25. // Set parent and column index
  26. $this->parent = $parent;
  27. $this->columnIndex = $columnIndex;
  28. }
  29. /**
  30. * Destructor.
  31. */
  32. public function __destruct()
  33. {
  34. unset($this->parent);
  35. }
  36. /**
  37. * Get column index.
  38. *
  39. * @return string
  40. */
  41. public function getColumnIndex()
  42. {
  43. return $this->columnIndex;
  44. }
  45. /**
  46. * Get cell iterator.
  47. *
  48. * @param int $startRow The row number at which to start iterating
  49. * @param int $endRow Optionally, the row number at which to stop iterating
  50. *
  51. * @return ColumnCellIterator
  52. */
  53. public function getCellIterator($startRow = 1, $endRow = null)
  54. {
  55. return new ColumnCellIterator($this->parent, $this->columnIndex, $startRow, $endRow);
  56. }
  57. }