This bundle integrates your Symfony 2/3/4 app with the PHPOffice PhpSpreadsheet
This bundle requires, in addition to prerequisites of each PHPOffice library:
* PHP 5.6 or higher * Symfony 2.7, 3.0 or 4.0
Use composer to require the latest stable version.
$ composer require yectep/phpspreadsheet-bundle
Then enable the bundle in your
$bundles = array( [...] new Yectep\PhpSpreadsheetBundle\PhpSpreadsheetBundle(), );
This bundle enables the
See also the official PHPOffice PhpSpreadsheet documentation.
Creates an empty
\PhpOffice\PhpSpreadsheet\Spreadsheet object, or, if an optional
$filename is passed, instantiates the
automatically detect and use the appropriate
IWriter class to read the file.
// In your controller $newSpreadsheet = $this->get('phpoffice.spreadsheet')->createSpreadsheet(); $existingXlsx = $this->get('phpoffice.spreadsheet')->createSpreadsheet('/path/to/file.xlsx');
Returns an instance of the
\PhpOffice\PhpSpreadsheet\Reader class of the given
Types are case sensitive. Supported types are:
Xlsx: Excel 2007
Xls: Excel 5/BIFF (95)
Xml: Excel 2003 XML
Slk: Symbolic Link (SYLK)
Ods: Open/Libre Office (ODS)
$readerXlsx = $this->get('phpoffice.spreadsheet')->createReader('Xlsx'); $spreadsheet = $readerXlsx->load('/path/to/file.xlsx');
\PhpOffice\PhpSpreadsheet\Spreadsheet object and a writer
an instance of a
\PhpOffice\PhpSpreadsheet\Writer class for that type.
In addition the the read types above, these types are additionally supported for writing, if
the appropriate PHP libraries are installed.
$spreadsheet = $this->get('phpoffice.spreadsheet')->createSpreadsheet(); $spreadsheet->getActiveSheet()->setCellValue('A1', 'Hello world'); $writerXlsx = $this->get('phpoffice.spreadsheet')->createWriter($spreadsheet, 'Xlsx'); $writerXlsx->save('/path/to/destination.xlsx');
Roadmap and Contributions
Contributions are more than welcome. Fork the project, and submit a PR when you're done.
Remaining todos include:
- Tests and test coverage
- Improved documentation
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- Merge pull request #5 from Dodenis/writerOptions-on-streamdResponse
- Update Factory.php
- Allow to add options for writer
- Merge pull request #4 from andrea-daru/streamed-response
By , 1 year ago
By andrea-daru, 1 year ago
- Merge pull request #3 from andrea-daru/bundle-reorganization
Moved Factory in src
By andrea-daru, 1 year ago
- Improve documentation
- Add Symfony 3/4 options
- Initial commit