ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
Worksheet.php
Go to the documentation of this file.
1<?php
37{
38 /* Break types */
39 const BREAK_NONE = 0;
40 const BREAK_ROW = 1;
41 const BREAK_COLUMN = 2;
42
43 /* Sheet state */
44 const SHEETSTATE_VISIBLE = 'visible';
45 const SHEETSTATE_HIDDEN = 'hidden';
46 const SHEETSTATE_VERYHIDDEN = 'veryHidden';
47
53 private static $_invalidCharacters = array('*', ':', '/', '\\', '?', '[', ']');
54
60 private $_parent;
61
67 private $_cellCollection = null;
68
74 private $_rowDimensions = array();
75
81 private $_defaultRowDimension = null;
82
88 private $_columnDimensions = array();
89
96
102 private $_drawingCollection = null;
103
109 private $_chartCollection = array();
110
116 private $_title;
117
124
130 private $_pageSetup;
131
138
145
151 private $_sheetView;
152
159
165 private $_styles = array();
166
173
180
186 private $_breaks = array();
187
193 private $_mergeCells = array();
194
200 private $_protectedCells = array();
201
207 private $_autoFilter = NULL;
208
214 private $_freezePane = '';
215
221 private $_showGridlines = true;
222
228 private $_printGridlines = false;
229
235 private $_showRowColHeaders = true;
236
242 private $_showSummaryBelow = true;
243
249 private $_showSummaryRight = true;
250
256 private $_comments = array();
257
263 private $_activeCell = 'A1';
264
270 private $_selectedCells = 'A1';
271
278
285
291 private $_rightToLeft = false;
292
298 private $_hyperlinkCollection = array();
299
305 private $_dataValidationCollection = array();
306
312 private $_tabColor;
313
319 private $_dirty = true;
320
326 private $_hash = null;
327
333 private $_codeName = null;
334
341 public function __construct(PHPExcel $pParent = null, $pTitle = 'Worksheet')
342 {
343 // Set parent and title
344 $this->_parent = $pParent;
345 $this->setTitle($pTitle, FALSE);
346 // setTitle can change $pTitle
347 $this->setCodeName($this->getTitle());
349
350 $this->_cellCollection = PHPExcel_CachedObjectStorageFactory::getInstance($this);
351
352 // Set page setup
353 $this->_pageSetup = new PHPExcel_Worksheet_PageSetup();
354
355 // Set page margins
356 $this->_pageMargins = new PHPExcel_Worksheet_PageMargins();
357
358 // Set page header/footer
359 $this->_headerFooter = new PHPExcel_Worksheet_HeaderFooter();
360
361 // Set sheet view
362 $this->_sheetView = new PHPExcel_Worksheet_SheetView();
363
364 // Drawing collection
365 $this->_drawingCollection = new ArrayObject();
366
367 // Chart collection
368 $this->_chartCollection = new ArrayObject();
369
370 // Protection
371 $this->_protection = new PHPExcel_Worksheet_Protection();
372
373 // Default row dimension
374 $this->_defaultRowDimension = new PHPExcel_Worksheet_RowDimension(NULL);
375
376 // Default column dimension
377 $this->_defaultColumnDimension = new PHPExcel_Worksheet_ColumnDimension(NULL);
378
379 $this->_autoFilter = new PHPExcel_Worksheet_AutoFilter(NULL, $this);
380 }
381
382
388 public function disconnectCells() {
389 if ( $this->_cellCollection !== NULL){
390 $this->_cellCollection->unsetWorksheetCells();
391 $this->_cellCollection = NULL;
392 }
393 // detach ourself from the workbook, so that it can then delete this worksheet successfully
394 $this->_parent = null;
395 }
396
401 function __destruct() {
403 ->clearCalculationCacheForWorksheet($this->_title);
404
405 $this->disconnectCells();
406 }
407
413 public function getCellCacheController() {
415 } // function getCellCacheController()
416
417
423 public static function getInvalidCharacters()
424 {
426 }
427
435 private static function _checkSheetCodeName($pValue)
436 {
437 $CharCount = PHPExcel_Shared_String::CountCharacters($pValue);
438 if ($CharCount == 0) {
439 throw new PHPExcel_Exception('Sheet code name cannot be empty.');
440 }
441 // Some of the printable ASCII characters are invalid: * : / \ ? [ ] and first and last characters cannot be a "'"
442 if ((str_replace(self::$_invalidCharacters, '', $pValue) !== $pValue) ||
443 (PHPExcel_Shared_String::Substring($pValue,-1,1)=='\'') ||
444 (PHPExcel_Shared_String::Substring($pValue,0,1)=='\'')) {
445 throw new PHPExcel_Exception('Invalid character found in sheet code name');
446 }
447
448 // Maximum 31 characters allowed for sheet title
449 if ($CharCount > 31) {
450 throw new PHPExcel_Exception('Maximum 31 characters allowed in sheet code name.');
451 }
452
453 return $pValue;
454 }
455
463 private static function _checkSheetTitle($pValue)
464 {
465 // Some of the printable ASCII characters are invalid: * : / \ ? [ ]
466 if (str_replace(self::$_invalidCharacters, '', $pValue) !== $pValue) {
467 throw new PHPExcel_Exception('Invalid character found in sheet title');
468 }
469
470 // Maximum 31 characters allowed for sheet title
471 if (PHPExcel_Shared_String::CountCharacters($pValue) > 31) {
472 throw new PHPExcel_Exception('Maximum 31 characters allowed in sheet title.');
473 }
474
475 return $pValue;
476 }
477
484 public function getCellCollection($pSorted = true)
485 {
486 if ($pSorted) {
487 // Re-order cell collection
488 return $this->sortCellCollection();
489 }
490 if ($this->_cellCollection !== NULL) {
491 return $this->_cellCollection->getCellList();
492 }
493 return array();
494 }
495
501 public function sortCellCollection()
502 {
503 if ($this->_cellCollection !== NULL) {
504 return $this->_cellCollection->getSortedCellList();
505 }
506 return array();
507 }
508
514 public function getRowDimensions()
515 {
517 }
518
524 public function getDefaultRowDimension()
525 {
527 }
528
534 public function getColumnDimensions()
535 {
537 }
538
545 {
547 }
548
554 public function getDrawingCollection()
555 {
557 }
558
564 public function getChartCollection()
565 {
567 }
568
576 public function addChart(PHPExcel_Chart $pChart = null, $iChartIndex = null)
577 {
578 $pChart->setWorksheet($this);
579 if (is_null($iChartIndex)) {
580 $this->_chartCollection[] = $pChart;
581 } else {
582 // Insert the chart at the requested index
583 array_splice($this->_chartCollection, $iChartIndex, 0, array($pChart));
584 }
585
586 return $pChart;
587 }
588
594 public function getChartCount()
595 {
596 return count($this->_chartCollection);
597 }
598
606 public function getChartByIndex($index = null)
607 {
608 $chartCount = count($this->_chartCollection);
609 if ($chartCount == 0) {
610 return false;
611 }
612 if (is_null($index)) {
613 $index = --$chartCount;
614 }
615 if (!isset($this->_chartCollection[$index])) {
616 return false;
617 }
618
619 return $this->_chartCollection[$index];
620 }
621
628 public function getChartNames()
629 {
630 $chartNames = array();
631 foreach($this->_chartCollection as $chart) {
632 $chartNames[] = $chart->getName();
633 }
634 return $chartNames;
635 }
636
644 public function getChartByName($chartName = '')
645 {
646 $chartCount = count($this->_chartCollection);
647 if ($chartCount == 0) {
648 return false;
649 }
650 foreach($this->_chartCollection as $index => $chart) {
651 if ($chart->getName() == $chartName) {
652 return $this->_chartCollection[$index];
653 }
654 }
655 return false;
656 }
657
663 public function refreshColumnDimensions()
664 {
665 $currentColumnDimensions = $this->getColumnDimensions();
666 $newColumnDimensions = array();
667
668 foreach ($currentColumnDimensions as $objColumnDimension) {
669 $newColumnDimensions[$objColumnDimension->getColumnIndex()] = $objColumnDimension;
670 }
671
672 $this->_columnDimensions = $newColumnDimensions;
673
674 return $this;
675 }
676
682 public function refreshRowDimensions()
683 {
684 $currentRowDimensions = $this->getRowDimensions();
685 $newRowDimensions = array();
686
687 foreach ($currentRowDimensions as $objRowDimension) {
688 $newRowDimensions[$objRowDimension->getRowIndex()] = $objRowDimension;
689 }
690
691 $this->_rowDimensions = $newRowDimensions;
692
693 return $this;
694 }
695
702 {
703 // Return
704 return 'A1' . ':' . $this->getHighestColumn() . $this->getHighestRow();
705 }
706
713 {
714 // Return
715 return 'A1' . ':' . $this->getHighestDataColumn() . $this->getHighestDataRow();
716 }
717
724 public function calculateColumnWidths($calculateMergeCells = false)
725 {
726 // initialize $autoSizes array
727 $autoSizes = array();
728 foreach ($this->getColumnDimensions() as $colDimension) {
729 if ($colDimension->getAutoSize()) {
730 $autoSizes[$colDimension->getColumnIndex()] = -1;
731 }
732 }
733
734 // There is only something to do if there are some auto-size columns
735 if (!empty($autoSizes)) {
736
737 // build list of cells references that participate in a merge
738 $isMergeCell = array();
739 foreach ($this->getMergeCells() as $cells) {
740 foreach (PHPExcel_Cell::extractAllCellReferencesInRange($cells) as $cellReference) {
741 $isMergeCell[$cellReference] = true;
742 }
743 }
744
745 // loop through all cells in the worksheet
746 foreach ($this->getCellCollection(false) as $cellID) {
747 $cell = $this->getCell($cellID);
748 if (isset($autoSizes[$this->_cellCollection->getCurrentColumn()])) {
749 // Determine width if cell does not participate in a merge
750 if (!isset($isMergeCell[$this->_cellCollection->getCurrentAddress()])) {
751 // Calculated value
752 // To formatted string
754 $cell->getCalculatedValue(),
755 $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode()
756 );
757
758 $autoSizes[$this->_cellCollection->getCurrentColumn()] = max(
759 (float) $autoSizes[$this->_cellCollection->getCurrentColumn()],
761 $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont(),
762 $cellValue,
763 $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getAlignment()->getTextRotation(),
764 $this->getDefaultStyle()->getFont()
765 )
766 );
767 }
768 }
769 }
770
771 // adjust column widths
772 foreach ($autoSizes as $columnIndex => $width) {
773 if ($width == -1) $width = $this->getDefaultColumnDimension()->getWidth();
774 $this->getColumnDimension($columnIndex)->setWidth($width);
775 }
776 }
777
778 return $this;
779 }
780
786 public function getParent() {
787 return $this->_parent;
788 }
789
796 public function rebindParent(PHPExcel $parent) {
797 if ($this->_parent !== null) {
798 $namedRanges = $this->_parent->getNamedRanges();
799 foreach ($namedRanges as $namedRange) {
800 $parent->addNamedRange($namedRange);
801 }
802
803 $this->_parent->removeSheetByIndex(
804 $this->_parent->getIndex($this)
805 );
806 }
807 $this->_parent = $parent;
808
809 return $this;
810 }
811
817 public function getTitle()
818 {
819 return $this->_title;
820 }
821
833 public function setTitle($pValue = 'Worksheet', $updateFormulaCellReferences = true)
834 {
835 // Is this a 'rename' or not?
836 if ($this->getTitle() == $pValue) {
837 return $this;
838 }
839
840 // Syntax check
841 self::_checkSheetTitle($pValue);
842
843 // Old title
844 $oldTitle = $this->getTitle();
845
846 if ($this->_parent) {
847 // Is there already such sheet name?
848 if ($this->_parent->sheetNameExists($pValue)) {
849 // Use name, but append with lowest possible integer
850
851 if (PHPExcel_Shared_String::CountCharacters($pValue) > 29) {
852 $pValue = PHPExcel_Shared_String::Substring($pValue,0,29);
853 }
854 $i = 1;
855 while ($this->_parent->sheetNameExists($pValue . ' ' . $i)) {
856 ++$i;
857 if ($i == 10) {
858 if (PHPExcel_Shared_String::CountCharacters($pValue) > 28) {
859 $pValue = PHPExcel_Shared_String::Substring($pValue,0,28);
860 }
861 } elseif ($i == 100) {
862 if (PHPExcel_Shared_String::CountCharacters($pValue) > 27) {
863 $pValue = PHPExcel_Shared_String::Substring($pValue,0,27);
864 }
865 }
866 }
867
868 $altTitle = $pValue . ' ' . $i;
869 return $this->setTitle($altTitle,$updateFormulaCellReferences);
870 }
871 }
872
873 // Set title
874 $this->_title = $pValue;
875 $this->_dirty = true;
876
877 if ($this->_parent) {
878 // New title
879 $newTitle = $this->getTitle();
881 ->renameCalculationCacheForWorksheet($oldTitle, $newTitle);
882 if ($updateFormulaCellReferences)
883 PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->_parent, $oldTitle, $newTitle);
884 }
885
886 return $this;
887 }
888
894 public function getSheetState() {
895 return $this->_sheetState;
896 }
897
905 $this->_sheetState = $value;
906 return $this;
907 }
908
914 public function getPageSetup()
915 {
916 return $this->_pageSetup;
917 }
918
926 {
927 $this->_pageSetup = $pValue;
928 return $this;
929 }
930
936 public function getPageMargins()
937 {
938 return $this->_pageMargins;
939 }
940
948 {
949 $this->_pageMargins = $pValue;
950 return $this;
951 }
952
958 public function getHeaderFooter()
959 {
961 }
962
970 {
971 $this->_headerFooter = $pValue;
972 return $this;
973 }
974
980 public function getSheetView()
981 {
982 return $this->_sheetView;
983 }
984
992 {
993 $this->_sheetView = $pValue;
994 return $this;
995 }
996
1002 public function getProtection()
1003 {
1004 return $this->_protection;
1005 }
1006
1014 {
1015 $this->_protection = $pValue;
1016 $this->_dirty = true;
1017
1018 return $this;
1019 }
1020
1028 public function getHighestColumn($row = null)
1029 {
1030 if ($row == null) {
1032 }
1033 return $this->getHighestDataColumn($row);
1034 }
1035
1043 public function getHighestDataColumn($row = null)
1044 {
1045 return $this->_cellCollection->getHighestColumn($row);
1046 }
1047
1055 public function getHighestRow($column = null)
1056 {
1057 if ($column == null) {
1059 }
1060 return $this->getHighestDataRow($column);
1061 }
1062
1070 public function getHighestDataRow($column = null)
1071 {
1072 return $this->_cellCollection->getHighestRow($column);
1073 }
1074
1080 public function getHighestRowAndColumn()
1081 {
1082 return $this->_cellCollection->getHighestRowAndColumn();
1083 }
1084
1093 public function setCellValue($pCoordinate = 'A1', $pValue = null, $returnCell = false)
1094 {
1095 $cell = $this->getCell(strtoupper($pCoordinate))->setValue($pValue);
1096 return ($returnCell) ? $cell : $this;
1097 }
1098
1108 public function setCellValueByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $returnCell = false)
1109 {
1110 $cell = $this->getCellByColumnAndRow($pColumn, $pRow)->setValue($pValue);
1111 return ($returnCell) ? $cell : $this;
1112 }
1113
1123 public function setCellValueExplicit($pCoordinate = 'A1', $pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING, $returnCell = false)
1124 {
1125 // Set value
1126 $cell = $this->getCell(strtoupper($pCoordinate))->setValueExplicit($pValue, $pDataType);
1127 return ($returnCell) ? $cell : $this;
1128 }
1129
1140 public function setCellValueExplicitByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING, $returnCell = false)
1141 {
1142 $cell = $this->getCellByColumnAndRow($pColumn, $pRow)->setValueExplicit($pValue, $pDataType);
1143 return ($returnCell) ? $cell : $this;
1144 }
1145
1153 public function getCell($pCoordinate = 'A1')
1154 {
1155 $pCoordinate = strtoupper($pCoordinate);
1156 // Check cell collection
1157 if ($this->_cellCollection->isDataSet($pCoordinate)) {
1158 return $this->_cellCollection->getCacheData($pCoordinate);
1159 }
1160
1161 // Worksheet reference?
1162 if (strpos($pCoordinate, '!') !== false) {
1163 $worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true);
1164 return $this->_parent->getSheetByName($worksheetReference[0])->getCell($worksheetReference[1]);
1165 }
1166
1167 // Named range?
1168 if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) &&
1169 (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) {
1170 $namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this);
1171 if ($namedRange !== NULL) {
1172 $pCoordinate = $namedRange->getRange();
1173 return $namedRange->getWorksheet()->getCell($pCoordinate);
1174 }
1175 }
1176
1177 // Uppercase coordinate
1178 $pCoordinate = strtoupper($pCoordinate);
1179
1180 if (strpos($pCoordinate, ':') !== false || strpos($pCoordinate, ',') !== false) {
1181 throw new PHPExcel_Exception('Cell coordinate can not be a range of cells.');
1182 } elseif (strpos($pCoordinate, '$') !== false) {
1183 throw new PHPExcel_Exception('Cell coordinate must not be absolute.');
1184 }
1185
1186 // Create new cell object
1187 return $this->_createNewCell($pCoordinate);
1188 }
1189
1197 public function getCellByColumnAndRow($pColumn = 0, $pRow = 1)
1198 {
1199 $columnLetter = PHPExcel_Cell::stringFromColumnIndex($pColumn);
1200 $coordinate = $columnLetter . $pRow;
1201
1202 if ($this->_cellCollection->isDataSet($coordinate)) {
1203 return $this->_cellCollection->getCacheData($coordinate);
1204 }
1205
1206 return $this->_createNewCell($coordinate);
1207 }
1208
1215 private function _createNewCell($pCoordinate)
1216 {
1217 $cell = $this->_cellCollection->addCacheData(
1218 $pCoordinate,
1219 new PHPExcel_Cell(
1220 NULL,
1222 $this
1223 )
1224 );
1225 $this->_cellCollectionIsSorted = false;
1226
1227 // Coordinates
1228 $aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate);
1229 if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0]))
1230 $this->_cachedHighestColumn = $aCoordinates[0];
1231 $this->_cachedHighestRow = max($this->_cachedHighestRow, $aCoordinates[1]);
1232
1233 // Cell needs appropriate xfIndex from dimensions records
1234 // but don't create dimension records if they don't already exist
1235 $rowDimension = $this->getRowDimension($aCoordinates[1], FALSE);
1236 $columnDimension = $this->getColumnDimension($aCoordinates[0], FALSE);
1237
1238 if ($rowDimension !== NULL && $rowDimension->getXfIndex() > 0) {
1239 // then there is a row dimension with explicit style, assign it to the cell
1240 $cell->setXfIndex($rowDimension->getXfIndex());
1241 } elseif ($columnDimension !== NULL && $columnDimension->getXfIndex() > 0) {
1242 // then there is a column dimension, assign it to the cell
1243 $cell->setXfIndex($columnDimension->getXfIndex());
1244 }
1245
1246 return $cell;
1247 }
1248
1256 public function cellExists($pCoordinate = 'A1')
1257 {
1258 // Worksheet reference?
1259 if (strpos($pCoordinate, '!') !== false) {
1260 $worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true);
1261 return $this->_parent->getSheetByName($worksheetReference[0])->cellExists(strtoupper($worksheetReference[1]));
1262 }
1263
1264 // Named range?
1265 if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) &&
1266 (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) {
1267 $namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this);
1268 if ($namedRange !== NULL) {
1269 $pCoordinate = $namedRange->getRange();
1270 if ($this->getHashCode() != $namedRange->getWorksheet()->getHashCode()) {
1271 if (!$namedRange->getLocalOnly()) {
1272 return $namedRange->getWorksheet()->cellExists($pCoordinate);
1273 } else {
1274 throw new PHPExcel_Exception('Named range ' . $namedRange->getName() . ' is not accessible from within sheet ' . $this->getTitle());
1275 }
1276 }
1277 }
1278 else { return false; }
1279 }
1280
1281 // Uppercase coordinate
1282 $pCoordinate = strtoupper($pCoordinate);
1283
1284 if (strpos($pCoordinate,':') !== false || strpos($pCoordinate,',') !== false) {
1285 throw new PHPExcel_Exception('Cell coordinate can not be a range of cells.');
1286 } elseif (strpos($pCoordinate,'$') !== false) {
1287 throw new PHPExcel_Exception('Cell coordinate must not be absolute.');
1288 } else {
1289 // Coordinates
1290 $aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate);
1291
1292 // Cell exists?
1293 return $this->_cellCollection->isDataSet($pCoordinate);
1294 }
1295 }
1296
1304 public function cellExistsByColumnAndRow($pColumn = 0, $pRow = 1)
1305 {
1306 return $this->cellExists(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow);
1307 }
1308
1315 public function getRowDimension($pRow = 1, $create = TRUE)
1316 {
1317 // Found
1318 $found = null;
1319
1320 // Get row dimension
1321 if (!isset($this->_rowDimensions[$pRow])) {
1322 if (!$create)
1323 return NULL;
1324 $this->_rowDimensions[$pRow] = new PHPExcel_Worksheet_RowDimension($pRow);
1325
1326 $this->_cachedHighestRow = max($this->_cachedHighestRow,$pRow);
1327 }
1328 return $this->_rowDimensions[$pRow];
1329 }
1330
1337 public function getColumnDimension($pColumn = 'A', $create = TRUE)
1338 {
1339 // Uppercase coordinate
1340 $pColumn = strtoupper($pColumn);
1341
1342 // Fetch dimensions
1343 if (!isset($this->_columnDimensions[$pColumn])) {
1344 if (!$create)
1345 return NULL;
1346 $this->_columnDimensions[$pColumn] = new PHPExcel_Worksheet_ColumnDimension($pColumn);
1347
1348 if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($pColumn))
1349 $this->_cachedHighestColumn = $pColumn;
1350 }
1351 return $this->_columnDimensions[$pColumn];
1352 }
1353
1360 public function getColumnDimensionByColumn($pColumn = 0)
1361 {
1363 }
1364
1370 public function getStyles()
1371 {
1372 return $this->_styles;
1373 }
1374
1382 public function getDefaultStyle()
1383 {
1384 return $this->_parent->getDefaultStyle();
1385 }
1386
1395 public function setDefaultStyle(PHPExcel_Style $pValue)
1396 {
1397 $this->_parent->getDefaultStyle()->applyFromArray(array(
1398 'font' => array(
1399 'name' => $pValue->getFont()->getName(),
1400 'size' => $pValue->getFont()->getSize(),
1401 ),
1402 ));
1403 return $this;
1404 }
1405
1413 public function getStyle($pCellCoordinate = 'A1')
1414 {
1415 // set this sheet as active
1416 $this->_parent->setActiveSheetIndex($this->_parent->getIndex($this));
1417
1418 // set cell coordinate as active
1419 $this->setSelectedCells(strtoupper($pCellCoordinate));
1420
1421 return $this->_parent->getCellXfSupervisor();
1422 }
1423
1430 public function getConditionalStyles($pCoordinate = 'A1')
1431 {
1432 $pCoordinate = strtoupper($pCoordinate);
1433 if (!isset($this->_conditionalStylesCollection[$pCoordinate])) {
1434 $this->_conditionalStylesCollection[$pCoordinate] = array();
1435 }
1436 return $this->_conditionalStylesCollection[$pCoordinate];
1437 }
1438
1445 public function conditionalStylesExists($pCoordinate = 'A1')
1446 {
1447 if (isset($this->_conditionalStylesCollection[strtoupper($pCoordinate)])) {
1448 return true;
1449 }
1450 return false;
1451 }
1452
1459 public function removeConditionalStyles($pCoordinate = 'A1')
1460 {
1461 unset($this->_conditionalStylesCollection[strtoupper($pCoordinate)]);
1462 return $this;
1463 }
1464
1471 {
1473 }
1474
1482 public function setConditionalStyles($pCoordinate = 'A1', $pValue)
1483 {
1484 $this->_conditionalStylesCollection[strtoupper($pCoordinate)] = $pValue;
1485 return $this;
1486 }
1487
1497 public function getStyleByColumnAndRow($pColumn = 0, $pRow = 1, $pColumn2 = null, $pRow2 = null)
1498 {
1499 if (!is_null($pColumn2) && !is_null($pRow2)) {
1500 $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow . ':' .
1501 PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2;
1502 return $this->getStyle($cellRange);
1503 }
1504
1505 return $this->getStyle(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow);
1506 }
1507
1519 public function setSharedStyle(PHPExcel_Style $pSharedCellStyle = null, $pRange = '')
1520 {
1521 $this->duplicateStyle($pSharedCellStyle, $pRange);
1522 return $this;
1523 }
1524
1535 public function duplicateStyle(PHPExcel_Style $pCellStyle = null, $pRange = '')
1536 {
1537 // make sure we have a real style and not supervisor
1538 $style = $pCellStyle->getIsSupervisor() ? $pCellStyle->getSharedComponent() : $pCellStyle;
1539
1540 // Add the style to the workbook if necessary
1541 $workbook = $this->_parent;
1542 if ($existingStyle = $this->_parent->getCellXfByHashCode($pCellStyle->getHashCode())) {
1543 // there is already such cell Xf in our collection
1544 $xfIndex = $existingStyle->getIndex();
1545 } else {
1546 // we don't have such a cell Xf, need to add
1547 $workbook->addCellXf($pCellStyle);
1548 $xfIndex = $pCellStyle->getIndex();
1549 }
1550
1551 // Calculate range outer borders
1552 list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($pRange . ':' . $pRange);
1553
1554 // Make sure we can loop upwards on rows and columns
1555 if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) {
1556 $tmp = $rangeStart;
1557 $rangeStart = $rangeEnd;
1558 $rangeEnd = $tmp;
1559 }
1560
1561 // Loop through cells and apply styles
1562 for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
1563 for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) {
1564 $this->getCell(PHPExcel_Cell::stringFromColumnIndex($col - 1) . $row)->setXfIndex($xfIndex);
1565 }
1566 }
1567
1568 return $this;
1569 }
1570
1581 public function duplicateConditionalStyle(array $pCellStyle = null, $pRange = '')
1582 {
1583 foreach($pCellStyle as $cellStyle) {
1584 if (!($cellStyle instanceof PHPExcel_Style_Conditional)) {
1585 throw new PHPExcel_Exception('Style is not a conditional style');
1586 }
1587 }
1588
1589 // Calculate range outer borders
1590 list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($pRange . ':' . $pRange);
1591
1592 // Make sure we can loop upwards on rows and columns
1593 if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) {
1594 $tmp = $rangeStart;
1595 $rangeStart = $rangeEnd;
1596 $rangeEnd = $tmp;
1597 }
1598
1599 // Loop through cells and apply styles
1600 for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
1601 for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) {
1602 $this->setConditionalStyles(PHPExcel_Cell::stringFromColumnIndex($col - 1) . $row, $pCellStyle);
1603 }
1604 }
1605
1606 return $this;
1607 }
1608
1623 public function duplicateStyleArray($pStyles = null, $pRange = '', $pAdvanced = true)
1624 {
1625 $this->getStyle($pRange)->applyFromArray($pStyles, $pAdvanced);
1626 return $this;
1627 }
1628
1637 public function setBreak($pCell = 'A1', $pBreak = PHPExcel_Worksheet::BREAK_NONE)
1638 {
1639 // Uppercase coordinate
1640 $pCell = strtoupper($pCell);
1641
1642 if ($pCell != '') {
1643 if ($pBreak == PHPExcel_Worksheet::BREAK_NONE) {
1644 if (isset($this->_breaks[$pCell])) {
1645 unset($this->_breaks[$pCell]);
1646 }
1647 } else {
1648 $this->_breaks[$pCell] = $pBreak;
1649 }
1650 } else {
1651 throw new PHPExcel_Exception('No cell coordinate specified.');
1652 }
1653
1654 return $this;
1655 }
1656
1665 public function setBreakByColumnAndRow($pColumn = 0, $pRow = 1, $pBreak = PHPExcel_Worksheet::BREAK_NONE)
1666 {
1667 return $this->setBreak(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow, $pBreak);
1668 }
1669
1675 public function getBreaks()
1676 {
1677 return $this->_breaks;
1678 }
1679
1687 public function mergeCells($pRange = 'A1:A1')
1688 {
1689 // Uppercase coordinate
1690 $pRange = strtoupper($pRange);
1691
1692 if (strpos($pRange,':') !== false) {
1693 $this->_mergeCells[$pRange] = $pRange;
1694
1695 // make sure cells are created
1696
1697 // get the cells in the range
1698 $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($pRange);
1699
1700 // create upper left cell if it does not already exist
1701 $upperLeft = $aReferences[0];
1702 if (!$this->cellExists($upperLeft)) {
1703 $this->getCell($upperLeft)->setValueExplicit(null, PHPExcel_Cell_DataType::TYPE_NULL);
1704 }
1705
1706 // create or blank out the rest of the cells in the range
1707 $count = count($aReferences);
1708 for ($i = 1; $i < $count; $i++) {
1709 $this->getCell($aReferences[$i])->setValueExplicit(null, PHPExcel_Cell_DataType::TYPE_NULL);
1710 }
1711
1712 } else {
1713 throw new PHPExcel_Exception('Merge must be set on a range of cells.');
1714 }
1715
1716 return $this;
1717 }
1718
1729 public function mergeCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1)
1730 {
1731 $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2;
1732 return $this->mergeCells($cellRange);
1733 }
1734
1742 public function unmergeCells($pRange = 'A1:A1')
1743 {
1744 // Uppercase coordinate
1745 $pRange = strtoupper($pRange);
1746
1747 if (strpos($pRange,':') !== false) {
1748 if (isset($this->_mergeCells[$pRange])) {
1749 unset($this->_mergeCells[$pRange]);
1750 } else {
1751 throw new PHPExcel_Exception('Cell range ' . $pRange . ' not known as merged.');
1752 }
1753 } else {
1754 throw new PHPExcel_Exception('Merge can only be removed from a range of cells.');
1755 }
1756
1757 return $this;
1758 }
1759
1770 public function unmergeCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1)
1771 {
1772 $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2;
1773 return $this->unmergeCells($cellRange);
1774 }
1775
1781 public function getMergeCells()
1782 {
1783 return $this->_mergeCells;
1784 }
1785
1792 public function setMergeCells($pValue = array())
1793 {
1794 $this->_mergeCells = $pValue;
1795
1796 return $this;
1797 }
1798
1808 public function protectCells($pRange = 'A1', $pPassword = '', $pAlreadyHashed = false)
1809 {
1810 // Uppercase coordinate
1811 $pRange = strtoupper($pRange);
1812
1813 if (!$pAlreadyHashed) {
1814 $pPassword = PHPExcel_Shared_PasswordHasher::hashPassword($pPassword);
1815 }
1816 $this->_protectedCells[$pRange] = $pPassword;
1817
1818 return $this;
1819 }
1820
1833 public function protectCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1, $pPassword = '', $pAlreadyHashed = false)
1834 {
1835 $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2;
1836 return $this->protectCells($cellRange, $pPassword, $pAlreadyHashed);
1837 }
1838
1846 public function unprotectCells($pRange = 'A1')
1847 {
1848 // Uppercase coordinate
1849 $pRange = strtoupper($pRange);
1850
1851 if (isset($this->_protectedCells[$pRange])) {
1852 unset($this->_protectedCells[$pRange]);
1853 } else {
1854 throw new PHPExcel_Exception('Cell range ' . $pRange . ' not known as protected.');
1855 }
1856 return $this;
1857 }
1858
1871 public function unprotectCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1, $pPassword = '', $pAlreadyHashed = false)
1872 {
1873 $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2;
1874 return $this->unprotectCells($cellRange, $pPassword, $pAlreadyHashed);
1875 }
1876
1882 public function getProtectedCells()
1883 {
1885 }
1886
1892 public function getAutoFilter()
1893 {
1894 return $this->_autoFilter;
1895 }
1896
1905 public function setAutoFilter($pValue)
1906 {
1907 $pRange = strtoupper($pValue);
1908
1909 if (is_string($pValue)) {
1910 $this->_autoFilter->setRange($pValue);
1911 } elseif(is_object($pValue) && ($pValue instanceof PHPExcel_Worksheet_AutoFilter)) {
1912 $this->_autoFilter = $pValue;
1913 }
1914 return $this;
1915 }
1916
1927 public function setAutoFilterByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1)
1928 {
1929 return $this->setAutoFilter(
1930 PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1
1931 . ':' .
1932 PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2
1933 );
1934 }
1935
1941 public function removeAutoFilter()
1942 {
1943 $this->_autoFilter->setRange(NULL);
1944 return $this;
1945 }
1946
1952 public function getFreezePane()
1953 {
1954 return $this->_freezePane;
1955 }
1956
1969 public function freezePane($pCell = '')
1970 {
1971 // Uppercase coordinate
1972 $pCell = strtoupper($pCell);
1973
1974 if (strpos($pCell,':') === false && strpos($pCell,',') === false) {
1975 $this->_freezePane = $pCell;
1976 } else {
1977 throw new PHPExcel_Exception('Freeze pane can not be set on a range of cells.');
1978 }
1979 return $this;
1980 }
1981
1990 public function freezePaneByColumnAndRow($pColumn = 0, $pRow = 1)
1991 {
1992 return $this->freezePane(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow);
1993 }
1994
2000 public function unfreezePane()
2001 {
2002 return $this->freezePane('');
2003 }
2004
2013 public function insertNewRowBefore($pBefore = 1, $pNumRows = 1) {
2014 if ($pBefore >= 1) {
2015 $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
2016 $objReferenceHelper->insertNewBefore('A' . $pBefore, 0, $pNumRows, $this);
2017 } else {
2018 throw new PHPExcel_Exception("Rows can only be inserted before at least row 1.");
2019 }
2020 return $this;
2021 }
2022
2031 public function insertNewColumnBefore($pBefore = 'A', $pNumCols = 1) {
2032 if (!is_numeric($pBefore)) {
2033 $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
2034 $objReferenceHelper->insertNewBefore($pBefore . '1', $pNumCols, 0, $this);
2035 } else {
2036 throw new PHPExcel_Exception("Column references should not be numeric.");
2037 }
2038 return $this;
2039 }
2040
2049 public function insertNewColumnBeforeByIndex($pBefore = 0, $pNumCols = 1) {
2050 if ($pBefore >= 0) {
2051 return $this->insertNewColumnBefore(PHPExcel_Cell::stringFromColumnIndex($pBefore), $pNumCols);
2052 } else {
2053 throw new PHPExcel_Exception("Columns can only be inserted before at least column A (0).");
2054 }
2055 }
2056
2065 public function removeRow($pRow = 1, $pNumRows = 1) {
2066 if ($pRow >= 1) {
2067 $highestRow = $this->getHighestDataRow();
2068 $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
2069 $objReferenceHelper->insertNewBefore('A' . ($pRow + $pNumRows), 0, -$pNumRows, $this);
2070 for($r = 0; $r < $pNumRows; ++$r) {
2071 $this->getCellCacheController()->removeRow($highestRow);
2072 --$highestRow;
2073 }
2074 } else {
2075 throw new PHPExcel_Exception("Rows to be deleted should at least start from row 1.");
2076 }
2077 return $this;
2078 }
2079
2088 public function removeColumn($pColumn = 'A', $pNumCols = 1) {
2089 if (!is_numeric($pColumn)) {
2090 $highestColumn = $this->getHighestDataColumn();
2092 $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
2093 $objReferenceHelper->insertNewBefore($pColumn . '1', -$pNumCols, 0, $this);
2094 for($c = 0; $c < $pNumCols; ++$c) {
2095 $this->getCellCacheController()->removeColumn($highestColumn);
2097 }
2098 } else {
2099 throw new PHPExcel_Exception("Column references should not be numeric.");
2100 }
2101 return $this;
2102 }
2103
2112 public function removeColumnByIndex($pColumn = 0, $pNumCols = 1) {
2113 if ($pColumn >= 0) {
2114 return $this->removeColumn(PHPExcel_Cell::stringFromColumnIndex($pColumn), $pNumCols);
2115 } else {
2116 throw new PHPExcel_Exception("Columns to be deleted should at least start from column 0");
2117 }
2118 }
2119
2125 public function getShowGridlines() {
2126 return $this->_showGridlines;
2127 }
2128
2135 public function setShowGridlines($pValue = false) {
2136 $this->_showGridlines = $pValue;
2137 return $this;
2138 }
2139
2145 public function getPrintGridlines() {
2147 }
2148
2155 public function setPrintGridlines($pValue = false) {
2156 $this->_printGridlines = $pValue;
2157 return $this;
2158 }
2159
2165 public function getShowRowColHeaders() {
2167 }
2168
2175 public function setShowRowColHeaders($pValue = false) {
2176 $this->_showRowColHeaders = $pValue;
2177 return $this;
2178 }
2179
2185 public function getShowSummaryBelow() {
2187 }
2188
2195 public function setShowSummaryBelow($pValue = true) {
2196 $this->_showSummaryBelow = $pValue;
2197 return $this;
2198 }
2199
2205 public function getShowSummaryRight() {
2207 }
2208
2215 public function setShowSummaryRight($pValue = true) {
2216 $this->_showSummaryRight = $pValue;
2217 return $this;
2218 }
2219
2225 public function getComments()
2226 {
2227 return $this->_comments;
2228 }
2229
2236 public function setComments($pValue = array())
2237 {
2238 $this->_comments = $pValue;
2239
2240 return $this;
2241 }
2242
2250 public function getComment($pCellCoordinate = 'A1')
2251 {
2252 // Uppercase coordinate
2253 $pCellCoordinate = strtoupper($pCellCoordinate);
2254
2255 if (strpos($pCellCoordinate,':') !== false || strpos($pCellCoordinate,',') !== false) {
2256 throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells.');
2257 } else if (strpos($pCellCoordinate,'$') !== false) {
2258 throw new PHPExcel_Exception('Cell coordinate string must not be absolute.');
2259 } else if ($pCellCoordinate == '') {
2260 throw new PHPExcel_Exception('Cell coordinate can not be zero-length string.');
2261 } else {
2262 // Check if we already have a comment for this cell.
2263 // If not, create a new comment.
2264 if (isset($this->_comments[$pCellCoordinate])) {
2265 return $this->_comments[$pCellCoordinate];
2266 } else {
2267 $newComment = new PHPExcel_Comment();
2268 $this->_comments[$pCellCoordinate] = $newComment;
2269 return $newComment;
2270 }
2271 }
2272 }
2273
2281 public function getCommentByColumnAndRow($pColumn = 0, $pRow = 1)
2282 {
2283 return $this->getComment(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow);
2284 }
2285
2292 public function getSelectedCell()
2293 {
2294 return $this->getSelectedCells();
2295 }
2296
2302 public function getActiveCell()
2303 {
2304 return $this->_activeCell;
2305 }
2306
2312 public function getSelectedCells()
2313 {
2314 return $this->_selectedCells;
2315 }
2316
2323 public function setSelectedCell($pCoordinate = 'A1')
2324 {
2325 return $this->setSelectedCells($pCoordinate);
2326 }
2327
2335 public function setSelectedCells($pCoordinate = 'A1')
2336 {
2337 // Uppercase coordinate
2338 $pCoordinate = strtoupper($pCoordinate);
2339
2340 // Convert 'A' to 'A:A'
2341 $pCoordinate = preg_replace('/^([A-Z]+)$/', '${1}:${1}', $pCoordinate);
2342
2343 // Convert '1' to '1:1'
2344 $pCoordinate = preg_replace('/^([0-9]+)$/', '${1}:${1}', $pCoordinate);
2345
2346 // Convert 'A:C' to 'A1:C1048576'
2347 $pCoordinate = preg_replace('/^([A-Z]+):([A-Z]+)$/', '${1}1:${2}1048576', $pCoordinate);
2348
2349 // Convert '1:3' to 'A1:XFD3'
2350 $pCoordinate = preg_replace('/^([0-9]+):([0-9]+)$/', 'A${1}:XFD${2}', $pCoordinate);
2351
2352 if (strpos($pCoordinate,':') !== false || strpos($pCoordinate,',') !== false) {
2353 list($first, ) = PHPExcel_Cell::splitRange($pCoordinate);
2354 $this->_activeCell = $first[0];
2355 } else {
2356 $this->_activeCell = $pCoordinate;
2357 }
2358 $this->_selectedCells = $pCoordinate;
2359 return $this;
2360 }
2361
2370 public function setSelectedCellByColumnAndRow($pColumn = 0, $pRow = 1)
2371 {
2372 return $this->setSelectedCells(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow);
2373 }
2374
2380 public function getRightToLeft() {
2381 return $this->_rightToLeft;
2382 }
2383
2390 public function setRightToLeft($value = false) {
2391 $this->_rightToLeft = $value;
2392 return $this;
2393 }
2394
2405 public function fromArray($source = null, $nullValue = null, $startCell = 'A1', $strictNullComparison = false) {
2406 if (is_array($source)) {
2407 // Convert a 1-D array to 2-D (for ease of looping)
2408 if (!is_array(end($source))) {
2409 $source = array($source);
2410 }
2411
2412 // start coordinate
2413 list ($startColumn, $startRow) = PHPExcel_Cell::coordinateFromString($startCell);
2414
2415 // Loop through $source
2416 foreach ($source as $rowData) {
2417 $currentColumn = $startColumn;
2418 foreach($rowData as $cellValue) {
2419 if ($strictNullComparison) {
2420 if ($cellValue !== $nullValue) {
2421 // Set cell value
2422 $this->getCell($currentColumn . $startRow)->setValue($cellValue);
2423 }
2424 } else {
2425 if ($cellValue != $nullValue) {
2426 // Set cell value
2427 $this->getCell($currentColumn . $startRow)->setValue($cellValue);
2428 }
2429 }
2430 ++$currentColumn;
2431 }
2432 ++$startRow;
2433 }
2434 } else {
2435 throw new PHPExcel_Exception("Parameter \$source should be an array.");
2436 }
2437 return $this;
2438 }
2439
2451 public function rangeToArray($pRange = 'A1', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) {
2452 // Returnvalue
2453 $returnValue = array();
2454 // Identify the range that we need to extract from the worksheet
2455 list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($pRange);
2456 $minCol = PHPExcel_Cell::stringFromColumnIndex($rangeStart[0] -1);
2457 $minRow = $rangeStart[1];
2458 $maxCol = PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0] -1);
2459 $maxRow = $rangeEnd[1];
2460
2461 $maxCol++;
2462 // Loop through rows
2463 $r = -1;
2464 for ($row = $minRow; $row <= $maxRow; ++$row) {
2465 $rRef = ($returnCellRef) ? $row : ++$r;
2466 $c = -1;
2467 // Loop through columns in the current row
2468 for ($col = $minCol; $col != $maxCol; ++$col) {
2469 $cRef = ($returnCellRef) ? $col : ++$c;
2470 // Using getCell() will create a new cell if it doesn't already exist. We don't want that to happen
2471 // so we test and retrieve directly against _cellCollection
2472 if ($this->_cellCollection->isDataSet($col.$row)) {
2473 // Cell exists
2474 $cell = $this->_cellCollection->getCacheData($col.$row);
2475 if ($cell->getValue() !== null) {
2476 if ($cell->getValue() instanceof PHPExcel_RichText) {
2477 $returnValue[$rRef][$cRef] = $cell->getValue()->getPlainText();
2478 } else {
2479 if ($calculateFormulas) {
2480 $returnValue[$rRef][$cRef] = $cell->getCalculatedValue();
2481 } else {
2482 $returnValue[$rRef][$cRef] = $cell->getValue();
2483 }
2484 }
2485
2486 if ($formatData) {
2487 $style = $this->_parent->getCellXfByIndex($cell->getXfIndex());
2488 $returnValue[$rRef][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString(
2489 $returnValue[$rRef][$cRef],
2490 ($style && $style->getNumberFormat()) ?
2491 $style->getNumberFormat()->getFormatCode() :
2493 );
2494 }
2495 } else {
2496 // Cell holds a NULL
2497 $returnValue[$rRef][$cRef] = $nullValue;
2498 }
2499 } else {
2500 // Cell doesn't exist
2501 $returnValue[$rRef][$cRef] = $nullValue;
2502 }
2503 }
2504 }
2505
2506 // Return
2507 return $returnValue;
2508 }
2509
2510
2523 public function namedRangeToArray($pNamedRange = '', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) {
2524 $namedRange = PHPExcel_NamedRange::resolveRange($pNamedRange, $this);
2525 if ($namedRange !== NULL) {
2526 $pWorkSheet = $namedRange->getWorksheet();
2527 $pCellRange = $namedRange->getRange();
2528
2529 return $pWorkSheet->rangeToArray( $pCellRange,
2530 $nullValue, $calculateFormulas, $formatData, $returnCellRef);
2531 }
2532
2533 throw new PHPExcel_Exception('Named Range '.$pNamedRange.' does not exist.');
2534 }
2535
2536
2547 public function toArray($nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) {
2548 // Garbage collect...
2549 $this->garbageCollect();
2550
2551 // Identify the range that we need to extract from the worksheet
2552 $maxCol = $this->getHighestColumn();
2553 $maxRow = $this->getHighestRow();
2554 // Return
2555 return $this->rangeToArray( 'A1:'.$maxCol.$maxRow,
2556 $nullValue, $calculateFormulas, $formatData, $returnCellRef);
2557 }
2558
2567 public function getRowIterator($startRow = 1, $endRow = null) {
2568 return new PHPExcel_Worksheet_RowIterator($this, $startRow, $endRow);
2569 }
2570
2579 public function getColumnIterator($startColumn = 'A', $endColumn = null) {
2580 return new PHPExcel_Worksheet_ColumnIterator($this, $startColumn, $endColumn);
2581 }
2582
2588 public function garbageCollect() {
2589 // Flush cache
2590 $this->_cellCollection->getCacheData('A1');
2591 // Build a reference table from images
2592// $imageCoordinates = array();
2593// $iterator = $this->getDrawingCollection()->getIterator();
2594// while ($iterator->valid()) {
2595// $imageCoordinates[$iterator->current()->getCoordinates()] = true;
2596//
2597// $iterator->next();
2598// }
2599//
2600 // Lookup highest column and highest row if cells are cleaned
2601 $colRow = $this->_cellCollection->getHighestRowAndColumn();
2602 $highestRow = $colRow['row'];
2603 $highestColumn = PHPExcel_Cell::columnIndexFromString($colRow['column']);
2604
2605 // Loop through column dimensions
2606 foreach ($this->_columnDimensions as $dimension) {
2607 $highestColumn = max($highestColumn,PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex()));
2608 }
2609
2610 // Loop through row dimensions
2611 foreach ($this->_rowDimensions as $dimension) {
2612 $highestRow = max($highestRow,$dimension->getRowIndex());
2613 }
2614
2615 // Cache values
2616 if ($highestColumn < 0) {
2617 $this->_cachedHighestColumn = 'A';
2618 } else {
2619 $this->_cachedHighestColumn = PHPExcel_Cell::stringFromColumnIndex(--$highestColumn);
2620 }
2621 $this->_cachedHighestRow = $highestRow;
2622
2623 // Return
2624 return $this;
2625 }
2626
2632 public function getHashCode() {
2633 if ($this->_dirty) {
2634 $this->_hash = md5( $this->_title .
2635 $this->_autoFilter .
2636 ($this->_protection->isProtectionEnabled() ? 't' : 'f') .
2637 __CLASS__
2638 );
2639 $this->_dirty = false;
2640 }
2641 return $this->_hash;
2642 }
2643
2654 public static function extractSheetTitle($pRange, $returnRange = false) {
2655 // Sheet title included?
2656 if (($sep = strpos($pRange, '!')) === false) {
2657 return '';
2658 }
2659
2660 if ($returnRange) {
2661 return array( trim(substr($pRange, 0, $sep),"'"),
2662 substr($pRange, $sep + 1)
2663 );
2664 }
2665
2666 return substr($pRange, $sep + 1);
2667 }
2668
2674 public function getHyperlink($pCellCoordinate = 'A1')
2675 {
2676 // return hyperlink if we already have one
2677 if (isset($this->_hyperlinkCollection[$pCellCoordinate])) {
2678 return $this->_hyperlinkCollection[$pCellCoordinate];
2679 }
2680
2681 // else create hyperlink
2682 $this->_hyperlinkCollection[$pCellCoordinate] = new PHPExcel_Cell_Hyperlink();
2683 return $this->_hyperlinkCollection[$pCellCoordinate];
2684 }
2685
2693 public function setHyperlink($pCellCoordinate = 'A1', PHPExcel_Cell_Hyperlink $pHyperlink = null)
2694 {
2695 if ($pHyperlink === null) {
2696 unset($this->_hyperlinkCollection[$pCellCoordinate]);
2697 } else {
2698 $this->_hyperlinkCollection[$pCellCoordinate] = $pHyperlink;
2699 }
2700 return $this;
2701 }
2702
2709 public function hyperlinkExists($pCoordinate = 'A1')
2710 {
2711 return isset($this->_hyperlinkCollection[$pCoordinate]);
2712 }
2713
2719 public function getHyperlinkCollection()
2720 {
2722 }
2723
2729 public function getDataValidation($pCellCoordinate = 'A1')
2730 {
2731 // return data validation if we already have one
2732 if (isset($this->_dataValidationCollection[$pCellCoordinate])) {
2733 return $this->_dataValidationCollection[$pCellCoordinate];
2734 }
2735
2736 // else create data validation
2737 $this->_dataValidationCollection[$pCellCoordinate] = new PHPExcel_Cell_DataValidation();
2738 return $this->_dataValidationCollection[$pCellCoordinate];
2739 }
2740
2748 public function setDataValidation($pCellCoordinate = 'A1', PHPExcel_Cell_DataValidation $pDataValidation = null)
2749 {
2750 if ($pDataValidation === null) {
2751 unset($this->_dataValidationCollection[$pCellCoordinate]);
2752 } else {
2753 $this->_dataValidationCollection[$pCellCoordinate] = $pDataValidation;
2754 }
2755 return $this;
2756 }
2757
2764 public function dataValidationExists($pCoordinate = 'A1')
2765 {
2766 return isset($this->_dataValidationCollection[$pCoordinate]);
2767 }
2768
2775 {
2777 }
2778
2785 public function shrinkRangeToFit($range) {
2786 $maxCol = $this->getHighestColumn();
2787 $maxRow = $this->getHighestRow();
2788 $maxCol = PHPExcel_Cell::columnIndexFromString($maxCol);
2789
2790 $rangeBlocks = explode(' ',$range);
2791 foreach ($rangeBlocks as &$rangeSet) {
2792 $rangeBoundaries = PHPExcel_Cell::getRangeBoundaries($rangeSet);
2793
2794 if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[0][0]) > $maxCol) { $rangeBoundaries[0][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol); }
2795 if ($rangeBoundaries[0][1] > $maxRow) { $rangeBoundaries[0][1] = $maxRow; }
2796 if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[1][0]) > $maxCol) { $rangeBoundaries[1][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol); }
2797 if ($rangeBoundaries[1][1] > $maxRow) { $rangeBoundaries[1][1] = $maxRow; }
2798 $rangeSet = $rangeBoundaries[0][0].$rangeBoundaries[0][1].':'.$rangeBoundaries[1][0].$rangeBoundaries[1][1];
2799 }
2800 unset($rangeSet);
2801 $stRange = implode(' ',$rangeBlocks);
2802
2803 return $stRange;
2804 }
2805
2811 public function getTabColor()
2812 {
2813 if ($this->_tabColor === NULL)
2814 $this->_tabColor = new PHPExcel_Style_Color();
2815
2816 return $this->_tabColor;
2817 }
2818
2824 public function resetTabColor()
2825 {
2826 $this->_tabColor = null;
2827 unset($this->_tabColor);
2828
2829 return $this;
2830 }
2831
2837 public function isTabColorSet()
2838 {
2839 return ($this->_tabColor !== NULL);
2840 }
2841
2847 public function copy() {
2848 $copied = clone $this;
2849
2850 return $copied;
2851 }
2852
2856 public function __clone() {
2857 foreach ($this as $key => $val) {
2858 if ($key == '_parent') {
2859 continue;
2860 }
2861
2862 if (is_object($val) || (is_array($val))) {
2863 if ($key == '_cellCollection') {
2864 $newCollection = clone $this->_cellCollection;
2865 $newCollection->copyCellCollection($this);
2866 $this->_cellCollection = $newCollection;
2867 } elseif ($key == '_drawingCollection') {
2868 $newCollection = clone $this->_drawingCollection;
2869 $this->_drawingCollection = $newCollection;
2870 } elseif (($key == '_autoFilter') && ($this->_autoFilter instanceof PHPExcel_Worksheet_AutoFilter)) {
2871 $newAutoFilter = clone $this->_autoFilter;
2872 $this->_autoFilter = $newAutoFilter;
2873 $this->_autoFilter->setParent($this);
2874 } else {
2875 $this->{$key} = unserialize(serialize($val));
2876 }
2877 }
2878 }
2879 }
2887 public function setCodeName($pValue=null){
2888 // Is this a 'rename' or not?
2889 if ($this->getCodeName() == $pValue) {
2890 return $this;
2891 }
2892 $pValue = str_replace(' ', '_', $pValue);//Excel does this automatically without flinching, we are doing the same
2893 // Syntax check
2894 // throw an exception if not valid
2896
2897 // We use the same code that setTitle to find a valid codeName else not using a space (Excel don't like) but a '_'
2898
2899 if ($this->getParent()) {
2900 // Is there already such sheet name?
2901 if ($this->getParent()->sheetCodeNameExists($pValue)) {
2902 // Use name, but append with lowest possible integer
2903
2904 if (PHPExcel_Shared_String::CountCharacters($pValue) > 29) {
2905 $pValue = PHPExcel_Shared_String::Substring($pValue,0,29);
2906 }
2907 $i = 1;
2908 while ($this->getParent()->sheetCodeNameExists($pValue . '_' . $i)) {
2909 ++$i;
2910 if ($i == 10) {
2911 if (PHPExcel_Shared_String::CountCharacters($pValue) > 28) {
2912 $pValue = PHPExcel_Shared_String::Substring($pValue,0,28);
2913 }
2914 } elseif ($i == 100) {
2915 if (PHPExcel_Shared_String::CountCharacters($pValue) > 27) {
2916 $pValue = PHPExcel_Shared_String::Substring($pValue,0,27);
2917 }
2918 }
2919 }
2920
2921 $pValue = $pValue . '_' . $i;// ok, we have a valid name
2922 //codeName is'nt used in formula : no need to call for an update
2923 //return $this->setTitle($altTitle,$updateFormulaCellReferences);
2924 }
2925 }
2926
2927 $this->_codeName=$pValue;
2928 return $this;
2929 }
2935 public function getCodeName(){
2936 return $this->_codeName;
2937 }
2942 public function hasCodeName(){
2943 return !(is_null($this->_codeName));
2944 }
2945}
$column
Definition: 39dropdown.php:62
An exception for terminatinating execution or to throw for unit testing.
static getInstance(PHPExcel_Worksheet $parent)
Initialise the cache storage.
static getInstance(PHPExcel $workbook=NULL)
Get an instance of this class.
const CALCULATION_REGEXP_CELLREF
Definition: Calculation.php:75
const CALCULATION_REGEXP_NAMEDRANGE
Definition: Calculation.php:77
static getRangeBoundaries($pRange='A1:A1')
Calculate range boundaries.
Definition: Cell.php:756
static extractAllCellReferencesInRange($pRange='A1')
Extract all cell references in range.
Definition: Cell.php:854
static stringFromColumnIndex($pColumnIndex=0)
String from columnindex.
Definition: Cell.php:825
static coordinateFromString($pCoordinateString='A1')
Coordinate from string.
Definition: Cell.php:580
static rangeBoundaries($pRange='A1:A1')
Calculate range boundaries.
Definition: Cell.php:707
static splitRange($pRange='A1:A1')
Split range into coordinate strings.
Definition: Cell.php:660
static columnIndexFromString($pString='A')
Column index from string.
Definition: Cell.php:782
static resolveRange($pNamedRange='', PHPExcel_Worksheet $pSheet)
Resolve a named range to a regular cell range.
Definition: NamedRange.php:229
static getInstance()
Get an instance of this class.
static calculateColumnWidth(PHPExcel_Style_Font $font, $cellText='', $rotation=0, PHPExcel_Style_Font $defaultFont=null)
Calculate an (approximate) OpenXML column width, based on font size and text contained.
Definition: Font.php:252
static hashPassword($pPassword='')
Create a password hash from a given string.
static CountCharacters($value, $enc='UTF-8')
Get character count.
Definition: String.php:550
static Substring($pValue='', $pStart=0, $pLength=0)
Get a substring of a UTF-8 encoded string.
Definition: String.php:572
static toFormattedString($value='0', $format=PHPExcel_Style_NumberFormat::FORMAT_GENERAL, $callBack=null)
Convert a value in a pre-defined format to a PHP string.
getFont()
Get Font.
Definition: Style.php:510
unprotectCellsByColumnAndRow($pColumn1=0, $pRow1=1, $pColumn2=0, $pRow2=1, $pPassword='', $pAlreadyHashed=false)
Remove protection on a cell range by using numeric cell coordinates.
Definition: Worksheet.php:1871
getProtection()
Get Protection.
Definition: Worksheet.php:1002
getHighestDataRow($column=null)
Get highest worksheet row that contains data.
Definition: Worksheet.php:1070
getHighestColumn($row=null)
Get highest worksheet column.
Definition: Worksheet.php:1028
getSheetState()
Get sheet state.
Definition: Worksheet.php:894
getBreaks()
Get breaks.
Definition: Worksheet.php:1675
getSheetView()
Get sheet view.
Definition: Worksheet.php:980
garbageCollect()
Run PHPExcel garabage collector.
Definition: Worksheet.php:2588
getHyperlinkCollection()
Get collection of hyperlinks.
Definition: Worksheet.php:2719
getDataValidationCollection()
Get collection of data validations.
Definition: Worksheet.php:2774
removeRow($pRow=1, $pNumRows=1)
Delete a row, updating all possible related data.
Definition: Worksheet.php:2065
duplicateStyle(PHPExcel_Style $pCellStyle=null, $pRange='')
Duplicate cell style to a range of cells.
Definition: Worksheet.php:1535
getComment($pCellCoordinate='A1')
Get comment for cell.
Definition: Worksheet.php:2250
protectCellsByColumnAndRow($pColumn1=0, $pRow1=1, $pColumn2=0, $pRow2=1, $pPassword='', $pAlreadyHashed=false)
Set protection on a cell range by using numeric cell coordinates.
Definition: Worksheet.php:1833
cellExistsByColumnAndRow($pColumn=0, $pRow=1)
Cell at a specific coordinate by using numeric cell coordinates exists?
Definition: Worksheet.php:1304
conditionalStylesExists($pCoordinate='A1')
Do conditional styles exist for this cell?
Definition: Worksheet.php:1445
getSelectedCell()
Get selected cell.
Definition: Worksheet.php:2292
getCell($pCoordinate='A1')
Get cell at a specific coordinate.
Definition: Worksheet.php:1153
getAutoFilter()
Get Autofilter.
Definition: Worksheet.php:1892
getShowSummaryRight()
Show summary right? (Row/Column outlining)
Definition: Worksheet.php:2205
getShowGridlines()
Show gridlines?
Definition: Worksheet.php:2125
removeAutoFilter()
Remove autofilter.
Definition: Worksheet.php:1941
static _checkSheetTitle($pValue)
Check sheet title for valid Excel syntax.
Definition: Worksheet.php:463
setBreakByColumnAndRow($pColumn=0, $pRow=1, $pBreak=PHPExcel_Worksheet::BREAK_NONE)
Set break on a cell by using numeric cell coordinates.
Definition: Worksheet.php:1665
setConditionalStyles($pCoordinate='A1', $pValue)
Set conditional styles.
Definition: Worksheet.php:1482
insertNewRowBefore($pBefore=1, $pNumRows=1)
Insert a new row, updating all possible related data.
Definition: Worksheet.php:2013
setMergeCells($pValue=array())
Set merge cells array for the entire sheet.
Definition: Worksheet.php:1792
calculateColumnWidths($calculateMergeCells=false)
Calculate widths for auto-size columns.
Definition: Worksheet.php:724
getRightToLeft()
Get right-to-left.
Definition: Worksheet.php:2380
static $_invalidCharacters
Definition: Worksheet.php:53
getChartNames()
Return an array of the names of charts on this worksheet.
Definition: Worksheet.php:628
resetTabColor()
Reset tab color.
Definition: Worksheet.php:2824
setCodeName($pValue=null)
Define the code name of the sheet.
Definition: Worksheet.php:2887
getRowIterator($startRow=1, $endRow=null)
Get row iterator.
Definition: Worksheet.php:2567
setHyperlink($pCellCoordinate='A1', PHPExcel_Cell_Hyperlink $pHyperlink=null)
Set hyperlnk.
Definition: Worksheet.php:2693
getDefaultRowDimension()
Get default row dimension.
Definition: Worksheet.php:524
setAutoFilter($pValue)
Set AutoFilter.
Definition: Worksheet.php:1905
mergeCells($pRange='A1:A1')
Set merge on a cell range.
Definition: Worksheet.php:1687
getHighestDataColumn($row=null)
Get highest worksheet column that contains data.
Definition: Worksheet.php:1043
getTabColor()
Get tab color.
Definition: Worksheet.php:2811
isTabColorSet()
Tab color set?
Definition: Worksheet.php:2837
getShowSummaryBelow()
Show summary below? (Row/Column outlining)
Definition: Worksheet.php:2185
getDefaultColumnDimension()
Get default column dimension.
Definition: Worksheet.php:544
mergeCellsByColumnAndRow($pColumn1=0, $pRow1=1, $pColumn2=0, $pRow2=1)
Set merge on a cell range by using numeric cell coordinates.
Definition: Worksheet.php:1729
getStyleByColumnAndRow($pColumn=0, $pRow=1, $pColumn2=null, $pRow2=null)
Get style for cell by using numeric cell coordinates.
Definition: Worksheet.php:1497
getHeaderFooter()
Get page header/footer.
Definition: Worksheet.php:958
getRowDimension($pRow=1, $create=TRUE)
Get row dimension at a specific row.
Definition: Worksheet.php:1315
getHashCode()
Get hash code.
Definition: Worksheet.php:2632
freezePane($pCell='')
Freeze Pane.
Definition: Worksheet.php:1969
shrinkRangeToFit($range)
Accepts a range, returning it as a range that falls within the current highest row and column of the ...
Definition: Worksheet.php:2785
sortCellCollection()
Sort collection of cells.
Definition: Worksheet.php:501
unmergeCellsByColumnAndRow($pColumn1=0, $pRow1=1, $pColumn2=0, $pRow2=1)
Remove merge on a cell range by using numeric cell coordinates.
Definition: Worksheet.php:1770
insertNewColumnBeforeByIndex($pBefore=0, $pNumCols=1)
Insert a new column, updating all possible related data.
Definition: Worksheet.php:2049
setSharedStyle(PHPExcel_Style $pSharedCellStyle=null, $pRange='')
Set shared cell style to a range of cells.
Definition: Worksheet.php:1519
getPageMargins()
Get page margins.
Definition: Worksheet.php:936
getDataValidation($pCellCoordinate='A1')
Get data validation.
Definition: Worksheet.php:2729
getComments()
Get comments.
Definition: Worksheet.php:2225
getHighestRow($column=null)
Get highest worksheet row.
Definition: Worksheet.php:1055
getChartCount()
Return the count of charts on this worksheet.
Definition: Worksheet.php:594
static extractSheetTitle($pRange, $returnRange=false)
Extract worksheet title from range.
Definition: Worksheet.php:2654
copy()
Copy worksheet (!= clone!)
Definition: Worksheet.php:2847
duplicateConditionalStyle(array $pCellStyle=null, $pRange='')
Duplicate conditional style to a range of cells.
Definition: Worksheet.php:1581
duplicateStyleArray($pStyles=null, $pRange='', $pAdvanced=true)
Duplicate cell style array to a range of cells.
Definition: Worksheet.php:1623
getSelectedCells()
Get selected cells.
Definition: Worksheet.php:2312
addChart(PHPExcel_Chart $pChart=null, $iChartIndex=null)
Add chart.
Definition: Worksheet.php:576
setPageMargins(PHPExcel_Worksheet_PageMargins $pValue)
Set page margins.
Definition: Worksheet.php:947
getActiveCell()
Get active cell.
Definition: Worksheet.php:2302
getHyperlink($pCellCoordinate='A1')
Get hyperlink.
Definition: Worksheet.php:2674
calculateWorksheetDataDimension()
Calculate worksheet data dimension.
Definition: Worksheet.php:712
setTitle($pValue='Worksheet', $updateFormulaCellReferences=true)
Set title.
Definition: Worksheet.php:833
__construct(PHPExcel $pParent=null, $pTitle='Worksheet')
Create a new worksheet.
Definition: Worksheet.php:341
setRightToLeft($value=false)
Set right-to-left.
Definition: Worksheet.php:2390
removeColumn($pColumn='A', $pNumCols=1)
Remove a column, updating all possible related data.
Definition: Worksheet.php:2088
getColumnDimension($pColumn='A', $create=TRUE)
Get column dimension at a specific column.
Definition: Worksheet.php:1337
namedRangeToArray($pNamedRange='', $nullValue=null, $calculateFormulas=true, $formatData=true, $returnCellRef=false)
Create array from a range of cells.
Definition: Worksheet.php:2523
setDataValidation($pCellCoordinate='A1', PHPExcel_Cell_DataValidation $pDataValidation=null)
Set data validation.
Definition: Worksheet.php:2748
setPageSetup(PHPExcel_Worksheet_PageSetup $pValue)
Set page setup.
Definition: Worksheet.php:925
unfreezePane()
Unfreeze Pane.
Definition: Worksheet.php:2000
setPrintGridlines($pValue=false)
Set print gridlines.
Definition: Worksheet.php:2155
setShowSummaryRight($pValue=true)
Set show summary right.
Definition: Worksheet.php:2215
getChartCollection()
Get collection of charts.
Definition: Worksheet.php:564
getFreezePane()
Get Freeze Pane.
Definition: Worksheet.php:1952
dataValidationExists($pCoordinate='A1')
Data validation at a specific coordinate exists?
Definition: Worksheet.php:2764
setCellValueByColumnAndRow($pColumn=0, $pRow=1, $pValue=null, $returnCell=false)
Set a cell value by using numeric cell coordinates.
Definition: Worksheet.php:1108
static getInvalidCharacters()
Get array of invalid characters for sheet title.
Definition: Worksheet.php:423
protectCells($pRange='A1', $pPassword='', $pAlreadyHashed=false)
Set protection on a cell range.
Definition: Worksheet.php:1808
fromArray($source=null, $nullValue=null, $startCell='A1', $strictNullComparison=false)
Fill worksheet from values in array.
Definition: Worksheet.php:2405
getCommentByColumnAndRow($pColumn=0, $pRow=1)
Get comment for cell by using numeric cell coordinates.
Definition: Worksheet.php:2281
setShowSummaryBelow($pValue=true)
Set show summary below.
Definition: Worksheet.php:2195
calculateWorksheetDimension()
Calculate worksheet dimension.
Definition: Worksheet.php:701
rebindParent(PHPExcel $parent)
Re-bind parent.
Definition: Worksheet.php:796
setComments($pValue=array())
Set comments array for the entire sheet.
Definition: Worksheet.php:2236
getTitle()
Get title.
Definition: Worksheet.php:817
getChartByName($chartName='')
Get a chart by name.
Definition: Worksheet.php:644
getPageSetup()
Get page setup.
Definition: Worksheet.php:914
insertNewColumnBefore($pBefore='A', $pNumCols=1)
Insert a new column, updating all possible related data.
Definition: Worksheet.php:2031
rangeToArray($pRange='A1', $nullValue=null, $calculateFormulas=true, $formatData=true, $returnCellRef=false)
Create array from a range of cells.
Definition: Worksheet.php:2451
setSelectedCell($pCoordinate='A1')
Selected cell.
Definition: Worksheet.php:2323
setBreak($pCell='A1', $pBreak=PHPExcel_Worksheet::BREAK_NONE)
Set break on a cell.
Definition: Worksheet.php:1637
getConditionalStyles($pCoordinate='A1')
Get conditional styles for a cell.
Definition: Worksheet.php:1430
getPrintGridlines()
Print gridlines?
Definition: Worksheet.php:2145
getRowDimensions()
Get collection of row dimensions.
Definition: Worksheet.php:514
getDrawingCollection()
Get collection of drawings.
Definition: Worksheet.php:554
setSheetView(PHPExcel_Worksheet_SheetView $pValue)
Set sheet view.
Definition: Worksheet.php:991
setDefaultStyle(PHPExcel_Style $pValue)
Set default style - should only be used by PHPExcel_IReader implementations!
Definition: Worksheet.php:1395
const SHEETSTATE_HIDDEN
Definition: Worksheet.php:45
getColumnDimensionByColumn($pColumn=0)
Get column dimension at a specific column by using numeric cell coordinates.
Definition: Worksheet.php:1360
setShowGridlines($pValue=false)
Set show gridlines.
Definition: Worksheet.php:2135
removeConditionalStyles($pCoordinate='A1')
Removes conditional styles for a cell.
Definition: Worksheet.php:1459
removeColumnByIndex($pColumn=0, $pNumCols=1)
Remove a column, updating all possible related data.
Definition: Worksheet.php:2112
getCodeName()
Return the code name of the sheet.
Definition: Worksheet.php:2935
getMergeCells()
Get merge cells array.
Definition: Worksheet.php:1781
cellExists($pCoordinate='A1')
Does the cell at a specific coordinate exist?
Definition: Worksheet.php:1256
hyperlinkExists($pCoordinate='A1')
Hyperlink at a specific coordinate exists?
Definition: Worksheet.php:2709
getCellCacheController()
Return the cache controller for the cell collection.
Definition: Worksheet.php:413
getCellByColumnAndRow($pColumn=0, $pRow=1)
Get cell at a specific coordinate by using numeric cell coordinates.
Definition: Worksheet.php:1197
getCellCollection($pSorted=true)
Get collection of cells.
Definition: Worksheet.php:484
setAutoFilterByColumnAndRow($pColumn1=0, $pRow1=1, $pColumn2=0, $pRow2=1)
Set Autofilter Range by using numeric cell coordinates.
Definition: Worksheet.php:1927
setShowRowColHeaders($pValue=false)
Set show row and column headers.
Definition: Worksheet.php:2175
freezePaneByColumnAndRow($pColumn=0, $pRow=1)
Freeze Pane by using numeric cell coordinates.
Definition: Worksheet.php:1990
getDefaultStyle()
Get default style of workbook.
Definition: Worksheet.php:1382
setHeaderFooter(PHPExcel_Worksheet_HeaderFooter $pValue)
Set page header/footer.
Definition: Worksheet.php:969
disconnectCells()
Disconnect all cells from this PHPExcel_Worksheet object, typically so that the worksheet object can ...
Definition: Worksheet.php:388
getStyles()
Get styles.
Definition: Worksheet.php:1370
getHighestRowAndColumn()
Get highest worksheet column and highest row that have cell records.
Definition: Worksheet.php:1080
toArray($nullValue=null, $calculateFormulas=true, $formatData=true, $returnCellRef=false)
Create array from worksheet.
Definition: Worksheet.php:2547
getColumnIterator($startColumn='A', $endColumn=null)
Get column iterator.
Definition: Worksheet.php:2579
__destruct()
Code to execute when this worksheet is unset()
Definition: Worksheet.php:401
setCellValueExplicit($pCoordinate='A1', $pValue=null, $pDataType=PHPExcel_Cell_DataType::TYPE_STRING, $returnCell=false)
Set a cell value.
Definition: Worksheet.php:1123
const SHEETSTATE_VERYHIDDEN
Definition: Worksheet.php:46
setProtection(PHPExcel_Worksheet_Protection $pValue)
Set Protection.
Definition: Worksheet.php:1013
hasCodeName()
Sheet has a code name ?
Definition: Worksheet.php:2942
setSelectedCellByColumnAndRow($pColumn=0, $pRow=1)
Selected cell by using numeric cell coordinates.
Definition: Worksheet.php:2370
setCellValue($pCoordinate='A1', $pValue=null, $returnCell=false)
Set a cell value.
Definition: Worksheet.php:1093
static _checkSheetCodeName($pValue)
Check sheet code name for valid Excel syntax.
Definition: Worksheet.php:435
_createNewCell($pCoordinate)
Create a new cell at the specified coordinate.
Definition: Worksheet.php:1215
unprotectCells($pRange='A1')
Remove protection on a cell range.
Definition: Worksheet.php:1846
const SHEETSTATE_VISIBLE
Definition: Worksheet.php:44
getShowRowColHeaders()
Show row and column headers?
Definition: Worksheet.php:2165
setCellValueExplicitByColumnAndRow($pColumn=0, $pRow=1, $pValue=null, $pDataType=PHPExcel_Cell_DataType::TYPE_STRING, $returnCell=false)
Set a cell value by using numeric cell coordinates.
Definition: Worksheet.php:1140
getProtectedCells()
Get protected cells.
Definition: Worksheet.php:1882
getStyle($pCellCoordinate='A1')
Get style for cell.
Definition: Worksheet.php:1413
getChartByIndex($index=null)
Get a chart by its index position.
Definition: Worksheet.php:606
setSheetState($value=PHPExcel_Worksheet::SHEETSTATE_VISIBLE)
Set sheet state.
Definition: Worksheet.php:904
refreshRowDimensions()
Refresh row dimensions.
Definition: Worksheet.php:682
__clone()
Implement PHP __clone to create a deep clone, not just a shallow copy.
Definition: Worksheet.php:2856
getColumnDimensions()
Get collection of column dimensions.
Definition: Worksheet.php:534
setSelectedCells($pCoordinate='A1')
Select a range of cells.
Definition: Worksheet.php:2335
refreshColumnDimensions()
Refresh column dimensions.
Definition: Worksheet.php:663
getConditionalStylesCollection()
Get collection of conditional styles.
Definition: Worksheet.php:1470
unmergeCells($pRange='A1:A1')
Remove merge on a cell range.
Definition: Worksheet.php:1742
getParent()
Get parent.
Definition: Worksheet.php:786
addNamedRange(PHPExcel_NamedRange $namedRange)
Add named range.
Definition: PHPExcel.php:778
$style
Definition: example_012.php:70
$r
Definition: example_031.php:79