Skip to content

Commit

Permalink
Document readers/writeres short name changes
Browse files Browse the repository at this point in the history
Closes #253
  • Loading branch information
PowerKiKi committed Oct 17, 2017
1 parent 79ab852 commit b3e6538
Showing 1 changed file with 43 additions and 19 deletions.
62 changes: 43 additions & 19 deletions docs/topics/migration-from-PHPExcel.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
PhpSpreadsheet introduced many breaking changes by introducing
namespaces and renaming some classes. To help you migrate existing
project, a tool was written to replace all references to PHPExcel
classes to their new names.
classes to their new names. But they are also manual changes that
need to be done.

## Automated tool

The tool is included in PhpSpreadsheet. It scans recursively all files
and directories, starting from the current directory. Assuming it was
Expand All @@ -17,12 +20,33 @@ 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
## Manual changes

In addition to automated changes, a few things need to be migrated manually.

### Renamed readers and writers

When using with `IOFactory::createReader()`, `IOFactory::createWriter()`
and `IOFactory::identify()`, the reader/writer short names are used.
Those were changed, along as their corresponding class, to remove ambiguity:

Before | After
-----------------|---------
`'CSV'` | `'Csv'`
`'Excel2003XML'` | `'Xml'`
`'Excel2007'` | `'Xlsx'`
`'Excel5'` | `'Xls'`
`'Gnumeric'` | `'Gnumeric'`
`'HTML'` | `'Html'`
`'OOCalc'` | `'Ods'`
`'OpenDocument'` | `'Ods'`
`'PDF'` | `'Pdf'`
`'SYLK'` | `'Slk'`


In addition to automated changes, usage of deprecated methods must be migrated
manually.
### Removed deprecated things

### Worksheet::duplicateStyleArray()
#### Worksheet::duplicateStyleArray()

``` php
// Before
Expand All @@ -32,7 +56,7 @@ $worksheet->duplicateStyleArray($styles, $range, $advanced);
$worksheet->getStyle($range)->applyFromArray($styles, $advanced);
```

### DataType::dataTypeForValue()
#### DataType::dataTypeForValue()

``` php
// Before
Expand All @@ -42,7 +66,7 @@ DataType::dataTypeForValue($value);
DefaultValueBinder::dataTypeForValue($value);
```

### Conditional::getCondition()
#### Conditional::getCondition()

``` php
// Before
Expand All @@ -52,7 +76,7 @@ $conditional->getCondition();
$conditional->getConditions()[0];
```

### Conditional::setCondition()
#### Conditional::setCondition()

``` php
// Before
Expand All @@ -62,7 +86,7 @@ $conditional->setCondition($value);
$conditional->setConditions($value);
```

### Worksheet::getDefaultStyle()
#### Worksheet::getDefaultStyle()

``` php
// Before
Expand All @@ -72,7 +96,7 @@ $worksheet->getDefaultStyle();
$worksheet->getParent()->getDefaultStyle();
```

### Worksheet::setDefaultStyle()
#### Worksheet::setDefaultStyle()

``` php
// Before
Expand All @@ -88,7 +112,7 @@ $worksheet->getParent()->getDefaultStyle()->applyFromArray([

```

### Worksheet::setSharedStyle()
#### Worksheet::setSharedStyle()

``` php
// Before
Expand All @@ -98,7 +122,7 @@ $worksheet->setSharedStyle($sharedStyle, $range);
$worksheet->duplicateStyle($sharedStyle, $range);
```

### Worksheet::getSelectedCell()
#### Worksheet::getSelectedCell()

``` php
// Before
Expand All @@ -108,7 +132,7 @@ $worksheet->getSelectedCell();
$worksheet->getSelectedCells();
```

### Writer\Xls::setTempDir()
#### Writer\Xls::setTempDir()

``` php
// Before
Expand All @@ -117,12 +141,12 @@ $writer->setTempDir();
// After, there is no way to set temporary storage directory anymore
```

## Autoloader
### Autoloader

The class `PHPExcel_Autoloader` was removed entirely and is replaced by composer
autoloading mechanism.

## Writing PDF
### Writing PDF

`PHPExcel_Settings::getPdfRenderer()` and `PHPExcel_Settings::setPdfRenderer()`
were removed. `PHPExcel_Settings::getPdfRendererName()` and
Expand All @@ -135,7 +159,7 @@ $rendererName = \PhpOffice\PhpSpreadsheet\Writer\Pdf\MPDF::class;
\PhpOffice\PhpSpreadsheet\Settings::setDefaultPdfWriter($rendererName);
```

## PclZip and ZipArchive
### PclZip and ZipArchive

Support for PclZip were dropped in favor of the more complete and modern
[PHP extension ZipArchive](http://php.net/manual/en/book.zip.php).
Expand All @@ -148,7 +172,7 @@ So the following were removed:
- `PHPExcel_Shared_ZipStreamWrapper`


## Cell caching
### Cell caching

Cell caching was heavily refactored to leverage
[PSR-16](http://www.php-fig.org/psr/psr-16/). That means most classes
Expand All @@ -174,7 +198,7 @@ to `\PhpOffice\PhpSpreadsheet::getCoordinates()` and

Refer to [the new documentation](./memory_saving.md) to see how to migrate.

## Dropped conditionally returned cell
### Dropped conditionally returned cell

For all the following methods, it is no more possible to change the type of
returned value. It always return the Worksheet and never the Cell or Rule:
Expand All @@ -195,7 +219,7 @@ $cell = $worksheet->setCellValue('A1', 'value', true);
$cell = $worksheet->getCell('A1')->setValue('value');
```

## Standardized keys for styling
### Standardized keys for styling

Array keys used for styling have been standardized for a more coherent experience.
It now uses the same wording and casing as the getter and setter:
Expand Down

0 comments on commit b3e6538

Please sign in to comment.