SheetView.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. class PHPExcel_Worksheet_SheetView
  8. {
  9. /* Sheet View types */
  10. const SHEETVIEW_NORMAL = 'normal';
  11. const SHEETVIEW_PAGE_LAYOUT = 'pageLayout';
  12. const SHEETVIEW_PAGE_BREAK_PREVIEW = 'pageBreakPreview';
  13. private static $sheetViewTypes = array(
  14. self::SHEETVIEW_NORMAL,
  15. self::SHEETVIEW_PAGE_LAYOUT,
  16. self::SHEETVIEW_PAGE_BREAK_PREVIEW,
  17. );
  18. /**
  19. * ZoomScale
  20. *
  21. * Valid values range from 10 to 400.
  22. *
  23. * @var int
  24. */
  25. private $zoomScale = 100;
  26. /**
  27. * ZoomScaleNormal
  28. *
  29. * Valid values range from 10 to 400.
  30. *
  31. * @var int
  32. */
  33. private $zoomScaleNormal = 100;
  34. /**
  35. * View
  36. *
  37. * Valid values range from 10 to 400.
  38. *
  39. * @var string
  40. */
  41. private $sheetviewType = self::SHEETVIEW_NORMAL;
  42. /**
  43. * Create a new PHPExcel_Worksheet_SheetView
  44. */
  45. public function __construct()
  46. {
  47. }
  48. /**
  49. * Get ZoomScale
  50. *
  51. * @return int
  52. */
  53. public function getZoomScale()
  54. {
  55. return $this->zoomScale;
  56. }
  57. /**
  58. * Set ZoomScale
  59. *
  60. * Valid values range from 10 to 400.
  61. *
  62. * @param int $pValue
  63. * @throws PHPExcel_Exception
  64. * @return PHPExcel_Worksheet_SheetView
  65. */
  66. public function setZoomScale($pValue = 100)
  67. {
  68. // Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface,
  69. // but it is apparently still able to handle any scale >= 1
  70. if (($pValue >= 1) || is_null($pValue)) {
  71. $this->zoomScale = $pValue;
  72. } else {
  73. throw new PHPExcel_Exception("Scale must be greater than or equal to 1.");
  74. }
  75. return $this;
  76. }
  77. /**
  78. * Get ZoomScaleNormal
  79. *
  80. * @return int
  81. */
  82. public function getZoomScaleNormal()
  83. {
  84. return $this->zoomScaleNormal;
  85. }
  86. /**
  87. * Set ZoomScale
  88. *
  89. * Valid values range from 10 to 400.
  90. *
  91. * @param int $pValue
  92. * @throws PHPExcel_Exception
  93. * @return PHPExcel_Worksheet_SheetView
  94. */
  95. public function setZoomScaleNormal($pValue = 100)
  96. {
  97. if (($pValue >= 1) || is_null($pValue)) {
  98. $this->zoomScaleNormal = $pValue;
  99. } else {
  100. throw new PHPExcel_Exception("Scale must be greater than or equal to 1.");
  101. }
  102. return $this;
  103. }
  104. /**
  105. * Get View
  106. *
  107. * @return string
  108. */
  109. public function getView()
  110. {
  111. return $this->sheetviewType;
  112. }
  113. /**
  114. * Set View
  115. *
  116. * Valid values are
  117. * 'normal' self::SHEETVIEW_NORMAL
  118. * 'pageLayout' self::SHEETVIEW_PAGE_LAYOUT
  119. * 'pageBreakPreview' self::SHEETVIEW_PAGE_BREAK_PREVIEW
  120. *
  121. * @param string $pValue
  122. * @throws PHPExcel_Exception
  123. * @return PHPExcel_Worksheet_SheetView
  124. */
  125. public function setView($pValue = null)
  126. {
  127. // MS Excel 2007 allows setting the view to 'normal', 'pageLayout' or 'pageBreakPreview' via the user interface
  128. if ($pValue === null) {
  129. $pValue = self::SHEETVIEW_NORMAL;
  130. }
  131. if (in_array($pValue, self::$sheetViewTypes)) {
  132. $this->sheetviewType = $pValue;
  133. } else {
  134. throw new PHPExcel_Exception("Invalid sheetview layout type.");
  135. }
  136. return $this;
  137. }
  138. /**
  139. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  140. */
  141. public function __clone()
  142. {
  143. $vars = get_object_vars($this);
  144. foreach ($vars as $key => $value) {
  145. if (is_object($value)) {
  146. $this->$key = clone $value;
  147. } else {
  148. $this->$key = $value;
  149. }
  150. }
  151. }
  152. }