robotusers / cakephp-excel

CakePHP Spreadsheet (Excel) plugin.
MIT License
23 stars 10 forks source link

Export #17

Open thiagoreri opened 5 years ago

thiagoreri commented 5 years ago

Is there a possibility, of doing the process to the contrary, make a find in the table and write in the file? In the case it would be a data export

robertpustulka commented 5 years ago

@thiagoreri

It is possible to dump the table into a spreadsheet file using your custom finder.

$table = TableRegistry::get('SomeTable');
$manager = new Manager();

$file = new File('your/file.xlsx');
$spreadsheet = $manager->getSpreadsheet($file);
$worksheet = $spreadsheet->getActiveSheet();

$manager->write($table, $worksheet, [
    'finder' => 'myFinder',
    'finderOptions' => [], //pass options to your finder
]);
$writer = $manager->save($spreadsheet, $file);

Check this method for reference: https://github.com/robotusers/cakephp-excel/blob/master/src/Excel/Manager.php#L154

thiagoreri commented 5 years ago

IS possible export for empty file?

When trying to do this happens the following error:

Invalid cell cordinate