diff --git a/docs/topics/migration-from-PHPExcel.md b/docs/topics/migration-from-PHPExcel.md index a7cd1134..a28da6a4 100644 --- a/docs/topics/migration-from-PHPExcel.md +++ b/docs/topics/migration-from-PHPExcel.md @@ -16,3 +16,103 @@ cd /project/to/migrate/src **Important** The tool will irreversibly modify your sources, be sure to backup everything, and double check the result before committing. + +## Removed deprecated things + +In addition to automated changes, usage of deprecated methods must be migrated +manually. + +### Worksheet::duplicateStyleArray() + +``` php +// Before +$worksheet->duplicateStyleArray($styles, $range, $advanced); + +// After +$worksheet->getStyle($range)->applyFromArray($styles, $advanced); +``` + +### DataType::dataTypeForValue() + +``` php +// Before +DataType::dataTypeForValue($value); + +// After +DefaultValueBinder::dataTypeForValue($value); +``` + +### Conditional::getCondition() + +``` php +// Before +$conditional->getCondition(); + +// After +$conditional->getConditions()[0]; +``` + +### Conditional::setCondition() + +``` php +// Before +$conditional->setCondition($value); + +// After +$conditional->setConditions($value); +``` + +### Worksheet::getDefaultStyle() + +``` php +// Before +$worksheet->getDefaultStyle(); + +// After +$worksheet->getParent()->getDefaultStyle(); +``` + +### Worksheet::setDefaultStyle() + +``` php +// Before +$worksheet->setDefaultStyle($value); + +// After +$worksheet->getParent()->getDefaultStyle()->applyFromArray([ + 'font' => [ + 'name' => $pValue->getFont()->getName(), + 'size' => $pValue->getFont()->getSize(), + ], +]); + +``` + +### Worksheet::setSharedStyle() + +``` php +// Before +$worksheet->setSharedStyle($sharedStyle, $range); + +// After +$worksheet->duplicateStyle($sharedStyle, $range); +``` + +### Worksheet::getSelectedCell() + +``` php +// Before +$worksheet->getSelectedCell(); + +// After +$worksheet->getSelectedCells(); +``` + +### Writer\Xls::setTempDir() + +``` php +// Before +$writer->setTempDir(); + +// After, there is no way to set temporary storage directory anymore +``` diff --git a/docs/topics/recipes.md b/docs/topics/recipes.md index ab197e9e..c074be74 100644 --- a/docs/topics/recipes.md +++ b/docs/topics/recipes.md @@ -585,10 +585,6 @@ execution whenever you are setting more than one style property. But the difference may barely be measurable unless you have many different styles in your workbook. -Prior to PHPExcel 1.7.0 duplicateStyleArray() was the recommended method -for styling a cell range, but this method has now been deprecated since -getStyle() has started to accept a cell range. - ### Number formats You often want to format numbers in Excel. For example you may want a diff --git a/samples/29_Advanced_value_binder.php b/samples/29_Advanced_value_binder.php index 82657347..260a612b 100644 --- a/samples/29_Advanced_value_binder.php +++ b/samples/29_Advanced_value_binder.php @@ -27,8 +27,8 @@ $spreadsheet->getProperties()->setCreator('Maarten Balliauw') // Set default font $helper->log('Set default font'); -$spreadsheet->getActiveSheet()->getDefaultStyle()->getFont()->setName('Arial'); -$spreadsheet->getActiveSheet()->getDefaultStyle()->getFont()->setSize(10); +$spreadsheet->getDefaultStyle()->getFont()->setName('Arial'); +$spreadsheet->getDefaultStyle()->getFont()->setSize(10); // Set column widths $helper->log('Set column widths'); diff --git a/src/PhpSpreadsheet/Cell/DataType.php b/src/PhpSpreadsheet/Cell/DataType.php index 73824b19..a64cb826 100644 --- a/src/PhpSpreadsheet/Cell/DataType.php +++ b/src/PhpSpreadsheet/Cell/DataType.php @@ -60,18 +60,6 @@ class DataType return self::$errorCodes; } - /** - * DataType for value - * - * @deprecated Replaced by \PhpOffice\PhpSpreadsheet\Cell\IValueBinder infrastructure, will be removed in version 1.8.0 - * @param mixed $pValue - * @return string - */ - public static function dataTypeForValue($pValue = null) - { - return DefaultValueBinder::dataTypeForValue($pValue); - } - /** * Check a string that it satisfies Excel requirements * diff --git a/src/PhpSpreadsheet/Style/Conditional.php b/src/PhpSpreadsheet/Style/Conditional.php index ba5bc275..d97d22d1 100644 --- a/src/PhpSpreadsheet/Style/Conditional.php +++ b/src/PhpSpreadsheet/Style/Conditional.php @@ -162,37 +162,6 @@ class Conditional implements \PhpOffice\PhpSpreadsheet\IComparable return $this; } - /** - * Get Condition - * - * @deprecated Deprecated, use getConditions instead - * @return string - */ - public function getCondition() - { - if (isset($this->condition[0])) { - return $this->condition[0]; - } - - return ''; - } - - /** - * Set Condition - * - * @deprecated Deprecated, use setConditions instead - * @param string $pValue Condition - * @return Conditional - */ - public function setCondition($pValue = '') - { - if (!is_array($pValue)) { - $pValue = [$pValue]; - } - - return $this->setConditions($pValue); - } - /** * Get Conditions * diff --git a/src/PhpSpreadsheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet.php index 5dd7bd1b..3d8ca1d8 100644 --- a/src/PhpSpreadsheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet.php @@ -756,7 +756,7 @@ class Worksheet implements IComparable $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont(), $cellValue, $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getAlignment()->getTextRotation(), - $this->getDefaultStyle()->getFont() + $this->getParent()->getDefaultStyle()->getFont() ) ); } @@ -1396,38 +1396,6 @@ class Worksheet implements IComparable return $this->styles; } - /** - * Get default style of workbook. - * - * @deprecated - * @throws Exception - * @return Style - */ - public function getDefaultStyle() - { - return $this->parent->getDefaultStyle(); - } - - /** - * Set default style - should only be used by \PhpOffice\PhpSpreadsheet\IReader implementations! - * - * @deprecated - * @param Style $pValue - * @throws Exception - * @return Worksheet - */ - public function setDefaultStyle(Style $pValue) - { - $this->parent->getDefaultStyle()->applyFromArray([ - 'font' => [ - 'name' => $pValue->getFont()->getName(), - 'size' => $pValue->getFont()->getSize(), - ], - ]); - - return $this; - } - /** * Get style for cell * @@ -1534,24 +1502,6 @@ class Worksheet implements IComparable return $this->getStyle(Cell::stringFromColumnIndex($pColumn) . $pRow); } - /** - * Set shared cell style to a range of cells - * - * Please note that this will overwrite existing cell styles for cells in range! - * - * @deprecated duplicateStyle - * @param Style $pSharedCellStyle Cell style to share - * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") - * @throws Exception - * @return Worksheet - */ - public function setSharedStyle(Style $pSharedCellStyle = null, $pRange = '') - { - $this->duplicateStyle($pSharedCellStyle, $pRange); - - return $this; - } - /** * Duplicate cell style to a range of cells * @@ -1636,27 +1586,6 @@ class Worksheet implements IComparable return $this; } - /** - * Duplicate cell style array to a range of cells - * - * Please note that this will overwrite existing cell styles for cells in range, - * if they are in the styles array. For example, if you decide to set a range of - * cells to font bold, only include font bold in the styles array. - * - * @deprecated - * @param array $pStyles Array containing style information - * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") - * @param bool $pAdvanced Advanced mode for setting borders. - * @throws Exception - * @return Worksheet - */ - public function duplicateStyleArray($pStyles = null, $pRange = '', $pAdvanced = true) - { - $this->getStyle($pRange)->applyFromArray($pStyles, $pAdvanced); - - return $this; - } - /** * Set break on a cell * @@ -2347,17 +2276,6 @@ class Worksheet implements IComparable return $this->getComment(Cell::stringFromColumnIndex($pColumn) . $pRow); } - /** - * Get selected cell - * - * @deprecated - * @return string - */ - public function getSelectedCell() - { - return $this->getSelectedCells(); - } - /** * Get active cell * diff --git a/src/PhpSpreadsheet/Writer/Xls.php b/src/PhpSpreadsheet/Writer/Xls.php index 2521438b..3c1ba66e 100644 --- a/src/PhpSpreadsheet/Writer/Xls.php +++ b/src/PhpSpreadsheet/Writer/Xls.php @@ -215,19 +215,6 @@ class Xls extends BaseWriter implements IWriter \PhpOffice\PhpSpreadsheet\Calculation::getInstance($this->spreadsheet)->getDebugLog()->setWriteDebugLog($saveDebugLog); } - /** - * Set temporary storage directory - * - * @deprecated - * @param string $pValue Temporary storage directory - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception when directory does not exist - * @return \PhpOffice\PhpSpreadsheet\Writer\Xls - */ - public function setTempDir($pValue = '') - { - return $this; - } - /** * Build the Worksheet Escher objects */