Dimension.Class.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: phperstar
  5. * Date: 2020/8/11
  6. * Time: 6:24 PM
  7. */
  8. namespace Util\PHPExcel\Worksheet;
  9. abstract class Dimension
  10. {
  11. /**
  12. * Visible?
  13. *
  14. * @var bool
  15. */
  16. private $visible = true;
  17. /**
  18. * Outline level
  19. *
  20. * @var int
  21. */
  22. private $outlineLevel = 0;
  23. /**
  24. * Collapsed
  25. *
  26. * @var bool
  27. */
  28. private $collapsed = false;
  29. /**
  30. * Index to cellXf. Null value means row has no explicit cellXf format.
  31. *
  32. * @var int|null
  33. */
  34. private $xfIndex;
  35. /**
  36. * Create a new PHPExcel_Worksheet_Dimension
  37. *
  38. * @param int $pIndex Numeric row index
  39. */
  40. public function __construct($initialValue = null)
  41. {
  42. // set dimension as unformatted by default
  43. $this->xfIndex = $initialValue;
  44. }
  45. /**
  46. * Get Visible
  47. *
  48. * @return bool
  49. */
  50. public function getVisible()
  51. {
  52. return $this->visible;
  53. }
  54. /**
  55. * Set Visible
  56. *
  57. * @param bool $pValue
  58. * @return PHPExcel_Worksheet_Dimension
  59. */
  60. public function setVisible($pValue = true)
  61. {
  62. $this->visible = $pValue;
  63. return $this;
  64. }
  65. /**
  66. * Get Outline Level
  67. *
  68. * @return int
  69. */
  70. public function getOutlineLevel()
  71. {
  72. return $this->outlineLevel;
  73. }
  74. /**
  75. * Set Outline Level
  76. *
  77. * Value must be between 0 and 7
  78. *
  79. * @param int $pValue
  80. * @throws PHPExcel_Exception
  81. * @return PHPExcel_Worksheet_Dimension
  82. */
  83. public function setOutlineLevel($pValue)
  84. {
  85. if ($pValue < 0 || $pValue > 7) {
  86. throw new PHPExcel_Exception("Outline level must range between 0 and 7.");
  87. }
  88. $this->outlineLevel = $pValue;
  89. return $this;
  90. }
  91. /**
  92. * Get Collapsed
  93. *
  94. * @return bool
  95. */
  96. public function getCollapsed()
  97. {
  98. return $this->collapsed;
  99. }
  100. /**
  101. * Set Collapsed
  102. *
  103. * @param bool $pValue
  104. * @return PHPExcel_Worksheet_Dimension
  105. */
  106. public function setCollapsed($pValue = true)
  107. {
  108. $this->collapsed = $pValue;
  109. return $this;
  110. }
  111. /**
  112. * Get index to cellXf
  113. *
  114. * @return int
  115. */
  116. public function getXfIndex()
  117. {
  118. return $this->xfIndex;
  119. }
  120. /**
  121. * Set index to cellXf
  122. *
  123. * @param int $pValue
  124. * @return PHPExcel_Worksheet_Dimension
  125. */
  126. public function setXfIndex($pValue = 0)
  127. {
  128. $this->xfIndex = $pValue;
  129. return $this;
  130. }
  131. /**
  132. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  133. */
  134. public function __clone()
  135. {
  136. $vars = get_object_vars($this);
  137. foreach ($vars as $key => $value) {
  138. if (is_object($value)) {
  139. $this->$key = clone $value;
  140. } else {
  141. $this->$key = $value;
  142. }
  143. }
  144. }
  145. }