Skip to content

Commit 279c62e

Browse files
Update docs.
1 parent 57214d9 commit 279c62e

2 files changed

Lines changed: 21 additions & 18 deletions

File tree

README.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
[![codecov](https://codecov.io/gh/robotusers/cakephp-excel/branch/master/graph/badge.svg)](https://codecov.io/gh/robotusers/cakephp-excel)
88

99
CakePHP Excel plugin allows for spreadsheet files manipulation with the power of CakePHP ORM.
10-
This plugin is build using [PHPExcel](https://github.com/PHPOffice/PHPExcel) library and can work with multiple types of spreadsheet files (excel, csv etc).
10+
This plugin is build using [PHPSpreadsheet](https://github.com/PHPOffice/PHPSpreadsheet) library and can work with multiple types of spreadsheet files (excel, csv etc).
11+
12+
**NOTE:**
13+
CakePHP Excel plugin versions 0.4.0 and lower used now abandoned [PHPExcel](https://github.com/PHPOffice/PHPExcel) library.
1114

1215
## Installation
1316

@@ -22,11 +25,11 @@ Excel plugin lets you manipulate spreadsheet files multiple ways. The simplest u
2225

2326
For example we are loading an excel file that contains some record data.
2427

25-
| | A | B | C |
26-
|:--|:------------: |:------------------:| :---:|
27-
| 1 | Led Zeppelin | Led Zeppelin II | 1969 |
28-
| 2 | Deep Purple | Machine Head | 1972 |
29-
| 3 | Pink Floyd | Wish You Were Here | 1975 |
28+
| | A | B | C |
29+
|:--|:------------: |:---------------------:| :---:|
30+
| 1 | Led Zeppelin | Led Zeppelin II | 1969 |
31+
| 2 | Deep Purple | Machine Head | 1972 |
32+
| 3 | Pink Floyd | Wish You Were Here | 1975 |
3033

3134
```php
3235
use Robotusers/Excel/Registry;
@@ -100,10 +103,10 @@ $row = $table->newEntity([
100103
$table->save($row);
101104
```
102105

103-
Now the new record is saved, but excel file has not been updated yet. You have to call `writeExcel()` method:
106+
Now the new record is saved, but excel file has not been updated yet. You have to call `writeSpreadsheet()` method:
104107

105108
```php
106-
$table->writeExcel();
109+
$table->writeSpreadsheet();
107110
```
108111

109112
You may also want to read or write only some of the rows and columns.
@@ -176,18 +179,18 @@ If you want to load data into your table you have to set a worksheet instance.
176179
use Cake\Filesystem\File;
177180

178181
$file = new File('path/to/file.xls');
179-
$excel = $table->getManager()->getExcel($file); // PHPExcel instance
180-
$worksheet = $excel->getActiveSheet(); // PHPExcel_Worksheet instance
182+
$spreadsheet = $table->getManager()->getSpreadsheet($file); // \PhpOffice\PhpSpreadsheet\Spreadsheet instance
183+
$worksheet = $spreadsheet->getActiveSheet(); // \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet instance
181184

182-
$table->setWorksheet($worksheet)->readExcel();
185+
$table->setWorksheet($worksheet)->readSpreadsheet();
183186
```
184187

185188
Now your table is populated with excel data.
186189

187190
If you want to write your data back to excel file you have to set a file.
188191

189192
```php
190-
$table->setFile($file)->writeExcel();
193+
$table->setFile($file)->writeSpreadsheet();
191194
```
192195

193196
## Working with different tables
@@ -201,8 +204,8 @@ $table = TableRegistry::get('SomeTable');
201204
$manager = new Manager();
202205

203206
$file = new File('file.xlsx');
204-
$excel = $manager->getExcel($file);
205-
$worksheet = $excel->getActiveSheet();
207+
$spreadsheet = $manager->getSpreadsheet($file);
208+
$worksheet = $spreadsheet->getActiveSheet();
206209

207210
$manager->read($worksheet, $table, [
208211
'columnMap' => [
@@ -223,5 +226,5 @@ $manager->write($table, $worksheet, [
223226
]
224227
]);
225228
//to actually save the file you have to call save()
226-
$writer = $manager->save($excel, $file);
229+
$writer = $manager->save($spreadsheet, $file);
227230
```

config/bootstrap.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
/*
2+
/*
33
* The MIT License
44
*
55
* Copyright 2017 RobotUsers
@@ -32,7 +32,7 @@
3232
$name = Registry::CONNECTON_NAME;
3333
$hasConnectionConfig = ConnectionManager::config($name);
3434
if (!$hasConnectionConfig && !in_array('sqlite', PDO::getAvailableDrivers())) {
35-
$msg = 'Excel not enabled. You need to either install pdo_sqlite, or define the "%s" connection name.';
35+
$msg = 'Spreadsheet not enabled. You need to either install pdo_sqlite, or define the "%s" connection name.';
3636
Log::warning(sprintf($msg, $name));
3737
return;
3838
}
@@ -45,4 +45,4 @@
4545
'cacheMetadata' => true,
4646
'quoteIdentifiers' => true,
4747
]);
48-
}
48+
}

0 commit comments

Comments
 (0)