ColumnDimension.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheet\Worksheet;
  3. class ColumnDimension extends Dimension
  4. {
  5. /**
  6. * Column index.
  7. *
  8. * @var string
  9. */
  10. private $columnIndex;
  11. /**
  12. * Column width.
  13. *
  14. * When this is set to a negative value, the column width should be ignored by IWriter
  15. *
  16. * @var float
  17. */
  18. private $width = -1;
  19. /**
  20. * Auto size?
  21. *
  22. * @var bool
  23. */
  24. private $autoSize = false;
  25. /**
  26. * Create a new ColumnDimension.
  27. *
  28. * @param string $pIndex Character column index
  29. */
  30. public function __construct($pIndex = 'A')
  31. {
  32. // Initialise values
  33. $this->columnIndex = $pIndex;
  34. // set dimension as unformatted by default
  35. parent::__construct(0);
  36. }
  37. /**
  38. * Get ColumnIndex.
  39. *
  40. * @return string
  41. */
  42. public function getColumnIndex()
  43. {
  44. return $this->columnIndex;
  45. }
  46. /**
  47. * Set ColumnIndex.
  48. *
  49. * @param string $pValue
  50. *
  51. * @return ColumnDimension
  52. */
  53. public function setColumnIndex($pValue)
  54. {
  55. $this->columnIndex = $pValue;
  56. return $this;
  57. }
  58. /**
  59. * Get Width.
  60. *
  61. * @return float
  62. */
  63. public function getWidth()
  64. {
  65. return $this->width;
  66. }
  67. /**
  68. * Set Width.
  69. *
  70. * @param float $pValue
  71. *
  72. * @return ColumnDimension
  73. */
  74. public function setWidth($pValue)
  75. {
  76. $this->width = $pValue;
  77. return $this;
  78. }
  79. /**
  80. * Get Auto Size.
  81. *
  82. * @return bool
  83. */
  84. public function getAutoSize()
  85. {
  86. return $this->autoSize;
  87. }
  88. /**
  89. * Set Auto Size.
  90. *
  91. * @param bool $pValue
  92. *
  93. * @return ColumnDimension
  94. */
  95. public function setAutoSize($pValue)
  96. {
  97. $this->autoSize = $pValue;
  98. return $this;
  99. }
  100. }