64 Commits

Author SHA1 Message Date
quamis
e84304cbe9
Merge ba1d66086d96fb8f0246e06a2d7567167d570cba into 91f756be0b0bf78f79f93a36ffdc240a5bf4099d 2021-03-21 18:12:31 +01:00
Petr Skoda
816596183f Add full support for PHP 8.0
Unfortunately due to PHPUnit 8.5 dependency
this also drops support for PHP 7.1
2021-02-08 14:31:55 +01:00
István Ignácz
41a9ae89ee #529 - tests for column width, row height and cell merge + minor refact
Tests
Added 'addOption' to OptionsManagerInterface
Moved 'setColumnWidths' and 'mergeCells' methods to Xlsx Writer implementation since the actual feature only works for Xlsx at the moment
2020-08-14 18:24:26 +02:00
István Ignácz
817e4f1f01 #729 - fix shrink to fit + add test
shrinkToFit was not handled in StyleMerger so it was overwritten by the default cell style
StyleManager didn't add the property to the xml if shrinkToFit was used without alignment or text wrap.
Unit test
2020-08-14 16:39:52 +02:00
Adrien Loison
7964dadc21 Add support for cells in error when writing XLSX and ODS
When appending data to an existing sheet, it was possible to get cells in error when reading (DIV/0 for instance). When trying to write them back, `addRow` would throw because `Cell`s in error were not supported by the writers.
2019-12-02 22:21:41 +01:00
Adrien Loison
9f4c094fa0 Cell alignment
This PR adds support for cell alignment for XLSX and ODS files.
You can now align the content of the cells this way:
```
use Box\Spout\Common\Entity\Style\CellAlignment;
use Box\Spout\Writer\Common\Creator\Style\StyleBuilder;

$style = (new StyleBuilder())
    ->setCellAlignment(CellAlignment::RIGHT)
    ->build();
...
```

Possible cell alignments are: LEFT, RIGHT, CENTER and JUSTIFY.
2019-10-27 18:58:56 +01:00
Adrien Loison
6a6d1df9df Fix typo - Boder => Border 2019-10-17 07:37:37 +00:00
Alexander Rakushin
52312b7045 Added tests for StyleRegistry and StyleMerger 2019-10-01 20:08:54 +00:00
Alexander Rakushin
e8c6d83104 сode formatting (CS Fixer) 2019-10-01 20:08:54 +00:00
Alexander Rakushin
40aecd7b90 Added support for cell formats when writing Excel files 2019-10-01 20:08:54 +00:00
Adrien Loison
40ee386edd Add helper functions to create specific readers and writers
Removed the `ReaderEntityFactory::createReader(Type)` method and replaced it by 3 methods:
- `ReaderEntityFactory::createCSVReader()`
- `ReaderEntityFactory::createXLSXReader()`
- `ReaderEntityFactory::createODSReader()`

This has the advantage of enabling autocomplete in the IDE, as the return type is no longer the interface but the concrete type. Since readers may expose different options, this is pretty useful.

Similarly, removed the `WriterEntityFactory::createWriter(Type)` method and replaced it by 3 methods:
- `WriterEntityFactory::createCSVWriter()`
- `WriterEntityFactory::createXLSXWriter()`
- `WriterEntityFactory::createODSWriter()`

Since this is a breaking change, I also updated the Upgrade guide.
Finally, the doc is up to date too.
2019-05-17 21:22:03 +02:00
madflow
e8693834a0 perf tests in development branch 2019-03-24 22:53:28 +01:00
Adrien Loison
171a2fab10 Fix test failure message 2019-02-02 09:55:16 +01:00
Adrien Loison
71cf0fe339 Fix sheet name escaping
Sheet names are stored as attributes of an XML entity. We therefore need a different escaping strategy, escaping quotes.
2019-01-26 16:14:15 +01:00
madflow
738ea30f35 use expectNotToPerformAssertions 2018-10-08 10:09:47 +02:00
madflow
8a1c48b6b0 rename EntityFactory for writers and readers #526 2018-09-03 11:15:09 +02:00
madflow
01ad5af2c5 fix risky tests and assert true for silent tests 2018-03-25 15:35:19 +02:00
Gabriel Caruso
4c7adbb33f Refactoring tests 2017-12-15 10:09:18 +01:00
Gabriel Caruso
0efdf48119 Support PHPUnit 6 2017-11-27 00:24:13 +01:00
Adrien Loison
f5168114d0 Merge Reader and Writer entities
Merged Cell/Row/Style entities
2017-11-19 02:54:17 +01:00
Adrien Loison
1c69dee9c9 Sheet visibility - ODS writer and reader 2017-11-11 11:11:47 +01:00
Adrien Loison
b9206fcb4b Sheet visibility - XLSX writer and reader 2017-11-11 11:11:47 +01:00
Adrien Loison
111f82d35f Add tests for cell styling 2017-11-10 21:35:59 +01:00
Adrien Loison
3d0f108b1d Consolidate external EntityFactory
All entities will now be created through a single factory (including the Writers).
Also, added a EntityFactory::createRowFromArray() to make it easier to create rows
2017-11-05 13:18:29 +01:00
Adrien Loison
3851e05f83 Remove @expectedException annotation 2017-11-05 02:21:09 +01:00
Adrien Loison
7274226b75 Row objects and Cell styling
This commit introduces Row and Cell entities, that will replace the arrays passed in previously.
It also adds support for Cell styling (instead of Row styling only).
2017-11-05 02:12:28 +01:00
Adrien Loison
b968513cb9 Fix code style 2017-09-06 00:33:43 +02:00
Adrien Loison
740fcfb8c1 Fix code before applying PHP CS Fixer 2017-09-06 00:33:43 +02:00
Adrien Loison
3bb4fd3d48 Move Sheet to Common/Entity (#438)
... and introduce a SheetManager
2017-05-30 16:49:07 +02:00
Adrien Loison
cc9a0b526b Refactory Writer Styles to match new code organization (#433)
Decomposed old StyleHelper into StyleManager, StyleRegistry and StyleMerger.
2017-05-30 13:05:18 +02:00
Adrien Loison
238756ab6e Move Style classes into Common folder (#432) 2017-05-30 00:56:50 +02:00
Adrien Loison
c4e25a168e Move entities and managers back to Common (#431) 2017-05-29 23:28:10 +02:00
Adrien Loison
cebffbe80c Move Cell and Options to Entity folder (#429) 2017-05-29 22:51:12 +02:00
Adrien Loison
bc17311f5f Refactor writers for better DI (#427)
This commit is a big refactor that improves the code organization.
It focuses on how dependencies are injected into the different classes. This is now done via some factories.

Also, the code is now built around entities (data model that only exposes getters and setters), managers (used to manage an entity) and helpers (used by the managers to perform some specific tasks).

The refactoring is not fully complete, as some dependencies are still hidden...
2017-05-29 22:18:40 +02:00
Adrien Loison
a366d0d0af Introduce an options manager for all writers (#423)
This will improve the management of options and simplify some methods' signatures.
This commit will also help moving the code to a better state regarding Dependency Injection.
2017-05-24 13:17:50 +02:00
madflow
4acd9ad087 Cell value objects (#383)
* first stab at cell objects, #182
* removed comment parameter, streamlined cell detection, more tests #182
* shorter constant names, missing isFormula() #182
* first batch of changes #182
* documentation #182
2017-05-01 12:09:24 +02:00
Adrien Loison
048105461c Fix shared strings XML Entities auto decode (#411)
When converting an XMLReader node to a SimpleXMLElement, the conversion would automatically decode the XML entities. This resulted in a double decode.
For example: """ was converted to """ when imported into a SimpleXMLElement and was again converted into " (quote).

This commit changes the way the XLSX Shared Strings file is processed. It also changes the unescaping logic for both XLSX and ODS.

Finally, it removes any usage of the SimpleXML library (yay!).
2017-04-28 02:27:33 +02:00
Adrien Loison
9f80ece73f Minor fixes for tests (#406) 2017-04-15 23:33:50 +02:00
Adrien Loison
4a65466b61 Prevent error when close() called while writer already closed (#402) 2017-03-28 15:07:48 +02:00
Adrien Loison
521f799366 [XLSX] A cell should not contain more than 32,767 characters (#365) 2016-11-29 15:43:38 -08:00
Adrien Loison
e276b4378e Fix crash when using associative array with empty row (#354) 2016-11-03 13:45:18 -07:00
Adrien Loison
179ab483d6 Empty rows do not need to be written for XLSX files (#336) 2016-10-17 11:40:52 -07:00
Adrien Loison
23f8cc4f05 Temp files should be deleted when an exception is thrown (#327)
If an exception is thrown while writing data, instead of letting the developer handle this situation gracefully, Spout can attempt to delete all the temporary files that were created so far, as well as the output file as it won't be completed and therefore corrupted.
2016-10-11 15:08:37 -07:00
Adrien Loison
3e0afd858f Apply custom style to empty cells if needed (#307)
Fixes #295

If a row should be written with a custom style, the handling of empty cells should change.
Instead of being skipped entirely, empty cells will be applied the custom style, if this style has custom background color or borders.
If not, then the cell definition can still be skipped.
2016-09-07 17:04:31 -07:00
madflow
277c353984 Fix #297 (#299) 2016-08-30 10:56:52 -07:00
madflow
ff2d54cc8d Fix #276, some general refinement (#289)
* Fix #276, some general refinement

* Failing test #267

* Fixed shared border definitions across different styles #267

* Fix finding the correct borderId
2016-08-23 19:57:57 -07:00
Adrien Loison
c94694cb60 API to set default row style (#290) 2016-08-16 21:18:44 -07:00
madflow
584121d478 Add background-color to styles (#211)
Removed default background color, cosmetics
Remove default background color
reuse bg colors
Cosmetics
Moved reusing fills to XLSX StyleHelper
Tests and inline doc
2016-08-10 13:11:47 -07:00
madflow
7a613eed8c Border ordering (#273)
* Fix #271

* Minor fix for quick copy+paste

* Added link to issue #271
2016-07-13 11:45:37 -07:00
madflow
e30bc37448 First stab at #135 - Add borders (#200)
Fixes #135

Added border support for ODS and XLSX files.
Updated README.
2016-06-18 23:36:10 -07:00