Commit Graph
100 Commits
Author SHA1 Message Date
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 ee998f7173 For PHP 7.1 for Composer
If local PHP is 7.2, we still want to download dependencies compatible with PHP 7.1
2019-01-04 19:24:28 +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 4d1d1c1e87 various improvements 2017-11-19 02:41:07 +01:00
Adrien Loison 102e17159c Make ODS reader return Row object 2017-11-19 01:36:18 +01:00
Adrien Loison 68a96367a8 Remove StyleMerger from RowManager 2017-11-18 21:19:31 +01:00
Adrien Loison 78b6639480 Make XLSX reader return Row objects 2017-11-18 20:53:22 +01:00
Adrien Loison a665b974fa Make CSV reader return Row objects 2017-11-18 19:08:27 +01:00
Adrien Loison 139f7fdfb3 Remove StyleMerger from Cell entity 2017-11-18 17:37:52 +01:00
Adrien Loison c826d15472 Fix charachters escaping with CSV reader/writer
PHP's built-in functions fputcsv and fgetcsv are not RFC-4180 compliant and include an escape character that's not defined in the spec.
This results in escaping characters that should not be escaped.
This commit disables this escaping mechanism.
2017-11-11 16:21:05 +01:00
Adrien Loison e2b519d6f9 Fetch XML file paths from Workbook Relationships 2017-11-11 15:25:12 +01:00
Adrien Loison 0c8a53c821 Fix isEmptyRow() check 2017-11-11 12:35:03 +01:00
Adrien Loison 5a470188a9 Merge remote-tracking branch 'origin/master' into develop_3.0 2017-11-11 12:20:28 +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 ddfa40e8b3 StyleMerger and RowManager changes
Move DI of StyleMerger to get rid of business logic in the entities Cell and Row
Simplify RowManager
2017-11-10 22:45:57 +01:00
Adrien Loison 111f82d35f Add tests for cell styling 2017-11-10 21:35:59 +01:00
Adrien Loison 8aec9ea992 Apply default row style in WorkbookManager
Instead of doing it in the Writer
2017-11-05 14:13:22 +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 2d2151ac8d Split Writer EntityFactory into interal and external ones 2017-11-05 13:04:03 +01:00
Adrien Loison ca5962271e Default row style should only apply to existing cells 2017-11-05 12:17:45 +01:00
Adrien Loison 727a90fd06 Remove @api annotation 2017-11-05 02:23:26 +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 fec27e9056 Update .php_cs.dist
Remove "void_return" rule
2017-11-04 16:43:36 +01:00
Adrien Loison c74c0d9127 Add support for 1904 dates
This commit adds support for dates using the 1904 calendar (starting 1904-01-01 00:00:00).
It also fixes some issues with the dates in 1900 calendar (which now correctly start at 1899-12-30 00:00:00).
Finally, it is now possible to have negative timestamps, representing dates before the base date (and up to 0000-01-01 00:00:00), as per the SpreadsheetML specs. Note that some versions of Excel don't support negative dates...
2017-11-04 16:33:46 +01:00
Adrien Loison e1ae3c8a81 Update php-cs config: increment_style 2017-11-04 13:32:22 +01:00
Adrien Loison 28c1bea28c Code style should not follow Yoda style 2017-10-04 00:53:05 +02: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 554ebf987b Setup PHP CS fixer
- Add PHP CS Fixer as a dev dependencies.
- Add PHP CS Fixer cache file to gitignore/gitattributes
- Add custom code style config
- Update TravisCI config to check code style
2017-09-06 00:33:43 +02:00
Adrien Loison 668c10a30d Introduce Managers for readers
Some helper classes were more managers than helpers...
2017-08-27 03:56:17 +02:00
Adrien Loison 61f2addefa Favor object creation in factories (#459)
Instead of passing factories in the constructors and let objects call the factory method, create all dependencies directly in the factories.
2017-08-27 02:40:39 +02:00
Adrien Loison 4ec3a21170 Random DI improvements (#458)
* Add random DI improvements

Fixing things that were previously missed

* Split InternalFactory into Manager and Helper factories
2017-08-27 01:44:20 +02:00
Adrien Loison b7e46740ce Refactor readers for better di (#457)
* Refactor readers to get a proper DI

Similar to what was done with writers, readers also needed to be updated to match the new way of doing things.
This commits promotes a better DI (factories, injection through constructors).

* Escapers should not be singletons

Instead, they should be proper object that can be injected where needed.
2017-08-27 00:01:17 +02:00
Adrien Loison fd6dd46b25 Update gitignore (#453) 2017-07-27 23:40:26 +02:00
Adrien Loison 6d44cd26cc Fix prefixed shared strings XML file (#450)
A prefixed sharedStrings.xml file was not properly read, as we were comparing the un-prefixed name with the possible prefixed name.
Also, this commit contains a fix for sheets with rows not starting at column A.
2017-07-25 14:16:22 +02:00
Adrien Loison ee5dee61c7 Fix HHVM jobs on Travis (#451) 2017-07-25 14:02:17 +02:00
Adrien Loison 40b4a57e6b Update README.md (#442) 2017-06-19 20:37:30 +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 30366e6a5d Inject ZipHelper through constructor (#437) 2017-05-30 15:19:05 +02:00
Adrien Loison 762dd1573a Inject GlobalFunctionsHelper through constructor for Writers (#436) 2017-05-30 14:37:38 +02:00
Adrien Loison 7ec0f565fd Rename SharedStringsHelper to SharedStringsManager (#435) 2017-05-30 14:11:18 +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 878c4a9c8b Rename Factory folder to Creator (#430) 2017-05-29 23:10:24 +02:00
Adrien Loison cebffbe80c Move Cell and Options to Entity folder (#429) 2017-05-29 22:51:12 +02:00
Adrien Loison 69b091b37c Move OptionManager from Common/Manager to Manager (#428) 2017-05-29 22:34:25 +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
Adrien Loison 99816b0b8e Use openFileInZip() only (#421) 2017-05-22 14:39:26 +02:00
Adrien Loison 80553c6c52 Bump min PHP version to 5.6 (#415) 2017-05-05 15:14:47 +02:00
Adrien Loison 606103f7fc Move all documentation to Spout's website (#413)
The README became really long. All the documentation (README + Wiki) has been moved to a custom website: http://opensource.box.com/spout/.
It is now possible to remove all the duplicate content from the README.
2017-05-02 14:47:00 +02:00
Adrien Loison 4e6db6a8a1 Update copyright year (#412) 2017-04-28 11:17:41 +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 1eb01a3d2a Use constants instead of arbitrary strings in SheetHelper (#407) 2017-04-15 23:52:48 +02:00
Adrien Loison 9f80ece73f Minor fixes for tests (#406) 2017-04-15 23:33:50 +02:00
Adrien Loison 7f8b95b2f3 Expose Sheet::isActive() to provide info about the last active sheet (#405) 2017-04-15 21:40:19 +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 742780613a Do not add space between text nodes (#401) 2017-03-28 14:36:15 +02:00
Adrien Loison 3128f86769 Remove max line length when reading CSV files (#399) 2017-03-28 13:55:06 +02:00
Adrien Loison d898f91917 Update README.md (#398) 2017-03-27 18:28:12 +02:00
Adrien Loison 33c9d2f2ed Enforce sheet name uniqueness per workbook (#397)
Instead of across all workbooks (in case of multiple spreadsheets being created at the same time).
2017-03-27 17:58:06 +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 984c9c1f67 Improve error message when invalid sheet name set (#364)
Instead of listing all the requirements, only list the requirements that actually failed to be met.
2016-11-29 14:36:57 -08:00
Adrien Loison e255895cff Refactor ODS escaper (#363) 2016-11-28 17:03:13 -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 9ce77405e0 Refactor Style::mergeWith() and StyleHelper::getStyleSectionContent() (#346) 2016-10-19 17:01:19 -07:00
Adrien Loison 4cb30bc36d Add Scrutinizer Code Quality badge (#345) 2016-10-18 20:29:33 -07:00
Adrien Loison bf616dee90 Bump dev-master version (#344) 2016-10-18 20:03:15 -07:00
Adrien Loison 3a330debb3 Move ReaderCommonOptions class to Common folder (#343) 2016-10-18 16:55:05 -07:00
Adrien Loison a19231fb68 Introduce XMLProcessor to reduce ODS,XLSX readers' complexity (#342) 2016-10-18 16:28:26 -07:00
Adrien Loison 73d5d0ea17 Remove text suffix in XLSX date formats (#341)
Some date formats have a text suffix, e.g. "mm/dd/yy;@". We should remove the ";...@" part.
2016-10-18 11:55:36 -07:00
Adrien Loison 687c321363 Refactor SharedStringsHelper::extractSharedStrings (#340) 2016-10-18 00:03:15 -07:00
Adrien Loison 2fa01cd838 Remove unused SimpleXMLElement::children() method (#339) 2016-10-17 22:49:37 -07:00
Adrien Loison 752f4bf64e Add ReaderOptions for all readers (#338)
Instead of passing every single option down the chain
2016-10-17 22:41:36 -07:00
Adrien Loison b61323d7d2 Remove XLSX references in ODS Writer (#337) 2016-10-17 11:54:49 -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 2fafb63115 ODS Reader should support num-rows-repeated for non empty rows (#335) 2016-10-17 10:51:12 -07:00
Adrien Loison 5ef5647558 Make getConcreteSheetIterator() protected (#334) 2016-10-17 10:26:37 -07:00
Adrien Loison 0978d340f0 Option to keep empty rows (#331)
* Add option to preserve empty rows when reading an XLSX file
* Add option to preserve empty rows when reading a CSV file
* Add option to preserve empty rows when reading an ODS file
2016-10-17 10:20:02 -07:00
Adrien Loison 77178122c3 Fix output file deletion after exception thrown on write (#328)
For relative paths, it would not work as the FileSystemHelper would not allow deleting a file that's not part of its base folder.
2016-10-12 11:15:07 -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 442a9837f1 Removing license badge (#320)
As Github now provides this information in the project's header
2016-09-30 10:11:05 -07:00
Adrien Loison cc07072cbb Better support for Date custom format (#316)
- To determine if a style should apply a date format, the presence of "applyNumberFormat" attribute on the "cellXfs" section of styles.xml is now optional. We only look at the "numFmtId" attribute (but early return if "applyNumberFormat" is set to "0").
- The format code can contain lowercase AND now uppercase characters as its pattern.
- "General" format code used as a custom format is now supported. It seems to be used by a bunch of programs...
2016-09-24 10:46:42 -07:00
Adrien Loison a07a96f523 Bump dev-master version (#309)
Bump to `2.7.x-dev` as 2.6.0 just got released
2016-09-08 09:34:43 -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
Adrien Loison d4e57b1f0d Add consistency using getCellXML() (#306) 2016-09-06 19:47:18 -07:00
Adrien Loison 435a9a016e Improve XLSX Escaper performance (#305) 2016-09-03 11:04:25 -07:00
Adrien Loison c94694cb60 API to set default row style (#290) 2016-08-16 21:18:44 -07:00
Adrien Loison b2dc0c3fa9 Fix tests on Windows (#288) 2016-08-10 12:09:37 -07:00
Adrien Loison 7f65993c87 Spout should be able to read prefixed styles.xml (#287) 2016-08-09 20:53:40 -07:00
Adrien Loison b75a3e34fc XLSX cells containing date values should respect shouldFormatDate option (#282)
Return the ISO 8601 date string directly if option is set
2016-07-20 20:12:00 -07:00
Adrien Loison 82605ab57b Do not return anything from constructor (#275) 2016-07-14 10:53:44 -07:00
Adrien Loison 54a1a09e29 Bump dev-master version (#270) 2016-07-11 20:07:56 +02:00
Adrien Loison a8eb7ad39c Shared strings table without uniqueCount and count should work (#269)
Use file based strategy in this case
2016-07-11 19:03:37 +02:00
Adrien Loison ffea8871a6 Add support for missing cell reference (#268)
When describing a cell, the cell reference (r="A1") is optional.
When not present, we should just increment the index of the last processed row.
2016-07-11 18:15:55 +02:00
Adrien Loison 192659cb24 Update README.md (#256) 2016-06-19 20:20:49 -07:00
Adrien Loison 1891c0b053 Fix XLSX reading when shared strings is missing the uniqueCount attribute (#255)
Use "count" attribute as a fallback
2016-06-16 10:06:11 -07:00