Compare commits

...

562 commits

Author SHA1 Message Date
Vitaliy Chesnokov
e31d0fa339
Fix switch...continue for php 7.3 2019-07-22 13:03:57 +03:00
Adrien Crivelli
39534e3dd3
Permanently archive the project
The project is dead and should not be used anymore.
2019-01-02 12:38:47 +11:00
Adrien Crivelli
c269793ee7
PHPExcel is deprecated 2017-12-25 11:39:38 +09:00
Adrien Crivelli
185bf41233 Fix typo in bug number 2017-03-02 09:38:00 +09:00
Adrien Crivelli
afb11493d0
Mentions incompatiblity with PHP 5.6.29 and SQLite3
Fixes #1085
Closes #1122
2017-02-14 14:33:15 +09:00
Adrien Crivelli
12f91aa295 Point contributors to PhpSpreadsheet 2016-10-03 19:33:09 +09:00
MarkBaker
d3373c97e1 Fix old reference to _sheetIndex in HTML Writer 2016-09-29 21:13:14 +01:00
MarkBaker
1c8c2379cc Fix to Radar and Scatter chart examples 2016-08-13 12:16:51 +01:00
MarkBaker
900325d0c8 Minor updates to composer 2016-08-04 23:55:21 +01:00
MarkBaker
e487f5c11a Fix for multiple worksheets, all with merge cells, in HTML Writer 2016-07-14 23:05:28 +01:00
MarkBaker
fcc5c65855 Fix to 01simple.php example after mis-commit 2016-06-05 16:48:23 +01:00
MarkBaker
650d2d099c Merge branch 'develop' into 1.8 2016-06-05 16:46:46 +01:00
MarkBaker
b2029564e5 Fix for XML settings, together with unit tests 2016-06-05 16:45:50 +01:00
Progi1984
b0ce48fd92 Merge pull request #895 from psirus0588/patch-1
Update 01-Getting-Started.md
2016-05-11 16:18:17 +02:00
psirus0588
772e66f74a Update 01-Getting-Started.md
delete fake url
2016-05-11 12:44:28 +03:00
MarkBaker
8af620f97b GH-879 Bug in file PHPExcel/Reader/CSV.php
Code logic identifying a defined separator when no separator is explicitly defined
Case-insensitive check when separator is explicitly defined
2016-04-14 23:19:40 +01:00
MarkBaker
c4782b6606 General: (sim642) Pull Request 489 - Implement actual timezone adjustment into PHPExcel_Shared_Date::PHPToExcel 2016-03-31 23:50:44 +01:00
MarkBaker
a1dee8f6c3 Bugfix: (vitalyrepin) Pull Request 869 - c:max and c:min elements shall NOT be inside c:orientation elements 2016-03-31 23:25:30 +01:00
Mark Baker
1a237573f9 Merge pull request #869 from vitalyrepin/1.8
Bug fix: c:max and c:min elements shall NOT be inside c:orientation elements
2016-03-31 22:33:59 +01:00
Vitaly Repin
44918984a1 Bug fix: c:max and c:min elements must not be inside c:orientation elements. They shall be inside c:scaling elements. Otherwise they are ignored by Excel and Libreoffice 2016-03-24 00:45:27 +02:00
MarkBaker
7fa160905b General: (rentalhost) Work Item GH-575 - Excel 2007 Reader freezes because of conditional formatting 2016-03-22 13:35:28 +00:00
MarkBaker
79f95213e0 Detect the presence of a sep=; line in CSV imports, and set the delimiter accordingly 2016-03-17 22:52:07 +00:00
MarkBaker
a806b79aba Allow inclusion of a sep=; line when creating csv files 2016-03-17 22:39:58 +00:00
MarkBaker
7d1c140974 Data validation example limiting the length of text that can be entered in a cell 2016-03-15 11:48:49 +00:00
MarkBaker
5e89b26e9d Testing pre-commit hook for lint checking 2016-03-07 11:50:12 +00:00
MarkBaker
1b6ed6b9c6 Testing pre-commit syntax check 2016-03-07 11:37:40 +00:00
MarkBaker
6fe91ac86a git hooks syntax error test 2016-03-07 11:36:29 +00:00
MarkBaker
d3fd1508a1 Testing pre-commit hook for lint check of PHP syntax 2016-03-07 10:03:52 +00:00
MarkBaker
bf2b74b57e Fix missing ; in last commit 2016-03-07 07:59:19 +00:00
MarkBaker
802a94fc5d Allow formatted strings as argument in PHPToExcel date conversion 2016-03-06 23:25:13 +00:00
MarkBaker
da91993df0 Minor fixes to documentation 2016-03-06 23:23:39 +00:00
MarkBaker
39d8b8f57a Feature: (Tomino2112) Work Item GH-808 - MemoryDrawing not working in HTML writer
Manual merge of Pull Request
2016-03-01 23:15:49 +00:00
MarkBaker
352e6ea5cc Allow HYPERLINK() function to set the tooltip, and add extra examples of setting hyperlinks either through PHPExcel methods or using the HYPERLINK() function 2016-03-01 12:34:05 +00:00
MarkBaker
6a3dd85f6f Docblock fix 2016-02-29 09:32:34 +00:00
MarkBaker
19d7849bd1 Fix reference for gd in composer 2016-02-09 15:27:30 +00:00
MarkBaker
36d2ba12e3 Added worksheet info example 2016-01-25 19:04:40 +00:00
MarkBaker
144f57e44a modify export ignores 2016-01-15 01:19:58 +00:00
MarkBaker
6ae1056fb2 Minor bugfixes and documentation changes 2016-01-13 22:38:20 +00:00
MarkBaker
f29b05b473 Merge branch '1.8' of https://github.com/PHPOffice/PHPExcel into 1.8 2016-01-01 16:42:05 +00:00
MarkBaker
e6ded71172 Fix default style for Fill Pattern 2016-01-01 16:41:35 +00:00
Mark Baker
de3aaa3726 Merge pull request #779 from dedulay/patch-1
Refactor code
2015-12-31 23:22:50 +00:00
dedulay
2221c5ed12 Refactor code
PHPExcel/Helper/HTML.php:769:Parse error - syntax error, unexpected '[', expecting ')'
2015-12-31 10:52:57 +03:00
MarkBaker
a27e053354 Refactor mappers out from Excel5 Reader completely 2015-12-31 00:16:34 +00:00
MarkBaker
dbb819003c More refactoring of Excel5 Reader mappings 2015-12-30 20:01:29 +00:00
MarkBaker
e11a76759f Update Travis configuration 2015-12-30 11:15:21 +00:00
MarkBaker
2743dc4acf Short array syntax in XEE Validator tests 2015-12-30 11:05:36 +00:00
MarkBaker
6d3a440aae Refactor colour mapping for Excel5 Reader 2015-12-30 02:17:40 +00:00
MarkBaker
2058c8468a Start work on implementing an option to ignore "empty" cells when reading a file 2015-12-30 00:24:36 +00:00
MarkBaker
7eb10adb3b Modify getCell() methods to allow creating a new cell if the selected cell doesn't exist as an option 2015-12-28 23:26:15 +00:00
MarkBaker
6f43f0429b Minor tweaks 2015-12-06 16:04:32 +00:00
MarkBaker
65310d164c Change PCLZip constructor name to __construct ready for PHP7 2015-11-27 01:02:37 +00:00
MarkBaker
ecdb406d4d A mass of small changes including
* Implementation of the Excel SUMIFS function
 * Fixes for Readers to handle various malformed spreadsheet file formats
 * Better error handling in Iterators
 * Suppression of Chart formula evaluation on save if formula evaluation is disabled
 * Changes for PHP7
 * Hopefully fixed a memory issue with unsetting PHPExcel object failing to unset the calculation engine
2015-11-15 18:04:45 +00:00
MarkBaker
6a8fca703c Fix to MEDIAN() function 2015-10-28 00:47:01 +00:00
MarkBaker
ba04463cc9 Remove savedPrecision from Calculation Engine 2015-10-15 23:07:22 +01:00
MarkBaker
cd151ae2e4 Fix for problem with xlsx files overriding the reserved number format codes below 164 with custom codes 2015-10-14 23:23:19 +01:00
MarkBaker
681c30b2ea Merge branch '1.8' of https://github.com/PHPOffice/PHPExcel into 1.8 2015-09-18 00:05:21 +01:00
MarkBaker
49d123e910 Fix to allow calculate formula against a workbook, without passing in a cell 2015-09-17 23:56:41 +01:00
Mark Baker
875f92dac9 Merge pull request #658 from stchr/1.8
Exclude /Examples and /unitTests from export. Not needed for production
2015-09-14 23:49:05 +01:00
Mark Baker
f6a2107856 Merge pull request #665 from Canta/patch-1
Fix for #633
2015-09-14 23:01:01 +01:00
MarkBaker
e7c7a6eb53 Merge branch '1.8' of https://github.com/PHPOffice/PHPExcel into 1.8 2015-09-14 22:56:11 +01:00
MarkBaker
54738ea3db mbstring in composer 2015-09-14 22:55:58 +01:00
Mark Baker
bf3e07e810 Merge pull request #666 from thefuzzy0ne/doc-fix
Fix typo.
2015-09-14 22:50:21 +01:00
Mark Baker
e878104849 Merge pull request #673 from valioDOTch/patch-2
Clarification on the license
2015-09-14 22:47:24 +01:00
Pat Mächler
78df8592e5 Clarification on the license
for details refer to https://github.com/PHPOffice/PHPExcel/pull/672
2015-09-14 15:57:45 +02:00
Darren Benney
bc29a1c38a Fix typo.
Docs referenced IReader class incorrectly.
2015-09-09 15:30:00 +01:00
Daniel Cantarín
889b0a4b3e Fix for #633
A typo in css syntax had nasty effects in exports.
2015-09-08 14:47:25 -03:00
stchr
18c6b498f8 Exclude /Examples and /unitTests from export. Not needed for production 2015-09-03 15:41:46 +02:00
MarkBaker
6eae139301 We shouldn't override any of the built-in MS Excel values (values below id 164)
But there's a lot of naughty homebrew xlsx writers that do use "reserved" id values that aren't actually used
So we make allowance for them rather than lose formatting masks
2015-08-14 19:50:24 +01:00
MarkBaker
663d942205 Fix to HTML generation with charts that fall outside of the main data area, and fix to show trailing / in folders for the jpgraph in examples 2015-08-03 19:40:16 +01:00
MarkBaker
8f7c2fd464 Additional work on number format masks 2015-08-03 00:33:29 +01:00
MarkBaker
941ab7d739 Handle some discrepancies between the ECMA standard and actual internal number formats used by MS Excel 2015-08-02 00:40:16 +01:00
MarkBaker
87ba429020 Improved masking for number format handling, particularly for datetime masks 2015-08-01 00:37:05 +01:00
MarkBaker
36eef2f163 New example to demonstrate merging two spreadsheet files into a single file 2015-07-16 22:29:15 +01:00
MarkBaker
1e4988e12c Case-sensitivity 2015-07-15 23:22:11 +01:00
MarkBaker
78378f1c88 GH-554 - Whitespace after toRichTextObject() - abide by coding standards 2015-07-12 23:25:34 +01:00
MarkBaker
879f86c235 GH-554 - Whitespace after toRichTextObject() 2015-07-12 23:16:41 +01:00
MarkBaker
7ced78b0be gitter link 2015-05-26 21:35:53 +01:00
MarkBaker
77cc77209b Minor performance tweak to OfficeOpenXML and BIFF Readers 2015-05-26 15:50:44 +01:00
MarkBaker
891478f6ab Updated Readme 2015-05-24 14:53:48 +01:00
MarkBaker
4f6d009ba5 Merge branch 'psr2' into develop 2015-05-24 14:16:04 +01:00
MarkBaker
3092adbb18 Minor fixes and docblock changes 2015-05-24 14:15:39 +01:00
MarkBaker
5bb69032b8 Merge branch 'psr2' into develop 2015-05-24 12:43:35 +01:00
MarkBaker
5f73ef34d3 Docblock fixes from long to integer 2015-05-24 12:43:08 +01:00
MarkBaker
e4d29824a6 General: (umpirsky) Work Item GH-548 - Optimize vlookup() sort 2015-05-24 12:32:24 +01:00
MarkBaker
1ba2ae0cec Bugfix: (ncrypthic) Work Item GH-570 - Ignore inlineStr type if formula element exists 2015-05-24 12:27:36 +01:00
MarkBaker
0f427685bd Merge branch 'psr2' into develop 2015-05-24 01:18:11 +01:00
MarkBaker
99b375613d PSR-2 coding standards for trendclass.... this really does want factoring out into a separate repo 2015-05-24 01:17:43 +01:00
MarkBaker
beec8f167a Merge branch 'psr2' into develop 2015-05-23 23:42:05 +01:00
MarkBaker
003c259801 Modifying a few constants to psr-2 standards 2015-05-23 23:41:38 +01:00
MarkBaker
217ef4297c Merge branch 'psr2' into develop 2015-05-23 18:37:44 +01:00
MarkBaker
98a087afb4 This should be the last of the writer changes for psr-2, leaving just trendlines before we've done as much as we can without breaking backward compatibility 2015-05-23 18:37:11 +01:00
MarkBaker
8f1be4f4de Merge branch 'psr2' into develop 2015-05-22 23:58:21 +01:00
MarkBaker
44f049a0a5 Fix to short array reference in tests for PHP < 5.4 2015-05-22 23:57:51 +01:00
MarkBaker
4c0434d608 Merge branch 'psr2' into develop 2015-05-22 23:32:07 +01:00
MarkBaker
e0cefe3360 Another big chunk of psr-2 2015-05-22 23:31:23 +01:00
MarkBaker
8e977aee29 Merge branch 'psr2' into develop 2015-05-22 08:04:09 +01:00
MarkBaker
3dcdba0c67 Another big blast of psr-2 changes. Getting close to the finishing line now 2015-05-22 08:03:34 +01:00
MarkBaker
8026fce4b6 Merge branch 'psr2' into develop 2015-05-20 23:55:46 +01:00
MarkBaker
85692956a7 Close to the end of the psr-2 work, just trends to go 2015-05-20 23:55:01 +01:00
MarkBaker
547d495247 Merge branch 'psr2' into develop 2015-05-20 23:20:16 +01:00
MarkBaker
c4ff34dde4 Yet more chunks of psr-2 goodness 2015-05-20 23:19:33 +01:00
MarkBaker
17c644bef6 Merge branch 'psr2' into develop 2015-05-20 19:18:12 +01:00
MarkBaker
0c177b5ea2 We modified another block of files to psr-2, and their jaws dropped when they saw what happened next 2015-05-20 19:17:17 +01:00
MarkBaker
b394056b56 Merge branch 'psr2' into develop 2015-05-20 00:21:04 +01:00
MarkBaker
7cd731e416 Feels like all the psr-2 work is finally entering its final lap.... of course, that's only step #1 in the grand roadmap, but it's a start 2015-05-20 00:20:20 +01:00
MarkBaker
f94dcb9852 Merge branch 'psr2' into develop 2015-05-18 18:57:39 +01:00
MarkBaker
4648e386f5 Getting close to the end of all this psr-2 goodness now, and beginning to think about splitting to a 1.8 branch and a 1.9 branch, with the 1.9 branch having a minimum PHP version of 5.4, so we can begin improving the code, starting with namespacing and a simple bootstrap for those who don't use composer 2015-05-18 16:39:04 +01:00
Progi1984
066a85d3d2 PSR2 Fixes 2015-05-17 20:00:00 +02:00
Progi1984
004d411772 PSR2 Fixes 2015-05-17 19:33:14 +02:00
Progi1984
004936e35a PSR2 Fixes 2015-05-17 19:26:34 +02:00
Progi1984
b6bc0db105 PSR2 Fixes 2015-05-17 18:34:30 +02:00
Progi1984
576effef30 PSR2 Fixes 2015-05-17 18:10:35 +02:00
Progi1984
09352e3e80 PSR2 Fixes 2015-05-17 15:00:02 +02:00
Progi1984
1d842ed218 PSR2 Fixes 2015-05-17 14:16:53 +02:00
Progi1984
4d65197b03 Merge branch 'psr2' of https://github.com/PHPOffice/PHPExcel into psr2 2015-05-17 12:12:10 +02:00
Progi1984
6b1764f771 PSR2 Fixes 2015-05-17 12:11:56 +02:00
MarkBaker
b531fd487e Merge branch 'psr2' of https://github.com/PHPOffice/PHPExcel into psr2 2015-05-17 10:23:26 +01:00
MarkBaker
f0fdc9430b More PSR-2 work, and eliminate duplicate code in Row/Column dimensions by extension of an abstract Dimension class containing common code/properties 2015-05-17 10:22:51 +01:00
Progi1984
9140e3da2e PSR2 Fixes 2015-05-17 11:22:28 +02:00
MarkBaker
4a6686e2dd Merge branch 'psr2' into develop 2015-05-17 00:48:21 +01:00
MarkBaker
334747867d Merge branch 'psr2' of https://github.com/PHPOffice/PHPExcel into psr2
Conflicts:
	Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php
2015-05-17 00:47:17 +01:00
MarkBaker
1663ef141c More psr-2 changes 2015-05-17 00:16:41 +01:00
MarkBaker
61e81377cb Yet more of the psr-2 work 2015-05-16 23:18:40 +01:00
Progi1984
082fb1b475 PSR2 Fixes 2015-05-16 23:09:31 +02:00
Progi1984
f827a25af2 PSR2 Fixes 2015-05-16 19:00:31 +02:00
Progi1984
1bf5ea414b PSR2 Fixes 2015-05-16 13:04:38 +02:00
MarkBaker
2af5e55f2c Merge branch 'psr2' into develop 2015-05-15 23:42:53 +01:00
MarkBaker
4c8dd00dff More psr-2 goodness 2015-05-15 23:41:50 +01:00
Progi1984
121eccd4c8 PSR-2 : Fixes 2015-05-15 13:36:15 +02:00
Progi1984
5508013569 PSR-2 : Fixes 2015-05-15 13:17:40 +02:00
Progi1984
96f3d0e6ee PSR-2 : Fixes 2015-05-15 12:55:10 +02:00
MarkBaker
e18ba38f16 More psr-2 for charts 2015-05-15 09:11:18 +01:00
MarkBaker
1c26425915 Merge branch 'psr2' into develop 2015-05-14 23:51:30 +01:00
MarkBaker
66169af898 PSR-2 coding standards for the charting 2015-05-14 23:50:28 +01:00
MarkBaker
7d9f45c176 Merge branch 'psr2' of https://github.com/PHPOffice/PHPExcel into psr2
Conflicts:
	Classes/PHPExcel/Calculation.php
	Classes/PHPExcel/Cell.php
2015-05-13 17:02:34 +01:00
MarkBaker
feac76dadf We changed the coding standard to PSR-2, and wow! What happened next was awesome 2015-05-13 17:00:22 +01:00
Progi1984
141a61a908 PSR-2 : Fixes 2015-05-13 13:36:53 +02:00
Progi1984
7d086fdbee PSR-2 : Fixes 2015-05-13 13:15:55 +02:00
Progi1984
2881bca443 PSR-2 : Fixes 2015-05-13 12:27:01 +02:00
MarkBaker
06c1ea78de PSR-2 goodness 2015-05-13 08:32:01 +01:00
Progi1984
d85222b45a PSR2 : Improve Travis Test 2015-05-13 08:02:23 +02:00
Progi1984
e018257896 PSR2 : Improve Travis Test 2015-05-13 08:02:03 +02:00
MarkBaker
b057a52377 Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into develop
Conflicts:
	.travis.yml
	composer.json
2015-05-13 01:35:34 +01:00
MarkBaker
4a977f1848 Fixed merge errors 2015-05-13 01:29:12 +01:00
MarkBaker
99b0beb721 Merge branch 'psr2' of https://github.com/PHPOffice/PHPExcel into psr2
Conflicts:
	Classes/PHPExcel/Calculation.php
	Classes/PHPExcel/Shared/CodePage.php
	Classes/PHPExcel/Shared/Date.php
	Classes/PHPExcel/Shared/ZipArchive.php
2015-05-13 00:45:56 +01:00
MarkBaker
f7296f58b4 More PSR-2 goodness.... getting there slowly 2015-05-13 00:40:55 +01:00
Progi1984
f37630e938 PSR-2 : Fixes 2015-05-12 17:57:29 +02:00
Progi1984
5bb747f8cc PSR-2 : Fixes 2015-05-12 14:01:22 +02:00
Progi1984
2896d62e08 PSR-2 : Improve Travis CI Report 2015-05-12 13:45:25 +02:00
Progi1984
6850d8a29d PSR-2 : Improve Travis CI Report 2015-05-12 13:36:33 +02:00
Progi1984
d019ce5956 PSR-2 : Improve Travis CI Report 2015-05-12 13:30:05 +02:00
Progi1984
661ff77749 Validation PSR-2 : Fixes 2015-05-12 13:17:41 +02:00
Progi1984
95b3fb024a Validation PSR-2 : Fixes 2015-05-12 12:43:52 +02:00
Progi1984
61b5fa0beb Validation PSR-2 : Tabs to spaces 2015-05-12 11:22:06 +02:00
MarkBaker
a86cbaa230 Merge branch 'psr2' of https://github.com/PHPOffice/PHPExcel into psr2 2015-05-12 08:01:33 +01:00
MarkBaker
0d855d0627 More PSR-2 changes 2015-05-12 08:00:59 +01:00
Progi1984
986b20bbb1 Travis CI : Support for PSR-2 test 2015-05-12 08:02:56 +02:00
MarkBaker
c70e289dac More efforts to get codebase to conform with PSR-2 coding standards 2015-05-11 22:38:52 +01:00
Progi1984
bb13357dcb Travis CI : Support for PSR-2 test 2015-05-11 12:58:26 +02:00
Progi1984
46dfaa9f8a Travis CI : Support for PSR-2 test 2015-05-11 12:30:47 +02:00
MarkBaker
547d2bd3b2 More PSR-2 2015-05-11 01:31:26 +01:00
MarkBaker
1efa7e8533 More PSR-2 adjustments 2015-05-10 23:25:04 +01:00
MarkBaker
c07b54172a More PSR-2 modifications 2015-05-09 14:33:20 +01:00
MarkBaker
b8f67c6f4d More PSR-2 changes, and fixes for a couple of breakages introduced by the last commit 2015-05-08 01:09:27 +01:00
MarkBaker
4f8c9bfc96 More PSR-2 work 2015-05-07 01:14:36 +01:00
MarkBaker
3c3154c4a3 PSR-2 variable naming for caching classes, remove leading underscores 2015-05-05 19:40:34 +01:00
MarkBaker
e885ef9196 Fix typo in memcache constructor 2015-05-05 01:37:34 +01:00
MarkBaker
b88a6f4947 Calculation example with cyclic formula 2015-05-04 23:41:52 +01:00
MarkBaker
b3d2db79ea Minor case-sensitivity bugfix to getCell when cell reference is a worksheet!cell
Work on PSR2 Coding standards
2015-05-04 23:36:20 +01:00
MarkBaker
e83c359c7c Move toward PSR-2 coding standards 2015-05-03 23:37:32 +01:00
MarkBaker
fca778225c Ajust copyright to 2015 2015-05-02 23:50:37 +01:00
MarkBaker
c9cb4d4286 Abstract function PHPExcel_Worksheet_CellIterator::adjustForExistingOnlyRange() cannot contain body 2015-05-01 08:06:07 +01:00
MarkBaker
2b6380693d change log 2015-04-30 23:54:21 +01:00
MarkBaker
7ccb90064b Rework of Iterators for existing cells only 2015-04-30 19:07:49 +01:00
MarkBaker
75bb9d7eda Fix regexp for XEE validation 2015-04-29 22:41:54 +01:00
MarkBaker
bc7028ae4e Modified XEE security scan to handle UTF-16 charset, and added unit tests for the security scan 2015-04-29 22:23:14 +01:00
MarkBaker
0ab614fd95 Security: XML filescan in XML-based Readers to prevent XML Entity Expansion (XEE)
(see http://projects.webappsec.org/w/page/13247002/XML%20Entity%20Expansion for an explanation of XEE injection) attacks
2015-04-29 00:43:04 +01:00
MarkBaker
72f3a3b6f4 Fix unit test for iterator 2015-04-27 23:07:30 +01:00
MarkBaker
f317842e2b Unit tests for row and column iterators 2015-04-27 22:47:47 +01:00
MarkBaker
d2b0ef2ad9 Pass arguments from Row to RowCellIterator and from Column to ColumnCellIterator 2015-04-26 17:37:48 +01:00
MarkBaker
ceddc13f82 Implement a ColumnIterator, refactoring of RowIterator
Currently this disables the setIterateOnlyExistingCells option

TODO Re-Implement setIterateOnlyExistingCells logic with the new structure
TODO Rationalise and abstract common methods in the iterator classes
2015-04-26 13:00:58 +01:00
MarkBaker
f96d9cedba Added RowIterator support for end row, and throws exceptions for invalid arguments 2015-04-25 21:49:30 +01:00
MarkBaker
a287bd44df Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into develop 2015-04-16 01:10:04 +01:00
MarkBaker
61f5baac4a GH-543 - Datetime at DefaultValueBinder
Personally, I don't call it a bug if people pass invalid arguments and it complains with an exception; but I've made some basic changes to support DateTime objects and objects with a __toString() method... Any other objects will throw a catchable fatal error, and it's up to user code to implement any exception handler to convert it to an exception and handle it
2015-04-16 01:09:29 +01:00
Mark Baker
37d9e6e256 Merge pull request #542 from jarederaj/patch-1
Update CacheBase.php to prevent fatal error
2015-04-09 21:58:50 +01:00
Jared Hall
2736af7994 Update CacheBase.php to prevent fatal error
When deleteCacheData() is called it will throw a fatal error if the _currentObject is null.
2015-04-09 14:46:42 -06:00
MarkBaker
eedcc49f81 Minor documentation fix 2015-04-08 17:27:14 +01:00
MarkBaker
caad6b1956 Minor bugfixes for date/time edge cases 2015-03-28 17:45:49 +00:00
MarkBaker
d9cda3f287 Unit tests for default value binder 2015-03-27 21:28:26 +00:00
MarkBaker
c5a117c82a Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into develop 2015-03-26 23:26:04 +00:00
MarkBaker
d44aebc0a4 Improve default value binder handling of string/numeric values
- Modified regexp to handle scientific notation and apply appropriate tests rather than drop through to string
 - modified handler to detect integers too long for PHP, and treat as string rather than convert to float
2015-03-26 23:25:24 +00:00
Mark Baker
929add1e36 Merge pull request #512 from andrey-yantsen/patch-1
Check for variable before using it
2015-03-19 09:43:11 +00:00
MarkBaker
78c2f23621 Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into develop 2015-03-09 23:59:39 +00:00
MarkBaker
d3148bdcdb Minor bugfixes 2015-03-09 23:59:13 +00:00
Mark Baker
43595b7c15 Merge pull request #527 from TouPye/develop
Set default plotDirection
2015-03-09 23:46:36 +00:00
Pierre Skowron
412a2520cd Set default plotDirection 2015-03-09 14:17:28 +01:00
MarkBaker
de9fc7b888 Update latest bugfix details in changelog 2015-03-04 23:37:52 +00:00
MarkBaker
a95e3f6607 Bugfix: Remove cells cleanly when calling RemoveRow() or RemoveColumn() 2015-03-04 23:36:38 +00:00
MarkBaker
538fbcd2e8 Additional regexp handling for UTF-8 strings 2015-02-15 00:01:01 +00:00
MarkBaker
518fbc1d36 GH-514 HTML Reader incorrectly converts some UTF-8 string cells to FALSE after regexp space trim 2015-02-14 23:52:57 +00:00
Andrey Yantsen
26e75b1f7a Check for variable before using it
In some cases $xfrm is empty SimpleXmlElement, so we should check for it before using $xfrm->ext->attributes()
2015-02-10 09:44:13 +03:00
MarkBaker
31aa953c0b Remove trailing white space from PCLZip 2015-02-04 15:41:59 +00:00
MarkBaker
391d7cbd9d Fix use of < and > (by escaping) in documentation for createSheet() 2015-02-02 16:45:59 +00:00
MarkBaker
71dba49fff Improvements to array arithmetic (MMULT)
Better setup of calculation function tests to ensure consistent environment
2015-01-23 23:44:32 +00:00
MarkBaker
b3c5e98022 I shouldn't modify compatibility mode in calculation tests without resetting it
TODO - should include setting/resetting this in all setup/teardown
2015-01-23 17:06:30 +00:00
MarkBaker
976e7f064a Excel TRIM function only trims spaces, not tabs or other spacing characters 2015-01-23 16:49:20 +00:00
MarkBaker
fb18b7b598 Fix to complex number format signing when mask has a decimal 2015-01-23 16:09:36 +00:00
MarkBaker
d778b41524 Fix to negative number handling with complex number format masks, so that the sign only appears once 2015-01-23 15:40:54 +00:00
MarkBaker
dc137c293a Method for reversing the case of a string, for use in comparisons where lower-case/upper-case is reversed 2015-01-18 12:31:18 +00:00
MarkBaker
c089cfd53f Modify numeric comparisons in calculation engine to make allowance for floating point imprecision 2015-01-17 22:51:48 +00:00
MarkBaker
16f2eb63a1 Additional examples for HTML to Rich Text helper (superscript and subscript) 2015-01-13 23:44:38 +00:00
MarkBaker
98f4754048 GH-496 - Error for superscript handling in HTML to Rich Text helper 2015-01-13 18:47:29 +00:00
MarkBaker
c7da475ef9 Inline styles for HTML not yet implemented 2015-01-12 23:18:46 +00:00
MarkBaker
5e24bcfedc Fix to getCellStyleXfByHashCode() method 2015-01-08 01:23:11 +00:00
MarkBaker
41d970f125 Force uppercase for cell address arguments 2015-01-07 22:36:19 +00:00
MarkBaker
ee309f6e93 Fix initialisation of html to Rich Text helper, and provide additional examples 2014-12-28 19:08:33 +00:00
MarkBaker
7a45239672 Added password-protected worksheet and richtext examples to runall 2014-12-27 23:58:57 +00:00
MarkBaker
0f146e4f31 Feature: Helper to convert basic HTML markup to a Rich Text object 2014-12-27 23:48:24 +00:00
MarkBaker
c40bb233bf Remove spurious file 2014-12-18 21:56:47 +00:00
MarkBaker
180ad168cb Additional minor tweaks to HTML reader for merged cells 2014-12-07 23:45:15 +00:00
MarkBaker
d7ea3e2ab0 Feature: (cifren/MBaker) Work Item GH-205 - Handling merge cells in HTML Reader 2014-12-07 14:45:55 +00:00
MarkBaker
b2e82a0e11 Updates to dcumentation, particularly for setting/reading cell values, and with handling date/time values 2014-12-06 20:50:57 +00:00
MarkBaker
4d67ff7de9 Bugfix: Work Item GH-302 - Fix for CEIL() and FLOOR() when number argument is zero 2014-12-06 17:44:27 +00:00
MarkBaker
741500da14 Add example of cyclic reference calculation 2014-12-06 00:16:41 +00:00
MarkBaker
a4afd4d313 Modify RAND() and RANDBETWEEN() to use mt_rand() 2014-12-06 00:16:09 +00:00
MarkBaker
ab49033479 Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into develop 2014-12-06 00:00:18 +00:00
MarkBaker
9daca467d6 Minor modifications to cyclic reference count logic in calculation engine 2014-12-05 23:59:41 +00:00
Mark Baker
51c72f30de Merge pull request #429 from CrandellWS/patch-1
Fix for substitute value is ZERO=0
2014-12-05 21:37:16 +00:00
MarkBaker
75464688d5 Github issue log reference for codepage 21010 issue 2014-12-05 21:32:53 +00:00
MarkBaker
3f85430e6c Some Excel writer libraries erroneously use Codepage 21010 for UTF-16LE instead of using Codepage 1200 2014-12-05 21:31:17 +00:00
MarkBaker
0296daa75c General: Set default Cyclic Reference behaviour to 1 to eliminate exception when using a single cyclic iteration in formulae 2014-12-03 08:05:25 +00:00
MarkBaker
2b389f97f1 ReadMe Notes on contributing 2014-12-01 22:35:42 +00:00
MarkBaker
2f76d1247b Additional notes on building pie, donut and radar charts 2014-12-01 22:35:23 +00:00
Mark Baker
2d73187b13 Merge pull request #460 from artsafin/develop
Make PHPExcel_Writer_PDF implement IWriter
2014-11-27 00:10:07 +00:00
MarkBaker
2be1bb0c2e GH-455 Fix case-sensitivity issue with PHPExcel_Chart_GridLines 2014-11-26 22:53:55 +00:00
MarkBaker
9940b262c4 Remove spurious worksheet created when instantiating the PHPExcel object, and only create sheets defined in the Excel2003XML file 2014-11-26 22:40:49 +00:00
MarkBaker
e7cfdacf95 Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into develop 2014-11-26 22:25:36 +00:00
MarkBaker
903f737a39 Bugfix: (bobwitlox) Work Item GH-467 - Bug in Excel2003XML reader, parsing merged cells 2014-11-26 22:24:53 +00:00
Progi1984
b243a7f7e8 Merge pull request #462 from paanblogger/develop
Check for is_object
2014-11-17 11:55:58 +01:00
Mohd Farhan Firdaus Jamil
793fc2a08f Check for is_object
Without this , it give php-warning-invalid-argument-supplied-for-foreach error.
2014-11-16 23:00:45 +08:00
Artur Safin
2338c3caf2 Make PHPExcel_Writer_PDF implement IWriter 2014-11-15 13:00:08 +02:00
Mark Baker
184c1bc290 Merge pull request #446 from wiseloren/develop
CP21454 "No Impact" conditional formatting fix for NumberFormat
2014-11-13 00:50:56 +00:00
MarkBaker
27e64c14ad Additional comments for hyperlinks in feature demo example 2014-11-12 22:22:20 +00:00
MarkBaker
5bce69de6f Bugfix: (frozenstupidity) Work Item GH-423 - Fix invalid NA return in VLOOKUP
Manual merge
2014-11-12 22:21:47 +00:00
MarkBaker
63de24eeba Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into develop 2014-11-11 23:19:05 +00:00
MarkBaker
fdefb8e392 Discard Autofilters in Excel2007 Reader when filter range isn't a valid range 2014-11-11 23:18:13 +00:00
Mark Baker
47a34b6a8f Merge pull request #457 from chamaeleon-nitr/patch-1
Bug in String.php
2014-11-11 21:40:55 +00:00
chamaeleon-nitr
832421bbca Bug in String.php
In function IsUTF8
2014-11-10 17:43:16 +03:00
Loren Klingman
26aa0b27f7 "No Impact" conditional formatting fix for NumberFormat 2014-10-15 11:32:27 -05:00
MarkBaker
37b4d18d45 Minor fixes to cyclic references in formulae 2014-09-13 16:12:45 +01:00
MarkBaker
01d6f7f1d5 Bugfix: (masanaikeshima) Work Item GH-426 - Pie chart won't work in Excel 2013 2014-09-10 17:45:17 +01:00
MarkBaker
2e1571c35b Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into develop
Conflicts:
	Examples/33chartcreate-pie.php
2014-09-10 17:29:08 +01:00
MarkBaker
c32dbfccc2 Fixing Pie Chart example to display pie charts 2014-09-10 17:27:03 +01:00
Mark Baker
981eaabe21 Merge pull request #435 from masanaikeshima/patch-1
Fixing Pie Chart example to display pie charts
2014-09-10 17:25:47 +01:00
masanaikeshima
548ff7c3e3 Fixing Pie Chart example to display pie charts
I have noticed that this example is currently throwing the following error when opening the produced Excel Spreadsheet -  "We found a problem with some content in <filename>.xlsx. Do you want us to try to recover as much as we can? If you trust the source of this workbook click Yes". 

In order to fix this I have set the removed the PlotGrouping setting (currently PHPExcel_Chart_DataSeries::GROUPING_STANDARD) to NULL and it appears to work.
2014-09-10 15:49:54 +01:00
MarkBaker
4baab36319 Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into develop 2014-09-10 00:00:11 +01:00
MarkBaker
d4a641c5c7 General: Work Item GH-394 - DefaultValueBinder is too much aggressive when converting string to numeric 2014-09-09 23:59:55 +01:00
MarkBaker
31d60ad524 Fix to getStyle() call for cell object 2014-09-09 23:57:16 +01:00
Progi1984
b56bcb980b Merge pull request #432 from driebit/fix-undefined-offset
Improve sheet index error handling
2014-09-08 19:09:23 +02:00
David de Boer
fdfd36cc04 Improve sheet index error handling
Fix 'Undefined offset: -1' warning, thrown when worksheets could
not be parsed and _activeSheetIndex equals -1.
2014-09-08 17:24:08 +02:00
MarkBaker
f77d3d1668 Bugfix: Work Item GH-384 - DOM loadHTMLFile() failing with options flags when using PHP < 5.4.0
Additional check that libxml is running at an appropriate version by testing if libxml flag value constants are defined
2014-09-05 10:20:12 +01:00
MarkBaker
57ce19d20a Remove references to PHP versions < 5.2 2014-09-05 10:17:39 +01:00
MarkBaker
66b9ffa8ac Minor tweaks to cell constructor 2014-09-03 22:43:59 +01:00
William Crandell
86a598f3ae Fix for substitute value is ZERO=0 2014-09-01 03:09:52 -05:00
MarkBaker
280620a753 Implement Excel VALUE() function, locale-warts and all 2014-08-30 00:12:31 +01:00
MarkBaker
ba1e16d630 Bugfix: - Fix for percentage operator in formulae for BIFF Writer 2014-08-27 23:27:11 +01:00
MarkBaker
99f4ebab0c Remove unused lineEnding methods from CSV Reader 2014-08-27 22:07:24 +01:00
MarkBaker
6d22097d0e Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into develop 2014-08-24 23:29:48 +01:00
MarkBaker
a7cf8c63e2 Bugfix: Work Item GH-384 - DOM loadHTMLFile() failing with options flags when using PHP < 5.4.0 2014-08-23 13:54:21 +01:00
Progi1984
b518c0d404 Merge pull request #424 from nvanheuverzwijn/patch-1
Fix indentation in documentation
2014-08-17 19:33:14 +02:00
MarkBaker
d777d0283d Support for cell readorder Context/LTR/RTL 2014-08-17 18:15:44 +01:00
Nicolas Vanheuverzwijn
cdaabc57f1 Fix indentation in documentation 2014-08-16 14:55:11 -04:00
MarkBaker
125f39c745 Minor performance tweak to PHPTemp and DiscISAM caching 2014-08-16 11:12:32 +01:00
MarkBaker
bdb8b50156 Use th rather than td for cells when in thead 2014-08-06 00:09:44 +01:00
MarkBaker
14e5e806a7 Bugfix: Fix to autoloader registration for backward compatibility with PHP 5.2.0 not accepting the prepend flag 2014-08-05 15:03:54 +01:00
MarkBaker
780cb74782 URL Hyperlink data may not use the full length of the data field, but could instead be terminated by a null byte character 2014-08-03 22:02:46 +01:00
MarkBaker
c2a04ab777 Add new example to runall 2014-08-03 00:22:49 +01:00
MarkBaker
0d07a35fe5 In-code comments and add data for linked validators example 2014-08-02 23:57:53 +01:00
MarkBaker
46e0758cbb New example demonstrating linked drop-down validation lists 2014-08-02 23:44:37 +01:00
Progi1984
1349511410 Merge pull request #412 from z38/develop
Use normal array syntax to support PHP <5.4 (fixes #411)
2014-07-28 16:48:40 +02:00
z38
5e70376018 Use normal array syntax to support PHP <5.4 2014-07-28 16:27:52 +02:00
MarkBaker
d9fa784e1b Bugfix: Work Item CP18105 - Loading an Excel 2007 spreadsheet throws an "Autofilter must be set on a range of cells" exception
Fix to jpgraph path for Chart Rendering tests
2014-07-27 15:18:00 +01:00
MarkBaker
ab693eafcd Feature: (bolovincev) Work Item GH-269 - Update Worksheet.php getStyleByColumnAndRow() to allow a range of cells rather than just a single cell 2014-07-27 13:12:44 +01:00
Mark Baker
983843d50c Merge pull request #269 from bolovincev/patch-1
Update Worksheet.php getStyleByColumnAndRow()
2014-07-27 13:07:19 +01:00
MarkBaker
698a56eb92 Bugfix: Work Item GH-350 - Keep/set the value on Reader _loadSheetsOnly as NULL, courtesy of Restless-ET 2014-07-27 12:51:38 +01:00
MarkBaker
6a0d5b3c2a Update change log 2014-07-27 12:39:01 +01:00
Mark Baker
23479fdde2 Merge pull request #379 from frost-nzcr4/ft-camelcase
Change the getter/setter for zeroHeight to camel case
2014-07-27 12:21:13 +01:00
Mark Baker
2a06bc9675 Merge pull request #405 from ymaerschalck/develop
XML External Entity (XXE) Processing
2014-07-27 12:18:58 +01:00
MarkBaker
3e6cf13df2 Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into develop 2014-07-26 19:46:43 +01:00
MarkBaker
fe6273f8e0 Fix for nested collapsed grouping when writing BIFF-format files, courtesy of ShadowEDX 2014-07-26 19:46:00 +01:00
Mark Baker
af03e186b3 Merge pull request #334 from atannus/develop
Fixes html entities to prevent parsing error of generated documentation.
2014-07-26 16:11:55 +01:00
MarkBaker
59cb459899 Case-sensitivity error 2014-07-26 15:45:44 +01:00
MarkBaker
134bd0fda6 Feature - New methods added for testing cell status within merge groups 2014-07-24 22:50:53 +01:00
MarkBaker
dff9880582 Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into develop 2014-07-22 23:48:52 +01:00
MarkBaker
9065cab60c DOMDocument not domDocument 2014-07-22 23:48:32 +01:00
Mark Baker
c3432f0ef7 Merge pull request #408 from matteofilippetto/develop
again division by zero
2014-07-22 22:57:52 +01:00
matteofilippetto
38ff5a49f8 again division by zero
$this->_width and $this->_height are defined as float so !== will return TRUE also if the value is 0 ( as !== use OR )
2014-07-22 17:40:31 +02:00
Yves Maerschalck
0787e56d41 XML External Entity (XXE) Processing
https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Processing

change simplexml_load_file to
simplexml_load_string(file_get_contents()) because load_file doesn't
work when
http://php.net/manual/en/function.libxml-disable-entity-loader.php is
true
2014-07-16 09:28:33 +02:00
MarkBaker
87be8d3d8e Bugfix to ensure that current cell is maintained when executing formula calculations 2014-07-15 23:33:06 +01:00
MarkBaker
c6d0a4d3d0 Additional divide by zero handling 2014-07-14 23:45:46 +01:00
Mark Baker
311d03b4c3 Merge pull request #329 from sarciszewski/patch-2
Update BaseDrawing.php
2014-07-14 23:37:03 +01:00
Mark Baker
b21fdba7ea Merge pull request #389 from CQD/develop
Add Mac CJK codepage definition.
2014-07-14 23:12:05 +01:00
MarkBaker
944a9ee32e PRs in changelog 2014-07-14 23:07:00 +01:00
Mark Baker
abd0db5ba7 Merge pull request #403 from frost-nzcr4/ft-157-ODF-comments
ODS read/write comments in the cell
2014-07-14 23:04:21 +01:00
Mark Baker
0e14e41299 Merge pull request #397 from goncons/develop
Open Document cell with not numeric formula
2014-07-14 23:01:13 +01:00
Mark Baker
11f906d932 Merge pull request #404 from WiktrzGE/develop
--Added 3 new classes: PHPExcel_Chart_Axis, PHPExcel_Chart_GridLines, PH...
2014-07-14 22:52:17 +01:00
Wiktor
568038c5bf --Added 3 new classes: PHPExcel_Chart_Axis, PHPExcel_Chart_GridLines, PHPExcel_Chart_Properties.php
--Modified Chart.php and Writer/Excel2007/Chart.php for using new classes
--Now it is possible to set some (most of existing) options of Axis, Major Grid-lines and Minor Grid-lines
--No need to use that feature
2014-07-14 16:59:53 +02:00
Alexander Pervakov
524c093895 Fix reader when comment within text:p element 2014-07-14 17:55:46 +04:00
Alexander Pervakov
a81a7da661 Add cell comment 2014-07-14 17:55:46 +04:00
Alexander Pervakov
927d1513cf Fix output in ODS example 2014-07-14 17:55:45 +04:00
Progi1984
f3df66a971 Merge pull request #399 from Nyholm/patch-1
Added PHP 5.6 and HHVM to travis.yml
2014-07-09 21:17:28 +02:00
Tobias Nyholm
4f6256e621 Added PHP 5.6 and HHVM to travis.yml 2014-07-09 12:18:09 +02:00
Progi1984
6335e6c008 Merge pull request #398 from papettoTV/develop
Fixed failed include PHPExcel.php in Examples/34chartupdate.php
2014-07-09 08:31:19 +02:00
yokota
1694960cd5 Fixed failed include PHPExcel.php 2014-07-09 10:53:03 +09:00
goncons
d03ffd6776 Open Document cell with not numeric formula
Trying to write a Open Document with non numeric formula in a cell this exception was generated:
"XMLWriter::writeAttribute() expects parameter 2 to be string, array given"
The problem was that writer was using
PHPExcel_Calculation::getInstance()->calculateCellValue($cell);
instead of
$cell->getCalculatedValue();
2014-07-06 18:48:07 -04:30
MarkBaker
59ef7c3325 Don't cache column width adjustment, because it should be based on the font size being used for a cell, and so should be dynamic 2014-07-03 01:01:39 +01:00
MarkBaker
ddec5e9706 Improve speed of calculation for autosize columns to reduce save time 2014-07-03 00:43:29 +01:00
CQD
ae2e4c9a01 Add MAC CJK codepage
Refering to 
http://msdn.microsoft.com/en-us/library/system.text.encodinginfo.codepage%28v=vs.110%29.aspx
2014-06-23 14:18:48 +08:00
CQD
05dbc90392 Code formating 2014-06-23 14:13:27 +08:00
CQD
0ff99cb6ab Code formating 2014-06-23 14:10:09 +08:00
Progi1984
78a065754d Merge pull request #387 from trxndynamics/develop
Minor Docblock update: corrected the return value from PHPExcel_Shared_Date::ExcelToPHPObject updated to reflect the PHP DateTime object that is to be returned.
2014-06-15 21:26:15 +02:00
Martin Evans
487888414a Minor Docblock update: corrected the return value from PHPExcel_Shared_Date::ExcelToPHPObject updated to reflect the PHP DateTime object that is to be returned. 2014-06-15 18:05:51 +01:00
Mark Baker
a396ec09bb Merge pull request #383 from alex-ception/develop
Fixed bug on jpgraph dependencies
2014-06-14 10:33:56 +01:00
Progi1984
0ce009a4d4 Merge pull request #386 from trxndynamics/develop
Minor Docblock update: return values on load function for PHPExcel_Reade...
2014-06-12 10:42:51 +02:00
Martin Evans
a6672451a5 Minor Docblock update: return values on load function for PHPExcel_Reader_IReader and Excel2007 now listed as @return PHPExcel in order to utilize auto complete via IDE. 2014-06-12 09:20:16 +01:00
Mark Baker
b2da39fc5d Merge pull request #367 from januarsiregar/develop
change sequential validation for orientation dompdf
2014-06-08 18:00:25 +01:00
Mark Baker
afb0101a32 Merge pull request #349 from luxbet/poisson_fix
Allow value of 0 to be passed into POISSON formula
2014-06-08 17:57:42 +01:00
Mark Baker
5c708feba8 Merge pull request #378 from frost-nzcr4/ft-157-ODF
Add basic ODS writing functionality
2014-06-08 17:52:35 +01:00
Mark Baker
cef1b274cd Merge pull request #352 from ke20/patch-1
Bug "Undefined variable: options"
2014-06-08 17:48:36 +01:00
MarkBaker
4935236f7b Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into develop 2014-06-06 23:57:40 +01:00
MarkBaker
5ab877958f Reduce memory usage after an xls load 2014-06-06 23:56:57 +01:00
Alexandre ANDRÉ
f5c0d0a3fd Fixed bug on jpgraph dependencies (It's suggested to use composer jpgraph/jpgraph instead of requiring these files) 2014-06-06 15:56:40 +02:00
Progi1984
0cf12f5dc3 Merge pull request #381 from shrimpwagon/patch-1
Invalid Index
2014-05-31 10:23:31 +02:00
Shawn Welch
5569c92449 Invalid Index
This happened when I tried to load an Excel doc that was exported by Google Docs. I'm guessing there is no author information or something? I dunno but this fixed worked.
2014-05-30 16:46:44 -04:00
Alexander Pervakov
a6f00db9c6 Change the getter/setter for zeroHeight to camel case 2014-05-30 14:37:11 +04:00
Alexander Pervakov
de6a1ab354 Add example 2014-05-30 11:57:43 +04:00
Alexander Pervakov
f51ed2c709 Implements basic writing functionality 2014-05-30 11:57:39 +04:00
Alexander Pervakov
2376bef3c2 Implement empty ODF archive
Work item CP1930, GH-157
2014-05-30 11:57:24 +04:00
Progi1984
9a0071bff1 Merge pull request #377 from dmelo/develop
Change the names of two variables on the examples, to make it camel case
2014-05-30 08:46:05 +02:00
Diogo Oliveira de Melo
c7060d29bd Change the names of variables $plotarea and $dataseriesLabel to $plotArea and $dataSeriesLabel, respectively, to make it camel case compliant 2014-05-29 16:45:21 -03:00
Mark Baker
4ab61ad35a Merge pull request #368 from TravisPaul/develop
Prevent autoload clash when previous code has used spl_autoload_register
2014-05-26 12:04:25 +01:00
Travis Paul
08c1f4b19a Prevent autoload clash when previous code has used spl_autoload_register 2014-05-14 16:31:09 -04:00
januar
6d72423579 change sequential validation for orientation dompdf 2014-05-10 18:24:51 +07:00
Kevin Auvinet
9a38a531da Bug "Undefined variable: options"
There is a bug for the var `$option`:

    Notice: Undefined variable: options in [...]/vendor/phpoffice/phpexcel/Classes/PHPExcel/Settings.php on line 384

This bug is fixed with `self::$_libXmlLoaderOptions == (LIBXML_DTDLOAD | LIBXML_DTDATTR)` instead of `$options == (LIBXML_DTDLOAD | LIBXML_DTDATTR)`
2014-04-15 15:07:06 +02:00
Bobby Sciacchitano
83e024da99 Allow value of 0 to be passed into POISSON formula 2014-04-08 11:52:02 +10:00
MarkBaker
c2a277c447 DocBlock updates 2014-04-03 17:59:47 +01:00
Mark Baker
b4a4062a5d GH-343 Error with PCLZip temporary directory 2014-03-29 00:06:50 +00:00
Mark Baker
6a057497d7 Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into develop 2014-03-29 00:00:14 +00:00
Mark Baker
0042e47c0b GH-347 Using $this in static context in Calculation engine 2014-03-28 23:59:38 +00:00
Mark Baker
3071fb39ae Merge pull request #346 from gondo/patch-1
removed unnecessary break
2014-03-28 22:01:06 +00:00
gondo
eb768751c6 removed unnecessary break 2014-03-28 22:53:04 +01:00
André Tannús
557ca47a6b Fixes html entities to prevent parsing error of generated documentation.
The html output contained "<style> and </style>" which causes a parse
error on stricter html validators. The solution was to swap < and > for
the equivalent html entities &lt; and &gt; respectivelly.

Signed-off-by: André Tannús <atannus@epungo.com.br>
2014-03-05 18:42:30 -03:00
Mark Baker
e69a5e4d0f Documentation updates 2014-03-02 15:22:49 +00:00
Mark Baker
198fdbcdca Merge branch 'master' of https://github.com/PHPOffice/PHPExcel 2014-03-02 15:00:23 +00:00
Mark Baker
7d9e19e8cc EMail address and changelog date 2014-03-02 14:57:53 +00:00
Mark Baker
357a3b1fc2 Documentation 2014-03-02 13:40:35 +00:00
Mark Baker
714b07881f Changelog 2014-03-02 13:27:41 +00:00
Mark Baker
518f06ee20 Documentation updates 2014-03-02 12:39:44 +00:00
Scott Arciszewski
be24d5d30f Update BaseDrawing.php
Avoid division by zero
2014-02-25 16:20:43 -05:00
Mark Baker
9d66087272 Merge pull request #328 from sarciszewski/patch-1
Update Excel2007.php
2014-02-24 17:25:55 +00:00
Scott Arciszewski
758f48baac Update Excel2007.php
Fix output corruption
2014-02-24 11:34:08 -05:00
Mark Baker
0c00677756 Merge pull request #297 from navarr/composer-xml
Add ext-xmlwriter as a Composer requirement
2014-02-23 16:04:10 +00:00
Mark Baker
0322690991 Merge pull request #305 from PowerKiKi/fix_SUMIF_condition_including_double_quote
Double quote support for SUMIF() condition
2014-02-23 16:02:10 +00:00
Mark Baker
e892215970 Bugfix: Work item GH321, GH158, CP17824 - LibreOffice created XLSX files results in an empty file.
Bugfix: Work item CP20760 - Formula references to cell on another sheet in ODS files
2014-02-23 15:35:05 +00:00
Mark Baker
2caeb22122 Bugfix: Work item CP20760 - Formula references to cell on another sheet in ODS files 2014-02-22 12:30:36 +00:00
Mark Baker
8f265a9342 Added XXE protection to HTML Reader 2014-02-21 11:08:57 +00:00
Mark Baker
65178504ca Added CVE reference to changelog 2014-02-21 10:53:52 +00:00
Mark Baker
6c8884b2eb Hopefully final tweak for XXE to prevent displaying errors if SimpleXML isn't available 2014-02-21 10:28:17 +00:00
Mark Baker
2f4fd4cdcb Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into develop 2014-02-21 10:22:28 +00:00
Mark Baker
16c1a19d34 Update security section in Reader documentation 2014-02-21 10:21:04 +00:00
Maarten Balliauw
81c1c55149 Merge pull request #323 from maartenba/develop
When libxmlloader options are the default values, disable the entity loader as well. CVE-2014-2054 by MITRE
2014-02-21 11:07:35 +01:00
Maarten Balliauw
fdc4532bc7 When libxmlloader options are teh default values, disable the entity loader as well. CVE-2014-2054 by MITRE 2014-02-21 11:06:44 +01:00
Mark Baker
1abf061df3 AS we're using simpleXML for xml reading still, we need to use libxml_disable_entity_loader(true); for XXE security patch 2014-02-21 10:01:44 +00:00
Mark Baker
98205e5ec7 Warning in security docs 2014-02-21 09:56:57 +00:00
Mark Baker
c243bcb8ad Updated documentation for XXE injection in readers 2014-02-21 09:51:59 +00:00
Maarten Balliauw
e04bf7ed09 Merge pull request #322 from maartenba/develop
Disabled libxml external entity loading by default.
2014-02-21 09:26:01 +01:00
Maarten Balliauw
1dad681142 Disabled libxml external entity loading by default.
If you want to allow loading external entity references in XML, call PHPExcel_Settings::setLibXmlLoaderOptions(0).
2014-02-21 09:23:55 +01:00
Mark Baker
220da7485e Bugfix: Work item CP20703 - Calculation engine incorrectly evaluates empty cells as #VALUE 2014-02-09 16:08:17 +00:00
Mark Baker
353c46886c Extend headers to handle IE 9 problems and IE/SSL caching problems 2014-02-09 15:27:36 +00:00
Adrien Crivelli
a0da3e32ec Double quote support for SUMIF() condition
SUMIF() condition can have double quote, such as '=SUMIF(A2:A4,">""",B2:B4)'.
This formula purpose is to compare the character double quote (").

In our previous patch (commit f1a1f525) we wrongly assumed that
PHPExcel_Calculation_MathTrig::SUMIF() expected the condition to escaped ('>""'),
but this is actually not the case in real use of PHPExcel, so the unit tests were
modified accordingly to use non-escaped condition ('>"').
2014-01-17 21:01:57 +09:00
Mark Baker
496b76e70a Bugfix: Work Item CP20604 - Adding Sheet to Workbook Bug 2014-01-08 10:15:07 +00:00
Navarr Barnier
dde17c4e1d Add ext-xmlwriter as a Composer requirement
XMLWriter is surprisingly a different extension from xml; and so is not installed on some systems (such as Gentoo).  This commit enforces it to be installed, since it's necessary for the functionality of PHPExcel.
2014-01-03 16:59:32 -05:00
Mark Baker
992aee683a Update to copyright year in file headers 2013-12-31 18:36:33 +00:00
Mark Baker
93b3b8eed2 Bugfix: Work Item GH-290 - AdvancedValueBinder "Division by zero"-error 2013-12-31 01:13:06 +00:00
Mark Baker
70892b93c8 Bugfix: (EliuFlorez) Work item GH-279 - Fatal error: Call to a member function cellExists() line: 3327 in calculation.php if referenced worksheet doesn't exist 2013-12-31 00:06:56 +00:00
Mark Baker
4a18c9cf58 Merge pull request #279 from EliuFlorez/patch-1
Update Calculation.php
2013-12-30 16:04:26 -08:00
Mark Baker
dc97d2f46b Improve fluent interface in charting methods 2013-12-30 23:44:42 +00:00
Mark Baker
19fc61114d Bugfix: (Roy Shahbazian) Work Item GH-299 - Fixed typo in Chart/Layout set/getYMode() 2013-12-30 22:27:40 +00:00
Mark Baker
8cd6f56fdd Bugfix: (Jazzo) Work Item GH-248 - Excel2007 does not correctly mark rows as hidden 2013-12-30 22:19:05 +00:00
Mark Baker
2bcaa01ecc Bugfix: Work Item GH-193 - Fix to empty worksheet garbage collection when using cell caching 2013-12-29 23:48:42 +00:00
Mark Baker
30070f35c2 Bugfix: Work Item GH-257 - Passing an array of cells to _generateRow() in the HTML/PDF Writer causes caching problems with last cell in the range 2013-12-28 13:40:24 +00:00
Mark Baker
56eae54a4b Minor fix to chart layout 2013-12-23 08:13:12 +00:00
Mark Baker
fcb794e2e2 Bugfix: Work Item GH-275 - Insert New Row/Column Before is not correctly updating formula references 2013-12-09 23:45:45 +00:00
Mark Baker
e79181cb4d Bugfix: Work Item GH-275 - Insert New Row/Column Before is not correctly updating formula references 2013-12-09 22:33:45 +00:00
Eliu Florez
b9907446a3 Update Calculation.php
PHPExcel Fatal error: Call to a member function cellExists() line: 3327
2013-12-04 22:46:55 -04:30
Mark Baker
7a90c5b888 Mods to handle encrypted files on both 32-bit and 64-bit versions of PHP - currently only tested on 32-bit Windows 2013-12-03 13:51:40 +00:00
Mark Baker
ee03569d72 General: (infojunkie) Work Item GH-276 - Convert properties to string in OOCalc reader 2013-12-01 11:37:10 +00:00
Mark Baker
9f93cab6c5 Merge pull request #276 from infojunkie/OOCalcReaderXML
Convert properties to string in OOCalc reader
2013-12-01 03:34:54 -08:00
Mark Baker
c7a6431e09 Feature: (trvrnrth) Work Item GH-261 - Add support for reading protected (RC4 encrypted) .xls files (tweaked for PHP 5.2 compatibility) 2013-11-28 23:43:57 +00:00
infojunkie
b671d8376f Convert properties to string in OOCalc reader 2013-11-25 16:18:46 -08:00
Mark Baker
4570c52d2a Bugfix: (PowerKiKi) Work Item GH-270/GH-31 - Binary comparison of strings are case insensitive 2013-11-23 21:38:09 +00:00
Mark Baker
56c9d079d1 Merge pull request #270 from PowerKiKi/issue_31
Binary comparaison of strings are case insensitive
2013-11-23 13:36:16 -08:00
Mark Baker
f2f097733b Bugfix: (PowerKiKi) Work Item GH-273 - ISTEXT() return wrong result if referencing an empty but formatted cell 2013-11-23 21:22:06 +00:00
Mark Baker
aa5a9d4168 Merge pull request #273 from PowerKiKi/issue_is_text
ISTEXT() return wrong result if referencing an empty but formatted cell
2013-11-23 13:00:50 -08:00
Adrien Crivelli
5d6687b6ce ISTEXT() return wrong result if referencing an empty but formatted cell
ISTEXT should always return FALSE for empty cells, however PHPExcel returns
TRUE if the cell is formatted. This can be reproduced in Excel by choosing
formatting category "Text" for cell A1, and then in cell B1 input the
formula '=ISTEXT(A1)'. B1 will display FALSE, but PHPExcel will return TRUE.

This patch fix the NULL value being incorrectly cast to an empty string, and
thus eliminating ISTEXT() issue (and probably several others).
2013-11-22 19:33:56 +09:00
Adrien Crivelli
f2e24ecdd4 Comparison operators on strings are usually case insensitive
Excel, Gnumeric and Google Spreadsheet are case insensitive, so the
default behavior of PHPExcel is modified accordingly.

However OpenOffice is case sensitive and is also supported via the
compatibility mode of PHPExcel.

Fixes #31
2013-11-21 16:04:59 +09:00
bolovincev
f505648ec5 Update Worksheet.php getStyleByColumnAndRow()
http://phpexcel.codeplex.com/discussions/263626

$objPHPExcel->getActiveSheet()->getStyleByColumnAndRow(1, 2, 5, 2)->applyFromArray($styleArray);

It is very convenient in cycles
2013-11-19 22:51:11 +03:00
Mark Baker
f5bd6dc0f2 Bugfix: (IndrekHaav) Work Item CP16208 - Fixed undefined variable error due to $styleArray being used before it's initialised 2013-11-18 14:28:22 +00:00
Mark Baker
9c6287a323 Bugfix: (IndrekHaav) Work Item GH-212 - Fix for formulae that reference a sheet whose name begins with a digit:
these were erroneously identified as numeric values, causing the parser to throw an undefined variable error.
2013-11-18 14:20:37 +00:00
Mark Baker
30459d260d General: (RomanSyroeshko) GB-265 - PHPExcel_Shared_String.IsUTF8 returns FALSE for Cyrillic UTF-8 input 2013-11-18 08:00:49 +00:00
Mark Baker
7f0a8044a4 Markdown charset, second attempt 2013-11-17 21:45:30 +00:00
Mark Baker
dc416f83a5 Fix UTF-8 in markdown 2013-11-17 21:36:43 +00:00
Mark Baker
aa660150ae Documentation (jamescostian) GH-234 - Fixed some malformed Markdown 2013-11-17 19:52:35 +00:00
Mark Baker
f3755a0965 Documentation fix: (PowerKiKi) GH-224 - Minor fix in DocBlock 2013-11-17 19:43:47 +00:00
Mark Baker
4eefabf7a0 Modify OOCalc reader to work with PCLZip rather than ZipArchive if configured to do so 2013-11-17 17:45:21 +00:00
Mark Baker
0d8a5d1f0b General: (adamriyadi) Work Item GH-247 - Modify PHPExcel_Reader_Excel2007 to use zipClass from PHPExcel_Settings::getZipClass()
This allows the use of PCLZip when reading for people that don't have access to ZipArchive
2013-11-17 17:33:56 +00:00
Mark Baker
7fb98dbcd5 Fix to new PCLZip wrapper locateName() method 2013-11-17 14:15:22 +00:00
Mark Baker
51a1661c79 Feature: (adamriyadi) GH-247 - Add locateName() and getFromName() to PHPExcel_Shared_ZipArchive 2013-11-17 13:09:11 +00:00
Mark Baker
732cb11e0c Feature: (LWol) Work Item GH-252 - Adding support for macros, Ribbon in Excel 2007 2013-11-17 00:11:45 +00:00
Mark Baker
fe84015077 On the chance that a cell doesn't have a defined style but it's still trying to be formatted 2013-11-16 10:38:30 +00:00
Mark Baker
968bfef0a2 Bugfix: When duplicating conditional styles, styles shifted by one column to the right 2013-11-15 19:24:51 +00:00
Mark Baker
1a85271db6 Bugfix: (Gemorroj) Work Item GH-268 - When duplicating styles, styles shifted by one column to the right 2013-11-15 19:11:08 +00:00
Mark Baker
8c0de39be2 Merge pull request #268 from Gemorroj/patch-1
When duplicating styles, styles shifted by one column to the right.
2013-11-15 11:08:15 -08:00
Gemorroj
df592cc7c4 When duplicating styles, styles shifted by one column to the right.
PHPExcel_Cell::rangeBoundaries -> PHPExcel_Cell::columnIndexFromString (Column index (base 1 !!!))
PHPExcel_Cell::stringFromColumnIndex Column index (base 0 !!!)
2013-11-15 12:29:21 +03:00
Mark Baker
74f8efc1f8 Modified getHighest calls for row/column at Worksheet level to accept optional column/row arguments 2013-11-09 10:21:54 +00:00
Mark Baker
13a98ef631 General: (dresenhista) Work Item GH-242 - Functionality to getHighestRow() for a specified column, and getHighestColumn() for a specified row 2013-11-09 00:40:59 +00:00
Mark Baker
2bbe908e77 Bugfix: (RomanSyroeshko) Work Item GH-267 - CHOOSE() returns "#VALUE!" if the 1st entry is chosen 2013-11-08 19:47:13 +00:00
Mark Baker
23c1b6c597 Merge pull request #267 from RomanSyroeshko/PHPExcel#258
CHOOSE() returns "#VALUE!" if the 1st entry is chosen
2013-11-08 11:43:14 -08:00
Mark Baker
2bd1c10b21 Further fix to regexp for preventing update of absolute rows when adjusting row references 2013-11-07 23:24:04 +00:00
Mark Baker
94a1a69373 Bugfix: Work item 20397 - Serious bug in absolute cell reference used in shared formula
Would also have affected insert/delete column/row
2013-11-07 23:14:39 +00:00
Roman Syroeshko
ded0f6dc13 https://github.com/PHPOffice/PHPExcel/issues/258
CHOOSE() returns "#VALUE!" if the 1st entry is chosen
2013-11-03 21:24:10 -08:00
Mark Baker
f9f37f566a Feature: (trvrnrth) - Add support for reading protected (RC4 encrypted) .xls files (64-bit Linux only) 2013-11-03 22:46:11 +00:00
Mark Baker
f20049c37e Merge pull request #261 from trvrnrth/excel5CryptoRC4
Add support for reading protected (RC4 encrypted) .xls files
2013-11-03 14:43:14 -08:00
Mark Baker
8d51b6e90a Merge pull request #228 from PowerKiKi/patch-sumif
Double quote support for SUMIF()
2013-10-31 07:03:07 -07:00
Mark Baker
acadff4b7b Merge pull request #256 from trik/develop
Excel 2007 fail with headers and footers containing multiple images
2013-10-30 15:01:58 -07:00
Mark Baker
fed92a3f91 Merge pull request #244 from Slamdunk/patch-1
Travis: test also against PHP 5.5
2013-10-30 06:56:47 -07:00
Mark Baker
6fd27196f0 Bugfix: (tavoarcila) Work Item GH-259 - Bug fix reading Open Office files 2013-10-30 13:50:40 +00:00
Trevor North
233021529c Implement Excel 5 RC4 stream decryption
The decryption functions and objects implemented here are are
based on the source of Spreadsheet-ParseExcel:
http://search.cpan.org/~jmcnamara/Spreadsheet-ParseExcel/
2013-10-29 11:25:36 +00:00
Mark Baker
f86458630f Trap for scientific format masks with "0" or "#" before the "E" 2013-10-28 19:13:59 +00:00
Mark Baker
bff907a1b8 Number format mask test for dates: test for "General" format should be case-insensitive, and scientific format mask shouldn't return a positive for date 2013-10-28 19:05:26 +00:00
Mark Baker
6d21efc173 Updated data validation example to show a list derived from data in the worksheet rather than from a comma-separated string 2013-10-17 11:19:20 +01:00
Marco Marche
a90b711edd Fixed problem in Excel 2007 reader with headers and footers containing multiple images. All images were substituted with the first one. 2013-10-17 10:50:14 +02:00
Mark Baker
9d22445673 Eliminate some code duplication 2013-10-13 17:09:09 +01:00
Mark Baker
b6e09de195 Fixed silly missing ; typo 2013-10-13 11:54:24 +01:00
Mark Baker
ea18123aea Added an isFormula() method to the cell object 2013-10-13 11:37:00 +01:00
Mark Baker
bdd1f6fa31 Added page header and footer examples to print options demo script 2013-10-13 11:31:01 +01:00
Mark Baker
4f82ad4160 Case-sensitivity fix 2013-10-09 12:48:41 +01:00
Mark Baker
68a0918ceb General: Fix to calculation properties for Excel2007 so that the opening application will only recalculate on load if it's actually required
General: Modified Excel2007 Writer to default preCalculateFormulas to false
         Note that autosize columns will still recalculate affected formulae internally
2013-10-04 20:48:15 +01:00
Mark Baker
555a4ab828 In code comments for stock chart improvements 2013-09-15 18:11:48 +01:00
Mark Baker
47f3888664 Fixed rendering of stock charts with jpgraph 2013-09-15 12:44:39 +01:00
Mark Baker
cb5fc9532f Fixes to stock charts 2013-09-14 23:13:17 +01:00
Filippo Tessarotto
4b0c98eb58 Travis: test also against PHP 5.5 2013-09-06 10:53:46 +02:00
Mark Baker
a11a8da417 Issue 19827 - Unknown codepage: 10008 2013-08-23 09:06:15 +01:00
Mark Baker
29746bb995 General: (cdhutch) Work item 20055 - remove array_shift in ReferenceHelper::insertNewBefore improves column or row delete speed 2013-08-18 12:32:40 +01:00
Mark Baker
44f953b69d Fixes to style duplication 2013-08-15 23:28:51 +01:00
Mark Baker
b726b23411 Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into develop 2013-08-15 18:13:43 +01:00
Mark Baker
60c9bf391c Excel compatibility mode for CSV Writer 2013-08-15 18:10:29 +01:00
Adrien Crivelli
f1a1f525ea Double quote support for SUMIF()
SUMIF() should handle double quotes properly in both criteria and
cells values. This is especially useful when we need to compare string
containing themselve double quote(s).
2013-08-08 12:17:00 +09:00
Mark Baker
2dcff606f7 Merge pull request #216 from nickypn/patch-1
Bulgarian localisation
2013-08-07 09:06:05 -07:00
Mark Baker
40a6d946ff Merge pull request #221 from nendrew/develop
Check whether margin-left is set in excel file when reading
2013-08-07 09:04:10 -07:00
Mark Baker
e2f8441da2 Merge pull request #219 from JackStone123/patch-1
Update 02-Loading-a-Spreadsheet.md
2013-08-05 07:36:30 -07:00
Mark Baker
5853494b68 Merge pull request #220 from JackStone123/patch-2
Update 10-Reading-and-Writing.md
2013-08-05 07:35:51 -07:00
Andreas Scheibleger
2d39be32cb Check whether margin-left is set in excel file when reading 2013-07-23 14:16:40 +02:00
Jack Stone
67ed42d0cd Update 10-Reading-and-Writing.md 2013-07-18 10:42:58 -04:00
Jack Stone
963931a7e3 Update 02-Loading-a-Spreadsheet.md 2013-07-18 10:34:27 -04:00
Nikolay Ninkov
d4277abd85 Bulgarian localisation
Start translation to Bulgarian language.
2013-07-15 09:28:47 +03:00
Mark Baker
b8f783e5a3 Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into develop 2013-07-11 12:25:16 +01:00
Mark Baker
d62615fbeb INDIRECT and OFFSET call to get worksheet rather than cell collection 2013-07-11 08:28:42 +01:00
Maarten Balliauw
a4e6355ef5 Update build.xml 2013-07-10 14:41:23 +02:00
Maarten Balliauw
8057604241 Updated include paths for examples 2013-07-10 13:33:04 +02:00
Maarten Balliauw
5818a79e67 Update bootstrap.php 2013-07-10 11:18:43 +02:00
Mark Baker
509bfd39e2 Added Horizontal FILL alignment for Excel5 and Excel2007 Readers/Writers, and Horizontal DISTRIBUTED alignment for Excel2007 Reader/Writer 2013-07-02 13:13:07 +01:00
Mark Baker
39953ff49f Feature: Added "Quote Prefix" to style settings (Excel2007 Reader and Writer only) 2013-06-25 23:13:13 +01:00
Mark Baker
6cea3bbf7b Minor fix to HTML Reader canRead method (even developers have brainfarts occasionally) 2013-06-21 22:52:29 +01:00
Mark Baker
da7cd71be8 Minor performance tweaks 2013-06-17 12:01:51 +01:00
Mark Baker
98e5ac2b24 Performance improvements 2013-06-17 11:37:29 +01:00
Mark Baker
2296a48349 Merge branch 'develop_1.7.9' of https://github.com/PHPOffice/PHPExcel into develop_1.7.9 2013-06-16 21:35:55 +01:00
Mark Baker
6216d2855c Performance tweaks 2013-06-16 21:35:35 +01:00
Mark Baker
90eff17853 Performance tweaks 2013-06-16 21:34:17 +01:00
Mark Baker
333c811c5e Minor performance tweaks to calculation engine 2013-06-16 16:24:34 +01:00
Mark Baker
a0859fd7d0 Fix to number format masking for scientific notation 2013-06-16 15:13:05 +01:00
Mark Baker
8f7db244de Eliminate unnecessary version checks 2013-06-16 10:26:16 +01:00
Mark Baker
4d92e77d00 Eliminate need for use of money_format() function; various fixes to HLOOKUP, VLOOKUP and DOLLAR functions + unit tests 2013-06-15 12:15:03 +01:00
Mark Baker
83bd690633 HLOOKUP 2013-06-15 00:03:48 +01:00
Mark Baker
dfc74f8b95 Feature: (amerov) - Implementation of the Excel HLOOKUP() function 2013-06-14 23:57:50 +01:00
Mark Baker
78c034880f Update changelog 2013-06-11 22:52:06 +01:00
Mark Baker
2c8bd2471b Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into develop 2013-06-10 23:21:48 +01:00
Mark Baker
9a36ddb1a2 Quick bugfix to PDF merge cell styling 2013-06-10 23:20:58 +01:00
Mark Baker
aeec8ef23c Fix to clone worksheet 2013-06-03 22:28:32 +01:00
Mark Baker
88751b3e75 Merge branch 'develop' into develop_1.7.9 2013-06-03 22:25:16 +01:00
Mark Baker
f44b412420 Fix to rewind filepointer when testing BOM marker 2013-06-03 13:39:58 +01:00
Mark Baker
d1a9725482 Merge pull request #194 from zordsdavini/patch-1
fixed undifind variable in _skipBOM
2013-06-03 03:03:57 -07:00
zordsdavini
dd8c1414ca fixed undifind variable in _skipBOM 2013-06-03 12:51:53 +03:00
Mark Baker
7a7634fba6 Only read first 8 bytes of a file when validating, rather than load the entire file into memory at that point 2013-05-24 12:57:42 +01:00
Mark Baker
b880b5ff9d Excel2007 reader wasn't always reading the print_titles properly, fix courtesy of watermark86 2013-05-24 09:29:43 +01:00
Mark Baker
de2248d1d4 Fix for SUMIF(), COUNTIF() and related functions if condition references a blank cell, courtesy of watermark86 2013-05-24 09:19:13 +01:00
Mark Baker
9331422a8a SQLite caching - fix error message 2013-05-23 22:34:08 +01:00
Mark Baker
4ac95ac24c GH-186 - sqlite OOP doesn't have a close method, need to use a procedural close 2013-05-23 12:37:02 +01:00
Mark Baker
c17a4a62a3 Improvements to formatting numbers with more complex masks 2013-05-21 18:00:57 +01:00
Mark Baker
46982cf098 Reader documentation markdown 2013-05-20 12:23:07 +01:00
Mark Baker
9e5ffa20da Reader documentation markdown 2013-05-20 12:21:56 +01:00
Mark Baker
c758748b39 Reader markdown 2013-05-20 07:44:14 +01:00
Mark Baker
d6ec415676 documentation markdown 2013-05-19 22:14:52 +01:00
Mark Baker
e7f8f616f7 documentation markdown 2013-05-18 23:22:27 +01:00
Mark Baker
62e9eacd56 documentation markdown 2013-05-18 15:56:43 +01:00
Mark Baker
1c98aaa76a documentation markdown 2013-05-17 17:49:12 +01:00
Mark Baker
e74b1e08f8 markdown documentation 2013-05-17 00:09:14 +01:00
Mark Baker
934b07cc76 case-sensitivity in filenames 2013-05-16 22:53:16 +01:00
Mark Baker
43c77557d7 case-sensitivity in file names 2013-05-16 22:52:37 +01:00
Mark Baker
8a25f345b8 documentation markdown 2013-05-16 21:59:54 +01:00
Mark Baker
b075996eee Markdown documentation 2013-05-16 17:34:11 +01:00
Mark Baker
9f575aff68 Manual PR merge to remove redundant brackets after throw in 2 files, courtesy of kachkaev 2013-05-15 18:02:24 +01:00
Mark Baker
6a4be7da3c Update to copyright year in file headers, and minor documentation updates 2013-05-14 12:20:28 +01:00
Mark Baker
76534a7bfc documentation markdown 2013-05-13 17:10:06 +01:00
Mark Baker
9879a71952 Documentation markdown 2013-05-13 14:45:30 +01:00
Mark Baker
80c78e1ab9 Initial work on converting documentation to markdown 2013-05-13 13:59:53 +01:00
Mark Baker
f6cb566e5d Merge pull request #176 from AndreasHeiberg/patch-1
Removed duplicate declaration of getStyle()
2013-05-11 01:02:30 -07:00
Andreas Heiberg
9a06b8a6fc Removed duplicate declaration of getStyle() 2013-05-11 00:14:19 +02:00
Mark Baker
c6c99bd990 Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into develop 2013-05-10 20:09:26 +01:00
Mark Baker
04c1608f3f Feature: Added getStyle() method to Cell object 2013-05-10 14:21:23 +01:00
Mark Baker
69dc096fe7 Added getStyle() method to Cell object 2013-05-09 22:28:23 +01:00
Mark Baker
b1c61d1be0 Fix file rewind in SYLK reader 2013-05-07 12:50:42 +01:00
Mark Baker
fd2a3773d8 Refactoring of canRead function in Readers, and minor fixes to Examples and documentation updates 2013-05-06 23:39:49 +01:00
Mark Baker
216ef82a14 Yet more docblock fixes 2013-04-30 12:45:13 +01:00
Mark Baker
c2bbafb4d9 Docblock fixes 2013-04-29 23:09:39 +01:00
Mark Baker
73d2757728 Fix for quoted worksheet names in INDIRECT and OFFSET methods; and Docblock fixes 2013-04-29 22:47:36 +01:00
Mark Baker
b8c462f1c2 ADded new autofilter example to runall 2013-04-29 17:39:03 +01:00
Mark Baker
bf80538aa0 Updated documentation with Autofilter execution, and provided an example script 2013-04-29 17:26:05 +01:00
Mark Baker
12baf4e097 Documentation updates 2013-04-29 09:14:32 +01:00
Mark Baker
9ecce7f009 Minor performance tweak 2013-04-29 00:06:06 +01:00
Mark Baker
cbe9e35e6f Fix for specifying version/date/format in documentation builds 2013-04-28 22:29:32 +01:00
Mark Baker
8b7e502129 Documentation updates 2013-04-28 18:06:20 +01:00
Mark Baker
2cf5e0f5aa Fix to version/date/docformat prompts in build script 2013-04-28 17:08:30 +01:00
Mark Baker
6f83afd512 Include Examples directory for release builds in phing build 2013-04-28 16:21:03 +01:00
Mark Baker
91eb758a6d Yet more docblock fixes 2013-04-28 16:02:46 +01:00
Mark Baker
d4e7026c95 docblocks 2013-04-27 23:36:39 +01:00
Mark Baker
a6ab41cd65 Merge pull request #173 from gmsantosxl/develop
Typo mistake
2013-04-27 15:13:29 -07:00
Mark Baker
82fb4382fd Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into develop 2013-04-27 22:48:20 +01:00
Mark Baker
d41c8aacf7 Modify build to use PHPDocumentor 2 rather than PHPDocumentor 1 2013-04-27 22:47:25 +01:00
Gabriel Machado
212b7acc79 Update IWriter.php
Fixing a typo
2013-04-27 18:17:14 -03:00
Mark Baker
e9a09c8903 Document blocks 2013-04-27 21:57:30 +01:00
Mark Baker
c660492446 Docblocks 2013-04-27 18:07:12 +01:00
Mark Baker
28f266bbba Docblock comments 2013-04-27 16:02:07 +01:00
Mark Baker
cfdd19e47c Docblock modifications 2013-04-27 14:49:08 +01:00
Mark Baker
4e9bfc4607 Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into develop 2013-04-27 13:42:44 +01:00
Mark Baker
4d9258c9e1 Modified some of the examples to show rich text and additional download headers that might be needed 2013-04-27 13:42:14 +01:00
Mark Baker
8debf76a8a Minor performance tweaks 2013-04-26 12:44:47 +01:00
Mark Baker
8a05ee8896 Added Docblocks for cell address and column sort callback functions 2013-04-26 07:46:50 +01:00
Mark Baker
d96364fda6 PHPDoc blocks 2013-04-25 23:44:15 +01:00
Mark Baker
7f7b520652 Some refactoring of insert/delete row/column reference methods 2013-04-25 17:53:29 +01:00
Mark Baker
db1fcd5cd6 Additional work on GH-161 for Breaks 2013-04-23 17:42:40 +01:00
Mark Baker
15bfe6b8d5 Update examples 2013-04-21 16:27:35 +01:00
Mark Baker
097ae1706e Additional work on GH-161 - Fix: Hyperlinks break when removing rows 2013-04-21 16:03:25 +01:00
Mark Baker
ab01a6c6dc Additional work on bugfix GH-161: Hyperlinks break when removing rows 2013-04-20 23:53:25 +01:00
Mark Baker
e76673bcc0 Bugfix: (Shanto) Work item GH-161 - Fix: Hyperlinks break when removing rows 2013-04-20 11:46:20 +01:00
Mark Baker
2d3451d95d Merge pull request #166 from neclimdul/extra_html_writer_row
Fix Extra Table Row From Images and Charts - Thanks
2013-04-20 02:43:03 -07:00
jgilliland
0a09b235ee Close tbody after images and charts 2013-04-16 17:29:19 -05:00
jgilliland
af01842f78 Remove empty row from empty charts and images 2013-04-16 17:27:20 -05:00
Mark Baker
db7b99ac8e Bugfix: (alexgann) Work item GH-154 - Fix merged-cell borders on HTML/PDF output 2013-04-01 17:26:26 +01:00
Mark Baker
663b8a1903 General: Modify cell's getCalculatedValue() method to return the content of RichText objects rather than the RichText object itself 2013-03-29 11:15:36 +00:00
Progi1984
f3e1d9660a Merge pull request #159 from sparksp/patch-1
Fix Excel5 category
2013-03-27 09:58:42 -07:00
Phill Sparks
0c15e8abb7 Fix Excel5 category
Update Excel5.php to remove hard-coded "Test result file" category
2013-03-27 16:12:35 +00:00
487 changed files with 102594 additions and 83895 deletions

3
.gitattributes vendored
View file

@ -1,4 +1,3 @@
/Build export-ignore
/Documentation export-ignore
/Tests export-ignore
/unitTests export-ignore
README.md export-ignore

View file

@ -1,13 +1,29 @@
language: php
php:
- 5.2
- 5.3.3
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
matrix:
allow_failures:
- php: hhvm
before_script:
## Packages
- sudo apt-get -qq update > /dev/null
## Composer
- composer self-update
- composer install --prefer-source --dev
- phpenv global "$TRAVIS_PHP_VERSION"
script:
- phpunit -c ./unitTests/
## PHP_CodeSniffer
- ./vendor/bin/phpcs --report-width=200 --report-summary --report-full Classes/ unitTests/ --standard=PSR2 -n
## PHPUnit
- phpunit -c ./unitTests/
notifications:
email: false

View file

@ -1,30 +1,37 @@
<?xml version="1.0"?>
<project name="PHPExcel" default="release-standard" basedir=".">
<taskdef classname="phing.tasks.ext.d51PearPkg2Task" name="d51pearpkg2"/>
<target name="gather">
<if>
<isfalse value="${packageVersion}"/>
<then>
<propertyprompt propertyName="packageVersion" defaultValue="1.0.0"
promptText="Enter PHPExcel version number"/>
</then>
<isset property="${packageVersion}"/>
<then>
<echo message="PHPExcel version number is ${packageVersion}" />
</then>
<else>
<propertyprompt propertyName="packageVersion" defaultValue="1.0.0"
promptText="Enter PHPExcel version number"/>
</else>
</if>
<if>
<isfalse value="${releaseDate}"/>
<then>
<propertyprompt propertyName="releaseDate" defaultValue="2010-01-01"
promptText="Enter PHPExcel release date"/>
</then>
<isset property="${releaseDate}"/>
<then>
<echo message="Release date is ${releaseDate}" />
</then>
<else>
<propertyprompt propertyName="releaseDate" defaultValue="2010-01-01"
promptText="Enter PHPExcel release date"/>
</else>
</if>
<if>
<isfalse value="${documentFormat}"/>
<then>
<propertyprompt propertyName="documentFormat" defaultValue="doc"
promptText="Enter Document Format"/>
</then>
<isset property="${documentFormat}"/>
<then>
<echo message="Document Format is ${documentFormat}" />
</then>
<else>
<propertyprompt propertyName="documentFormat" defaultValue="doc"
promptText="Enter Document Format"/>
</else>
</if>
</target>
@ -42,6 +49,12 @@
</fileset>
</copy>
<copy todir="${phing.dir}/build/Examples" overwrite="true">
<fileset dir="${phing.dir}/../Examples">
<include name="**/*"/>
</fileset>
</copy>
<copy todir="${phing.dir}/build/Documentation" overwrite="true">
<fileset dir="${phing.dir}/../Documentation">
<include name="*.${documentFormat}"/>
@ -57,12 +70,6 @@
</fileset>
</copy>
<copy todir="${phing.dir}/build/unitTests" overwrite="true">
<fileset dir="${phing.dir}/../unitTests">
<include name="**/*"/>
</fileset>
</copy>
<copy file="${phing.dir}/../changelog.txt" tofile="${phing.dir}/build/changelog.txt" overwrite="true"/>
<copy file="${phing.dir}/../license.md" tofile="${phing.dir}/build/license.txt" overwrite="true"/>
<copy file="${phing.dir}/../install.txt" tofile="${phing.dir}/build/install.txt" overwrite="true"/>
@ -87,7 +94,7 @@
</fileset>
<filterchain>
<replaceregexp>
<regexp pattern="Fixed in SVN" replace="${releaseDate} (v${packageVersion})"/>
<regexp pattern="Fixed in develop branch for release v${packageVersion}" replace="${releaseDate} (v${packageVersion})"/>
</replaceregexp>
</filterchain>
</reflexive>
@ -95,17 +102,13 @@
<target name="apidocs" depends="versionNumber">
<echo msg="Generating API documentation..."/>
<phpdoc title="PHPExcel classes"
destdir="${phing.dir}/build/Documentation/API"
sourcecode="true"
output="HTML:Smarty:PHP"
defaultcategoryname="PHPExcel"
defaultpackagename="PHPExcel"
pear="true">
<phpdoc2 title="PHPExcel classes"
destdir="${phing.dir}/build/Documentation/API"
template="responsive">
<fileset dir="${phing.dir}/build/Classes">
<include name="**/*.php"/>
</fileset>
</phpdoc>
</phpdoc2>
</target>
<target name="release-standard" depends="apidocs">
@ -136,7 +139,7 @@
<element name="description" value="A pure PHP library for reading and writing spreadsheet files" />
<element name="authors">
<element name="Mark Baker">
<element name="e-mail" value="mbaker@inviqa.com" />
<element name="e-mail" value="mark@lange.demon.co.uk" />
</element>
</element>
</metadata>
@ -147,6 +150,8 @@
</target>
<target name="release-pear" depends="versionNumber">
<taskdef classname="phing.tasks.ext.d51PearPkg2Task" name="d51pearpkg2"/>
<mkdir dir="${phing.dir}/release"/>
<echo msg="Creating PEAR release package (v${packageVersion})..."/>
@ -182,7 +187,7 @@
<delete dir="${phing.dir}/build"/>
</target>
<target name="release-documentation">
<target name="release-documentation" depends="gather">
<mkdir dir="${phing.dir}/release"/>
<echo msg="Creating documentation release (v${packageVersion} with ${documentFormat} documents)..."/>
@ -208,4 +213,4 @@
<echo msg="Cleaning build directory: ./build"/>
<delete dir="${phing.dir}/build"/>
</target>
</project>
</project>

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,19 @@
<?php
PHPExcel_Autoloader::register();
// As we always try to run the autoloader before anything else, we can use it to do a few
// simple checks and initialisations
//PHPExcel_Shared_ZipStreamWrapper::register();
// check mbstring.func_overload
if (ini_get('mbstring.func_overload') & 2) {
throw new PHPExcel_Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
}
PHPExcel_Shared_String::buildCharacterSets();
/**
* PHPExcel
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,66 +31,51 @@
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
PHPExcel_Autoloader::Register();
// As we always try to run the autoloader before anything else, we can use it to do a few
// simple checks and initialisations
//PHPExcel_Shared_ZipStreamWrapper::register();
// check mbstring.func_overload
if (ini_get('mbstring.func_overload') & 2) {
throw new PHPExcel_Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
}
PHPExcel_Shared_String::buildCharacterSets();
/**
* PHPExcel_Autoloader
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Autoloader
{
/**
* Register the Autoloader with SPL
*
*/
public static function Register() {
public static function register()
{
if (function_exists('__autoload')) {
// Register any existing autoloader function with SPL, so we don't get any clashes
// Register any existing autoloader function with SPL, so we don't get any clashes
spl_autoload_register('__autoload');
}
// Register ourselves with SPL
return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));
} // function Register()
// Register ourselves with SPL
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
return spl_autoload_register(array('PHPExcel_Autoloader', 'load'), true, true);
} else {
return spl_autoload_register(array('PHPExcel_Autoloader', 'load'));
}
}
/**
* Autoload a class identified by name
*
* @param string $pClassName Name of the object to load
*/
public static function Load($pClassName){
if ((class_exists($pClassName,FALSE)) || (strpos($pClassName, 'PHPExcel') !== 0)) {
// Either already loaded, or not a PHPExcel class request
return FALSE;
public static function load($pClassName)
{
if ((class_exists($pClassName, false)) || (strpos($pClassName, 'PHPExcel') !== 0)) {
// Either already loaded, or not a PHPExcel class request
return false;
}
$pClassFilePath = PHPEXCEL_ROOT .
str_replace('_',DIRECTORY_SEPARATOR,$pClassName) .
'.php';
str_replace('_', DIRECTORY_SEPARATOR, $pClassName) .
'.php';
if ((file_exists($pClassFilePath) === FALSE) || (is_readable($pClassFilePath) === FALSE)) {
// Can't load
return FALSE;
if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) {
// Can't load
return false;
}
require($pClassFilePath);
} // function Load()
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_CachedObjectStorage_APC
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,28 +21,19 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_CachedObjectStorage_APC
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Prefix used to uniquely identify cache data for this worksheet
*
* @access private
* @var string
*/
private $_cachePrefix = null;
private $cachePrefix = null;
/**
* Cache timeout
@ -49,8 +41,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
* @access private
* @var integer
*/
private $_cacheTime = 600;
private $cacheTime = 600;
/**
* Store cell data in cache for the current cell object if it's "dirty",
@ -60,19 +51,23 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty) {
$this->_currentObject->detach();
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) {
if (!apc_store(
$this->cachePrefix . $this->currentObjectID . '.cache',
serialize($this->currentObject),
$this->cacheTime
)) {
$this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in APC');
throw new PHPExcel_Exception('Failed to store cell ' . $this->currentObjectID . ' in APC');
}
$this->_currentCellIsDirty = false;
$this->currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
$this->currentObjectID = $this->currentObject = null;
}
/**
* Add or Update a cell in cache identified by coordinate address
@ -80,40 +75,41 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
* @access public
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
$this->storeData();
}
$this->_cellCache[$pCoord] = true;
$this->cellCache[$pCoord] = true;
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
$this->_currentCellIsDirty = true;
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
} // function addCacheData()
}
/**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
* @access public
* @param string $pCoord Coordinate address of the cell to check
* @return void
* @throws PHPExcel_Exception
* @return boolean
*/
public function isDataSet($pCoord) {
public function isDataSet($pCoord)
{
// Check if the requested entry is the current object, or exists in the cache
if (parent::isDataSet($pCoord)) {
if ($this->_currentObjectID == $pCoord) {
if ($this->currentObjectID == $pCoord) {
return true;
}
// Check if the requested entry still exists in apc
$success = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
if ($success === FALSE) {
$success = apc_fetch($this->cachePrefix.$pCoord.'.cache');
if ($success === false) {
// Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
@ -121,8 +117,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
return true;
}
return false;
} // function isDataSet()
}
/**
* Get cell at a specific coordinate
@ -132,16 +127,17 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject;
public function getCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return $this->currentObject;
}
$this->_storeData();
$this->storeData();
// Check if the entry that has been requested actually exists
if (parent::isDataSet($pCoord)) {
$obj = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
if ($obj === FALSE) {
$obj = apc_fetch($this->cachePrefix . $pCoord . '.cache');
if ($obj === false) {
// Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
@ -152,29 +148,28 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
$this->_currentObject = unserialize($obj);
$this->currentObjectID = $pCoord;
$this->currentObject = unserialize($obj);
// Re-attach this as the cell's parent
$this->_currentObject->attach($this);
$this->currentObject->attach($this);
// Return requested entry
return $this->_currentObject;
} // function getCacheData()
return $this->currentObject;
}
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {
$this->_storeData();
}
return parent::getCellList();
}
return parent::getCellList();
}
/**
* Delete a cell in cache identified by coordinate address
@ -183,14 +178,14 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord) {
public function deleteCacheData($pCoord)
{
// Delete the entry from APC
apc_delete($this->_cachePrefix.$pCoord.'.cache');
apc_delete($this->cachePrefix.$pCoord.'.cache');
// Delete the entry from our cell address array
parent::deleteCacheData($pCoord);
} // function deleteCacheData()
}
/**
* Clone the cell collection
@ -200,50 +195,50 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
* @throws PHPExcel_Exception
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
public function copyCellCollection(PHPExcel_Worksheet $parent)
{
parent::copyCellCollection($parent);
// Get a new id for the new file name
$baseUnique = $this->_getUniqueID();
$newCachePrefix = substr(md5($baseUnique),0,8).'.';
$baseUnique = $this->getUniqueID();
$newCachePrefix = substr(md5($baseUnique), 0, 8) . '.';
$cacheList = $this->getCellList();
foreach($cacheList as $cellID) {
if ($cellID != $this->_currentObjectID) {
$obj = apc_fetch($this->_cachePrefix.$cellID.'.cache');
if ($obj === FALSE) {
foreach ($cacheList as $cellID) {
if ($cellID != $this->currentObjectID) {
$obj = apc_fetch($this->cachePrefix . $cellID . '.cache');
if ($obj === false) {
// Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($cellID);
throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in APC');
throw new PHPExcel_Exception('Cell entry ' . $cellID . ' no longer exists in APC');
}
if (!apc_store($newCachePrefix.$cellID.'.cache',$obj,$this->_cacheTime)) {
if (!apc_store($newCachePrefix . $cellID . '.cache', $obj, $this->cacheTime)) {
$this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in APC');
throw new PHPExcel_Exception('Failed to store cell ' . $cellID . ' in APC');
}
}
}
$this->_cachePrefix = $newCachePrefix;
} // function copyCellCollection()
$this->cachePrefix = $newCachePrefix;
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() {
if ($this->_currentObject !== NULL) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
public function unsetWorksheetCells()
{
if ($this->currentObject !== null) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
// Flush the APC cache
$this->__destruct();
$this->_cellCache = array();
$this->cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
} // function unsetWorksheetCells()
$this->parent = null;
}
/**
* Initialise this new cell collection
@ -251,29 +246,29 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments
*/
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
public function __construct(PHPExcel_Worksheet $parent, $arguments)
{
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
if ($this->_cachePrefix === NULL) {
$baseUnique = $this->_getUniqueID();
$this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
$this->_cacheTime = $cacheTime;
if ($this->cachePrefix === null) {
$baseUnique = $this->getUniqueID();
$this->cachePrefix = substr(md5($baseUnique), 0, 8) . '.';
$this->cacheTime = $cacheTime;
parent::__construct($parent);
}
} // function __construct()
}
/**
* Destroy this cell collection
*/
public function __destruct() {
public function __destruct()
{
$cacheList = $this->getCellList();
foreach($cacheList as $cellID) {
apc_delete($this->_cachePrefix.$cellID.'.cache');
foreach ($cacheList as $cellID) {
apc_delete($this->cachePrefix . $cellID . '.cache');
}
} // function __destruct()
}
/**
* Identify whether the caching method is currently available
@ -281,15 +276,15 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
*
* @return boolean
*/
public static function cacheMethodIsAvailable() {
public static function cacheMethodIsAvailable()
{
if (!function_exists('apc_store')) {
return FALSE;
return false;
}
if (apc_sma_info() === FALSE) {
return FALSE;
if (apc_sma_info() === false) {
return false;
}
return TRUE;
return true;
}
}

View file

@ -1,298 +1,368 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_CachedObjectStorage_CacheBase
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
abstract class PHPExcel_CachedObjectStorage_CacheBase {
/**
* Parent worksheet
*
* @var PHPExcel_Worksheet
*/
protected $_parent;
/**
* The currently active Cell
*
* @var PHPExcel_Cell
*/
protected $_currentObject = null;
/**
* Coordinate address of the currently active Cell
*
* @var string
*/
protected $_currentObjectID = null;
/**
* Flag indicating whether the currently active Cell requires saving
*
* @var boolean
*/
protected $_currentCellIsDirty = true;
/**
* An array of cells or cell pointers for the worksheet cells held in this cache,
* and indexed by their coordinate address within the worksheet
*
* @var array of mixed
*/
protected $_cellCache = array();
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
*/
public function __construct(PHPExcel_Worksheet $parent) {
// Set our parent worksheet.
// This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when
// they are woken from a serialized state
$this->_parent = $parent;
} // function __construct()
public function getParent()
{
return $this->_parent;
}
/**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
*/
public function isDataSet($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return true;
}
// Check if the requested entry exists in the cache
return isset($this->_cellCache[$pCoord]);
} // function isDataSet()
/**
* Move a cell object from one address to another
*
* @param string $fromAddress Current address of the cell to move
* @param string $toAddress Destination address of the cell to move
* @return boolean
*/
public function moveCell($fromAddress, $toAddress) {
if ($fromAddress === $this->_currentObjectID) {
$this->_currentObjectID = $toAddress;
}
$this->_currentCellIsDirty = true;
if (isset($this->_cellCache[$fromAddress])) {
$this->_cellCache[$toAddress] = &$this->_cellCache[$fromAddress];
unset($this->_cellCache[$fromAddress]);
}
return TRUE;
} // function moveCell()
/**
* Add or Update a cell in cache
*
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws PHPExcel_Exception
*/
public function updateCacheData(PHPExcel_Cell $cell) {
return $this->addCacheData($cell->getCoordinate(),$cell);
} // function updateCacheData()
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
$this->_currentObject->detach();
$this->_currentObjectID = $this->_currentObject = null;
}
if (is_object($this->_cellCache[$pCoord])) {
$this->_cellCache[$pCoord]->detach();
unset($this->_cellCache[$pCoord]);
}
$this->_currentCellIsDirty = false;
} // function deleteCacheData()
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
*/
public function getCellList() {
return array_keys($this->_cellCache);
} // function getCellList()
/**
* Sort the list of all cell addresses currently held in cache by row and column
*
* @return void
*/
public function getSortedCellList() {
$sortKeys = array();
foreach ($this->getCellList() as $coord) {
list($column,$row) = sscanf($coord,'%[A-Z]%d');
$sortKeys[sprintf('%09d%3s',$row,$column)] = $coord;
}
ksort($sortKeys);
return array_values($sortKeys);
} // function sortCellList()
/**
* Get highest worksheet column and highest row that have cell records
*
* @return array Highest column name and highest row number
*/
public function getHighestRowAndColumn()
{
// Lookup highest column and highest row
$col = array('A' => '1A');
$row = array(1);
foreach ($this->getCellList() as $coord) {
list($c,$r) = sscanf($coord,'%[A-Z]%d');
$row[$r] = $r;
$col[$c] = strlen($c).$c;
}
if (!empty($row)) {
// Determine highest column and row
$highestRow = max($row);
$highestColumn = substr(max($col),1);
}
return array( 'row' => $highestRow,
'column' => $highestColumn
);
}
public function getCurrentAddress()
{
return $this->_currentObjectID;
}
public function getCurrentColumn()
{
list($column,$row) = sscanf($this->_currentObjectID, '%[A-Z]%d');
return $column;
}
public function getCurrentRow()
{
list($column,$row) = sscanf($this->_currentObjectID, '%[A-Z]%d');
return $row;
}
/**
* Get highest worksheet column
*
* @return string Highest column name
*/
public function getHighestColumn()
{
$colRow = $this->getHighestRowAndColumn();
return $colRow['column'];
}
/**
* Get highest worksheet row
*
* @return int Highest row number
*/
public function getHighestRow()
{
$colRow = $this->getHighestRowAndColumn();
return $colRow['row'];
}
/**
* Generate a unique ID for cache referencing
*
* @return string Unique Reference
*/
protected function _getUniqueID() {
if (function_exists('posix_getpid')) {
$baseUnique = posix_getpid();
} else {
$baseUnique = mt_rand();
}
return uniqid($baseUnique,true);
}
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
$this->_currentCellIsDirty;
$this->_storeData();
$this->_parent = $parent;
if (($this->_currentObject !== NULL) && (is_object($this->_currentObject))) {
$this->_currentObject->attach($this);
}
} // function copyCellCollection()
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable() {
return true;
}
}
<?php
/**
* PHPExcel_CachedObjectStorage_CacheBase
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
abstract class PHPExcel_CachedObjectStorage_CacheBase
{
/**
* Parent worksheet
*
* @var PHPExcel_Worksheet
*/
protected $parent;
/**
* The currently active Cell
*
* @var PHPExcel_Cell
*/
protected $currentObject = null;
/**
* Coordinate address of the currently active Cell
*
* @var string
*/
protected $currentObjectID = null;
/**
* Flag indicating whether the currently active Cell requires saving
*
* @var boolean
*/
protected $currentCellIsDirty = true;
/**
* An array of cells or cell pointers for the worksheet cells held in this cache,
* and indexed by their coordinate address within the worksheet
*
* @var array of mixed
*/
protected $cellCache = array();
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
*/
public function __construct(PHPExcel_Worksheet $parent)
{
// Set our parent worksheet.
// This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when
// they are woken from a serialized state
$this->parent = $parent;
}
/**
* Return the parent worksheet for this cell collection
*
* @return PHPExcel_Worksheet
*/
public function getParent()
{
return $this->parent;
}
/**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
*/
public function isDataSet($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return true;
}
// Check if the requested entry exists in the cache
return isset($this->cellCache[$pCoord]);
}
/**
* Move a cell object from one address to another
*
* @param string $fromAddress Current address of the cell to move
* @param string $toAddress Destination address of the cell to move
* @return boolean
*/
public function moveCell($fromAddress, $toAddress)
{
if ($fromAddress === $this->currentObjectID) {
$this->currentObjectID = $toAddress;
}
$this->currentCellIsDirty = true;
if (isset($this->cellCache[$fromAddress])) {
$this->cellCache[$toAddress] = &$this->cellCache[$fromAddress];
unset($this->cellCache[$fromAddress]);
}
return true;
}
/**
* Add or Update a cell in cache
*
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function updateCacheData(PHPExcel_Cell $cell)
{
return $this->addCacheData($cell->getCoordinate(), $cell);
}
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID && !is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObjectID = $this->currentObject = null;
}
if (is_object($this->cellCache[$pCoord])) {
$this->cellCache[$pCoord]->detach();
unset($this->cellCache[$pCoord]);
}
$this->currentCellIsDirty = false;
}
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList()
{
return array_keys($this->cellCache);
}
/**
* Sort the list of all cell addresses currently held in cache by row and column
*
* @return string[]
*/
public function getSortedCellList()
{
$sortKeys = array();
foreach ($this->getCellList() as $coord) {
sscanf($coord, '%[A-Z]%d', $column, $row);
$sortKeys[sprintf('%09d%3s', $row, $column)] = $coord;
}
ksort($sortKeys);
return array_values($sortKeys);
}
/**
* Get highest worksheet column and highest row that have cell records
*
* @return array Highest column name and highest row number
*/
public function getHighestRowAndColumn()
{
// Lookup highest column and highest row
$col = array('A' => '1A');
$row = array(1);
foreach ($this->getCellList() as $coord) {
sscanf($coord, '%[A-Z]%d', $c, $r);
$row[$r] = $r;
$col[$c] = strlen($c).$c;
}
if (!empty($row)) {
// Determine highest column and row
$highestRow = max($row);
$highestColumn = substr(max($col), 1);
}
return array(
'row' => $highestRow,
'column' => $highestColumn
);
}
/**
* Return the cell address of the currently active cell object
*
* @return string
*/
public function getCurrentAddress()
{
return $this->currentObjectID;
}
/**
* Return the column address of the currently active cell object
*
* @return string
*/
public function getCurrentColumn()
{
sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row);
return $column;
}
/**
* Return the row address of the currently active cell object
*
* @return integer
*/
public function getCurrentRow()
{
sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row);
return (integer) $row;
}
/**
* Get highest worksheet column
*
* @param string $row Return the highest column for the specified row,
* or the highest column of any row if no row number is passed
* @return string Highest column name
*/
public function getHighestColumn($row = null)
{
if ($row == null) {
$colRow = $this->getHighestRowAndColumn();
return $colRow['column'];
}
$columnList = array(1);
foreach ($this->getCellList() as $coord) {
sscanf($coord, '%[A-Z]%d', $c, $r);
if ($r != $row) {
continue;
}
$columnList[] = PHPExcel_Cell::columnIndexFromString($c);
}
return PHPExcel_Cell::stringFromColumnIndex(max($columnList) - 1);
}
/**
* Get highest worksheet row
*
* @param string $column Return the highest row for the specified column,
* or the highest row of any column if no column letter is passed
* @return int Highest row number
*/
public function getHighestRow($column = null)
{
if ($column == null) {
$colRow = $this->getHighestRowAndColumn();
return $colRow['row'];
}
$rowList = array(0);
foreach ($this->getCellList() as $coord) {
sscanf($coord, '%[A-Z]%d', $c, $r);
if ($c != $column) {
continue;
}
$rowList[] = $r;
}
return max($rowList);
}
/**
* Generate a unique ID for cache referencing
*
* @return string Unique Reference
*/
protected function getUniqueID()
{
if (function_exists('posix_getpid')) {
$baseUnique = posix_getpid();
} else {
$baseUnique = mt_rand();
}
return uniqid($baseUnique, true);
}
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent)
{
$this->currentCellIsDirty;
$this->storeData();
$this->parent = $parent;
if (($this->currentObject !== null) && (is_object($this->currentObject))) {
$this->currentObject->attach($this);
}
} // function copyCellCollection()
/**
* Remove a row, deleting all cells in that row
*
* @param string $row Row number to remove
* @return void
*/
public function removeRow($row)
{
foreach ($this->getCellList() as $coord) {
sscanf($coord, '%[A-Z]%d', $c, $r);
if ($r == $row) {
$this->deleteCacheData($coord);
}
}
}
/**
* Remove a column, deleting all cells in that column
*
* @param string $column Column ID to remove
* @return void
*/
public function removeColumn($column)
{
foreach ($this->getCellList() as $coord) {
sscanf($coord, '%[A-Z]%d', $c, $r);
if ($c == $column) {
$this->deleteCacheData($coord);
}
}
}
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable()
{
return true;
}
}

View file

@ -1,219 +1,208 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_CachedObjectStorage_DiscISAM
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/**
* Name of the file for this cache
*
* @var string
*/
private $_fileName = NULL;
/**
* File handle for this cache file
*
* @var resource
*/
private $_fileHandle = NULL;
/**
* Directory/Folder where the cache file is located
*
* @var string
*/
private $_cacheDirectory = NULL;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty) {
$this->_currentObject->detach();
fseek($this->_fileHandle,0,SEEK_END);
$offset = ftell($this->_fileHandle);
fwrite($this->_fileHandle, serialize($this->_currentObject));
$this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset,
'sz' => ftell($this->_fileHandle) - $offset
);
$this->_currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
}
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
$this->_currentCellIsDirty = true;
return $cell;
} // function addCacheData()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject;
}
$this->_storeData();
// Check if the entry that has been requested actually exists
if (!isset($this->_cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']);
$this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz']));
// Re-attach this as the cell's parent
$this->_currentObject->attach($this);
// Return requested entry
return $this->_currentObject;
} // function getCacheData()
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {
$this->_storeData();
}
return parent::getCellList();
}
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
parent::copyCellCollection($parent);
// Get a new id for the new file name
$baseUnique = $this->_getUniqueID();
$newFileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
// Copy the existing cell cache file
copy ($this->_fileName,$newFileName);
$this->_fileName = $newFileName;
// Open the copied cell cache file
$this->_fileHandle = fopen($this->_fileName,'a+');
} // function copyCellCollection()
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
// Close down the temporary cache file
$this->__destruct();
} // function unsetWorksheetCells()
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments
*/
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
$this->_cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== NULL))
? $arguments['dir']
: PHPExcel_Shared_File::sys_get_temp_dir();
parent::__construct($parent);
if (is_null($this->_fileHandle)) {
$baseUnique = $this->_getUniqueID();
$this->_fileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
$this->_fileHandle = fopen($this->_fileName,'a+');
}
} // function __construct()
/**
* Destroy this cell collection
*/
public function __destruct() {
if (!is_null($this->_fileHandle)) {
fclose($this->_fileHandle);
unlink($this->_fileName);
}
$this->_fileHandle = null;
} // function __destruct()
}
<?php
/**
* PHPExcel_CachedObjectStorage_DiscISAM
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Name of the file for this cache
*
* @var string
*/
private $fileName = null;
/**
* File handle for this cache file
*
* @var resource
*/
private $fileHandle = null;
/**
* Directory/Folder where the cache file is located
*
* @var string
*/
private $cacheDirectory = null;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
fseek($this->fileHandle, 0, SEEK_END);
$this->cellCache[$this->currentObjectID] = array(
'ptr' => ftell($this->fileHandle),
'sz' => fwrite($this->fileHandle, serialize($this->currentObject))
);
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
}
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
$this->storeData();
}
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
}
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return $this->currentObject;
}
$this->storeData();
// Check if the entry that has been requested actually exists
if (!isset($this->cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->currentObjectID = $pCoord;
fseek($this->fileHandle, $this->cellCache[$pCoord]['ptr']);
$this->currentObject = unserialize(fread($this->fileHandle, $this->cellCache[$pCoord]['sz']));
// Re-attach this as the cell's parent
$this->currentObject->attach($this);
// Return requested entry
return $this->currentObject;
}
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
return parent::getCellList();
}
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
*/
public function copyCellCollection(PHPExcel_Worksheet $parent)
{
parent::copyCellCollection($parent);
// Get a new id for the new file name
$baseUnique = $this->getUniqueID();
$newFileName = $this->cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
// Copy the existing cell cache file
copy($this->fileName, $newFileName);
$this->fileName = $newFileName;
// Open the copied cell cache file
$this->fileHandle = fopen($this->fileName, 'a+');
}
/**
* Clear the cell collection and disconnect from our parent
*
*/
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
$this->cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->parent = null;
// Close down the temporary cache file
$this->__destruct();
}
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments
*/
public function __construct(PHPExcel_Worksheet $parent, $arguments)
{
$this->cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== null))
? $arguments['dir']
: PHPExcel_Shared_File::sys_get_temp_dir();
parent::__construct($parent);
if (is_null($this->fileHandle)) {
$baseUnique = $this->getUniqueID();
$this->fileName = $this->cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
$this->fileHandle = fopen($this->fileName, 'a+');
}
}
/**
* Destroy this cell collection
*/
public function __destruct()
{
if (!is_null($this->fileHandle)) {
fclose($this->fileHandle);
unlink($this->fileName);
}
$this->fileHandle = null;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_CachedObjectStorage_ICache
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,93 +21,83 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_CachedObjectStorage_ICache
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
interface PHPExcel_CachedObjectStorage_ICache
{
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws PHPExcel_Exception
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell);
public function addCacheData($pCoord, PHPExcel_Cell $cell);
/**
* Add or Update a cell in cache
*
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws PHPExcel_Exception
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function updateCacheData(PHPExcel_Cell $cell);
public function updateCacheData(PHPExcel_Cell $cell);
/**
* Fetch a cell from cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to retrieve
* @return PHPExcel_Cell Cell that was found, or null if not found
* @throws PHPExcel_Exception
* @param string $pCoord Coordinate address of the cell to retrieve
* @return PHPExcel_Cell Cell that was found, or null if not found
* @throws PHPExcel_Exception
*/
public function getCacheData($pCoord);
public function getCacheData($pCoord);
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord);
public function deleteCacheData($pCoord);
/**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
*/
public function isDataSet($pCoord);
/**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
*/
public function isDataSet($pCoord);
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
*/
public function getCellList();
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList();
/**
* Get the list of all cell addresses currently held in cache sorted by column and row
*
* @return void
*/
public function getSortedCellList();
/**
* Get the list of all cell addresses currently held in cache sorted by column and row
*
* @return string[]
*/
public function getSortedCellList();
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent);
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable();
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent);
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable();
}

View file

@ -1,152 +1,149 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_CachedObjectStorage_Igbinary
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty) {
$this->_currentObject->detach();
$this->_cellCache[$this->_currentObjectID] = igbinary_serialize($this->_currentObject);
$this->_currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
}
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
$this->_currentCellIsDirty = true;
return $cell;
} // function addCacheData()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject;
}
$this->_storeData();
// Check if the entry that has been requested actually exists
if (!isset($this->_cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
$this->_currentObject = igbinary_unserialize($this->_cellCache[$pCoord]);
// Re-attach this as the cell's parent
$this->_currentObject->attach($this);
// Return requested entry
return $this->_currentObject;
} // function getCacheData()
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {
$this->_storeData();
}
return parent::getCellList();
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
} // function unsetWorksheetCells()
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable() {
if (!function_exists('igbinary_serialize')) {
return false;
}
return true;
}
}
<?php
/**
* PHPExcel_CachedObjectStorage_Igbinary
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
$this->cellCache[$this->currentObjectID] = igbinary_serialize($this->currentObject);
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
$this->storeData();
}
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
} // function addCacheData()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return $this->currentObject;
}
$this->storeData();
// Check if the entry that has been requested actually exists
if (!isset($this->cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->currentObjectID = $pCoord;
$this->currentObject = igbinary_unserialize($this->cellCache[$pCoord]);
// Re-attach this as the cell's parent
$this->currentObject->attach($this);
// Return requested entry
return $this->currentObject;
} // function getCacheData()
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
return parent::getCellList();
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
$this->cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->parent = null;
} // function unsetWorksheetCells()
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable()
{
if (!function_exists('igbinary_serialize')) {
return false;
}
return true;
}
}

View file

@ -1,312 +1,308 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_CachedObjectStorage_Memcache
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/**
* Prefix used to uniquely identify cache data for this worksheet
*
* @var string
*/
private $_cachePrefix = null;
/**
* Cache timeout
*
* @var integer
*/
private $_cacheTime = 600;
/**
* Memcache interface
*
* @var resource
*/
private $_memcache = null;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty) {
$this->_currentObject->detach();
$obj = serialize($this->_currentObject);
if (!$this->_memcache->replace($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
if (!$this->_memcache->add($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
$this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in MemCache');
}
}
$this->_currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
}
$this->_cellCache[$pCoord] = true;
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
$this->_currentCellIsDirty = true;
return $cell;
} // function addCacheData()
/**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
* @param string $pCoord Coordinate address of the cell to check
* @return void
* @return boolean
*/
public function isDataSet($pCoord) {
// Check if the requested entry is the current object, or exists in the cache
if (parent::isDataSet($pCoord)) {
if ($this->_currentObjectID == $pCoord) {
return true;
}
// Check if the requested entry still exists in Memcache
$success = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
if ($success === false) {
// Entry no longer exists in Memcache, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
}
return true;
}
return false;
} // function isDataSet()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject;
}
$this->_storeData();
// Check if the entry that has been requested actually exists
if (parent::isDataSet($pCoord)) {
$obj = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
if ($obj === false) {
// Entry no longer exists in Memcache, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
}
} else {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
$this->_currentObject = unserialize($obj);
// Re-attach this as the cell's parent
$this->_currentObject->attach($this);
// Return requested entry
return $this->_currentObject;
} // function getCacheData()
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {
$this->_storeData();
}
return parent::getCellList();
}
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord) {
// Delete the entry from Memcache
$this->_memcache->delete($this->_cachePrefix.$pCoord.'.cache');
// Delete the entry from our cell address array
parent::deleteCacheData($pCoord);
} // function deleteCacheData()
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
parent::copyCellCollection($parent);
// Get a new id for the new file name
$baseUnique = $this->_getUniqueID();
$newCachePrefix = substr(md5($baseUnique),0,8).'.';
$cacheList = $this->getCellList();
foreach($cacheList as $cellID) {
if ($cellID != $this->_currentObjectID) {
$obj = $this->_memcache->get($this->_cachePrefix.$cellID.'.cache');
if ($obj === false) {
// Entry no longer exists in Memcache, so clear it from the cache array
parent::deleteCacheData($cellID);
throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in MemCache');
}
if (!$this->_memcache->add($newCachePrefix.$cellID.'.cache',$obj,NULL,$this->_cacheTime)) {
$this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in MemCache');
}
}
}
$this->_cachePrefix = $newCachePrefix;
} // function copyCellCollection()
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
// Flush the Memcache cache
$this->__destruct();
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
} // function unsetWorksheetCells()
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments
*/
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
$memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';
$memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
if (is_null($this->_cachePrefix)) {
$baseUnique = $this->_getUniqueID();
$this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
// Set a new Memcache object and connect to the Memcache server
$this->_memcache = new Memcache();
if (!$this->_memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback'))) {
throw new PHPExcel_Exception('Could not connect to MemCache server at '.$memcacheServer.':'.$memcachePort);
}
$this->_cacheTime = $cacheTime;
parent::__construct($parent);
}
} // function __construct()
/**
* Memcache error handler
*
* @param string $host Memcache server
* @param integer $port Memcache port
* @throws PHPExcel_Exception
*/
public function failureCallback($host, $port) {
throw new PHPExcel_Exception('memcache '.$host.':'.$port.' failed');
}
/**
* Destroy this cell collection
*/
public function __destruct() {
$cacheList = $this->getCellList();
foreach($cacheList as $cellID) {
$this->_memcache->delete($this->_cachePrefix.$cellID.'.cache');
}
} // function __destruct()
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable() {
if (!function_exists('memcache_add')) {
return false;
}
return true;
}
}
<?php
/**
* PHPExcel_CachedObjectStorage_Memcache
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Prefix used to uniquely identify cache data for this worksheet
*
* @var string
*/
private $cachePrefix = null;
/**
* Cache timeout
*
* @var integer
*/
private $cacheTime = 600;
/**
* Memcache interface
*
* @var resource
*/
private $memcache = null;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
$obj = serialize($this->currentObject);
if (!$this->memcache->replace($this->cachePrefix . $this->currentObjectID . '.cache', $obj, null, $this->cacheTime)) {
if (!$this->memcache->add($this->cachePrefix . $this->currentObjectID . '.cache', $obj, null, $this->cacheTime)) {
$this->__destruct();
throw new PHPExcel_Exception("Failed to store cell {$this->currentObjectID} in MemCache");
}
}
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
$this->storeData();
}
$this->cellCache[$pCoord] = true;
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
} // function addCacheData()
/**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
* @return boolean
*/
public function isDataSet($pCoord)
{
// Check if the requested entry is the current object, or exists in the cache
if (parent::isDataSet($pCoord)) {
if ($this->currentObjectID == $pCoord) {
return true;
}
// Check if the requested entry still exists in Memcache
$success = $this->memcache->get($this->cachePrefix.$pCoord.'.cache');
if ($success === false) {
// Entry no longer exists in Memcache, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
}
return true;
}
return false;
}
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return $this->currentObject;
}
$this->storeData();
// Check if the entry that has been requested actually exists
if (parent::isDataSet($pCoord)) {
$obj = $this->memcache->get($this->cachePrefix . $pCoord . '.cache');
if ($obj === false) {
// Entry no longer exists in Memcache, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception("Cell entry {$pCoord} no longer exists in MemCache");
}
} else {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->currentObjectID = $pCoord;
$this->currentObject = unserialize($obj);
// Re-attach this as the cell's parent
$this->currentObject->attach($this);
// Return requested entry
return $this->currentObject;
}
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
return parent::getCellList();
}
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord)
{
// Delete the entry from Memcache
$this->memcache->delete($this->cachePrefix . $pCoord . '.cache');
// Delete the entry from our cell address array
parent::deleteCacheData($pCoord);
}
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent)
{
parent::copyCellCollection($parent);
// Get a new id for the new file name
$baseUnique = $this->getUniqueID();
$newCachePrefix = substr(md5($baseUnique), 0, 8) . '.';
$cacheList = $this->getCellList();
foreach ($cacheList as $cellID) {
if ($cellID != $this->currentObjectID) {
$obj = $this->memcache->get($this->cachePrefix.$cellID.'.cache');
if ($obj === false) {
// Entry no longer exists in Memcache, so clear it from the cache array
parent::deleteCacheData($cellID);
throw new PHPExcel_Exception("Cell entry {$cellID} no longer exists in MemCache");
}
if (!$this->memcache->add($newCachePrefix . $cellID . '.cache', $obj, null, $this->cacheTime)) {
$this->__destruct();
throw new PHPExcel_Exception("Failed to store cell {$cellID} in MemCache");
}
}
}
$this->cachePrefix = $newCachePrefix;
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
// Flush the Memcache cache
$this->__destruct();
$this->cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->parent = null;
}
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments
*/
public function __construct(PHPExcel_Worksheet $parent, $arguments)
{
$memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';
$memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
if (is_null($this->cachePrefix)) {
$baseUnique = $this->getUniqueID();
$this->cachePrefix = substr(md5($baseUnique), 0, 8) . '.';
// Set a new Memcache object and connect to the Memcache server
$this->memcache = new Memcache();
if (!$this->memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback'))) {
throw new PHPExcel_Exception("Could not connect to MemCache server at {$memcacheServer}:{$memcachePort}");
}
$this->cacheTime = $cacheTime;
parent::__construct($parent);
}
}
/**
* Memcache error handler
*
* @param string $host Memcache server
* @param integer $port Memcache port
* @throws PHPExcel_Exception
*/
public function failureCallback($host, $port)
{
throw new PHPExcel_Exception("memcache {$host}:{$port} failed");
}
/**
* Destroy this cell collection
*/
public function __destruct()
{
$cacheList = $this->getCellList();
foreach ($cacheList as $cellID) {
$this->memcache->delete($this->cachePrefix.$cellID . '.cache');
}
}
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable()
{
if (!function_exists('memcache_add')) {
return false;
}
return true;
}
}

View file

@ -1,125 +1,118 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_CachedObjectStorage_Memory
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/**
* Dummy method callable from CacheBase, but unused by Memory cache
*
* @return void
*/
protected function _storeData() {
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
$this->_cellCache[$pCoord] = $cell;
// Set current entry to the new/updated entry
$this->_currentObjectID = $pCoord;
return $cell;
} // function addCacheData()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
// Check if the entry that has been requested actually exists
if (!isset($this->_cellCache[$pCoord])) {
$this->_currentObjectID = NULL;
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
// Return requested entry
return $this->_cellCache[$pCoord];
} // function getCacheData()
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
parent::copyCellCollection($parent);
$newCollection = array();
foreach($this->_cellCache as $k => &$cell) {
$newCollection[$k] = clone $cell;
$newCollection[$k]->attach($parent);
}
$this->_cellCache = $newCollection;
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() {
// Because cells are all stored as intact objects in memory, we need to detach each one from the parent
foreach($this->_cellCache as $k => &$cell) {
$cell->detach();
$this->_cellCache[$k] = null;
}
unset($cell);
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
} // function unsetWorksheetCells()
}
<?php
/**
* PHPExcel_CachedObjectStorage_Memory
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Dummy method callable from CacheBase, but unused by Memory cache
*
* @return void
*/
protected function storeData()
{
}
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
$this->cellCache[$pCoord] = $cell;
// Set current entry to the new/updated entry
$this->currentObjectID = $pCoord;
return $cell;
}
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord)
{
// Check if the entry that has been requested actually exists
if (!isset($this->cellCache[$pCoord])) {
$this->currentObjectID = null;
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->currentObjectID = $pCoord;
// Return requested entry
return $this->cellCache[$pCoord];
}
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
*/
public function copyCellCollection(PHPExcel_Worksheet $parent)
{
parent::copyCellCollection($parent);
$newCollection = array();
foreach ($this->cellCache as $k => &$cell) {
$newCollection[$k] = clone $cell;
$newCollection[$k]->attach($this);
}
$this->cellCache = $newCollection;
}
/**
* Clear the cell collection and disconnect from our parent
*
*/
public function unsetWorksheetCells()
{
// Because cells are all stored as intact objects in memory, we need to detach each one from the parent
foreach ($this->cellCache as $k => &$cell) {
$cell->detach();
$this->cellCache[$k] = null;
}
unset($cell);
$this->cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->parent = null;
}
}

View file

@ -1,137 +1,133 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_CachedObjectStorage_MemoryGZip
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty) {
$this->_currentObject->detach();
$this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject));
$this->_currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
}
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
$this->_currentCellIsDirty = true;
return $cell;
} // function addCacheData()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject;
}
$this->_storeData();
// Check if the entry that has been requested actually exists
if (!isset($this->_cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
$this->_currentObject = unserialize(gzinflate($this->_cellCache[$pCoord]));
// Re-attach this as the cell's parent
$this->_currentObject->attach($this);
// Return requested entry
return $this->_currentObject;
} // function getCacheData()
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {
$this->_storeData();
}
return parent::getCellList();
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
} // function unsetWorksheetCells()
}
<?php
/**
* PHPExcel_CachedObjectStorage_MemoryGZip
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
$this->cellCache[$this->currentObjectID] = gzdeflate(serialize($this->currentObject));
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
}
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
$this->storeData();
}
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
}
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return $this->currentObject;
}
$this->storeData();
// Check if the entry that has been requested actually exists
if (!isset($this->cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->currentObjectID = $pCoord;
$this->currentObject = unserialize(gzinflate($this->cellCache[$pCoord]));
// Re-attach this as the cell's parent
$this->currentObject->attach($this);
// Return requested entry
return $this->currentObject;
}
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
return parent::getCellList();
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
$this->cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->parent = null;
}
}

View file

@ -1,137 +1,129 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_CachedObjectStorage_MemorySerialized
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty) {
$this->_currentObject->detach();
$this->_cellCache[$this->_currentObjectID] = serialize($this->_currentObject);
$this->_currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
}
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
$this->_currentCellIsDirty = true;
return $cell;
} // function addCacheData()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject;
}
$this->_storeData();
// Check if the entry that has been requested actually exists
if (!isset($this->_cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
$this->_currentObject = unserialize($this->_cellCache[$pCoord]);
// Re-attach this as the cell's parent
$this->_currentObject->attach($this);
// Return requested entry
return $this->_currentObject;
} // function getCacheData()
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {
$this->_storeData();
}
return parent::getCellList();
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
} // function unsetWorksheetCells()
}
<?php
/**
* PHPExcel_CachedObjectStorage_MemorySerialized
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
$this->cellCache[$this->currentObjectID] = serialize($this->currentObject);
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
}
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
$this->storeData();
}
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
}
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return $this->currentObject;
}
$this->storeData();
// Check if the entry that has been requested actually exists
if (!isset($this->cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->currentObjectID = $pCoord;
$this->currentObject = unserialize($this->cellCache[$pCoord]);
// Re-attach this as the cell's parent
$this->currentObject->attach($this);
// Return requested entry
return $this->currentObject;
}
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
return parent::getCellList();
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
$this->cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->parent = null;
}
}

View file

@ -1,206 +1,200 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_CachedObjectStorage_PHPTemp
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/**
* Name of the file for this cache
*
* @var string
*/
private $_fileHandle = null;
/**
* Memory limit to use before reverting to file cache
*
* @var integer
*/
private $_memoryCacheSize = null;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty) {
$this->_currentObject->detach();
fseek($this->_fileHandle,0,SEEK_END);
$offset = ftell($this->_fileHandle);
fwrite($this->_fileHandle, serialize($this->_currentObject));
$this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset,
'sz' => ftell($this->_fileHandle) - $offset
);
$this->_currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
}
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
$this->_currentCellIsDirty = true;
return $cell;
} // function addCacheData()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject;
}
$this->_storeData();
// Check if the entry that has been requested actually exists
if (!isset($this->_cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']);
$this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz']));
// Re-attach this as the cell's parent
$this->_currentObject->attach($this);
// Return requested entry
return $this->_currentObject;
} // function getCacheData()
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {
$this->_storeData();
}
return parent::getCellList();
}
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
parent::copyCellCollection($parent);
// Open a new stream for the cell cache data
$newFileHandle = fopen('php://temp/maxmemory:'.$this->_memoryCacheSize,'a+');
// Copy the existing cell cache data to the new stream
fseek($this->_fileHandle,0);
while (!feof($this->_fileHandle)) {
fwrite($newFileHandle,fread($this->_fileHandle, 1024));
}
$this->_fileHandle = $newFileHandle;
} // function copyCellCollection()
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
// Close down the php://temp file
$this->__destruct();
} // function unsetWorksheetCells()
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments
*/
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
$this->_memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB';
parent::__construct($parent);
if (is_null($this->_fileHandle)) {
$this->_fileHandle = fopen('php://temp/maxmemory:'.$this->_memoryCacheSize,'a+');
}
} // function __construct()
/**
* Destroy this cell collection
*/
public function __destruct() {
if (!is_null($this->_fileHandle)) {
fclose($this->_fileHandle);
}
$this->_fileHandle = null;
} // function __destruct()
}
<?php
/**
* PHPExcel_CachedObjectStorage_PHPTemp
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Name of the file for this cache
*
* @var string
*/
private $fileHandle = null;
/**
* Memory limit to use before reverting to file cache
*
* @var integer
*/
private $memoryCacheSize = null;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
fseek($this->fileHandle, 0, SEEK_END);
$this->cellCache[$this->currentObjectID] = array(
'ptr' => ftell($this->fileHandle),
'sz' => fwrite($this->fileHandle, serialize($this->currentObject))
);
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
}
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
$this->storeData();
}
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
}
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return $this->currentObject;
}
$this->storeData();
// Check if the entry that has been requested actually exists
if (!isset($this->cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->currentObjectID = $pCoord;
fseek($this->fileHandle, $this->cellCache[$pCoord]['ptr']);
$this->currentObject = unserialize(fread($this->fileHandle, $this->cellCache[$pCoord]['sz']));
// Re-attach this as the cell's parent
$this->currentObject->attach($this);
// Return requested entry
return $this->currentObject;
}
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
return parent::getCellList();
}
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent)
{
parent::copyCellCollection($parent);
// Open a new stream for the cell cache data
$newFileHandle = fopen('php://temp/maxmemory:' . $this->memoryCacheSize, 'a+');
// Copy the existing cell cache data to the new stream
fseek($this->fileHandle, 0);
while (!feof($this->fileHandle)) {
fwrite($newFileHandle, fread($this->fileHandle, 1024));
}
$this->fileHandle = $newFileHandle;
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
$this->cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->parent = null;
// Close down the php://temp file
$this->__destruct();
}
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments
*/
public function __construct(PHPExcel_Worksheet $parent, $arguments)
{
$this->memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB';
parent::__construct($parent);
if (is_null($this->fileHandle)) {
$this->fileHandle = fopen('php://temp/maxmemory:' . $this->memoryCacheSize, 'a+');
}
}
/**
* Destroy this cell collection
*/
public function __destruct()
{
if (!is_null($this->fileHandle)) {
fclose($this->fileHandle);
}
$this->fileHandle = null;
}
}

View file

@ -1,307 +1,307 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_CachedObjectStorage_SQLite
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/**
* Database table name
*
* @var string
*/
private $_TableName = null;
/**
* Database handle
*
* @var resource
*/
private $_DBHandle = null;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty) {
$this->_currentObject->detach();
if (!$this->_DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES('".$this->_currentObjectID."','".sqlite_escape_string(serialize($this->_currentObject))."')"))
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
$this->_currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
}
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
$this->_currentCellIsDirty = true;
return $cell;
} // function addCacheData()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject;
}
$this->_storeData();
$query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
$cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
if ($cellResultSet === false) {
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
} elseif ($cellResultSet->numRows() == 0) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
$cellResult = $cellResultSet->fetchSingle();
$this->_currentObject = unserialize($cellResult);
// Re-attach this as the cell's parent
$this->_currentObject->attach($this);
// Return requested entry
return $this->_currentObject;
} // function getCacheData()
/**
* Is a value set for an indexed cell?
*
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
*/
public function isDataSet($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return true;
}
// Check if the requested entry exists in the cache
$query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
$cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
if ($cellResultSet === false) {
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
} elseif ($cellResultSet->numRows() == 0) {
// Return null if requested entry doesn't exist in cache
return false;
}
return true;
} // function isDataSet()
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
$this->_currentObject->detach();
$this->_currentObjectID = $this->_currentObject = null;
}
// Check if the requested entry exists in the cache
$query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
if (!$this->_DBHandle->queryExec($query))
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
$this->_currentCellIsDirty = false;
} // function deleteCacheData()
/**
* Move a cell object from one address to another
*
* @param string $fromAddress Current address of the cell to move
* @param string $toAddress Destination address of the cell to move
* @return boolean
*/
public function moveCell($fromAddress, $toAddress) {
if ($fromAddress === $this->_currentObjectID) {
$this->_currentObjectID = $toAddress;
}
$query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$toAddress."'";
$result = $this->_DBHandle->exec($query);
if ($result === false)
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
$query = "UPDATE kvp_".$this->_TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'";
$result = $this->_DBHandle->exec($query);
if ($result === false)
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
return TRUE;
} // function moveCell()
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {
$this->_storeData();
}
$query = "SELECT id FROM kvp_".$this->_TableName;
$cellIdsResult = $this->_DBHandle->unbufferedQuery($query,SQLITE_ASSOC);
if ($cellIdsResult === false)
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
$cellKeys = array();
foreach($cellIdsResult as $row) {
$cellKeys[] = $row['id'];
}
return $cellKeys;
} // function getCellList()
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
$this->_currentCellIsDirty;
$this->_storeData();
// Get a new id for the new table name
$tableName = str_replace('.','_',$this->_getUniqueID());
if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
AS SELECT * FROM kvp_'.$this->_TableName))
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
// Copy the existing cell cache file
$this->_TableName = $tableName;
} // function copyCellCollection()
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
// Close down the temporary cache file
$this->__destruct();
} // function unsetWorksheetCells()
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
*/
public function __construct(PHPExcel_Worksheet $parent) {
parent::__construct($parent);
if (is_null($this->_DBHandle)) {
$this->_TableName = str_replace('.','_',$this->_getUniqueID());
$_DBName = ':memory:';
$this->_DBHandle = new SQLiteDatabase($_DBName);
if ($this->_DBHandle === false)
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
}
} // function __construct()
/**
* Destroy this cell collection
*/
public function __destruct() {
if (!is_null($this->_DBHandle)) {
$this->_DBHandle->queryExec('DROP TABLE kvp_'.$this->_TableName);
$this->_DBHandle->close();
}
$this->_DBHandle = null;
} // function __destruct()
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable() {
if (!function_exists('sqlite_open')) {
return false;
}
return true;
}
}
<?php
/**
* PHPExcel_CachedObjectStorage_SQLite
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Database table name
*
* @var string
*/
private $TableName = null;
/**
* Database handle
*
* @var resource
*/
private $DBHandle = null;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
if (!$this->DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->TableName." VALUES('".$this->currentObjectID."','".sqlite_escape_string(serialize($this->currentObject))."')")) {
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
}
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
}
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
$this->storeData();
}
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
}
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return $this->currentObject;
}
$this->storeData();
$query = "SELECT value FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
$cellResultSet = $this->DBHandle->query($query, SQLITE_ASSOC);
if ($cellResultSet === false) {
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
} elseif ($cellResultSet->numRows() == 0) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->currentObjectID = $pCoord;
$cellResult = $cellResultSet->fetchSingle();
$this->currentObject = unserialize($cellResult);
// Re-attach this as the cell's parent
$this->currentObject->attach($this);
// Return requested entry
return $this->currentObject;
}
/**
* Is a value set for an indexed cell?
*
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
*/
public function isDataSet($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return true;
}
// Check if the requested entry exists in the cache
$query = "SELECT id FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
$cellResultSet = $this->DBHandle->query($query, SQLITE_ASSOC);
if ($cellResultSet === false) {
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
} elseif ($cellResultSet->numRows() == 0) {
// Return null if requested entry doesn't exist in cache
return false;
}
return true;
}
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
$this->currentObject->detach();
$this->currentObjectID = $this->currentObject = null;
}
// Check if the requested entry exists in the cache
$query = "DELETE FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
if (!$this->DBHandle->queryExec($query)) {
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
}
$this->currentCellIsDirty = false;
}
/**
* Move a cell object from one address to another
*
* @param string $fromAddress Current address of the cell to move
* @param string $toAddress Destination address of the cell to move
* @return boolean
*/
public function moveCell($fromAddress, $toAddress)
{
if ($fromAddress === $this->currentObjectID) {
$this->currentObjectID = $toAddress;
}
$query = "DELETE FROM kvp_".$this->TableName." WHERE id='".$toAddress."'";
$result = $this->DBHandle->exec($query);
if ($result === false) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
$query = "UPDATE kvp_".$this->TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'";
$result = $this->DBHandle->exec($query);
if ($result === false) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
return true;
}
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
$query = "SELECT id FROM kvp_".$this->TableName;
$cellIdsResult = $this->DBHandle->unbufferedQuery($query, SQLITE_ASSOC);
if ($cellIdsResult === false) {
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
}
$cellKeys = array();
foreach ($cellIdsResult as $row) {
$cellKeys[] = $row['id'];
}
return $cellKeys;
}
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent)
{
$this->currentCellIsDirty;
$this->storeData();
// Get a new id for the new table name
$tableName = str_replace('.', '_', $this->getUniqueID());
if (!$this->DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
AS SELECT * FROM kvp_'.$this->TableName)
) {
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
}
// Copy the existing cell cache file
$this->TableName = $tableName;
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->parent = null;
// Close down the temporary cache file
$this->__destruct();
}
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
*/
public function __construct(PHPExcel_Worksheet $parent)
{
parent::__construct($parent);
if (is_null($this->DBHandle)) {
$this->TableName = str_replace('.', '_', $this->getUniqueID());
$_DBName = ':memory:';
$this->DBHandle = new SQLiteDatabase($_DBName);
if ($this->DBHandle === false) {
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
}
if (!$this->DBHandle->queryExec('CREATE TABLE kvp_'.$this->TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) {
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
}
}
}
/**
* Destroy this cell collection
*/
public function __destruct()
{
if (!is_null($this->DBHandle)) {
$this->DBHandle->queryExec('DROP TABLE kvp_'.$this->TableName);
}
$this->DBHandle = null;
}
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable()
{
if (!function_exists('sqlite_open')) {
return false;
}
return true;
}
}

View file

@ -1,322 +1,346 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_CachedObjectStorage_SQLite3
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/**
* Database table name
*
* @var string
*/
private $_TableName = null;
/**
* Database handle
*
* @var resource
*/
private $_DBHandle = null;
private $_selectQuery;
private $_insertQuery;
private $_updateQuery;
private $_deleteQuery;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty) {
$this->_currentObject->detach();
$this->_insertQuery->bindValue('id',$this->_currentObjectID,SQLITE3_TEXT);
$this->_insertQuery->bindValue('data',serialize($this->_currentObject),SQLITE3_BLOB);
$result = $this->_insertQuery->execute();
if ($result === false)
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
$this->_currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
}
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
$this->_currentCellIsDirty = true;
return $cell;
} // function addCacheData()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject;
}
$this->_storeData();
$this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
$cellResult = $this->_selectQuery->execute();
if ($cellResult === FALSE) {
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
}
$cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
if ($cellData === FALSE) {
// Return null if requested entry doesn't exist in cache
return NULL;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
$this->_currentObject = unserialize($cellData['value']);
// Re-attach this as the cell's parent
$this->_currentObject->attach($this);
// Return requested entry
return $this->_currentObject;
} // function getCacheData()
/**
* Is a value set for an indexed cell?
*
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
*/
public function isDataSet($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return TRUE;
}
// Check if the requested entry exists in the cache
$this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
$cellResult = $this->_selectQuery->execute();
if ($cellResult === FALSE) {
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
}
$cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
return ($cellData === FALSE) ? FALSE : TRUE;
} // function isDataSet()
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
$this->_currentObject->detach();
$this->_currentObjectID = $this->_currentObject = NULL;
}
// Check if the requested entry exists in the cache
$this->_deleteQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
$result = $this->_deleteQuery->execute();
if ($result === FALSE)
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
$this->_currentCellIsDirty = FALSE;
} // function deleteCacheData()
/**
* Move a cell object from one address to another
*
* @param string $fromAddress Current address of the cell to move
* @param string $toAddress Destination address of the cell to move
* @return boolean
*/
public function moveCell($fromAddress, $toAddress) {
if ($fromAddress === $this->_currentObjectID) {
$this->_currentObjectID = $toAddress;
}
$this->_deleteQuery->bindValue('id',$toAddress,SQLITE3_TEXT);
$result = $this->_deleteQuery->execute();
if ($result === false)
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
$this->_updateQuery->bindValue('toid',$toAddress,SQLITE3_TEXT);
$this->_updateQuery->bindValue('fromid',$fromAddress,SQLITE3_TEXT);
$result = $this->_updateQuery->execute();
if ($result === false)
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
return TRUE;
} // function moveCell()
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {
$this->_storeData();
}
$query = "SELECT id FROM kvp_".$this->_TableName;
$cellIdsResult = $this->_DBHandle->query($query);
if ($cellIdsResult === false)
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
$cellKeys = array();
while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) {
$cellKeys[] = $row['id'];
}
return $cellKeys;
} // function getCellList()
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
$this->_currentCellIsDirty;
$this->_storeData();
// Get a new id for the new table name
$tableName = str_replace('.','_',$this->_getUniqueID());
if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
AS SELECT * FROM kvp_'.$this->_TableName))
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
// Copy the existing cell cache file
$this->_TableName = $tableName;
} // function copyCellCollection()
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
// Close down the temporary cache file
$this->__destruct();
} // function unsetWorksheetCells()
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
*/
public function __construct(PHPExcel_Worksheet $parent) {
parent::__construct($parent);
if (is_null($this->_DBHandle)) {
$this->_TableName = str_replace('.','_',$this->_getUniqueID());
$_DBName = ':memory:';
$this->_DBHandle = new SQLite3($_DBName);
if ($this->_DBHandle === false)
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
}
$this->_selectQuery = $this->_DBHandle->prepare("SELECT value FROM kvp_".$this->_TableName." WHERE id = :id");
$this->_insertQuery = $this->_DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES(:id,:data)");
$this->_updateQuery = $this->_DBHandle->prepare("UPDATE kvp_".$this->_TableName." SET id=:toId WHERE id=:fromId");
$this->_deleteQuery = $this->_DBHandle->prepare("DELETE FROM kvp_".$this->_TableName." WHERE id = :id");
} // function __construct()
/**
* Destroy this cell collection
*/
public function __destruct() {
if (!is_null($this->_DBHandle)) {
$this->_DBHandle->exec('DROP TABLE kvp_'.$this->_TableName);
$this->_DBHandle->close();
}
$this->_DBHandle = null;
} // function __destruct()
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable() {
if (!class_exists('SQLite3',FALSE)) {
return false;
}
return true;
}
}
<?php
/**
* PHPExcel_CachedObjectStorage_SQLite3
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Database table name
*
* @var string
*/
private $TableName = null;
/**
* Database handle
*
* @var resource
*/
private $DBHandle = null;
/**
* Prepared statement for a SQLite3 select query
*
* @var SQLite3Stmt
*/
private $selectQuery;
/**
* Prepared statement for a SQLite3 insert query
*
* @var SQLite3Stmt
*/
private $insertQuery;
/**
* Prepared statement for a SQLite3 update query
*
* @var SQLite3Stmt
*/
private $updateQuery;
/**
* Prepared statement for a SQLite3 delete query
*
* @var SQLite3Stmt
*/
private $deleteQuery;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
$this->insertQuery->bindValue('id', $this->currentObjectID, SQLITE3_TEXT);
$this->insertQuery->bindValue('data', serialize($this->currentObject), SQLITE3_BLOB);
$result = $this->insertQuery->execute();
if ($result === false) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
}
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
$this->storeData();
}
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
}
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return $this->currentObject;
}
$this->storeData();
$this->selectQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
$cellResult = $this->selectQuery->execute();
if ($cellResult === false) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
$cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
if ($cellData === false) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->currentObjectID = $pCoord;
$this->currentObject = unserialize($cellData['value']);
// Re-attach this as the cell's parent
$this->currentObject->attach($this);
// Return requested entry
return $this->currentObject;
}
/**
* Is a value set for an indexed cell?
*
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
*/
public function isDataSet($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return true;
}
// Check if the requested entry exists in the cache
$this->selectQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
$cellResult = $this->selectQuery->execute();
if ($cellResult === false) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
$cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
return ($cellData === false) ? false : true;
}
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
$this->currentObject->detach();
$this->currentObjectID = $this->currentObject = null;
}
// Check if the requested entry exists in the cache
$this->deleteQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
$result = $this->deleteQuery->execute();
if ($result === false) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
$this->currentCellIsDirty = false;
}
/**
* Move a cell object from one address to another
*
* @param string $fromAddress Current address of the cell to move
* @param string $toAddress Destination address of the cell to move
* @return boolean
*/
public function moveCell($fromAddress, $toAddress)
{
if ($fromAddress === $this->currentObjectID) {
$this->currentObjectID = $toAddress;
}
$this->deleteQuery->bindValue('id', $toAddress, SQLITE3_TEXT);
$result = $this->deleteQuery->execute();
if ($result === false) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
$this->updateQuery->bindValue('toid', $toAddress, SQLITE3_TEXT);
$this->updateQuery->bindValue('fromid', $fromAddress, SQLITE3_TEXT);
$result = $this->updateQuery->execute();
if ($result === false) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
return true;
}
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
$query = "SELECT id FROM kvp_".$this->TableName;
$cellIdsResult = $this->DBHandle->query($query);
if ($cellIdsResult === false) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
$cellKeys = array();
while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) {
$cellKeys[] = $row['id'];
}
return $cellKeys;
}
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent)
{
$this->currentCellIsDirty;
$this->storeData();
// Get a new id for the new table name
$tableName = str_replace('.', '_', $this->getUniqueID());
if (!$this->DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
AS SELECT * FROM kvp_'.$this->TableName)
) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
// Copy the existing cell cache file
$this->TableName = $tableName;
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->parent = null;
// Close down the temporary cache file
$this->__destruct();
}
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
*/
public function __construct(PHPExcel_Worksheet $parent)
{
parent::__construct($parent);
if (is_null($this->DBHandle)) {
$this->TableName = str_replace('.', '_', $this->getUniqueID());
$_DBName = ':memory:';
$this->DBHandle = new SQLite3($_DBName);
if ($this->DBHandle === false) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
if (!$this->DBHandle->exec('CREATE TABLE kvp_'.$this->TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
}
$this->selectQuery = $this->DBHandle->prepare("SELECT value FROM kvp_".$this->TableName." WHERE id = :id");
$this->insertQuery = $this->DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->TableName." VALUES(:id,:data)");
$this->updateQuery = $this->DBHandle->prepare("UPDATE kvp_".$this->TableName." SET id=:toId WHERE id=:fromId");
$this->deleteQuery = $this->DBHandle->prepare("DELETE FROM kvp_".$this->TableName." WHERE id = :id");
}
/**
* Destroy this cell collection
*/
public function __destruct()
{
if (!is_null($this->DBHandle)) {
$this->DBHandle->exec('DROP TABLE kvp_'.$this->TableName);
$this->DBHandle->close();
}
$this->DBHandle = null;
}
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable()
{
if (!class_exists('SQLite3', false)) {
return false;
}
return true;
}
}

View file

@ -1,294 +1,289 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_CachedObjectStorage_Wincache
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/**
* Prefix used to uniquely identify cache data for this worksheet
*
* @var string
*/
private $_cachePrefix = null;
/**
* Cache timeout
*
* @var integer
*/
private $_cacheTime = 600;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty) {
$this->_currentObject->detach();
$obj = serialize($this->_currentObject);
if (wincache_ucache_exists($this->_cachePrefix.$this->_currentObjectID.'.cache')) {
if (!wincache_ucache_set($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) {
$this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache');
}
} else {
if (!wincache_ucache_add($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) {
$this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache');
}
}
$this->_currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
}
$this->_cellCache[$pCoord] = true;
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
$this->_currentCellIsDirty = true;
return $cell;
} // function addCacheData()
/**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
*/
public function isDataSet($pCoord) {
// Check if the requested entry is the current object, or exists in the cache
if (parent::isDataSet($pCoord)) {
if ($this->_currentObjectID == $pCoord) {
return true;
}
// Check if the requested entry still exists in cache
$success = wincache_ucache_exists($this->_cachePrefix.$pCoord.'.cache');
if ($success === false) {
// Entry no longer exists in Wincache, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
}
return true;
}
return false;
} // function isDataSet()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject;
}
$this->_storeData();
// Check if the entry that has been requested actually exists
$obj = null;
if (parent::isDataSet($pCoord)) {
$success = false;
$obj = wincache_ucache_get($this->_cachePrefix.$pCoord.'.cache', $success);
if ($success === false) {
// Entry no longer exists in WinCache, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
}
} else {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
$this->_currentObject = unserialize($obj);
// Re-attach this as the cell's parent
$this->_currentObject->attach($this);
// Return requested entry
return $this->_currentObject;
} // function getCacheData()
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {
$this->_storeData();
}
return parent::getCellList();
}
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord) {
// Delete the entry from Wincache
wincache_ucache_delete($this->_cachePrefix.$pCoord.'.cache');
// Delete the entry from our cell address array
parent::deleteCacheData($pCoord);
} // function deleteCacheData()
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
parent::copyCellCollection($parent);
// Get a new id for the new file name
$baseUnique = $this->_getUniqueID();
$newCachePrefix = substr(md5($baseUnique),0,8).'.';
$cacheList = $this->getCellList();
foreach($cacheList as $cellID) {
if ($cellID != $this->_currentObjectID) {
$success = false;
$obj = wincache_ucache_get($this->_cachePrefix.$cellID.'.cache', $success);
if ($success === false) {
// Entry no longer exists in WinCache, so clear it from the cache array
parent::deleteCacheData($cellID);
throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in Wincache');
}
if (!wincache_ucache_add($newCachePrefix.$cellID.'.cache', $obj, $this->_cacheTime)) {
$this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in Wincache');
}
}
}
$this->_cachePrefix = $newCachePrefix;
} // function copyCellCollection()
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
// Flush the WinCache cache
$this->__destruct();
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
} // function unsetWorksheetCells()
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments
*/
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
if (is_null($this->_cachePrefix)) {
$baseUnique = $this->_getUniqueID();
$this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
$this->_cacheTime = $cacheTime;
parent::__construct($parent);
}
} // function __construct()
/**
* Destroy this cell collection
*/
public function __destruct() {
$cacheList = $this->getCellList();
foreach($cacheList as $cellID) {
wincache_ucache_delete($this->_cachePrefix.$cellID.'.cache');
}
} // function __destruct()
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable() {
if (!function_exists('wincache_ucache_add')) {
return false;
}
return true;
}
}
<?php
/**
* PHPExcel_CachedObjectStorage_Wincache
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Prefix used to uniquely identify cache data for this worksheet
*
* @var string
*/
private $cachePrefix = null;
/**
* Cache timeout
*
* @var integer
*/
private $cacheTime = 600;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
$obj = serialize($this->currentObject);
if (wincache_ucache_exists($this->cachePrefix.$this->currentObjectID.'.cache')) {
if (!wincache_ucache_set($this->cachePrefix.$this->currentObjectID.'.cache', $obj, $this->cacheTime)) {
$this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$this->currentObjectID.' in WinCache');
}
} else {
if (!wincache_ucache_add($this->cachePrefix.$this->currentObjectID.'.cache', $obj, $this->cacheTime)) {
$this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$this->currentObjectID.' in WinCache');
}
}
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
}
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
$this->storeData();
}
$this->cellCache[$pCoord] = true;
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
}
/**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
*/
public function isDataSet($pCoord)
{
// Check if the requested entry is the current object, or exists in the cache
if (parent::isDataSet($pCoord)) {
if ($this->currentObjectID == $pCoord) {
return true;
}
// Check if the requested entry still exists in cache
$success = wincache_ucache_exists($this->cachePrefix.$pCoord.'.cache');
if ($success === false) {
// Entry no longer exists in Wincache, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
}
return true;
}
return false;
}
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return $this->currentObject;
}
$this->storeData();
// Check if the entry that has been requested actually exists
$obj = null;
if (parent::isDataSet($pCoord)) {
$success = false;
$obj = wincache_ucache_get($this->cachePrefix.$pCoord.'.cache', $success);
if ($success === false) {
// Entry no longer exists in WinCache, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
}
} else {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->currentObjectID = $pCoord;
$this->currentObject = unserialize($obj);
// Re-attach this as the cell's parent
$this->currentObject->attach($this);
// Return requested entry
return $this->currentObject;
}
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
return parent::getCellList();
}
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord)
{
// Delete the entry from Wincache
wincache_ucache_delete($this->cachePrefix.$pCoord.'.cache');
// Delete the entry from our cell address array
parent::deleteCacheData($pCoord);
}
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent)
{
parent::copyCellCollection($parent);
// Get a new id for the new file name
$baseUnique = $this->getUniqueID();
$newCachePrefix = substr(md5($baseUnique), 0, 8) . '.';
$cacheList = $this->getCellList();
foreach ($cacheList as $cellID) {
if ($cellID != $this->currentObjectID) {
$success = false;
$obj = wincache_ucache_get($this->cachePrefix.$cellID.'.cache', $success);
if ($success === false) {
// Entry no longer exists in WinCache, so clear it from the cache array
parent::deleteCacheData($cellID);
throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in Wincache');
}
if (!wincache_ucache_add($newCachePrefix.$cellID.'.cache', $obj, $this->cacheTime)) {
$this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in Wincache');
}
}
}
$this->cachePrefix = $newCachePrefix;
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
// Flush the WinCache cache
$this->__destruct();
$this->cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->parent = null;
}
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments
*/
public function __construct(PHPExcel_Worksheet $parent, $arguments)
{
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
if (is_null($this->cachePrefix)) {
$baseUnique = $this->getUniqueID();
$this->cachePrefix = substr(md5($baseUnique), 0, 8).'.';
$this->cacheTime = $cacheTime;
parent::__construct($parent);
}
}
/**
* Destroy this cell collection
*/
public function __destruct()
{
$cacheList = $this->getCellList();
foreach ($cacheList as $cellID) {
wincache_ucache_delete($this->cachePrefix.$cellID.'.cache');
}
}
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable()
{
if (!function_exists('wincache_ucache_add')) {
return false;
}
return true;
}
}

View file

@ -1,9 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_CachedObjectStorageFactory
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -21,19 +21,10 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_CachedObjectStorageFactory
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorageFactory
{
const cache_in_memory = 'Memory';
@ -48,28 +39,26 @@ class PHPExcel_CachedObjectStorageFactory
const cache_to_sqlite = 'SQLite';
const cache_to_sqlite3 = 'SQLite3';
/**
* Name of the method used for cell cacheing
*
* @var string
*/
private static $_cacheStorageMethod = NULL;
private static $cacheStorageMethod = null;
/**
* Name of the class used for cell cacheing
*
* @var string
*/
private static $_cacheStorageClass = NULL;
private static $cacheStorageClass = null;
/**
* List of all possible cache storage methods
*
* @var string[]
*/
private static $_storageMethods = array(
private static $storageMethods = array(
self::cache_in_memory,
self::cache_in_memory_gzip,
self::cache_in_memory_serialized,
@ -83,13 +72,12 @@ class PHPExcel_CachedObjectStorageFactory
self::cache_to_sqlite3,
);
/**
* Default arguments for each cache storage method
*
* @var array of mixed array
*/
private static $_storageMethodDefaultParameters = array(
private static $storageMethodDefaultParameters = array(
self::cache_in_memory => array(
),
self::cache_in_memory_gzip => array(
@ -100,7 +88,7 @@ class PHPExcel_CachedObjectStorageFactory
),
self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB'
),
self::cache_to_discISAM => array( 'dir' => NULL
self::cache_to_discISAM => array( 'dir' => null
),
self::cache_to_apc => array( 'cacheTime' => 600
),
@ -116,36 +104,32 @@ class PHPExcel_CachedObjectStorageFactory
),
);
/**
* Arguments for the active cache storage method
*
* @var array of mixed array
*/
private static $_storageMethodParameters = array();
private static $storageMethodParameters = array();
/**
* Return the current cache storage method
*
* @return string|NULL
* @return string|null
**/
public static function getCacheStorageMethod()
{
return self::$_cacheStorageMethod;
} // function getCacheStorageMethod()
return self::$cacheStorageMethod;
}
/**
* Return the current cache storage class
*
* @return PHPExcel_CachedObjectStorage_ICache|NULL
* @return PHPExcel_CachedObjectStorage_ICache|null
**/
public static function getCacheStorageClass()
{
return self::$_cacheStorageClass;
} // function getCacheStorageClass()
return self::$cacheStorageClass;
}
/**
* Return the list of all possible cache storage methods
@ -154,9 +138,8 @@ class PHPExcel_CachedObjectStorageFactory
**/
public static function getAllCacheStorageMethods()
{
return self::$_storageMethods;
} // function getCacheStorageMethods()
return self::$storageMethods;
}
/**
* Return the list of all available cache storage methods
@ -166,15 +149,14 @@ class PHPExcel_CachedObjectStorageFactory
public static function getCacheStorageMethods()
{
$activeMethods = array();
foreach(self::$_storageMethods as $storageMethod) {
foreach (self::$storageMethods as $storageMethod) {
$cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $storageMethod;
if (call_user_func(array($cacheStorageClass, 'cacheMethodIsAvailable'))) {
$activeMethods[] = $storageMethod;
}
}
return $activeMethods;
} // function getCacheStorageMethods()
}
/**
* Identify the cache storage method to use
@ -186,30 +168,29 @@ class PHPExcel_CachedObjectStorageFactory
**/
public static function initialize($method = self::cache_in_memory, $arguments = array())
{
if (!in_array($method,self::$_storageMethods)) {
return FALSE;
if (!in_array($method, self::$storageMethods)) {
return false;
}
$cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method;
if (!call_user_func(array( $cacheStorageClass,
'cacheMethodIsAvailable'))) {
return FALSE;
return false;
}
self::$_storageMethodParameters[$method] = self::$_storageMethodDefaultParameters[$method];
foreach($arguments as $k => $v) {
if (array_key_exists($k, self::$_storageMethodParameters[$method])) {
self::$_storageMethodParameters[$method][$k] = $v;
self::$storageMethodParameters[$method] = self::$storageMethodDefaultParameters[$method];
foreach ($arguments as $k => $v) {
if (array_key_exists($k, self::$storageMethodParameters[$method])) {
self::$storageMethodParameters[$method][$k] = $v;
}
}
if (self::$_cacheStorageMethod === NULL) {
self::$_cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $method;
self::$_cacheStorageMethod = $method;
if (self::$cacheStorageMethod === null) {
self::$cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $method;
self::$cacheStorageMethod = $method;
}
return TRUE;
} // function initialize()
return true;
}
/**
* Initialise the cache storage
@ -219,29 +200,32 @@ class PHPExcel_CachedObjectStorageFactory
**/
public static function getInstance(PHPExcel_Worksheet $parent)
{
$cacheMethodIsAvailable = TRUE;
if (self::$_cacheStorageMethod === NULL) {
$cacheMethodIsAvailable = true;
if (self::$cacheStorageMethod === null) {
$cacheMethodIsAvailable = self::initialize();
}
if ($cacheMethodIsAvailable) {
$instance = new self::$_cacheStorageClass( $parent,
self::$_storageMethodParameters[self::$_cacheStorageMethod]
);
if ($instance !== NULL) {
$instance = new self::$cacheStorageClass(
$parent,
self::$storageMethodParameters[self::$cacheStorageMethod]
);
if ($instance !== null) {
return $instance;
}
}
return FALSE;
} // function getInstance()
public static function finalize()
{
self::$_cacheStorageMethod = NULL;
self::$_cacheStorageClass = NULL;
self::$_storageMethodParameters = array();
}
return false;
}
/**
* Clear the cache storage
*
**/
public static function finalize()
{
self::$cacheStorageMethod = null;
self::$cacheStorageClass = null;
self::$storageMethodParameters = array();
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_CalcEngine_CyclicReferenceStack
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,39 +21,74 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CalcEngine_CyclicReferenceStack
{
/**
* The call stack for calculated cells
*
* @var mixed[]
*/
private $stack = array();
/**
* Return the number of entries on the stack
*
* @return integer
*/
public function count()
{
return count($this->stack);
}
class PHPExcel_CalcEngine_CyclicReferenceStack {
/**
* Push a new entry onto the stack
*
* @param mixed $value
*/
public function push($value)
{
$this->stack[$value] = $value;
}
private $_stack = array();
/**
* Pop the last entry from the stack
*
* @return mixed
*/
public function pop()
{
return array_pop($this->stack);
}
/**
* Test to see if a specified entry exists on the stack
*
* @param mixed $value The value to test
*/
public function onStack($value)
{
return isset($this->stack[$value]);
}
public function count() {
return count($this->_stack);
}
/**
* Clear the stack
*/
public function clear()
{
$this->stack = array();
}
public function push($value) {
$this->_stack[] = $value;
} // function push()
public function pop() {
return array_pop($this->_stack);
} // function pop()
public function onStack($value) {
return in_array($value,$this->_stack);
}
public function clear() {
$this->_stack = array();
} // function push()
public function showStack() {
return $this->_stack;
}
} // class PHPExcel_CalcEngine_CyclicReferenceStack
/**
* Return an array of all entries on the stack
*
* @return mixed[]
*/
public function showStack()
{
return $this->stack;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_CalcEngine_Logger
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,102 +21,131 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CalcEngine_Logger
{
/**
* Flag to determine whether a debug log should be generated by the calculation engine
* If true, then a debug log will be generated
* If false, then a debug log will not be generated
*
* @var boolean
*/
private $writeDebugLog = false;
/**
* PHPExcel_Calculation_Logger
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CalcEngine_Logger {
/**
* Flag to determine whether a debug log should be echoed by the calculation engine
* If true, then a debug log will be echoed
* If false, then a debug log will not be echoed
* A debug log can only be echoed if it is generated
*
* @var boolean
*/
private $echoDebugLog = false;
/**
* Flag to determine whether a debug log should be generated by the calculation engine
* If true, then a debug log will be generated
* If false, then a debug log will not be generated
*
* @var boolean
*
*/
private $_writeDebugLog = FALSE;
/**
* The debug log generated by the calculation engine
*
* @var string[]
*/
private $debugLog = array();
/**
* Flag to determine whether a debug log should be echoed by the calculation engine
* If true, then a debug log will be echoed
* If false, then a debug log will not be echoed
* A debug log can only be echoed if it is generated
*
* @var boolean
*
*/
private $_echoDebugLog = FALSE;
/**
* The calculation engine cell reference stack
*
* @var PHPExcel_CalcEngine_CyclicReferenceStack
*/
private $cellStack;
/**
* The debug log generated by the calculation engine
*
* @var string[]
*
*/
private $_debugLog = array();
/**
* Instantiate a Calculation engine logger
*
* @param PHPExcel_CalcEngine_CyclicReferenceStack $stack
*/
public function __construct(PHPExcel_CalcEngine_CyclicReferenceStack $stack)
{
$this->cellStack = $stack;
}
/**
* The calculation engine cell reference stack
*
* @var PHPExcel_CalcEngine_CyclicReferenceStack
*
*/
private $_cellStack;
/**
* Enable/Disable Calculation engine logging
*
* @param boolean $pValue
*/
public function setWriteDebugLog($pValue = false)
{
$this->writeDebugLog = $pValue;
}
public function __construct(PHPExcel_CalcEngine_CyclicReferenceStack $stack) {
$this->_cellStack = $stack;
}
/**
* Return whether calculation engine logging is enabled or disabled
*
* @return boolean
*/
public function getWriteDebugLog()
{
return $this->writeDebugLog;
}
public function setWriteDebugLog($pValue = FALSE) {
$this->_writeDebugLog = $pValue;
}
/**
* Enable/Disable echoing of debug log information
*
* @param boolean $pValue
*/
public function setEchoDebugLog($pValue = false)
{
$this->echoDebugLog = $pValue;
}
public function getWriteDebugLog() {
return $this->_writeDebugLog;
}
/**
* Return whether echoing of debug log information is enabled or disabled
*
* @return boolean
*/
public function getEchoDebugLog()
{
return $this->echoDebugLog;
}
public function setEchoDebugLog($pValue = FALSE) {
$this->_echoDebugLog = $pValue;
}
/**
* Write an entry to the calculation engine debug log
*/
public function writeDebugLog()
{
// Only write the debug log if logging is enabled
if ($this->writeDebugLog) {
$message = implode(func_get_args());
$cellReference = implode(' -> ', $this->cellStack->showStack());
if ($this->echoDebugLog) {
echo $cellReference,
($this->cellStack->count() > 0 ? ' => ' : ''),
$message,
PHP_EOL;
}
$this->debugLog[] = $cellReference .
($this->cellStack->count() > 0 ? ' => ' : '') .
$message;
}
}
public function getEchoDebugLog() {
return $this->_echoDebugLog;
}
public function writeDebugLog() {
// Only write the debug log if logging is enabled
if ($this->_writeDebugLog) {
$message = implode(func_get_args());
$cellReference = implode(' -> ', $this->_cellStack->showStack());
if ($this->_echoDebugLog) {
echo $cellReference,
($this->_cellStack->count() > 0 ? ' => ' : ''),
$message,
PHP_EOL;
}
$this->_debugLog[] = $cellReference .
($this->_cellStack->count() > 0 ? ' => ' : '') .
$message;
}
} // function _writeDebug()
public function clearLog() {
$this->_debugLog = array();
} // function flushLogger()
public function getLog() {
return $this->_debugLog;
} // function flushLogger()
} // class PHPExcel_CalcEngine_Logger
/**
* Clear the calculation engine debug log
*/
public function clearLog()
{
$this->debugLog = array();
}
/**
* Return the calculation engine debug log
*
* @return string[]
*/
public function getLog()
{
return $this->debugLog;
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Calculation_Exception
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,33 +21,26 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Calculation_Exception
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Exception extends PHPExcel_Exception {
/**
* Error handler callback
*
* @param mixed $code
* @param mixed $string
* @param mixed $file
* @param mixed $line
* @param mixed $context
*/
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
$e = new self($string, $code);
$e->line = $line;
$e->file = $file;
throw $e;
}
class PHPExcel_Calculation_Exception extends PHPExcel_Exception
{
/**
* Error handler callback
*
* @param mixed $code
* @param mixed $string
* @param mixed $file
* @param mixed $line
* @param mixed $context
*/
public static function errorHandlerCallback($code, $string, $file, $line, $context)
{
$e = new self($string, $code);
$e->line = $line;
$e->file = $file;
throw $e;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Calculation_ExceptionHandler
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,30 +21,25 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Calculation_ExceptionHandler
{
/**
* Register errorhandler
*/
public function __construct()
{
set_error_handler(array('PHPExcel_Calculation_Exception', 'errorHandlerCallback'), E_ALL);
}
/**
* PHPExcel_Calculation_ExceptionHandler
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_ExceptionHandler {
/**
* Register errorhandler
*/
public function __construct() {
set_error_handler(array('PHPExcel_Calculation_Exception', 'errorHandlerCallback'), E_ALL);
}
/**
* Unregister errorhandler
*/
public function __destruct() {
restore_error_handler();
}
/**
* Unregister errorhandler
*/
public function __destruct()
{
restore_error_handler();
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,32 @@
<?php
/*
PARTLY BASED ON:
Copyright (c) 2007 E. W. Bachtal, Inc.
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.
http://ewbi.blogs.com/develops/2007/03/excel_formula_p.html
http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html
*/
/**
* PHPExcel
* PHPExcel_Calculation_FormulaToken
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,104 +44,74 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/*
PARTLY BASED ON:
Copyright (c) 2007 E. W. Bachtal, Inc.
class PHPExcel_Calculation_FormulaToken
{
/* Token types */
const TOKEN_TYPE_NOOP = 'Noop';
const TOKEN_TYPE_OPERAND = 'Operand';
const TOKEN_TYPE_FUNCTION = 'Function';
const TOKEN_TYPE_SUBEXPRESSION = 'Subexpression';
const TOKEN_TYPE_ARGUMENT = 'Argument';
const TOKEN_TYPE_OPERATORPREFIX = 'OperatorPrefix';
const TOKEN_TYPE_OPERATORINFIX = 'OperatorInfix';
const TOKEN_TYPE_OPERATORPOSTFIX = 'OperatorPostfix';
const TOKEN_TYPE_WHITESPACE = 'Whitespace';
const TOKEN_TYPE_UNKNOWN = 'Unknown';
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:
/* Token subtypes */
const TOKEN_SUBTYPE_NOTHING = 'Nothing';
const TOKEN_SUBTYPE_START = 'Start';
const TOKEN_SUBTYPE_STOP = 'Stop';
const TOKEN_SUBTYPE_TEXT = 'Text';
const TOKEN_SUBTYPE_NUMBER = 'Number';
const TOKEN_SUBTYPE_LOGICAL = 'Logical';
const TOKEN_SUBTYPE_ERROR = 'Error';
const TOKEN_SUBTYPE_RANGE = 'Range';
const TOKEN_SUBTYPE_MATH = 'Math';
const TOKEN_SUBTYPE_CONCATENATION = 'Concatenation';
const TOKEN_SUBTYPE_INTERSECTION = 'Intersection';
const TOKEN_SUBTYPE_UNION = 'Union';
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
/**
* Value
*
* @var string
*/
private $value;
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.
/**
* Token Type (represented by TOKEN_TYPE_*)
*
* @var string
*/
private $tokenType;
http://ewbi.blogs.com/develops/2007/03/excel_formula_p.html
http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html
*/
/**
* PHPExcel_Calculation_FormulaToken
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_FormulaToken {
/* Token types */
const TOKEN_TYPE_NOOP = 'Noop';
const TOKEN_TYPE_OPERAND = 'Operand';
const TOKEN_TYPE_FUNCTION = 'Function';
const TOKEN_TYPE_SUBEXPRESSION = 'Subexpression';
const TOKEN_TYPE_ARGUMENT = 'Argument';
const TOKEN_TYPE_OPERATORPREFIX = 'OperatorPrefix';
const TOKEN_TYPE_OPERATORINFIX = 'OperatorInfix';
const TOKEN_TYPE_OPERATORPOSTFIX = 'OperatorPostfix';
const TOKEN_TYPE_WHITESPACE = 'Whitespace';
const TOKEN_TYPE_UNKNOWN = 'Unknown';
/* Token subtypes */
const TOKEN_SUBTYPE_NOTHING = 'Nothing';
const TOKEN_SUBTYPE_START = 'Start';
const TOKEN_SUBTYPE_STOP = 'Stop';
const TOKEN_SUBTYPE_TEXT = 'Text';
const TOKEN_SUBTYPE_NUMBER = 'Number';
const TOKEN_SUBTYPE_LOGICAL = 'Logical';
const TOKEN_SUBTYPE_ERROR = 'Error';
const TOKEN_SUBTYPE_RANGE = 'Range';
const TOKEN_SUBTYPE_MATH = 'Math';
const TOKEN_SUBTYPE_CONCATENATION = 'Concatenation';
const TOKEN_SUBTYPE_INTERSECTION = 'Intersection';
const TOKEN_SUBTYPE_UNION = 'Union';
/**
* Value
*
* @var string
*/
private $_value;
/**
* Token Type (represented by TOKEN_TYPE_*)
*
* @var string
*/
private $_tokenType;
/**
* Token SubType (represented by TOKEN_SUBTYPE_*)
*
* @var string
*/
private $_tokenSubType;
/**
* Token SubType (represented by TOKEN_SUBTYPE_*)
*
* @var string
*/
private $tokenSubType;
/**
* Create a new PHPExcel_Calculation_FormulaToken
*
* @param string $pValue
* @param string $pTokenType Token type (represented by TOKEN_TYPE_*)
* @param string $pTokenSubType Token Subtype (represented by TOKEN_SUBTYPE_*)
* @param string $pValue
* @param string $pTokenType Token type (represented by TOKEN_TYPE_*)
* @param string $pTokenSubType Token Subtype (represented by TOKEN_SUBTYPE_*)
*/
public function __construct($pValue, $pTokenType = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN, $pTokenSubType = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING)
{
// Initialise values
$this->_value = $pValue;
$this->_tokenType = $pTokenType;
$this->_tokenSubType = $pTokenSubType;
// Initialise values
$this->value = $pValue;
$this->tokenType = $pTokenType;
$this->tokenSubType = $pTokenSubType;
}
/**
@ -125,17 +119,19 @@ class PHPExcel_Calculation_FormulaToken {
*
* @return string
*/
public function getValue() {
return $this->_value;
public function getValue()
{
return $this->value;
}
/**
* Set Value
*
* @param string $value
* @param string $value
*/
public function setValue($value) {
$this->_value = $value;
public function setValue($value)
{
$this->value = $value;
}
/**
@ -143,17 +139,19 @@ class PHPExcel_Calculation_FormulaToken {
*
* @return string
*/
public function getTokenType() {
return $this->_tokenType;
public function getTokenType()
{
return $this->tokenType;
}
/**
* Set Token Type
*
* @param string $value
* @param string $value
*/
public function setTokenType($value = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN) {
$this->_tokenType = $value;
public function setTokenType($value = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN)
{
$this->tokenType = $value;
}
/**
@ -161,16 +159,18 @@ class PHPExcel_Calculation_FormulaToken {
*
* @return string
*/
public function getTokenSubType() {
return $this->_tokenSubType;
public function getTokenSubType()
{
return $this->tokenSubType;
}
/**
* Set Token SubType
*
* @param string $value
* @param string $value
*/
public function setTokenSubType($value = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
$this->_tokenSubType = $value;
public function setTokenSubType($value = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING)
{
$this->tokenSubType = $value;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Calculation_Function
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,72 +21,64 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Calculation_Function
{
/* Function categories */
const CATEGORY_CUBE = 'Cube';
const CATEGORY_DATABASE = 'Database';
const CATEGORY_DATE_AND_TIME = 'Date and Time';
const CATEGORY_ENGINEERING = 'Engineering';
const CATEGORY_FINANCIAL = 'Financial';
const CATEGORY_INFORMATION = 'Information';
const CATEGORY_LOGICAL = 'Logical';
const CATEGORY_LOOKUP_AND_REFERENCE = 'Lookup and Reference';
const CATEGORY_MATH_AND_TRIG = 'Math and Trig';
const CATEGORY_STATISTICAL = 'Statistical';
const CATEGORY_TEXT_AND_DATA = 'Text and Data';
/**
* Category (represented by CATEGORY_*)
*
* @var string
*/
private $category;
/**
* PHPExcel_Calculation_Function
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Function {
/* Function categories */
const CATEGORY_CUBE = 'Cube';
const CATEGORY_DATABASE = 'Database';
const CATEGORY_DATE_AND_TIME = 'Date and Time';
const CATEGORY_ENGINEERING = 'Engineering';
const CATEGORY_FINANCIAL = 'Financial';
const CATEGORY_INFORMATION = 'Information';
const CATEGORY_LOGICAL = 'Logical';
const CATEGORY_LOOKUP_AND_REFERENCE = 'Lookup and Reference';
const CATEGORY_MATH_AND_TRIG = 'Math and Trig';
const CATEGORY_STATISTICAL = 'Statistical';
const CATEGORY_TEXT_AND_DATA = 'Text and Data';
/**
* Excel name
*
* @var string
*/
private $excelName;
/**
* Category (represented by CATEGORY_*)
*
* @var string
*/
private $_category;
/**
* Excel name
*
* @var string
*/
private $_excelName;
/**
* PHPExcel name
*
* @var string
*/
private $_phpExcelName;
/**
* PHPExcel name
*
* @var string
*/
private $phpExcelName;
/**
* Create a new PHPExcel_Calculation_Function
*
* @param string $pCategory Category (represented by CATEGORY_*)
* @param string $pExcelName Excel function name
* @param string $pPHPExcelName PHPExcel function mapping
* @throws PHPExcel_Calculation_Exception
* @param string $pCategory Category (represented by CATEGORY_*)
* @param string $pExcelName Excel function name
* @param string $pPHPExcelName PHPExcel function mapping
* @throws PHPExcel_Calculation_Exception
*/
public function __construct($pCategory = NULL, $pExcelName = NULL, $pPHPExcelName = NULL)
public function __construct($pCategory = null, $pExcelName = null, $pPHPExcelName = null)
{
if (($pCategory !== NULL) && ($pExcelName !== NULL) && ($pPHPExcelName !== NULL)) {
// Initialise values
$this->_category = $pCategory;
$this->_excelName = $pExcelName;
$this->_phpExcelName = $pPHPExcelName;
} else {
throw new PHPExcel_Calculation_Exception("Invalid parameters passed.");
}
if (($pCategory !== null) && ($pExcelName !== null) && ($pPHPExcelName !== null)) {
// Initialise values
$this->category = $pCategory;
$this->excelName = $pExcelName;
$this->phpExcelName = $pPHPExcelName;
} else {
throw new PHPExcel_Calculation_Exception("Invalid parameters passed.");
}
}
/**
@ -93,22 +86,24 @@ class PHPExcel_Calculation_Function {
*
* @return string
*/
public function getCategory() {
return $this->_category;
public function getCategory()
{
return $this->category;
}
/**
* Set Category (represented by CATEGORY_*)
*
* @param string $value
* @throws PHPExcel_Calculation_Exception
* @param string $value
* @throws PHPExcel_Calculation_Exception
*/
public function setCategory($value = null) {
if (!is_null($value)) {
$this->_category = $value;
} else {
throw new PHPExcel_Calculation_Exception("Invalid parameter passed.");
}
public function setCategory($value = null)
{
if (!is_null($value)) {
$this->category = $value;
} else {
throw new PHPExcel_Calculation_Exception("Invalid parameter passed.");
}
}
/**
@ -116,17 +111,19 @@ class PHPExcel_Calculation_Function {
*
* @return string
*/
public function getExcelName() {
return $this->_excelName;
public function getExcelName()
{
return $this->excelName;
}
/**
* Set Excel name
*
* @param string $value
* @param string $value
*/
public function setExcelName($value) {
$this->_excelName = $value;
public function setExcelName($value)
{
$this->excelName = $value;
}
/**
@ -134,16 +131,18 @@ class PHPExcel_Calculation_Function {
*
* @return string
*/
public function getPHPExcelName() {
return $this->_phpExcelName;
public function getPHPExcelName()
{
return $this->phpExcelName;
}
/**
* Set PHPExcel name
*
* @param string $value
* @param string $value
*/
public function setPHPExcelName($value) {
$this->_phpExcelName = $value;
public function setPHPExcelName($value)
{
$this->phpExcelName = $value;
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,18 @@
<?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel
* PHPExcel_Calculation_Logical
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -18,271 +28,258 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Calculation_Logical
{
/**
* TRUE
*
* Returns the boolean TRUE.
*
* Excel Function:
* =TRUE()
*
* @access public
* @category Logical Functions
* @return boolean True
*/
public static function TRUE()
{
return true;
}
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
/**
* FALSE
*
* Returns the boolean FALSE.
*
* Excel Function:
* =FALSE()
*
* @access public
* @category Logical Functions
* @return boolean False
*/
public static function FALSE()
{
return false;
}
/**
* LOGICAL_AND
*
* Returns boolean TRUE if all its arguments are TRUE; returns FALSE if one or more argument is FALSE.
*
* Excel Function:
* =AND(logical1[,logical2[, ...]])
*
* The arguments must evaluate to logical values such as TRUE or FALSE, or the arguments must be arrays
* or references that contain logical values.
*
* Boolean arguments are treated as True or False as appropriate
* Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
*
* @access public
* @category Logical Functions
* @param mixed $arg,... Data values
* @return boolean The logical AND of the arguments.
*/
public static function LOGICAL_AND()
{
// Return value
$returnValue = true;
// Loop through the arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
$argCount = -1;
foreach ($aArgs as $argCount => $arg) {
// Is it a boolean value?
if (is_bool($arg)) {
$returnValue = $returnValue && $arg;
} elseif ((is_numeric($arg)) && (!is_string($arg))) {
$returnValue = $returnValue && ($arg != 0);
} elseif (is_string($arg)) {
$arg = strtoupper($arg);
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
$arg = true;
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
$arg = false;
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
$returnValue = $returnValue && ($arg != 0);
}
}
// Return
if ($argCount < 0) {
return PHPExcel_Calculation_Functions::VALUE();
}
return $returnValue;
}
/**
* LOGICAL_OR
*
* Returns boolean TRUE if any argument is TRUE; returns FALSE if all arguments are FALSE.
*
* Excel Function:
* =OR(logical1[,logical2[, ...]])
*
* The arguments must evaluate to logical values such as TRUE or FALSE, or the arguments must be arrays
* or references that contain logical values.
*
* Boolean arguments are treated as True or False as appropriate
* Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
*
* @access public
* @category Logical Functions
* @param mixed $arg,... Data values
* @return boolean The logical OR of the arguments.
*/
public static function LOGICAL_OR()
{
// Return value
$returnValue = false;
// Loop through the arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
$argCount = -1;
foreach ($aArgs as $argCount => $arg) {
// Is it a boolean value?
if (is_bool($arg)) {
$returnValue = $returnValue || $arg;
} elseif ((is_numeric($arg)) && (!is_string($arg))) {
$returnValue = $returnValue || ($arg != 0);
} elseif (is_string($arg)) {
$arg = strtoupper($arg);
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
$arg = true;
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
$arg = false;
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
$returnValue = $returnValue || ($arg != 0);
}
}
// Return
if ($argCount < 0) {
return PHPExcel_Calculation_Functions::VALUE();
}
return $returnValue;
}
/**
* NOT
*
* Returns the boolean inverse of the argument.
*
* Excel Function:
* =NOT(logical)
*
* The argument must evaluate to a logical value such as TRUE or FALSE
*
* Boolean arguments are treated as True or False as appropriate
* Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
*
* @access public
* @category Logical Functions
* @param mixed $logical A value or expression that can be evaluated to TRUE or FALSE
* @return boolean The boolean inverse of the argument.
*/
public static function NOT($logical = false)
{
$logical = PHPExcel_Calculation_Functions::flattenSingleValue($logical);
if (is_string($logical)) {
$logical = strtoupper($logical);
if (($logical == 'TRUE') || ($logical == PHPExcel_Calculation::getTRUE())) {
return false;
} elseif (($logical == 'FALSE') || ($logical == PHPExcel_Calculation::getFALSE())) {
return true;
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
}
return !$logical;
}
/**
* STATEMENT_IF
*
* Returns one value if a condition you specify evaluates to TRUE and another value if it evaluates to FALSE.
*
* Excel Function:
* =IF(condition[,returnIfTrue[,returnIfFalse]])
*
* Condition is any value or expression that can be evaluated to TRUE or FALSE.
* For example, A10=100 is a logical expression; if the value in cell A10 is equal to 100,
* the expression evaluates to TRUE. Otherwise, the expression evaluates to FALSE.
* This argument can use any comparison calculation operator.
* ReturnIfTrue is the value that is returned if condition evaluates to TRUE.
* For example, if this argument is the text string "Within budget" and the condition argument evaluates to TRUE,
* then the IF function returns the text "Within budget"
* If condition is TRUE and ReturnIfTrue is blank, this argument returns 0 (zero). To display the word TRUE, use
* the logical value TRUE for this argument.
* ReturnIfTrue can be another formula.
* ReturnIfFalse is the value that is returned if condition evaluates to FALSE.
* For example, if this argument is the text string "Over budget" and the condition argument evaluates to FALSE,
* then the IF function returns the text "Over budget".
* If condition is FALSE and ReturnIfFalse is omitted, then the logical value FALSE is returned.
* If condition is FALSE and ReturnIfFalse is blank, then the value 0 (zero) is returned.
* ReturnIfFalse can be another formula.
*
* @access public
* @category Logical Functions
* @param mixed $condition Condition to evaluate
* @param mixed $returnIfTrue Value to return when condition is true
* @param mixed $returnIfFalse Optional value to return when condition is false
* @return mixed The value of returnIfTrue or returnIfFalse determined by condition
*/
public static function STATEMENT_IF($condition = true, $returnIfTrue = 0, $returnIfFalse = false)
{
$condition = (is_null($condition)) ? true : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($condition);
$returnIfTrue = (is_null($returnIfTrue)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfTrue);
$returnIfFalse = (is_null($returnIfFalse)) ? false : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfFalse);
return ($condition) ? $returnIfTrue : $returnIfFalse;
}
/**
* IFERROR
*
* Excel Function:
* =IFERROR(testValue,errorpart)
*
* @access public
* @category Logical Functions
* @param mixed $testValue Value to check, is also the value returned when no error
* @param mixed $errorpart Value to return when testValue is an error condition
* @return mixed The value of errorpart or testValue determined by error condition
*/
public static function IFERROR($testValue = '', $errorpart = '')
{
$testValue = (is_null($testValue)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($testValue);
$errorpart = (is_null($errorpart)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($errorpart);
return self::STATEMENT_IF(PHPExcel_Calculation_Functions::IS_ERROR($testValue), $errorpart, $testValue);
}
}
/**
* PHPExcel_Calculation_Logical
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Logical {
/**
* TRUE
*
* Returns the boolean TRUE.
*
* Excel Function:
* =TRUE()
*
* @access public
* @category Logical Functions
* @return boolean True
*/
public static function TRUE() {
return TRUE;
} // function TRUE()
/**
* FALSE
*
* Returns the boolean FALSE.
*
* Excel Function:
* =FALSE()
*
* @access public
* @category Logical Functions
* @return boolean False
*/
public static function FALSE() {
return FALSE;
} // function FALSE()
/**
* LOGICAL_AND
*
* Returns boolean TRUE if all its arguments are TRUE; returns FALSE if one or more argument is FALSE.
*
* Excel Function:
* =AND(logical1[,logical2[, ...]])
*
* The arguments must evaluate to logical values such as TRUE or FALSE, or the arguments must be arrays
* or references that contain logical values.
*
* Boolean arguments are treated as True or False as appropriate
* Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
*
* @access public
* @category Logical Functions
* @param mixed $arg,... Data values
* @return boolean The logical AND of the arguments.
*/
public static function LOGICAL_AND() {
// Return value
$returnValue = TRUE;
// Loop through the arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
$argCount = -1;
foreach ($aArgs as $argCount => $arg) {
// Is it a boolean value?
if (is_bool($arg)) {
$returnValue = $returnValue && $arg;
} elseif ((is_numeric($arg)) && (!is_string($arg))) {
$returnValue = $returnValue && ($arg != 0);
} elseif (is_string($arg)) {
$arg = strtoupper($arg);
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
$arg = TRUE;
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
$arg = FALSE;
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
$returnValue = $returnValue && ($arg != 0);
}
}
// Return
if ($argCount < 0) {
return PHPExcel_Calculation_Functions::VALUE();
}
return $returnValue;
} // function LOGICAL_AND()
/**
* LOGICAL_OR
*
* Returns boolean TRUE if any argument is TRUE; returns FALSE if all arguments are FALSE.
*
* Excel Function:
* =OR(logical1[,logical2[, ...]])
*
* The arguments must evaluate to logical values such as TRUE or FALSE, or the arguments must be arrays
* or references that contain logical values.
*
* Boolean arguments are treated as True or False as appropriate
* Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
*
* @access public
* @category Logical Functions
* @param mixed $arg,... Data values
* @return boolean The logical OR of the arguments.
*/
public static function LOGICAL_OR() {
// Return value
$returnValue = FALSE;
// Loop through the arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
$argCount = -1;
foreach ($aArgs as $argCount => $arg) {
// Is it a boolean value?
if (is_bool($arg)) {
$returnValue = $returnValue || $arg;
} elseif ((is_numeric($arg)) && (!is_string($arg))) {
$returnValue = $returnValue || ($arg != 0);
} elseif (is_string($arg)) {
$arg = strtoupper($arg);
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
$arg = TRUE;
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
$arg = FALSE;
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
$returnValue = $returnValue || ($arg != 0);
}
}
// Return
if ($argCount < 0) {
return PHPExcel_Calculation_Functions::VALUE();
}
return $returnValue;
} // function LOGICAL_OR()
/**
* NOT
*
* Returns the boolean inverse of the argument.
*
* Excel Function:
* =NOT(logical)
*
* The argument must evaluate to a logical value such as TRUE or FALSE
*
* Boolean arguments are treated as True or False as appropriate
* Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
*
* @access public
* @category Logical Functions
* @param mixed $logical A value or expression that can be evaluated to TRUE or FALSE
* @return boolean The boolean inverse of the argument.
*/
public static function NOT($logical=FALSE) {
$logical = PHPExcel_Calculation_Functions::flattenSingleValue($logical);
if (is_string($logical)) {
$logical = strtoupper($logical);
if (($logical == 'TRUE') || ($logical == PHPExcel_Calculation::getTRUE())) {
return FALSE;
} elseif (($logical == 'FALSE') || ($logical == PHPExcel_Calculation::getFALSE())) {
return TRUE;
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
}
return !$logical;
} // function NOT()
/**
* STATEMENT_IF
*
* Returns one value if a condition you specify evaluates to TRUE and another value if it evaluates to FALSE.
*
* Excel Function:
* =IF(condition[,returnIfTrue[,returnIfFalse]])
*
* Condition is any value or expression that can be evaluated to TRUE or FALSE.
* For example, A10=100 is a logical expression; if the value in cell A10 is equal to 100,
* the expression evaluates to TRUE. Otherwise, the expression evaluates to FALSE.
* This argument can use any comparison calculation operator.
* ReturnIfTrue is the value that is returned if condition evaluates to TRUE.
* For example, if this argument is the text string "Within budget" and the condition argument evaluates to TRUE,
* then the IF function returns the text "Within budget"
* If condition is TRUE and ReturnIfTrue is blank, this argument returns 0 (zero). To display the word TRUE, use
* the logical value TRUE for this argument.
* ReturnIfTrue can be another formula.
* ReturnIfFalse is the value that is returned if condition evaluates to FALSE.
* For example, if this argument is the text string "Over budget" and the condition argument evaluates to FALSE,
* then the IF function returns the text "Over budget".
* If condition is FALSE and ReturnIfFalse is omitted, then the logical value FALSE is returned.
* If condition is FALSE and ReturnIfFalse is blank, then the value 0 (zero) is returned.
* ReturnIfFalse can be another formula.
*
* @access public
* @category Logical Functions
* @param mixed $condition Condition to evaluate
* @param mixed $returnIfTrue Value to return when condition is true
* @param mixed $returnIfFalse Optional value to return when condition is false
* @return mixed The value of returnIfTrue or returnIfFalse determined by condition
*/
public static function STATEMENT_IF($condition = TRUE, $returnIfTrue = 0, $returnIfFalse = FALSE) {
$condition = (is_null($condition)) ? TRUE : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($condition);
$returnIfTrue = (is_null($returnIfTrue)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfTrue);
$returnIfFalse = (is_null($returnIfFalse)) ? FALSE : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfFalse);
return ($condition) ? $returnIfTrue : $returnIfFalse;
} // function STATEMENT_IF()
/**
* IFERROR
*
* Excel Function:
* =IFERROR(testValue,errorpart)
*
* @access public
* @category Logical Functions
* @param mixed $testValue Value to check, is also the value returned when no error
* @param mixed $errorpart Value to return when testValue is an error condition
* @return mixed The value of errorpart or testValue determined by error condition
*/
public static function IFERROR($testValue = '', $errorpart = '') {
$testValue = (is_null($testValue)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($testValue);
$errorpart = (is_null($errorpart)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($errorpart);
return self::STATEMENT_IF(PHPExcel_Calculation_Functions::IS_ERROR($testValue), $errorpart, $testValue);
} // function IFERROR()
} // class PHPExcel_Calculation_Logical

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Calculation_Token_Stack
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,56 +21,91 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Calculation_Token_Stack
{
/**
* The parser stack for formulae
*
* @var mixed[]
*/
private $stack = array();
/**
* Count of entries in the parser stack
*
* @var integer
*/
private $count = 0;
class PHPExcel_Calculation_Token_Stack {
/**
* Return the number of entries on the stack
*
* @return integer
*/
public function count()
{
return $this->count;
}
private $_stack = array();
private $_count = 0;
/**
* Push a new entry onto the stack
*
* @param mixed $type
* @param mixed $value
* @param mixed $reference
*/
public function push($type, $value, $reference = null)
{
$this->stack[$this->count++] = array(
'type' => $type,
'value' => $value,
'reference' => $reference
);
if ($type == 'Function') {
$localeFunction = PHPExcel_Calculation::localeFunc($value);
if ($localeFunction != $value) {
$this->stack[($this->count - 1)]['localeValue'] = $localeFunction;
}
}
}
/**
* Pop the last entry from the stack
*
* @return mixed
*/
public function pop()
{
if ($this->count > 0) {
return $this->stack[--$this->count];
}
return null;
}
public function count() {
return $this->_count;
} // function count()
/**
* Return an entry from the stack without removing it
*
* @param integer $n number indicating how far back in the stack we want to look
* @return mixed
*/
public function last($n = 1)
{
if ($this->count - $n < 0) {
return null;
}
return $this->stack[$this->count - $n];
}
public function push($type,$value,$reference=null) {
$this->_stack[$this->_count++] = array('type' => $type,
'value' => $value,
'reference' => $reference
);
if ($type == 'Function') {
$localeFunction = PHPExcel_Calculation::_localeFunc($value);
if ($localeFunction != $value) {
$this->_stack[($this->_count - 1)]['localeValue'] = $localeFunction;
}
}
} // function push()
public function pop() {
if ($this->_count > 0) {
return $this->_stack[--$this->_count];
}
return null;
} // function pop()
public function last($n=1) {
if ($this->_count-$n < 0) {
return null;
}
return $this->_stack[$this->_count-$n];
} // function last()
function clear() {
$this->_stack = array();
$this->_count = 0;
}
} // class PHPExcel_Calculation_Token_Stack
/**
* Clear the stack
*/
public function clear()
{
$this->stack = array();
$this->count = 0;
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,18 @@
<?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel
* PHPExcel_Cell_AdvancedValueBinder
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,29 +30,10 @@
*
* @category PHPExcel
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Cell_AdvancedValueBinder
*
* @category PHPExcel
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
{
/**
@ -66,37 +57,41 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
if ($dataType === PHPExcel_Cell_DataType::TYPE_STRING && !$value instanceof PHPExcel_RichText) {
// Test for booleans using locale-setting
if ($value == PHPExcel_Calculation::getTRUE()) {
$cell->setValueExplicit( TRUE, PHPExcel_Cell_DataType::TYPE_BOOL);
$cell->setValueExplicit(true, PHPExcel_Cell_DataType::TYPE_BOOL);
return true;
} elseif($value == PHPExcel_Calculation::getFALSE()) {
$cell->setValueExplicit( FALSE, PHPExcel_Cell_DataType::TYPE_BOOL);
} elseif ($value == PHPExcel_Calculation::getFALSE()) {
$cell->setValueExplicit(false, PHPExcel_Cell_DataType::TYPE_BOOL);
return true;
}
// Check for number in scientific format
if (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NUMBER.'$/', $value)) {
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
$cell->setValueExplicit((float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
return true;
}
// Check for fraction
if (preg_match('/^([+-]?) *([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) {
if (preg_match('/^([+-]?)\s*([0-9]+)\s?\/\s*([0-9]+)$/', $value, $matches)) {
// Convert value to number
$value = $matches[2] / $matches[3];
if ($matches[1] == '-') $value = 0 - $value;
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
if ($matches[1] == '-') {
$value = 0 - $value;
}
$cell->setValueExplicit((float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( '??/??' );
$cell->getWorksheet()->getStyle($cell->getCoordinate())
->getNumberFormat()->setFormatCode('??/??');
return true;
} elseif (preg_match('/^([+-]?)([0-9]*) +([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) {
// Convert value to number
$value = $matches[2] + ($matches[3] / $matches[4]);
if ($matches[1] == '-') $value = 0 - $value;
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
if ($matches[1] == '-') {
$value = 0 - $value;
}
$cell->setValueExplicit((float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( '# ??/??' );
$cell->getWorksheet()->getStyle($cell->getCoordinate())
->getNumberFormat()->setFormatCode('# ??/??');
return true;
}
@ -104,10 +99,10 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
if (preg_match('/^\-?[0-9]*\.?[0-9]*\s?\%$/', $value)) {
// Convert value to number
$value = (float) str_replace('%', '', $value) / 100;
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00 );
$cell->getWorksheet()->getStyle($cell->getCoordinate())
->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00);
return true;
}
@ -118,20 +113,20 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
if (preg_match('/^'.preg_quote($currencyCode).' *(\d{1,3}('.preg_quote($thousandsSeparator).'\d{3})*|(\d+))('.preg_quote($decimalSeparator).'\d{2})?$/', $value)) {
// Convert value to number
$value = (float) trim(str_replace(array($currencyCode, $thousandsSeparator, $decimalSeparator), array('', '', '.'), $value));
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
$cell->getWorksheet()->getStyle($cell->getCoordinate())
->getNumberFormat()->setFormatCode(
str_replace('$', $currencyCode, PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE )
str_replace('$', $currencyCode, PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE)
);
return true;
} elseif (preg_match('/^\$ *(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) {
// Convert value to number
$value = (float) trim(str_replace(array('$',','), '', $value));
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE );
$cell->getWorksheet()->getStyle($cell->getCoordinate())
->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
return true;
}
@ -142,8 +137,8 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
$days = $h / 24 + $m / 1440;
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3 );
$cell->getWorksheet()->getStyle($cell->getCoordinate())
->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3);
return true;
}
@ -155,8 +150,8 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
// Convert value to number
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 );
$cell->getWorksheet()->getStyle($cell->getCoordinate())
->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4);
return true;
}
@ -170,18 +165,18 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
} else {
$formatCode = 'yyyy-mm-dd';
}
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
$cell->getWorksheet()->getStyle($cell->getCoordinate())
->getNumberFormat()->setFormatCode($formatCode);
return true;
}
// Check for newline character "\n"
if (strpos($value, "\n") !== FALSE) {
if (strpos($value, "\n") !== false) {
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING);
// Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getAlignment()->setWrapText(TRUE);
$cell->getWorksheet()->getStyle($cell->getCoordinate())
->getAlignment()->setWrapText(true);
return true;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Cell_DataType
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,19 +21,10 @@
*
* @category PHPExcel
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Cell_DataType
*
* @category PHPExcel
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Cell_DataType
{
/* Data types */
@ -50,7 +42,7 @@ class PHPExcel_Cell_DataType
*
* @var array
*/
private static $_errorCodes = array(
private static $errorCodes = array(
'#NULL!' => 0,
'#DIV/0!' => 1,
'#VALUE!' => 2,
@ -65,8 +57,9 @@ class PHPExcel_Cell_DataType
*
* @return array
*/
public static function getErrorCodes() {
return self::$_errorCodes;
public static function getErrorCodes()
{
return self::$errorCodes;
}
/**
@ -76,7 +69,8 @@ class PHPExcel_Cell_DataType
* @param mixed $pValue
* @return string
*/
public static function dataTypeForValue($pValue = null) {
public static function dataTypeForValue($pValue = null)
{
return PHPExcel_Cell_DefaultValueBinder::dataTypeForValue($pValue);
}
@ -112,11 +106,10 @@ class PHPExcel_Cell_DataType
{
$pValue = (string) $pValue;
if ( !array_key_exists($pValue, self::$_errorCodes) ) {
if (!array_key_exists($pValue, self::$errorCodes)) {
$pValue = '#NULL!';
}
return $pValue;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Cell_DataValidation
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,19 +21,10 @@
*
* @category PHPExcel
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Cell_DataValidation
*
* @category PHPExcel
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Cell_DataValidation
{
/* Data validation types */
@ -65,91 +57,91 @@ class PHPExcel_Cell_DataValidation
*
* @var string
*/
private $_formula1;
private $formula1;
/**
* Formula 2
*
* @var string
*/
private $_formula2;
private $formula2;
/**
* Type
*
* @var string
*/
private $_type = PHPExcel_Cell_DataValidation::TYPE_NONE;
private $type = PHPExcel_Cell_DataValidation::TYPE_NONE;
/**
* Error style
*
* @var string
*/
private $_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
private $errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
/**
* Operator
*
* @var string
*/
private $_operator;
private $operator;
/**
* Allow Blank
*
* @var boolean
*/
private $_allowBlank;
private $allowBlank;
/**
* Show DropDown
*
* @var boolean
*/
private $_showDropDown;
private $showDropDown;
/**
* Show InputMessage
*
* @var boolean
*/
private $_showInputMessage;
private $showInputMessage;
/**
* Show ErrorMessage
*
* @var boolean
*/
private $_showErrorMessage;
private $showErrorMessage;
/**
* Error title
*
* @var string
*/
private $_errorTitle;
private $errorTitle;
/**
* Error
*
* @var string
*/
private $_error;
private $error;
/**
* Prompt title
*
* @var string
*/
private $_promptTitle;
private $promptTitle;
/**
* Prompt
*
* @var string
*/
private $_prompt;
private $prompt;
/**
* Create a new PHPExcel_Cell_DataValidation
@ -157,19 +149,19 @@ class PHPExcel_Cell_DataValidation
public function __construct()
{
// Initialise member variables
$this->_formula1 = '';
$this->_formula2 = '';
$this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE;
$this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
$this->_operator = '';
$this->_allowBlank = FALSE;
$this->_showDropDown = FALSE;
$this->_showInputMessage = FALSE;
$this->_showErrorMessage = FALSE;
$this->_errorTitle = '';
$this->_error = '';
$this->_promptTitle = '';
$this->_prompt = '';
$this->formula1 = '';
$this->formula2 = '';
$this->type = PHPExcel_Cell_DataValidation::TYPE_NONE;
$this->errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
$this->operator = '';
$this->allowBlank = false;
$this->showDropDown = false;
$this->showInputMessage = false;
$this->showErrorMessage = false;
$this->errorTitle = '';
$this->error = '';
$this->promptTitle = '';
$this->prompt = '';
}
/**
@ -177,8 +169,9 @@ class PHPExcel_Cell_DataValidation
*
* @return string
*/
public function getFormula1() {
return $this->_formula1;
public function getFormula1()
{
return $this->formula1;
}
/**
@ -187,8 +180,9 @@ class PHPExcel_Cell_DataValidation
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setFormula1($value = '') {
$this->_formula1 = $value;
public function setFormula1($value = '')
{
$this->formula1 = $value;
return $this;
}
@ -197,8 +191,9 @@ class PHPExcel_Cell_DataValidation
*
* @return string
*/
public function getFormula2() {
return $this->_formula2;
public function getFormula2()
{
return $this->formula2;
}
/**
@ -207,8 +202,9 @@ class PHPExcel_Cell_DataValidation
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setFormula2($value = '') {
$this->_formula2 = $value;
public function setFormula2($value = '')
{
$this->formula2 = $value;
return $this;
}
@ -217,8 +213,9 @@ class PHPExcel_Cell_DataValidation
*
* @return string
*/
public function getType() {
return $this->_type;
public function getType()
{
return $this->type;
}
/**
@ -227,8 +224,9 @@ class PHPExcel_Cell_DataValidation
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setType($value = PHPExcel_Cell_DataValidation::TYPE_NONE) {
$this->_type = $value;
public function setType($value = PHPExcel_Cell_DataValidation::TYPE_NONE)
{
$this->type = $value;
return $this;
}
@ -237,8 +235,9 @@ class PHPExcel_Cell_DataValidation
*
* @return string
*/
public function getErrorStyle() {
return $this->_errorStyle;
public function getErrorStyle()
{
return $this->errorStyle;
}
/**
@ -247,8 +246,9 @@ class PHPExcel_Cell_DataValidation
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setErrorStyle($value = PHPExcel_Cell_DataValidation::STYLE_STOP) {
$this->_errorStyle = $value;
public function setErrorStyle($value = PHPExcel_Cell_DataValidation::STYLE_STOP)
{
$this->errorStyle = $value;
return $this;
}
@ -257,8 +257,9 @@ class PHPExcel_Cell_DataValidation
*
* @return string
*/
public function getOperator() {
return $this->_operator;
public function getOperator()
{
return $this->operator;
}
/**
@ -267,8 +268,9 @@ class PHPExcel_Cell_DataValidation
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setOperator($value = '') {
$this->_operator = $value;
public function setOperator($value = '')
{
$this->operator = $value;
return $this;
}
@ -277,8 +279,9 @@ class PHPExcel_Cell_DataValidation
*
* @return boolean
*/
public function getAllowBlank() {
return $this->_allowBlank;
public function getAllowBlank()
{
return $this->allowBlank;
}
/**
@ -287,8 +290,9 @@ class PHPExcel_Cell_DataValidation
* @param boolean $value
* @return PHPExcel_Cell_DataValidation
*/
public function setAllowBlank($value = false) {
$this->_allowBlank = $value;
public function setAllowBlank($value = false)
{
$this->allowBlank = $value;
return $this;
}
@ -297,8 +301,9 @@ class PHPExcel_Cell_DataValidation
*
* @return boolean
*/
public function getShowDropDown() {
return $this->_showDropDown;
public function getShowDropDown()
{
return $this->showDropDown;
}
/**
@ -307,8 +312,9 @@ class PHPExcel_Cell_DataValidation
* @param boolean $value
* @return PHPExcel_Cell_DataValidation
*/
public function setShowDropDown($value = false) {
$this->_showDropDown = $value;
public function setShowDropDown($value = false)
{
$this->showDropDown = $value;
return $this;
}
@ -317,8 +323,9 @@ class PHPExcel_Cell_DataValidation
*
* @return boolean
*/
public function getShowInputMessage() {
return $this->_showInputMessage;
public function getShowInputMessage()
{
return $this->showInputMessage;
}
/**
@ -327,8 +334,9 @@ class PHPExcel_Cell_DataValidation
* @param boolean $value
* @return PHPExcel_Cell_DataValidation
*/
public function setShowInputMessage($value = false) {
$this->_showInputMessage = $value;
public function setShowInputMessage($value = false)
{
$this->showInputMessage = $value;
return $this;
}
@ -337,8 +345,9 @@ class PHPExcel_Cell_DataValidation
*
* @return boolean
*/
public function getShowErrorMessage() {
return $this->_showErrorMessage;
public function getShowErrorMessage()
{
return $this->showErrorMessage;
}
/**
@ -347,8 +356,9 @@ class PHPExcel_Cell_DataValidation
* @param boolean $value
* @return PHPExcel_Cell_DataValidation
*/
public function setShowErrorMessage($value = false) {
$this->_showErrorMessage = $value;
public function setShowErrorMessage($value = false)
{
$this->showErrorMessage = $value;
return $this;
}
@ -357,8 +367,9 @@ class PHPExcel_Cell_DataValidation
*
* @return string
*/
public function getErrorTitle() {
return $this->_errorTitle;
public function getErrorTitle()
{
return $this->errorTitle;
}
/**
@ -367,8 +378,9 @@ class PHPExcel_Cell_DataValidation
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setErrorTitle($value = '') {
$this->_errorTitle = $value;
public function setErrorTitle($value = '')
{
$this->errorTitle = $value;
return $this;
}
@ -377,8 +389,9 @@ class PHPExcel_Cell_DataValidation
*
* @return string
*/
public function getError() {
return $this->_error;
public function getError()
{
return $this->error;
}
/**
@ -387,8 +400,9 @@ class PHPExcel_Cell_DataValidation
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setError($value = '') {
$this->_error = $value;
public function setError($value = '')
{
$this->error = $value;
return $this;
}
@ -397,8 +411,9 @@ class PHPExcel_Cell_DataValidation
*
* @return string
*/
public function getPromptTitle() {
return $this->_promptTitle;
public function getPromptTitle()
{
return $this->promptTitle;
}
/**
@ -407,8 +422,9 @@ class PHPExcel_Cell_DataValidation
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setPromptTitle($value = '') {
$this->_promptTitle = $value;
public function setPromptTitle($value = '')
{
$this->promptTitle = $value;
return $this;
}
@ -417,8 +433,9 @@ class PHPExcel_Cell_DataValidation
*
* @return string
*/
public function getPrompt() {
return $this->_prompt;
public function getPrompt()
{
return $this->prompt;
}
/**
@ -427,8 +444,9 @@ class PHPExcel_Cell_DataValidation
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setPrompt($value = '') {
$this->_prompt = $value;
public function setPrompt($value = '')
{
$this->prompt = $value;
return $this;
}
@ -437,29 +455,31 @@ class PHPExcel_Cell_DataValidation
*
* @return string Hash code
*/
public function getHashCode() {
public function getHashCode()
{
return md5(
$this->_formula1
. $this->_formula2
. $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE
. $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP
. $this->_operator
. ($this->_allowBlank ? 't' : 'f')
. ($this->_showDropDown ? 't' : 'f')
. ($this->_showInputMessage ? 't' : 'f')
. ($this->_showErrorMessage ? 't' : 'f')
. $this->_errorTitle
. $this->_error
. $this->_promptTitle
. $this->_prompt
. __CLASS__
$this->formula1 .
$this->formula2 .
$this->type = PHPExcel_Cell_DataValidation::TYPE_NONE .
$this->errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP .
$this->operator .
($this->allowBlank ? 't' : 'f') .
($this->showDropDown ? 't' : 'f') .
($this->showInputMessage ? 't' : 'f') .
($this->showErrorMessage ? 't' : 'f') .
$this->errorTitle .
$this->error .
$this->promptTitle .
$this->prompt .
__CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
public function __clone()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {

View file

@ -1,8 +1,18 @@
<?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel
* PHPExcel_Cell_DefaultValueBinder
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,29 +30,10 @@
*
* @category PHPExcel
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Cell_DefaultValueBinder
*
* @category PHPExcel
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
{
/**
@ -57,13 +48,20 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
// sanitize UTF-8 strings
if (is_string($value)) {
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
} elseif (is_object($value)) {
// Handle any objects that might be injected
if ($value instanceof DateTime) {
$value = $value->format('Y-m-d H:i:s');
} elseif (!($value instanceof PHPExcel_RichText)) {
$value = (string) $value;
}
}
// Set value explicit
$cell->setValueExplicit( $value, self::dataTypeForValue($value) );
$cell->setValueExplicit($value, self::dataTypeForValue($value));
// Done!
return TRUE;
return true;
}
/**
@ -72,35 +70,33 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
* @param mixed $pValue
* @return string
*/
public static function dataTypeForValue($pValue = null) {
public static function dataTypeForValue($pValue = null)
{
// Match the value against a few data types
if (is_null($pValue)) {
if ($pValue === null) {
return PHPExcel_Cell_DataType::TYPE_NULL;
} elseif ($pValue === '') {
return PHPExcel_Cell_DataType::TYPE_STRING;
} elseif ($pValue instanceof PHPExcel_RichText) {
return PHPExcel_Cell_DataType::TYPE_INLINE;
} elseif ($pValue{0} === '=' && strlen($pValue) > 1) {
return PHPExcel_Cell_DataType::TYPE_FORMULA;
} elseif (is_bool($pValue)) {
return PHPExcel_Cell_DataType::TYPE_BOOL;
} elseif (is_float($pValue) || is_int($pValue)) {
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
} elseif (preg_match('/^\-?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)$/', $pValue)) {
} elseif (preg_match('/^[\+\-]?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)([Ee][\-\+]?[0-2]?\d{1,3})?$/', $pValue)) {
$tValue = ltrim($pValue, '+-');
if (is_string($pValue) && $tValue{0} === '0' && strlen($tValue) > 1 && $tValue{1} !== '.') {
return PHPExcel_Cell_DataType::TYPE_STRING;
} elseif ((strpos($pValue, '.') === false) && ($pValue > PHP_INT_MAX)) {
return PHPExcel_Cell_DataType::TYPE_STRING;
}
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
} elseif (is_string($pValue) && array_key_exists($pValue, PHPExcel_Cell_DataType::getErrorCodes())) {
return PHPExcel_Cell_DataType::TYPE_ERROR;
} else {
return PHPExcel_Cell_DataType::TYPE_STRING;
}
return PHPExcel_Cell_DataType::TYPE_STRING;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Cell_Hyperlink
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,19 +21,10 @@
*
* @category PHPExcel
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Cell_Hyperlink
*
* @category PHPExcel
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Cell_Hyperlink
{
/**
@ -40,14 +32,14 @@ class PHPExcel_Cell_Hyperlink
*
* @var string
*/
private $_url;
private $url;
/**
* Tooltip to display on the hyperlink
*
* @var string
*/
private $_tooltip;
private $tooltip;
/**
* Create a new PHPExcel_Cell_Hyperlink
@ -58,8 +50,8 @@ class PHPExcel_Cell_Hyperlink
public function __construct($pUrl = '', $pTooltip = '')
{
// Initialise member variables
$this->_url = $pUrl;
$this->_tooltip = $pTooltip;
$this->url = $pUrl;
$this->tooltip = $pTooltip;
}
/**
@ -67,8 +59,9 @@ class PHPExcel_Cell_Hyperlink
*
* @return string
*/
public function getUrl() {
return $this->_url;
public function getUrl()
{
return $this->url;
}
/**
@ -77,8 +70,9 @@ class PHPExcel_Cell_Hyperlink
* @param string $value
* @return PHPExcel_Cell_Hyperlink
*/
public function setUrl($value = '') {
$this->_url = $value;
public function setUrl($value = '')
{
$this->url = $value;
return $this;
}
@ -87,8 +81,9 @@ class PHPExcel_Cell_Hyperlink
*
* @return string
*/
public function getTooltip() {
return $this->_tooltip;
public function getTooltip()
{
return $this->tooltip;
}
/**
@ -97,8 +92,9 @@ class PHPExcel_Cell_Hyperlink
* @param string $value
* @return PHPExcel_Cell_Hyperlink
*/
public function setTooltip($value = '') {
$this->_tooltip = $value;
public function setTooltip($value = '')
{
$this->tooltip = $value;
return $this;
}
@ -107,8 +103,9 @@ class PHPExcel_Cell_Hyperlink
*
* @return boolean
*/
public function isInternal() {
return strpos($this->_url, 'sheet://') !== false;
public function isInternal()
{
return strpos($this->url, 'sheet://') !== false;
}
/**
@ -116,11 +113,12 @@ class PHPExcel_Cell_Hyperlink
*
* @return string Hash code
*/
public function getHashCode() {
public function getHashCode()
{
return md5(
$this->_url
. $this->_tooltip
. __CLASS__
$this->url .
$this->tooltip .
__CLASS__
);
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,7 +21,7 @@
*
* @category PHPExcel
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
@ -31,7 +32,7 @@
*
* @category PHPExcel
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
interface PHPExcel_Cell_IValueBinder
{
@ -42,5 +43,5 @@ interface PHPExcel_Cell_IValueBinder
* @param mixed $value Value to bind in cell
* @return boolean
*/
public function bindValue(PHPExcel_Cell $cell, $value = NULL);
public function bindValue(PHPExcel_Cell $cell, $value = null);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,561 @@
<?php
/**
* Created by PhpStorm.
* User: Wiktor Trzonkowski
* Date: 6/17/14
* Time: 12:11 PM
*/
class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties
{
/**
* Axis Number
*
* @var array of mixed
*/
private $axisNumber = array(
'format' => self::FORMAT_CODE_GENERAL,
'source_linked' => 1
);
/**
* Axis Options
*
* @var array of mixed
*/
private $axisOptions = array(
'minimum' => null,
'maximum' => null,
'major_unit' => null,
'minor_unit' => null,
'orientation' => self::ORIENTATION_NORMAL,
'minor_tick_mark' => self::TICK_MARK_NONE,
'major_tick_mark' => self::TICK_MARK_NONE,
'axis_labels' => self::AXIS_LABELS_NEXT_TO,
'horizontal_crosses' => self::HORIZONTAL_CROSSES_AUTOZERO,
'horizontal_crosses_value' => null
);
/**
* Fill Properties
*
* @var array of mixed
*/
private $fillProperties = array(
'type' => self::EXCEL_COLOR_TYPE_ARGB,
'value' => null,
'alpha' => 0
);
/**
* Line Properties
*
* @var array of mixed
*/
private $lineProperties = array(
'type' => self::EXCEL_COLOR_TYPE_ARGB,
'value' => null,
'alpha' => 0
);
/**
* Line Style Properties
*
* @var array of mixed
*/
private $lineStyleProperties = array(
'width' => '9525',
'compound' => self::LINE_STYLE_COMPOUND_SIMPLE,
'dash' => self::LINE_STYLE_DASH_SOLID,
'cap' => self::LINE_STYLE_CAP_FLAT,
'join' => self::LINE_STYLE_JOIN_BEVEL,
'arrow' => array(
'head' => array(
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
'size' => self::LINE_STYLE_ARROW_SIZE_5
),
'end' => array(
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
'size' => self::LINE_STYLE_ARROW_SIZE_8
),
)
);
/**
* Shadow Properties
*
* @var array of mixed
*/
private $shadowProperties = array(
'presets' => self::SHADOW_PRESETS_NOSHADOW,
'effect' => null,
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => 'black',
'alpha' => 40,
),
'size' => array(
'sx' => null,
'sy' => null,
'kx' => null
),
'blur' => null,
'direction' => null,
'distance' => null,
'algn' => null,
'rotWithShape' => null
);
/**
* Glow Properties
*
* @var array of mixed
*/
private $glowProperties = array(
'size' => null,
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => 'black',
'alpha' => 40
)
);
/**
* Soft Edge Properties
*
* @var array of mixed
*/
private $softEdges = array(
'size' => null
);
/**
* Get Series Data Type
*
* @return string
*/
public function setAxisNumberProperties($format_code)
{
$this->axisNumber['format'] = (string) $format_code;
$this->axisNumber['source_linked'] = 0;
}
/**
* Get Axis Number Format Data Type
*
* @return string
*/
public function getAxisNumberFormat()
{
return $this->axisNumber['format'];
}
/**
* Get Axis Number Source Linked
*
* @return string
*/
public function getAxisNumberSourceLinked()
{
return (string) $this->axisNumber['source_linked'];
}
/**
* Set Axis Options Properties
*
* @param string $axis_labels
* @param string $horizontal_crosses_value
* @param string $horizontal_crosses
* @param string $axis_orientation
* @param string $major_tmt
* @param string $minor_tmt
* @param string $minimum
* @param string $maximum
* @param string $major_unit
* @param string $minor_unit
*
*/
public function setAxisOptionsProperties($axis_labels, $horizontal_crosses_value = null, $horizontal_crosses = null, $axis_orientation = null, $major_tmt = null, $minor_tmt = null, $minimum = null, $maximum = null, $major_unit = null, $minor_unit = null)
{
$this->axisOptions['axis_labels'] = (string) $axis_labels;
($horizontal_crosses_value !== null) ? $this->axisOptions['horizontal_crosses_value'] = (string) $horizontal_crosses_value : null;
($horizontal_crosses !== null) ? $this->axisOptions['horizontal_crosses'] = (string) $horizontal_crosses : null;
($axis_orientation !== null) ? $this->axisOptions['orientation'] = (string) $axis_orientation : null;
($major_tmt !== null) ? $this->axisOptions['major_tick_mark'] = (string) $major_tmt : null;
($minor_tmt !== null) ? $this->axisOptions['minor_tick_mark'] = (string) $minor_tmt : null;
($minor_tmt !== null) ? $this->axisOptions['minor_tick_mark'] = (string) $minor_tmt : null;
($minimum !== null) ? $this->axisOptions['minimum'] = (string) $minimum : null;
($maximum !== null) ? $this->axisOptions['maximum'] = (string) $maximum : null;
($major_unit !== null) ? $this->axisOptions['major_unit'] = (string) $major_unit : null;
($minor_unit !== null) ? $this->axisOptions['minor_unit'] = (string) $minor_unit : null;
}
/**
* Get Axis Options Property
*
* @param string $property
*
* @return string
*/
public function getAxisOptionsProperty($property)
{
return $this->axisOptions[$property];
}
/**
* Set Axis Orientation Property
*
* @param string $orientation
*
*/
public function setAxisOrientation($orientation)
{
$this->orientation = (string) $orientation;
}
/**
* Set Fill Property
*
* @param string $color
* @param int $alpha
* @param string $type
*
*/
public function setFillParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB)
{
$this->fillProperties = $this->setColorProperties($color, $alpha, $type);
}
/**
* Set Line Property
*
* @param string $color
* @param int $alpha
* @param string $type
*
*/
public function setLineParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB)
{
$this->lineProperties = $this->setColorProperties($color, $alpha, $type);
}
/**
* Get Fill Property
*
* @param string $property
*
* @return string
*/
public function getFillProperty($property)
{
return $this->fillProperties[$property];
}
/**
* Get Line Property
*
* @param string $property
*
* @return string
*/
public function getLineProperty($property)
{
return $this->lineProperties[$property];
}
/**
* Set Line Style Properties
*
* @param float $line_width
* @param string $compound_type
* @param string $dash_type
* @param string $cap_type
* @param string $join_type
* @param string $head_arrow_type
* @param string $head_arrow_size
* @param string $end_arrow_type
* @param string $end_arrow_size
*
*/
public function setLineStyleProperties($line_width = null, $compound_type = null, $dash_type = null, $cap_type = null, $join_type = null, $head_arrow_type = null, $head_arrow_size = null, $end_arrow_type = null, $end_arrow_size = null)
{
(!is_null($line_width)) ? $this->lineStyleProperties['width'] = $this->getExcelPointsWidth((float) $line_width) : null;
(!is_null($compound_type)) ? $this->lineStyleProperties['compound'] = (string) $compound_type : null;
(!is_null($dash_type)) ? $this->lineStyleProperties['dash'] = (string) $dash_type : null;
(!is_null($cap_type)) ? $this->lineStyleProperties['cap'] = (string) $cap_type : null;
(!is_null($join_type)) ? $this->lineStyleProperties['join'] = (string) $join_type : null;
(!is_null($head_arrow_type)) ? $this->lineStyleProperties['arrow']['head']['type'] = (string) $head_arrow_type : null;
(!is_null($head_arrow_size)) ? $this->lineStyleProperties['arrow']['head']['size'] = (string) $head_arrow_size : null;
(!is_null($end_arrow_type)) ? $this->lineStyleProperties['arrow']['end']['type'] = (string) $end_arrow_type : null;
(!is_null($end_arrow_size)) ? $this->lineStyleProperties['arrow']['end']['size'] = (string) $end_arrow_size : null;
}
/**
* Get Line Style Property
*
* @param array|string $elements
*
* @return string
*/
public function getLineStyleProperty($elements)
{
return $this->getArrayElementsValue($this->lineStyleProperties, $elements);
}
/**
* Get Line Style Arrow Excel Width
*
* @param string $arrow
*
* @return string
*/
public function getLineStyleArrowWidth($arrow)
{
return $this->getLineStyleArrowSize($this->lineStyleProperties['arrow'][$arrow]['size'], 'w');
}
/**
* Get Line Style Arrow Excel Length
*
* @param string $arrow
*
* @return string
*/
public function getLineStyleArrowLength($arrow)
{
return $this->getLineStyleArrowSize($this->lineStyleProperties['arrow'][$arrow]['size'], 'len');
}
/**
* Set Shadow Properties
*
* @param int $shadow_presets
* @param string $sh_color_value
* @param string $sh_color_type
* @param string $sh_color_alpha
* @param float $sh_blur
* @param int $sh_angle
* @param float $sh_distance
*
*/
public function setShadowProperties($sh_presets, $sh_color_value = null, $sh_color_type = null, $sh_color_alpha = null, $sh_blur = null, $sh_angle = null, $sh_distance = null)
{
$this->setShadowPresetsProperties((int) $sh_presets)
->setShadowColor(
is_null($sh_color_value) ? $this->shadowProperties['color']['value'] : $sh_color_value,
is_null($sh_color_alpha) ? (int) $this->shadowProperties['color']['alpha'] : $sh_color_alpha,
is_null($sh_color_type) ? $this->shadowProperties['color']['type'] : $sh_color_type
)
->setShadowBlur($sh_blur)
->setShadowAngle($sh_angle)
->setShadowDistance($sh_distance);
}
/**
* Set Shadow Color
*
* @param int $shadow_presets
*
* @return PHPExcel_Chart_Axis
*/
private function setShadowPresetsProperties($shadow_presets)
{
$this->shadowProperties['presets'] = $shadow_presets;
$this->setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets));
return $this;
}
/**
* Set Shadow Properties from Maped Values
*
* @param array $properties_map
* @param * $reference
*
* @return PHPExcel_Chart_Axis
*/
private function setShadowProperiesMapValues(array $properties_map, &$reference = null)
{
$base_reference = $reference;
foreach ($properties_map as $property_key => $property_val) {
if (is_array($property_val)) {
if ($reference === null) {
$reference = & $this->shadowProperties[$property_key];
} else {
$reference = & $reference[$property_key];
}
$this->setShadowProperiesMapValues($property_val, $reference);
} else {
if ($base_reference === null) {
$this->shadowProperties[$property_key] = $property_val;
} else {
$reference[$property_key] = $property_val;
}
}
}
return $this;
}
/**
* Set Shadow Color
*
* @param string $color
* @param int $alpha
* @param string $type
*
* @return PHPExcel_Chart_Axis
*/
private function setShadowColor($color, $alpha, $type)
{
$this->shadowProperties['color'] = $this->setColorProperties($color, $alpha, $type);
return $this;
}
/**
* Set Shadow Blur
*
* @param float $blur
*
* @return PHPExcel_Chart_Axis
*/
private function setShadowBlur($blur)
{
if ($blur !== null) {
$this->shadowProperties['blur'] = (string) $this->getExcelPointsWidth($blur);
}
return $this;
}
/**
* Set Shadow Angle
*
* @param int $angle
*
* @return PHPExcel_Chart_Axis
*/
private function setShadowAngle($angle)
{
if ($angle !== null) {
$this->shadowProperties['direction'] = (string) $this->getExcelPointsAngle($angle);
}
return $this;
}
/**
* Set Shadow Distance
*
* @param float $distance
*
* @return PHPExcel_Chart_Axis
*/
private function setShadowDistance($distance)
{
if ($distance !== null) {
$this->shadowProperties['distance'] = (string) $this->getExcelPointsWidth($distance);
}
return $this;
}
/**
* Get Glow Property
*
* @param float $size
* @param string $color_value
* @param int $color_alpha
* @param string $color_type
*/
public function getShadowProperty($elements)
{
return $this->getArrayElementsValue($this->shadowProperties, $elements);
}
/**
* Set Glow Properties
*
* @param float $size
* @param string $color_value
* @param int $color_alpha
* @param string $color_type
*/
public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null)
{
$this->setGlowSize($size)
->setGlowColor(
is_null($color_value) ? $this->glowProperties['color']['value'] : $color_value,
is_null($color_alpha) ? (int) $this->glowProperties['color']['alpha'] : $color_alpha,
is_null($color_type) ? $this->glowProperties['color']['type'] : $color_type
);
}
/**
* Get Glow Property
*
* @param array|string $property
*
* @return string
*/
public function getGlowProperty($property)
{
return $this->getArrayElementsValue($this->glowProperties, $property);
}
/**
* Set Glow Color
*
* @param float $size
*
* @return PHPExcel_Chart_Axis
*/
private function setGlowSize($size)
{
if (!is_null($size)) {
$this->glowProperties['size'] = $this->getExcelPointsWidth($size);
}
return $this;
}
/**
* Set Glow Color
*
* @param string $color
* @param int $alpha
* @param string $type
*
* @return PHPExcel_Chart_Axis
*/
private function setGlowColor($color, $alpha, $type)
{
$this->glowProperties['color'] = $this->setColorProperties($color, $alpha, $type);
return $this;
}
/**
* Set Soft Edges Size
*
* @param float $size
*/
public function setSoftEdges($size)
{
if (!is_null($size)) {
$softEdges['size'] = (string) $this->getExcelPointsWidth($size);
}
}
/**
* Get Soft Edges Size
*
* @return string
*/
public function getSoftEdgesSize()
{
return $this->softEdges['size'];
}
}

View file

@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -18,337 +18,373 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Chart_DataSeries
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Chart_DataSeries
{
const TYPE_BARCHART = 'barChart';
const TYPE_BARCHART_3D = 'bar3DChart';
const TYPE_LINECHART = 'lineChart';
const TYPE_LINECHART_3D = 'line3DChart';
const TYPE_AREACHART = 'areaChart';
const TYPE_AREACHART_3D = 'area3DChart';
const TYPE_PIECHART = 'pieChart';
const TYPE_PIECHART_3D = 'pie3DChart';
const TYPE_DOUGHTNUTCHART = 'doughnutChart';
const TYPE_DONUTCHART = self::TYPE_DOUGHTNUTCHART; // Synonym
const TYPE_SCATTERCHART = 'scatterChart';
const TYPE_SURFACECHART = 'surfaceChart';
const TYPE_SURFACECHART_3D = 'surface3DChart';
const TYPE_RADARCHART = 'radarChart';
const TYPE_BUBBLECHART = 'bubbleChart';
const TYPE_STOCKCHART = 'stockChart';
const TYPE_CANDLECHART = self::TYPE_STOCKCHART; // Synonym
const TYPE_BARCHART = 'barChart';
const TYPE_BARCHART_3D = 'bar3DChart';
const TYPE_LINECHART = 'lineChart';
const TYPE_LINECHART_3D = 'line3DChart';
const TYPE_AREACHART = 'areaChart';
const TYPE_AREACHART_3D = 'area3DChart';
const TYPE_PIECHART = 'pieChart';
const TYPE_PIECHART_3D = 'pie3DChart';
const TYPE_DOUGHTNUTCHART = 'doughnutChart';
const TYPE_DONUTCHART = self::TYPE_DOUGHTNUTCHART; // Synonym
const TYPE_SCATTERCHART = 'scatterChart';
const TYPE_SURFACECHART = 'surfaceChart';
const TYPE_SURFACECHART_3D = 'surface3DChart';
const TYPE_RADARCHART = 'radarChart';
const TYPE_BUBBLECHART = 'bubbleChart';
const TYPE_STOCKCHART = 'stockChart';
const GROUPING_CLUSTERED = 'clustered';
const GROUPING_STACKED = 'stacked';
const GROUPING_PERCENT_STACKED = 'percentStacked';
const GROUPING_STANDARD = 'standard';
const GROUPING_CLUSTERED = 'clustered';
const GROUPING_STACKED = 'stacked';
const GROUPING_PERCENT_STACKED = 'percentStacked';
const GROUPING_STANDARD = 'standard';
const DIRECTION_BAR = 'bar';
const DIRECTION_HORIZONTAL = self::DIRECTION_BAR;
const DIRECTION_COL = 'col';
const DIRECTION_COLUMN = self::DIRECTION_COL;
const DIRECTION_VERTICAL = self::DIRECTION_COL;
const DIRECTION_BAR = 'bar';
const DIRECTION_HORIZONTAL = self::DIRECTION_BAR;
const DIRECTION_COL = 'col';
const DIRECTION_COLUMN = self::DIRECTION_COL;
const DIRECTION_VERTICAL = self::DIRECTION_COL;
const STYLE_LINEMARKER = 'lineMarker';
const STYLE_SMOOTHMARKER = 'smoothMarker';
const STYLE_MARKER = 'marker';
const STYLE_FILLED = 'filled';
const STYLE_LINEMARKER = 'lineMarker';
const STYLE_SMOOTHMARKER = 'smoothMarker';
const STYLE_MARKER = 'marker';
const STYLE_FILLED = 'filled';
/**
* Series Plot Type
*
* @var string
*/
private $_plotType = null;
/**
* Series Plot Type
*
* @var string
*/
private $plotType;
/**
* Plot Grouping Type
*
* @var boolean
*/
private $_plotGrouping = null;
/**
* Plot Grouping Type
*
* @var boolean
*/
private $plotGrouping;
/**
* Plot Direction
*
* @var boolean
*/
private $_plotDirection = null;
/**
* Plot Direction
*
* @var boolean
*/
private $plotDirection;
/**
* Plot Style
*
* @var string
*/
private $_plotStyle = null;
/**
* Plot Style
*
* @var string
*/
private $plotStyle;
/**
* Order of plots in Series
*
* @var array of integer
*/
private $_plotOrder = array();
/**
* Order of plots in Series
*
* @var array of integer
*/
private $plotOrder = array();
/**
* Plot Label
*
* @var array of PHPExcel_Chart_DataSeriesValues
*/
private $_plotLabel = array();
/**
* Plot Label
*
* @var array of PHPExcel_Chart_DataSeriesValues
*/
private $plotLabel = array();
/**
* Plot Category
*
* @var array of PHPExcel_Chart_DataSeriesValues
*/
private $_plotCategory = array();
/**
* Plot Category
*
* @var array of PHPExcel_Chart_DataSeriesValues
*/
private $plotCategory = array();
/**
* Smooth Line
*
* @var string
*/
private $_smoothLine = null;
/**
* Smooth Line
*
* @var string
*/
private $smoothLine;
/**
* Plot Values
*
* @var array of PHPExcel_Chart_DataSeriesValues
*/
private $_plotValues = array();
/**
* Plot Values
*
* @var array of PHPExcel_Chart_DataSeriesValues
*/
private $plotValues = array();
/**
* Create a new PHPExcel_Chart_DataSeries
*/
public function __construct($plotType = null, $plotGrouping = null, $plotOrder = array(), $plotLabel = array(), $plotCategory = array(), $plotValues = array(), $smoothLine = null, $plotStyle = null)
{
$this->_plotType = $plotType;
$this->_plotGrouping = $plotGrouping;
$this->_plotOrder = $plotOrder;
$keys = array_keys($plotValues);
$this->_plotValues = $plotValues;
if ((count($plotLabel) == 0) || (is_null($plotLabel[$keys[0]]))) {
$plotLabel[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
}
/**
* Create a new PHPExcel_Chart_DataSeries
*/
public function __construct($plotType = null, $plotGrouping = null, $plotOrder = array(), $plotLabel = array(), $plotCategory = array(), $plotValues = array(), $plotDirection = null, $smoothLine = null, $plotStyle = null)
{
$this->plotType = $plotType;
$this->plotGrouping = $plotGrouping;
$this->plotOrder = $plotOrder;
$keys = array_keys($plotValues);
$this->plotValues = $plotValues;
if ((count($plotLabel) == 0) || (is_null($plotLabel[$keys[0]]))) {
$plotLabel[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
}
$this->_plotLabel = $plotLabel;
if ((count($plotCategory) == 0) || (is_null($plotCategory[$keys[0]]))) {
$plotCategory[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
}
$this->_plotCategory = $plotCategory;
$this->_smoothLine = $smoothLine;
$this->_plotStyle = $plotStyle;
}
$this->plotLabel = $plotLabel;
if ((count($plotCategory) == 0) || (is_null($plotCategory[$keys[0]]))) {
$plotCategory[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
}
$this->plotCategory = $plotCategory;
$this->smoothLine = $smoothLine;
$this->plotStyle = $plotStyle;
if (is_null($plotDirection)) {
$plotDirection = self::DIRECTION_COL;
}
$this->plotDirection = $plotDirection;
}
/**
* Get Plot Type
*
* @return string
*/
public function getPlotType() {
return $this->_plotType;
}
/**
* Get Plot Type
*
* @return string
*/
public function getPlotType()
{
return $this->plotType;
}
/**
* Set Plot Type
*
* @param string $plotType
*/
public function setPlotType($plotType = '') {
$this->_plotType = $plotType;
}
/**
* Set Plot Type
*
* @param string $plotType
* @return PHPExcel_Chart_DataSeries
*/
public function setPlotType($plotType = '')
{
$this->plotType = $plotType;
return $this;
}
/**
* Get Plot Grouping Type
*
* @return string
*/
public function getPlotGrouping() {
return $this->_plotGrouping;
}
/**
* Get Plot Grouping Type
*
* @return string
*/
public function getPlotGrouping()
{
return $this->plotGrouping;
}
/**
* Set Plot Grouping Type
*
* @param string $groupingType
*/
public function setPlotGrouping($groupingType = null) {
$this->_plotGrouping = $groupingType;
}
/**
* Set Plot Grouping Type
*
* @param string $groupingType
* @return PHPExcel_Chart_DataSeries
*/
public function setPlotGrouping($groupingType = null)
{
$this->plotGrouping = $groupingType;
return $this;
}
/**
* Get Plot Direction
*
* @return string
*/
public function getPlotDirection() {
return $this->_plotDirection;
}
/**
* Get Plot Direction
*
* @return string
*/
public function getPlotDirection()
{
return $this->plotDirection;
}
/**
* Set Plot Direction
*
* @param string $plotDirection
*/
public function setPlotDirection($plotDirection = null) {
$this->_plotDirection = $plotDirection;
}
/**
* Set Plot Direction
*
* @param string $plotDirection
* @return PHPExcel_Chart_DataSeries
*/
public function setPlotDirection($plotDirection = null)
{
$this->plotDirection = $plotDirection;
return $this;
}
/**
* Get Plot Order
*
* @return string
*/
public function getPlotOrder() {
return $this->_plotOrder;
}
/**
* Get Plot Order
*
* @return string
*/
public function getPlotOrder()
{
return $this->plotOrder;
}
/**
* Get Plot Labels
*
* @return array of PHPExcel_Chart_DataSeriesValues
*/
public function getPlotLabels() {
return $this->_plotLabel;
}
/**
* Get Plot Labels
*
* @return array of PHPExcel_Chart_DataSeriesValues
*/
public function getPlotLabels()
{
return $this->plotLabel;
}
/**
* Get Plot Label by Index
*
* @return PHPExcel_Chart_DataSeriesValues
*/
public function getPlotLabelByIndex($index) {
$keys = array_keys($this->_plotLabel);
if (in_array($index,$keys)) {
return $this->_plotLabel[$index];
} elseif(isset($keys[$index])) {
return $this->_plotLabel[$keys[$index]];
}
return false;
}
/**
* Get Plot Label by Index
*
* @return PHPExcel_Chart_DataSeriesValues
*/
public function getPlotLabelByIndex($index)
{
$keys = array_keys($this->plotLabel);
if (in_array($index, $keys)) {
return $this->plotLabel[$index];
} elseif (isset($keys[$index])) {
return $this->plotLabel[$keys[$index]];
}
return false;
}
/**
* Get Plot Categories
*
* @return array of PHPExcel_Chart_DataSeriesValues
*/
public function getPlotCategories() {
return $this->_plotCategory;
}
/**
* Get Plot Categories
*
* @return array of PHPExcel_Chart_DataSeriesValues
*/
public function getPlotCategories()
{
return $this->plotCategory;
}
/**
* Get Plot Category by Index
*
* @return PHPExcel_Chart_DataSeriesValues
*/
public function getPlotCategoryByIndex($index) {
$keys = array_keys($this->_plotCategory);
if (in_array($index,$keys)) {
return $this->_plotCategory[$index];
} elseif(isset($keys[$index])) {
return $this->_plotCategory[$keys[$index]];
}
return false;
}
/**
* Get Plot Category by Index
*
* @return PHPExcel_Chart_DataSeriesValues
*/
public function getPlotCategoryByIndex($index)
{
$keys = array_keys($this->plotCategory);
if (in_array($index, $keys)) {
return $this->plotCategory[$index];
} elseif (isset($keys[$index])) {
return $this->plotCategory[$keys[$index]];
}
return false;
}
/**
* Get Plot Style
*
* @return string
*/
public function getPlotStyle() {
return $this->_plotStyle;
}
/**
* Get Plot Style
*
* @return string
*/
public function getPlotStyle()
{
return $this->plotStyle;
}
/**
* Set Plot Style
*
* @param string $plotStyle
*/
public function setPlotStyle($plotStyle = null) {
$this->_plotStyle = $plotStyle;
}
/**
* Set Plot Style
*
* @param string $plotStyle
* @return PHPExcel_Chart_DataSeries
*/
public function setPlotStyle($plotStyle = null)
{
$this->plotStyle = $plotStyle;
return $this;
}
/**
* Get Plot Values
*
* @return array of PHPExcel_Chart_DataSeriesValues
*/
public function getPlotValues() {
return $this->_plotValues;
}
/**
* Get Plot Values
*
* @return array of PHPExcel_Chart_DataSeriesValues
*/
public function getPlotValues()
{
return $this->plotValues;
}
/**
* Get Plot Values by Index
*
* @return PHPExcel_Chart_DataSeriesValues
*/
public function getPlotValuesByIndex($index) {
$keys = array_keys($this->_plotValues);
if (in_array($index,$keys)) {
return $this->_plotValues[$index];
} elseif(isset($keys[$index])) {
return $this->_plotValues[$keys[$index]];
}
return false;
}
/**
* Get Plot Values by Index
*
* @return PHPExcel_Chart_DataSeriesValues
*/
public function getPlotValuesByIndex($index)
{
$keys = array_keys($this->plotValues);
if (in_array($index, $keys)) {
return $this->plotValues[$index];
} elseif (isset($keys[$index])) {
return $this->plotValues[$keys[$index]];
}
return false;
}
/**
* Get Number of Plot Series
*
* @return integer
*/
public function getPlotSeriesCount() {
return count($this->_plotValues);
}
/**
* Get Number of Plot Series
*
* @return integer
*/
public function getPlotSeriesCount()
{
return count($this->plotValues);
}
/**
* Get Smooth Line
*
* @return boolean
*/
public function getSmoothLine() {
return $this->_smoothLine;
}
/**
* Get Smooth Line
*
* @return boolean
*/
public function getSmoothLine()
{
return $this->smoothLine;
}
/**
* Set Smooth Line
*
* @param boolean $smoothLine
*/
public function setSmoothLine($smoothLine = TRUE) {
$this->_smoothLine = $smoothLine;
}
public function refresh(PHPExcel_Worksheet $worksheet) {
foreach($this->_plotValues as $plotValues) {
if ($plotValues !== NULL)
$plotValues->refresh($worksheet, TRUE);
}
foreach($this->_plotLabel as $plotValues) {
if ($plotValues !== NULL)
$plotValues->refresh($worksheet, TRUE);
}
foreach($this->_plotCategory as $plotValues) {
if ($plotValues !== NULL)
$plotValues->refresh($worksheet, FALSE);
}
}
/**
* Set Smooth Line
*
* @param boolean $smoothLine
* @return PHPExcel_Chart_DataSeries
*/
public function setSmoothLine($smoothLine = true)
{
$this->smoothLine = $smoothLine;
return $this;
}
public function refresh(PHPExcel_Worksheet $worksheet)
{
foreach ($this->plotValues as $plotValues) {
if ($plotValues !== null) {
$plotValues->refresh($worksheet, true);
}
}
foreach ($this->plotLabel as $plotValues) {
if ($plotValues !== null) {
$plotValues->refresh($worksheet, true);
}
}
foreach ($this->plotCategory as $plotValues) {
if ($plotValues !== null) {
$plotValues->refresh($worksheet, false);
}
}
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Chart_DataSeriesValues
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -18,310 +19,315 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Chart_DataSeriesValues
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Chart_DataSeriesValues
{
const DATASERIES_TYPE_STRING = 'String';
const DATASERIES_TYPE_NUMBER = 'Number';
const DATASERIES_TYPE_STRING = 'String';
const DATASERIES_TYPE_NUMBER = 'Number';
private static $_dataTypeValues = array(
self::DATASERIES_TYPE_STRING,
self::DATASERIES_TYPE_NUMBER,
);
private static $dataTypeValues = array(
self::DATASERIES_TYPE_STRING,
self::DATASERIES_TYPE_NUMBER,
);
/**
* Series Data Type
*
* @var string
*/
private $_dataType = null;
/**
* Series Data Type
*
* @var string
*/
private $dataType;
/**
* Series Data Source
*
* @var string
*/
private $_dataSource = null;
/**
* Series Data Source
*
* @var string
*/
private $dataSource;
/**
* Format Code
*
* @var string
*/
private $_formatCode = null;
/**
* Format Code
*
* @var string
*/
private $formatCode;
/**
* Series Point Marker
*
* @var string
*/
private $_marker = null;
/**
* Series Point Marker
*
* @var string
*/
private $pointMarker;
/**
* Point Count (The number of datapoints in the dataseries)
*
* @var integer
*/
private $_pointCount = 0;
/**
* Point Count (The number of datapoints in the dataseries)
*
* @var integer
*/
private $pointCount = 0;
/**
* Data Values
*
* @var array of mixed
*/
private $_dataValues = array();
/**
* Data Values
*
* @var array of mixed
*/
private $dataValues = array();
/**
* Create a new PHPExcel_Chart_DataSeriesValues object
*/
public function __construct($dataType = self::DATASERIES_TYPE_NUMBER, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = array(), $marker = null)
{
$this->setDataType($dataType);
$this->_dataSource = $dataSource;
$this->_formatCode = $formatCode;
$this->_pointCount = $pointCount;
$this->_dataValues = $dataValues;
$this->_marker = $marker;
}
/**
* Create a new PHPExcel_Chart_DataSeriesValues object
*/
public function __construct($dataType = self::DATASERIES_TYPE_NUMBER, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = array(), $marker = null)
{
$this->setDataType($dataType);
$this->dataSource = $dataSource;
$this->formatCode = $formatCode;
$this->pointCount = $pointCount;
$this->dataValues = $dataValues;
$this->pointMarker = $marker;
}
/**
* Get Series Data Type
*
* @return string
*/
public function getDataType() {
return $this->_dataType;
}
/**
* Get Series Data Type
*
* @return string
*/
public function getDataType()
{
return $this->dataType;
}
/**
* Set Series Data Type
*
* @param string $dataType Datatype of this data series
* Typical values are:
* PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_STRING
* Normally used for axis point values
* PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_NUMBER
* Normally used for chart data values
* @return PHPExcel_Chart_DataSeriesValues
*/
public function setDataType($dataType = self::DATASERIES_TYPE_NUMBER) {
if (!in_array($dataType, self::$_dataTypeValues)) {
throw new PHPExcel_Chart_Exception('Invalid datatype for chart data series values');
}
$this->_dataType = $dataType;
/**
* Set Series Data Type
*
* @param string $dataType Datatype of this data series
* Typical values are:
* PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_STRING
* Normally used for axis point values
* PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_NUMBER
* Normally used for chart data values
* @return PHPExcel_Chart_DataSeriesValues
*/
public function setDataType($dataType = self::DATASERIES_TYPE_NUMBER)
{
if (!in_array($dataType, self::$dataTypeValues)) {
throw new PHPExcel_Chart_Exception('Invalid datatype for chart data series values');
}
$this->dataType = $dataType;
return $this;
}
return $this;
}
/**
* Get Series Data Source (formula)
*
* @return string
*/
public function getDataSource() {
return $this->_dataSource;
}
/**
* Get Series Data Source (formula)
*
* @return string
*/
public function getDataSource()
{
return $this->dataSource;
}
/**
* Set Series Data Source (formula)
*
* @param string $dataSource
* @return PHPExcel_Chart_DataSeriesValues
*/
public function setDataSource($dataSource = null, $refreshDataValues = true) {
$this->_dataSource = $dataSource;
/**
* Set Series Data Source (formula)
*
* @param string $dataSource
* @return PHPExcel_Chart_DataSeriesValues
*/
public function setDataSource($dataSource = null, $refreshDataValues = true)
{
$this->dataSource = $dataSource;
if ($refreshDataValues) {
// TO DO
}
if ($refreshDataValues) {
// TO DO
}
return $this;
}
return $this;
}
/**
* Get Point Marker
*
* @return string
*/
public function getPointMarker() {
return $this->_marker;
}
/**
* Get Point Marker
*
* @return string
*/
public function getPointMarker()
{
return $this->pointMarker;
}
/**
* Set Point Marker
*
* @param string $marker
* @return PHPExcel_Chart_DataSeriesValues
*/
public function setPointMarker($marker = null) {
$this->_marker = $marker;
/**
* Set Point Marker
*
* @param string $marker
* @return PHPExcel_Chart_DataSeriesValues
*/
public function setPointMarker($marker = null)
{
$this->pointMarker = $marker;
return $this;
}
return $this;
}
/**
* Get Series Format Code
*
* @return string
*/
public function getFormatCode() {
return $this->_formatCode;
}
/**
* Get Series Format Code
*
* @return string
*/
public function getFormatCode()
{
return $this->formatCode;
}
/**
* Set Series Format Code
*
* @param string $formatCode
* @return PHPExcel_Chart_DataSeriesValues
*/
public function setFormatCode($formatCode = null) {
$this->_formatCode = $formatCode;
/**
* Set Series Format Code
*
* @param string $formatCode
* @return PHPExcel_Chart_DataSeriesValues
*/
public function setFormatCode($formatCode = null)
{
$this->formatCode = $formatCode;
return $this;
}
return $this;
}
/**
* Get Series Point Count
*
* @return integer
*/
public function getPointCount() {
return $this->_pointCount;
}
/**
* Get Series Point Count
*
* @return integer
*/
public function getPointCount()
{
return $this->pointCount;
}
/**
* Identify if the Data Series is a multi-level or a simple series
*
* @return boolean
*/
public function isMultiLevelSeries() {
if (count($this->_dataValues) > 0) {
return is_array($this->_dataValues[0]);
}
return null;
}
/**
* Identify if the Data Series is a multi-level or a simple series
*
* @return boolean
*/
public function isMultiLevelSeries()
{
if (count($this->dataValues) > 0) {
return is_array($this->dataValues[0]);
}
return null;
}
/**
* Return the level count of a multi-level Data Series
*
* @return boolean
*/
public function multiLevelCount() {
$levelCount = 0;
foreach($this->_dataValues as $dataValueSet) {
$levelCount = max($levelCount,count($dataValueSet));
}
return $levelCount;
}
/**
* Return the level count of a multi-level Data Series
*
* @return boolean
*/
public function multiLevelCount()
{
$levelCount = 0;
foreach ($this->dataValues as $dataValueSet) {
$levelCount = max($levelCount, count($dataValueSet));
}
return $levelCount;
}
/**
* Get Series Data Values
*
* @return array of mixed
*/
public function getDataValues() {
return $this->_dataValues;
}
/**
* Get Series Data Values
*
* @return array of mixed
*/
public function getDataValues()
{
return $this->dataValues;
}
/**
* Get the first Series Data value
*
* @return mixed
*/
public function getDataValue() {
$count = count($this->_dataValues);
if ($count == 0) {
return null;
} elseif ($count == 1) {
return $this->_dataValues[0];
}
return $this->_dataValues;
}
/**
* Get the first Series Data value
*
* @return mixed
*/
public function getDataValue()
{
$count = count($this->dataValues);
if ($count == 0) {
return null;
} elseif ($count == 1) {
return $this->dataValues[0];
}
return $this->dataValues;
}
/**
* Set Series Data Values
*
* @param array $dataValues
* @param boolean $refreshDataSource
* TRUE - refresh the value of _dataSource based on the values of $dataValues
* FALSE - don't change the value of _dataSource
* @return PHPExcel_Chart_DataSeriesValues
*/
public function setDataValues($dataValues = array(), $refreshDataSource = TRUE) {
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($dataValues);
$this->_pointCount = count($dataValues);
/**
* Set Series Data Values
*
* @param array $dataValues
* @param boolean $refreshDataSource
* TRUE - refresh the value of dataSource based on the values of $dataValues
* FALSE - don't change the value of dataSource
* @return PHPExcel_Chart_DataSeriesValues
*/
public function setDataValues($dataValues = array(), $refreshDataSource = true)
{
$this->dataValues = PHPExcel_Calculation_Functions::flattenArray($dataValues);
$this->pointCount = count($dataValues);
if ($refreshDataSource) {
// TO DO
}
if ($refreshDataSource) {
// TO DO
}
return $this;
}
return $this;
}
private function _stripNulls($var) {
return $var !== NULL;
}
private function stripNulls($var)
{
return $var !== null;
}
public function refresh(PHPExcel_Worksheet $worksheet, $flatten = TRUE) {
if ($this->_dataSource !== NULL) {
$calcEngine = PHPExcel_Calculation::getInstance($worksheet->getParent());
$newDataValues = PHPExcel_Calculation::_unwrapResult(
$calcEngine->_calculateFormulaValue(
'='.$this->_dataSource,
NULL,
$worksheet->getCell('A1')
)
);
if ($flatten) {
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
foreach($this->_dataValues as &$dataValue) {
if ((!empty($dataValue)) && ($dataValue[0] == '#')) {
$dataValue = 0.0;
}
}
unset($dataValue);
} else {
$cellRange = explode('!',$this->_dataSource);
if (count($cellRange) > 1) {
list(,$cellRange) = $cellRange;
}
public function refresh(PHPExcel_Worksheet $worksheet, $flatten = true)
{
if ($this->dataSource !== null) {
$calcEngine = PHPExcel_Calculation::getInstance($worksheet->getParent());
$newDataValues = PHPExcel_Calculation::unwrapResult(
$calcEngine->_calculateFormulaValue(
'='.$this->dataSource,
null,
$worksheet->getCell('A1')
)
);
if ($flatten) {
$this->dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
foreach ($this->dataValues as &$dataValue) {
if ((!empty($dataValue)) && ($dataValue[0] == '#')) {
$dataValue = 0.0;
}
}
unset($dataValue);
} else {
$cellRange = explode('!', $this->dataSource);
if (count($cellRange) > 1) {
list(, $cellRange) = $cellRange;
}
$dimensions = PHPExcel_Cell::rangeDimension(str_replace('$','',$cellRange));
if (($dimensions[0] == 1) || ($dimensions[1] == 1)) {
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
} else {
$newArray = array_values(array_shift($newDataValues));
foreach($newArray as $i => $newDataSet) {
$newArray[$i] = array($newDataSet);
}
foreach($newDataValues as $newDataSet) {
$i = 0;
foreach($newDataSet as $newDataVal) {
array_unshift($newArray[$i++],$newDataVal);
}
}
$this->_dataValues = $newArray;
}
}
$this->_pointCount = count($this->_dataValues);
}
}
$dimensions = PHPExcel_Cell::rangeDimension(str_replace('$', '', $cellRange));
if (($dimensions[0] == 1) || ($dimensions[1] == 1)) {
$this->dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
} else {
$newArray = array_values(array_shift($newDataValues));
foreach ($newArray as $i => $newDataSet) {
$newArray[$i] = array($newDataSet);
}
foreach ($newDataValues as $newDataSet) {
$i = 0;
foreach ($newDataSet as $newDataVal) {
array_unshift($newArray[$i++], $newDataVal);
}
}
$this->dataValues = $newArray;
}
}
$this->pointCount = count($this->dataValues);
}
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Chart_Exception
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,33 +21,26 @@
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Chart_Exception
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Chart_Exception extends PHPExcel_Exception {
/**
* Error handler callback
*
* @param mixed $code
* @param mixed $string
* @param mixed $file
* @param mixed $line
* @param mixed $context
*/
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
$e = new self($string, $code);
$e->line = $line;
$e->file = $file;
throw $e;
}
class PHPExcel_Chart_Exception extends PHPExcel_Exception
{
/**
* Error handler callback
*
* @param mixed $code
* @param mixed $string
* @param mixed $file
* @param mixed $line
* @param mixed $context
*/
public static function errorHandlerCallback($code, $string, $file, $line, $context)
{
$e = new self($string, $code);
$e->line = $line;
$e->file = $file;
throw $e;
}
}

View file

@ -0,0 +1,472 @@
<?php
/**
* Created by PhpStorm.
* User: Wiktor Trzonkowski
* Date: 7/2/14
* Time: 2:36 PM
*/
class PHPExcel_Chart_GridLines extends PHPExcel_Chart_Properties
{
/**
* Properties of Class:
* Object State (State for Minor Tick Mark) @var bool
* Line Properties @var array of mixed
* Shadow Properties @var array of mixed
* Glow Properties @var array of mixed
* Soft Properties @var array of mixed
*
*/
private $objectState = false;
private $lineProperties = array(
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => null,
'alpha' => 0
),
'style' => array(
'width' => '9525',
'compound' => self::LINE_STYLE_COMPOUND_SIMPLE,
'dash' => self::LINE_STYLE_DASH_SOLID,
'cap' => self::LINE_STYLE_CAP_FLAT,
'join' => self::LINE_STYLE_JOIN_BEVEL,
'arrow' => array(
'head' => array(
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
'size' => self::LINE_STYLE_ARROW_SIZE_5
),
'end' => array(
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
'size' => self::LINE_STYLE_ARROW_SIZE_8
),
)
)
);
private $shadowProperties = array(
'presets' => self::SHADOW_PRESETS_NOSHADOW,
'effect' => null,
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => 'black',
'alpha' => 85,
),
'size' => array(
'sx' => null,
'sy' => null,
'kx' => null
),
'blur' => null,
'direction' => null,
'distance' => null,
'algn' => null,
'rotWithShape' => null
);
private $glowProperties = array(
'size' => null,
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => 'black',
'alpha' => 40
)
);
private $softEdges = array(
'size' => null
);
/**
* Get Object State
*
* @return bool
*/
public function getObjectState()
{
return $this->objectState;
}
/**
* Change Object State to True
*
* @return PHPExcel_Chart_GridLines
*/
private function activateObject()
{
$this->objectState = true;
return $this;
}
/**
* Set Line Color Properties
*
* @param string $value
* @param int $alpha
* @param string $type
*/
public function setLineColorProperties($value, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_STANDARD)
{
$this->activateObject()
->lineProperties['color'] = $this->setColorProperties(
$value,
$alpha,
$type
);
}
/**
* Set Line Color Properties
*
* @param float $line_width
* @param string $compound_type
* @param string $dash_type
* @param string $cap_type
* @param string $join_type
* @param string $head_arrow_type
* @param string $head_arrow_size
* @param string $end_arrow_type
* @param string $end_arrow_size
*/
public function setLineStyleProperties($line_width = null, $compound_type = null, $dash_type = null, $cap_type = null, $join_type = null, $head_arrow_type = null, $head_arrow_size = null, $end_arrow_type = null, $end_arrow_size = null)
{
$this->activateObject();
(!is_null($line_width))
? $this->lineProperties['style']['width'] = $this->getExcelPointsWidth((float) $line_width)
: null;
(!is_null($compound_type))
? $this->lineProperties['style']['compound'] = (string) $compound_type
: null;
(!is_null($dash_type))
? $this->lineProperties['style']['dash'] = (string) $dash_type
: null;
(!is_null($cap_type))
? $this->lineProperties['style']['cap'] = (string) $cap_type
: null;
(!is_null($join_type))
? $this->lineProperties['style']['join'] = (string) $join_type
: null;
(!is_null($head_arrow_type))
? $this->lineProperties['style']['arrow']['head']['type'] = (string) $head_arrow_type
: null;
(!is_null($head_arrow_size))
? $this->lineProperties['style']['arrow']['head']['size'] = (string) $head_arrow_size
: null;
(!is_null($end_arrow_type))
? $this->lineProperties['style']['arrow']['end']['type'] = (string) $end_arrow_type
: null;
(!is_null($end_arrow_size))
? $this->lineProperties['style']['arrow']['end']['size'] = (string) $end_arrow_size
: null;
}
/**
* Get Line Color Property
*
* @param string $parameter
*
* @return string
*/
public function getLineColorProperty($parameter)
{
return $this->lineProperties['color'][$parameter];
}
/**
* Get Line Style Property
*
* @param array|string $elements
*
* @return string
*/
public function getLineStyleProperty($elements)
{
return $this->getArrayElementsValue($this->lineProperties['style'], $elements);
}
/**
* Set Glow Properties
*
* @param float $size
* @param string $color_value
* @param int $color_alpha
* @param string $color_type
*
*/
public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null)
{
$this
->activateObject()
->setGlowSize($size)
->setGlowColor($color_value, $color_alpha, $color_type);
}
/**
* Get Glow Color Property
*
* @param string $property
*
* @return string
*/
public function getGlowColor($property)
{
return $this->glowProperties['color'][$property];
}
/**
* Get Glow Size
*
* @return string
*/
public function getGlowSize()
{
return $this->glowProperties['size'];
}
/**
* Set Glow Size
*
* @param float $size
*
* @return PHPExcel_Chart_GridLines
*/
private function setGlowSize($size)
{
$this->glowProperties['size'] = $this->getExcelPointsWidth((float) $size);
return $this;
}
/**
* Set Glow Color
*
* @param string $color
* @param int $alpha
* @param string $type
*
* @return PHPExcel_Chart_GridLines
*/
private function setGlowColor($color, $alpha, $type)
{
if (!is_null($color)) {
$this->glowProperties['color']['value'] = (string) $color;
}
if (!is_null($alpha)) {
$this->glowProperties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
}
if (!is_null($type)) {
$this->glowProperties['color']['type'] = (string) $type;
}
return $this;
}
/**
* Get Line Style Arrow Parameters
*
* @param string $arrow_selector
* @param string $property_selector
*
* @return string
*/
public function getLineStyleArrowParameters($arrow_selector, $property_selector)
{
return $this->getLineStyleArrowSize($this->lineProperties['style']['arrow'][$arrow_selector]['size'], $property_selector);
}
/**
* Set Shadow Properties
*
* @param int $sh_presets
* @param string $sh_color_value
* @param string $sh_color_type
* @param int $sh_color_alpha
* @param string $sh_blur
* @param int $sh_angle
* @param float $sh_distance
*
*/
public function setShadowProperties($sh_presets, $sh_color_value = null, $sh_color_type = null, $sh_color_alpha = null, $sh_blur = null, $sh_angle = null, $sh_distance = null)
{
$this->activateObject()
->setShadowPresetsProperties((int) $sh_presets)
->setShadowColor(
is_null($sh_color_value) ? $this->shadowProperties['color']['value'] : $sh_color_value,
is_null($sh_color_alpha) ? (int) $this->shadowProperties['color']['alpha'] : $this->getTrueAlpha($sh_color_alpha),
is_null($sh_color_type) ? $this->shadowProperties['color']['type'] : $sh_color_type
)
->setShadowBlur($sh_blur)
->setShadowAngle($sh_angle)
->setShadowDistance($sh_distance);
}
/**
* Set Shadow Presets Properties
*
* @param int $shadow_presets
*
* @return PHPExcel_Chart_GridLines
*/
private function setShadowPresetsProperties($shadow_presets)
{
$this->shadowProperties['presets'] = $shadow_presets;
$this->setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets));
return $this;
}
/**
* Set Shadow Properties Values
*
* @param array $properties_map
* @param * $reference
*
* @return PHPExcel_Chart_GridLines
*/
private function setShadowProperiesMapValues(array $properties_map, &$reference = null)
{
$base_reference = $reference;
foreach ($properties_map as $property_key => $property_val) {
if (is_array($property_val)) {
if ($reference === null) {
$reference = & $this->shadowProperties[$property_key];
} else {
$reference = & $reference[$property_key];
}
$this->setShadowProperiesMapValues($property_val, $reference);
} else {
if ($base_reference === null) {
$this->shadowProperties[$property_key] = $property_val;
} else {
$reference[$property_key] = $property_val;
}
}
}
return $this;
}
/**
* Set Shadow Color
*
* @param string $color
* @param int $alpha
* @param string $type
* @return PHPExcel_Chart_GridLines
*/
private function setShadowColor($color, $alpha, $type)
{
if (!is_null($color)) {
$this->shadowProperties['color']['value'] = (string) $color;
}
if (!is_null($alpha)) {
$this->shadowProperties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
}
if (!is_null($type)) {
$this->shadowProperties['color']['type'] = (string) $type;
}
return $this;
}
/**
* Set Shadow Blur
*
* @param float $blur
*
* @return PHPExcel_Chart_GridLines
*/
private function setShadowBlur($blur)
{
if ($blur !== null) {
$this->shadowProperties['blur'] = (string) $this->getExcelPointsWidth($blur);
}
return $this;
}
/**
* Set Shadow Angle
*
* @param int $angle
* @return PHPExcel_Chart_GridLines
*/
private function setShadowAngle($angle)
{
if ($angle !== null) {
$this->shadowProperties['direction'] = (string) $this->getExcelPointsAngle($angle);
}
return $this;
}
/**
* Set Shadow Distance
*
* @param float $distance
* @return PHPExcel_Chart_GridLines
*/
private function setShadowDistance($distance)
{
if ($distance !== null) {
$this->shadowProperties['distance'] = (string) $this->getExcelPointsWidth($distance);
}
return $this;
}
/**
* Get Shadow Property
*
* @param string $elements
* @param array $elements
* @return string
*/
public function getShadowProperty($elements)
{
return $this->getArrayElementsValue($this->shadowProperties, $elements);
}
/**
* Set Soft Edges Size
*
* @param float $size
*/
public function setSoftEdgesSize($size)
{
if (!is_null($size)) {
$this->activateObject();
$softEdges['size'] = (string) $this->getExcelPointsWidth($size);
}
}
/**
* Get Soft Edges Size
*
* @return string
*/
public function getSoftEdgesSize()
{
return $this->softEdges['size'];
}
}

View file

@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -18,400 +18,469 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Chart_Layout
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Chart_Layout
{
/**
* layoutTarget
*
* @var string
*/
private $_layoutTarget = NULL;
/**
* layoutTarget
*
* @var string
*/
private $layoutTarget;
/**
* X Mode
*
* @var string
*/
private $_xMode = NULL;
/**
* X Mode
*
* @var string
*/
private $xMode;
/**
* Y Mode
*
* @var string
*/
private $_yMode = NULL;
/**
* Y Mode
*
* @var string
*/
private $yMode;
/**
* X-Position
*
* @var float
*/
private $_xPos = NULL;
/**
* X-Position
*
* @var float
*/
private $xPos;
/**
* Y-Position
*
* @var float
*/
private $_yPos = NULL;
/**
* Y-Position
*
* @var float
*/
private $yPos;
/**
* width
*
* @var float
*/
private $_width = NULL;
/**
* width
*
* @var float
*/
private $width;
/**
* height
*
* @var float
*/
private $_height = NULL;
/**
* height
*
* @var float
*/
private $height;
/**
* show legend key
* Specifies that legend keys should be shown in data labels
*
* @var boolean
*/
private $_showLegendKey = NULL;
/**
* show legend key
* Specifies that legend keys should be shown in data labels
*
* @var boolean
*/
private $showLegendKey;
/**
* show value
* Specifies that the value should be shown in a data label.
*
* @var boolean
*/
private $_showVal = NULL;
/**
* show value
* Specifies that the value should be shown in a data label.
*
* @var boolean
*/
private $showVal;
/**
* show category name
* Specifies that the category name should be shown in the data label.
*
* @var boolean
*/
private $_showCatName = NULL;
/**
* show category name
* Specifies that the category name should be shown in the data label.
*
* @var boolean
*/
private $showCatName;
/**
* show data series name
* Specifies that the series name should be shown in the data label.
*
* @var boolean
*/
private $_showSerName = NULL;
/**
* show data series name
* Specifies that the series name should be shown in the data label.
*
* @var boolean
*/
private $showSerName;
/**
* show percentage
* Specifies that the percentage should be shown in the data label.
*
* @var boolean
*/
private $_showPercent = NULL;
/**
* show percentage
* Specifies that the percentage should be shown in the data label.
*
* @var boolean
*/
private $showPercent;
/**
* show bubble size
*
* @var boolean
*/
private $_showBubbleSize = NULL;
/**
* show bubble size
*
* @var boolean
*/
private $showBubbleSize;
/**
* show leader lines
* Specifies that leader lines should be shown for the data label.
*
* @var boolean
*/
private $_showLeaderLines = NULL;
/**
* show leader lines
* Specifies that leader lines should be shown for the data label.
*
* @var boolean
*/
private $showLeaderLines;
/**
* Create a new PHPExcel_Chart_Layout
*/
public function __construct($layout=array())
{
if (isset($layout['layoutTarget'])) { $this->_layoutTarget = $layout['layoutTarget']; }
if (isset($layout['xMode'])) { $this->_xMode = $layout['xMode']; }
if (isset($layout['yMode'])) { $this->_yMode = $layout['yMode']; }
if (isset($layout['x'])) { $this->_xPos = (float) $layout['x']; }
if (isset($layout['y'])) { $this->_yPos = (float) $layout['y']; }
if (isset($layout['w'])) { $this->_width = (float) $layout['w']; }
if (isset($layout['h'])) { $this->_height = (float) $layout['h']; }
}
/**
* Create a new PHPExcel_Chart_Layout
*/
public function __construct($layout = array())
{
if (isset($layout['layoutTarget'])) {
$this->layoutTarget = $layout['layoutTarget'];
}
if (isset($layout['xMode'])) {
$this->xMode = $layout['xMode'];
}
if (isset($layout['yMode'])) {
$this->yMode = $layout['yMode'];
}
if (isset($layout['x'])) {
$this->xPos = (float) $layout['x'];
}
if (isset($layout['y'])) {
$this->yPos = (float) $layout['y'];
}
if (isset($layout['w'])) {
$this->width = (float) $layout['w'];
}
if (isset($layout['h'])) {
$this->height = (float) $layout['h'];
}
}
/**
* Get Layout Target
*
* @return string
*/
public function getLayoutTarget() {
return $this->_layoutTarget;
}
/**
* Get Layout Target
*
* @return string
*/
public function getLayoutTarget()
{
return $this->layoutTarget;
}
/**
* Set Layout Target
*
* @param Layout Target $value
*/
public function setLayoutTarget($value) {
$this->_layoutTarget = $value;
}
/**
* Set Layout Target
*
* @param Layout Target $value
* @return PHPExcel_Chart_Layout
*/
public function setLayoutTarget($value)
{
$this->layoutTarget = $value;
return $this;
}
/**
* Get X-Mode
*
* @return string
*/
public function getXMode() {
return $this->_xMode;
}
/**
* Get X-Mode
*
* @return string
*/
public function getXMode()
{
return $this->xMode;
}
/**
* Set X-Mode
*
* @param X-Mode $value
*/
public function setXMode($value) {
$this->_xMode = $value;
}
/**
* Set X-Mode
*
* @param X-Mode $value
* @return PHPExcel_Chart_Layout
*/
public function setXMode($value)
{
$this->xMode = $value;
return $this;
}
/**
* Get Y-Mode
*
* @return string
*/
public function getYMode() {
return $this->_xMode;
}
/**
* Get Y-Mode
*
* @return string
*/
public function getYMode()
{
return $this->yMode;
}
/**
* Set Y-Mode
*
* @param Y-Mode $value
*/
public function setYMode($value) {
$this->_xMode = $value;
}
/**
* Set Y-Mode
*
* @param Y-Mode $value
* @return PHPExcel_Chart_Layout
*/
public function setYMode($value)
{
$this->yMode = $value;
return $this;
}
/**
* Get X-Position
*
* @return number
*/
public function getXPosition() {
return $this->_xPos;
}
/**
* Get X-Position
*
* @return number
*/
public function getXPosition()
{
return $this->xPos;
}
/**
* Set X-Position
*
* @param X-Position $value
*/
public function setXPosition($value) {
$this->_xPos = $value;
}
/**
* Set X-Position
*
* @param X-Position $value
* @return PHPExcel_Chart_Layout
*/
public function setXPosition($value)
{
$this->xPos = $value;
return $this;
}
/**
* Get Y-Position
*
* @return number
*/
public function getYPosition() {
return $this->_yPos;
}
/**
* Get Y-Position
*
* @return number
*/
public function getYPosition()
{
return $this->yPos;
}
/**
* Set Y-Position
*
* @param Y-Position $value
*/
public function setYPosition($value) {
$this->_yPos = $value;
}
/**
* Set Y-Position
*
* @param Y-Position $value
* @return PHPExcel_Chart_Layout
*/
public function setYPosition($value)
{
$this->yPos = $value;
return $this;
}
/**
* Get Width
*
* @return number
*/
public function getWidth() {
return $this->_width;
}
/**
* Get Width
*
* @return number
*/
public function getWidth()
{
return $this->width;
}
/**
* Set Width
*
* @param Width $value
*/
public function setWidth($value) {
$this->_width = $value;
}
/**
* Set Width
*
* @param Width $value
* @return PHPExcel_Chart_Layout
*/
public function setWidth($value)
{
$this->width = $value;
return $this;
}
/**
* Get Height
*
* @return number
*/
public function getHeight() {
return $this->_height;
}
/**
* Get Height
*
* @return number
*/
public function getHeight()
{
return $this->height;
}
/**
* Set Height
*
* @param Height $value
*/
public function setHeight($value) {
$this->_height = $value;
}
/**
* Set Height
*
* @param Height $value
* @return PHPExcel_Chart_Layout
*/
public function setHeight($value)
{
$this->height = $value;
return $this;
}
/**
* Get show legend key
*
* @return boolean
*/
public function getShowLegendKey() {
return $this->_showLegendKey;
}
/**
* Get show legend key
*
* @return boolean
*/
public function getShowLegendKey()
{
return $this->showLegendKey;
}
/**
* Set show legend key
* Specifies that legend keys should be shown in data labels.
*
* @param boolean $value Show legend key
*/
public function setShowLegendKey($value) {
$this->_showLegendKey = $value;
}
/**
* Set show legend key
* Specifies that legend keys should be shown in data labels.
*
* @param boolean $value Show legend key
* @return PHPExcel_Chart_Layout
*/
public function setShowLegendKey($value)
{
$this->showLegendKey = $value;
return $this;
}
/**
* Get show value
*
* @return boolean
*/
public function getShowVal() {
return $this->_showVal;
}
/**
* Get show value
*
* @return boolean
*/
public function getShowVal()
{
return $this->showVal;
}
/**
* Set show val
* Specifies that the value should be shown in data labels.
*
* @param boolean $value Show val
*/
public function setShowVal($value) {
$this->_showVal = $value;
}
/**
* Set show val
* Specifies that the value should be shown in data labels.
*
* @param boolean $value Show val
* @return PHPExcel_Chart_Layout
*/
public function setShowVal($value)
{
$this->showVal = $value;
return $this;
}
/**
* Get show category name
*
* @return boolean
*/
public function getShowCatName() {
return $this->_showCatName;
}
/**
* Get show category name
*
* @return boolean
*/
public function getShowCatName()
{
return $this->showCatName;
}
/**
* Set show cat name
* Specifies that the category name should be shown in data labels.
*
* @param boolean $value Show cat name
*/
public function setShowCatName($value) {
$this->_showCatName = $value;
}
/**
* Set show cat name
* Specifies that the category name should be shown in data labels.
*
* @param boolean $value Show cat name
* @return PHPExcel_Chart_Layout
*/
public function setShowCatName($value)
{
$this->showCatName = $value;
return $this;
}
/**
* Get show data series name
*
* @return boolean
*/
public function getShowSerName() {
return $this->_showSerName;
}
/**
* Get show data series name
*
* @return boolean
*/
public function getShowSerName()
{
return $this->showSerName;
}
/**
* Set show ser name
* Specifies that the series name should be shown in data labels.
*
* @param boolean $value Show ser name
*/
public function setShowSerName($value) {
$this->_showSerName = $value;
}
/**
* Set show ser name
* Specifies that the series name should be shown in data labels.
*
* @param boolean $value Show series name
* @return PHPExcel_Chart_Layout
*/
public function setShowSerName($value)
{
$this->showSerName = $value;
return $this;
}
/**
* Get show percentage
*
* @return boolean
*/
public function getShowPercent() {
return $this->_showPercent;
}
/**
* Get show percentage
*
* @return boolean
*/
public function getShowPercent()
{
return $this->showPercent;
}
/**
* Set show percentage
* Specifies that the percentage should be shown in data labels.
*
* @param boolean $value Show percentage
*/
public function setShowPercent($value) {
$this->_showPercent = $value;
}
/**
* Set show percentage
* Specifies that the percentage should be shown in data labels.
*
* @param boolean $value Show percentage
* @return PHPExcel_Chart_Layout
*/
public function setShowPercent($value)
{
$this->showPercent = $value;
return $this;
}
/**
* Get show bubble size
*
* @return boolean
*/
public function getShowBubbleSize() {
return $this->_showBubbleSize;
}
/**
* Get show bubble size
*
* @return boolean
*/
public function getShowBubbleSize()
{
return $this->showBubbleSize;
}
/**
* Set show bubble size
* Specifies that the bubble size should be shown in data labels.
*
* @param boolean $value Show bubble size
*/
public function setShowBubbleSize($value) {
$this->_showBubbleSize = $value;
}
/**
* Set show bubble size
* Specifies that the bubble size should be shown in data labels.
*
* @param boolean $value Show bubble size
* @return PHPExcel_Chart_Layout
*/
public function setShowBubbleSize($value)
{
$this->showBubbleSize = $value;
return $this;
}
/**
* Get show leader lines
*
* @return boolean
*/
public function getShowLeaderLines() {
return $this->_showLeaderLines;
}
/**
* Set show leader lines
* Specifies that leader lines should be shown in data labels.
*
* @param boolean $value Show leader lines
*/
public function setShowLeaderLines($value) {
$this->_showLeaderLines = $value;
}
/**
* Get show leader lines
*
* @return boolean
*/
public function getShowLeaderLines()
{
return $this->showLeaderLines;
}
/**
* Set show leader lines
* Specifies that leader lines should be shown in data labels.
*
* @param boolean $value Show leader lines
* @return PHPExcel_Chart_Layout
*/
public function setShowLeaderLines($value)
{
$this->showLeaderLines = $value;
return $this;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Chart_Legend
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -18,154 +19,152 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Chart_Legend
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Chart_Legend
{
/** Legend positions */
const xlLegendPositionBottom = -4107; // Below the chart.
const xlLegendPositionCorner = 2; // In the upper right-hand corner of the chart border.
const xlLegendPositionCustom = -4161; // A custom position.
const xlLegendPositionLeft = -4131; // Left of the chart.
const xlLegendPositionRight = -4152; // Right of the chart.
const xlLegendPositionTop = -4160; // Above the chart.
/** Legend positions */
const xlLegendPositionBottom = -4107; // Below the chart.
const xlLegendPositionCorner = 2; // In the upper right-hand corner of the chart border.
const xlLegendPositionCustom = -4161; // A custom position.
const xlLegendPositionLeft = -4131; // Left of the chart.
const xlLegendPositionRight = -4152; // Right of the chart.
const xlLegendPositionTop = -4160; // Above the chart.
const POSITION_RIGHT = 'r';
const POSITION_LEFT = 'l';
const POSITION_BOTTOM = 'b';
const POSITION_TOP = 't';
const POSITION_TOPRIGHT = 'tr';
const POSITION_RIGHT = 'r';
const POSITION_LEFT = 'l';
const POSITION_BOTTOM = 'b';
const POSITION_TOP = 't';
const POSITION_TOPRIGHT = 'tr';
private static $_positionXLref = array( self::xlLegendPositionBottom => self::POSITION_BOTTOM,
self::xlLegendPositionCorner => self::POSITION_TOPRIGHT,
self::xlLegendPositionCustom => '??',
self::xlLegendPositionLeft => self::POSITION_LEFT,
self::xlLegendPositionRight => self::POSITION_RIGHT,
self::xlLegendPositionTop => self::POSITION_TOP
);
private static $positionXLref = array(
self::xlLegendPositionBottom => self::POSITION_BOTTOM,
self::xlLegendPositionCorner => self::POSITION_TOPRIGHT,
self::xlLegendPositionCustom => '??',
self::xlLegendPositionLeft => self::POSITION_LEFT,
self::xlLegendPositionRight => self::POSITION_RIGHT,
self::xlLegendPositionTop => self::POSITION_TOP
);
/**
* Legend position
*
* @var string
*/
private $_position = self::POSITION_RIGHT;
/**
* Legend position
*
* @var string
*/
private $position = self::POSITION_RIGHT;
/**
* Allow overlay of other elements?
*
* @var boolean
*/
private $_overlay = TRUE;
/**
* Allow overlay of other elements?
*
* @var boolean
*/
private $overlay = true;
/**
* Legend Layout
*
* @var PHPExcel_Chart_Layout
*/
private $_layout = NULL;
/**
* Legend Layout
*
* @var PHPExcel_Chart_Layout
*/
private $layout = null;
/**
* Create a new PHPExcel_Chart_Legend
*/
public function __construct($position = self::POSITION_RIGHT, PHPExcel_Chart_Layout $layout = NULL, $overlay = FALSE)
{
$this->setPosition($position);
$this->_layout = $layout;
$this->setOverlay($overlay);
}
/**
* Create a new PHPExcel_Chart_Legend
*/
public function __construct($position = self::POSITION_RIGHT, PHPExcel_Chart_Layout $layout = null, $overlay = false)
{
$this->setPosition($position);
$this->layout = $layout;
$this->setOverlay($overlay);
}
/**
* Get legend position as an excel string value
*
* @return string
*/
public function getPosition() {
return $this->_position;
}
/**
* Get legend position as an excel string value
*
* @return string
*/
public function getPosition()
{
return $this->position;
}
/**
* Get legend position using an excel string value
*
* @param string $position
*/
public function setPosition($position = self::POSITION_RIGHT) {
if (!in_array($position,self::$_positionXLref)) {
return false;
}
/**
* Get legend position using an excel string value
*
* @param string $position
*/
public function setPosition($position = self::POSITION_RIGHT)
{
if (!in_array($position, self::$positionXLref)) {
return false;
}
$this->_position = $position;
return true;
}
$this->position = $position;
return true;
}
/**
* Get legend position as an Excel internal numeric value
*
* @return number
*/
public function getPositionXL() {
return array_search($this->_position,self::$_positionXLref);
}
/**
* Get legend position as an Excel internal numeric value
*
* @return number
*/
public function getPositionXL()
{
return array_search($this->position, self::$positionXLref);
}
/**
* Set legend position using an Excel internal numeric value
*
* @param number $positionXL
*/
public function setPositionXL($positionXL = self::xlLegendPositionRight) {
if (!array_key_exists($positionXL,self::$_positionXLref)) {
return false;
}
/**
* Set legend position using an Excel internal numeric value
*
* @param number $positionXL
*/
public function setPositionXL($positionXL = self::xlLegendPositionRight)
{
if (!array_key_exists($positionXL, self::$positionXLref)) {
return false;
}
$this->_position = self::$_positionXLref[$positionXL];
return true;
}
$this->position = self::$positionXLref[$positionXL];
return true;
}
/**
* Get allow overlay of other elements?
*
* @return boolean
*/
public function getOverlay() {
return $this->_overlay;
}
/**
* Get allow overlay of other elements?
*
* @return boolean
*/
public function getOverlay()
{
return $this->overlay;
}
/**
* Set allow overlay of other elements?
*
* @param boolean $overlay
* @return boolean
*/
public function setOverlay($overlay = FALSE) {
if (!is_bool($overlay)) {
return false;
}
/**
* Set allow overlay of other elements?
*
* @param boolean $overlay
* @return boolean
*/
public function setOverlay($overlay = false)
{
if (!is_bool($overlay)) {
return false;
}
$this->_overlay = $overlay;
return true;
}
/**
* Get Layout
*
* @return PHPExcel_Chart_Layout
*/
public function getLayout() {
return $this->_layout;
}
$this->overlay = $overlay;
return true;
}
/**
* Get Layout
*
* @return PHPExcel_Chart_Layout
*/
public function getLayout()
{
return $this->layout;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Chart_PlotArea
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -18,108 +19,108 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Chart_PlotArea
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Chart_PlotArea
{
/**
* PlotArea Layout
*
* @var PHPExcel_Chart_Layout
*/
private $_layout = null;
/**
* PlotArea Layout
*
* @var PHPExcel_Chart_Layout
*/
private $layout = null;
/**
* Plot Series
*
* @var array of PHPExcel_Chart_DataSeries
*/
private $_plotSeries = array();
/**
* Plot Series
*
* @var array of PHPExcel_Chart_DataSeries
*/
private $plotSeries = array();
/**
* Create a new PHPExcel_Chart_PlotArea
*/
public function __construct(PHPExcel_Chart_Layout $layout = null, $plotSeries = array())
{
$this->_layout = $layout;
$this->_plotSeries = $plotSeries;
}
/**
* Create a new PHPExcel_Chart_PlotArea
*/
public function __construct(PHPExcel_Chart_Layout $layout = null, $plotSeries = array())
{
$this->layout = $layout;
$this->plotSeries = $plotSeries;
}
/**
* Get Layout
*
* @return PHPExcel_Chart_Layout
*/
public function getLayout() {
return $this->_layout;
}
/**
* Get Layout
*
* @return PHPExcel_Chart_Layout
*/
public function getLayout()
{
return $this->layout;
}
/**
* Get Number of Plot Groups
*
* @return array of PHPExcel_Chart_DataSeries
*/
public function getPlotGroupCount() {
return count($this->_plotSeries);
}
/**
* Get Number of Plot Groups
*
* @return array of PHPExcel_Chart_DataSeries
*/
public function getPlotGroupCount()
{
return count($this->plotSeries);
}
/**
* Get Number of Plot Series
*
* @return integer
*/
public function getPlotSeriesCount() {
$seriesCount = 0;
foreach($this->_plotSeries as $plot) {
$seriesCount += $plot->getPlotSeriesCount();
}
return $seriesCount;
}
/**
* Get Number of Plot Series
*
* @return integer
*/
public function getPlotSeriesCount()
{
$seriesCount = 0;
foreach ($this->plotSeries as $plot) {
$seriesCount += $plot->getPlotSeriesCount();
}
return $seriesCount;
}
/**
* Get Plot Series
*
* @return array of PHPExcel_Chart_DataSeries
*/
public function getPlotGroup() {
return $this->_plotSeries;
}
/**
* Get Plot Series
*
* @return array of PHPExcel_Chart_DataSeries
*/
public function getPlotGroup()
{
return $this->plotSeries;
}
/**
* Get Plot Series by Index
*
* @return PHPExcel_Chart_DataSeries
*/
public function getPlotGroupByIndex($index) {
return $this->_plotSeries[$index];
}
/**
* Get Plot Series by Index
*
* @return PHPExcel_Chart_DataSeries
*/
public function getPlotGroupByIndex($index)
{
return $this->plotSeries[$index];
}
/**
* Set Plot Series
*
* @param [PHPExcel_Chart_DataSeries]
*/
public function setPlotSeries($plotSeries = array()) {
$this->_plotSeries = $plotSeries;
}
public function refresh(PHPExcel_Worksheet $worksheet) {
foreach($this->_plotSeries as $plotSeries) {
$plotSeries->refresh($worksheet);
}
}
/**
* Set Plot Series
*
* @param [PHPExcel_Chart_DataSeries]
* @return PHPExcel_Chart_PlotArea
*/
public function setPlotSeries($plotSeries = array())
{
$this->plotSeries = $plotSeries;
return $this;
}
public function refresh(PHPExcel_Worksheet $worksheet)
{
foreach ($this->plotSeries as $plotSeries) {
$plotSeries->refresh($worksheet);
}
}
}

View file

@ -0,0 +1,363 @@
<?php
/**
* Created by PhpStorm.
* User: nhw2h8s
* Date: 7/2/14
* Time: 5:45 PM
*/
abstract class PHPExcel_Chart_Properties
{
const
EXCEL_COLOR_TYPE_STANDARD = 'prstClr',
EXCEL_COLOR_TYPE_SCHEME = 'schemeClr',
EXCEL_COLOR_TYPE_ARGB = 'srgbClr';
const
AXIS_LABELS_LOW = 'low',
AXIS_LABELS_HIGH = 'high',
AXIS_LABELS_NEXT_TO = 'nextTo',
AXIS_LABELS_NONE = 'none';
const
TICK_MARK_NONE = 'none',
TICK_MARK_INSIDE = 'in',
TICK_MARK_OUTSIDE = 'out',
TICK_MARK_CROSS = 'cross';
const
HORIZONTAL_CROSSES_AUTOZERO = 'autoZero',
HORIZONTAL_CROSSES_MAXIMUM = 'max';
const
FORMAT_CODE_GENERAL = 'General',
FORMAT_CODE_NUMBER = '#,##0.00',
FORMAT_CODE_CURRENCY = '$#,##0.00',
FORMAT_CODE_ACCOUNTING = '_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)',
FORMAT_CODE_DATE = 'm/d/yyyy',
FORMAT_CODE_TIME = '[$-F400]h:mm:ss AM/PM',
FORMAT_CODE_PERCENTAGE = '0.00%',
FORMAT_CODE_FRACTION = '# ?/?',
FORMAT_CODE_SCIENTIFIC = '0.00E+00',
FORMAT_CODE_TEXT = '@',
FORMAT_CODE_SPECIAL = '00000';
const
ORIENTATION_NORMAL = 'minMax',
ORIENTATION_REVERSED = 'maxMin';
const
LINE_STYLE_COMPOUND_SIMPLE = 'sng',
LINE_STYLE_COMPOUND_DOUBLE = 'dbl',
LINE_STYLE_COMPOUND_THICKTHIN = 'thickThin',
LINE_STYLE_COMPOUND_THINTHICK = 'thinThick',
LINE_STYLE_COMPOUND_TRIPLE = 'tri',
LINE_STYLE_DASH_SOLID = 'solid',
LINE_STYLE_DASH_ROUND_DOT = 'sysDot',
LINE_STYLE_DASH_SQUERE_DOT = 'sysDash',
LINE_STYPE_DASH_DASH = 'dash',
LINE_STYLE_DASH_DASH_DOT = 'dashDot',
LINE_STYLE_DASH_LONG_DASH = 'lgDash',
LINE_STYLE_DASH_LONG_DASH_DOT = 'lgDashDot',
LINE_STYLE_DASH_LONG_DASH_DOT_DOT = 'lgDashDotDot',
LINE_STYLE_CAP_SQUARE = 'sq',
LINE_STYLE_CAP_ROUND = 'rnd',
LINE_STYLE_CAP_FLAT = 'flat',
LINE_STYLE_JOIN_ROUND = 'bevel',
LINE_STYLE_JOIN_MITER = 'miter',
LINE_STYLE_JOIN_BEVEL = 'bevel',
LINE_STYLE_ARROW_TYPE_NOARROW = null,
LINE_STYLE_ARROW_TYPE_ARROW = 'triangle',
LINE_STYLE_ARROW_TYPE_OPEN = 'arrow',
LINE_STYLE_ARROW_TYPE_STEALTH = 'stealth',
LINE_STYLE_ARROW_TYPE_DIAMOND = 'diamond',
LINE_STYLE_ARROW_TYPE_OVAL = 'oval',
LINE_STYLE_ARROW_SIZE_1 = 1,
LINE_STYLE_ARROW_SIZE_2 = 2,
LINE_STYLE_ARROW_SIZE_3 = 3,
LINE_STYLE_ARROW_SIZE_4 = 4,
LINE_STYLE_ARROW_SIZE_5 = 5,
LINE_STYLE_ARROW_SIZE_6 = 6,
LINE_STYLE_ARROW_SIZE_7 = 7,
LINE_STYLE_ARROW_SIZE_8 = 8,
LINE_STYLE_ARROW_SIZE_9 = 9;
const
SHADOW_PRESETS_NOSHADOW = null,
SHADOW_PRESETS_OUTER_BOTTTOM_RIGHT = 1,
SHADOW_PRESETS_OUTER_BOTTOM = 2,
SHADOW_PRESETS_OUTER_BOTTOM_LEFT = 3,
SHADOW_PRESETS_OUTER_RIGHT = 4,
SHADOW_PRESETS_OUTER_CENTER = 5,
SHADOW_PRESETS_OUTER_LEFT = 6,
SHADOW_PRESETS_OUTER_TOP_RIGHT = 7,
SHADOW_PRESETS_OUTER_TOP = 8,
SHADOW_PRESETS_OUTER_TOP_LEFT = 9,
SHADOW_PRESETS_INNER_BOTTTOM_RIGHT = 10,
SHADOW_PRESETS_INNER_BOTTOM = 11,
SHADOW_PRESETS_INNER_BOTTOM_LEFT = 12,
SHADOW_PRESETS_INNER_RIGHT = 13,
SHADOW_PRESETS_INNER_CENTER = 14,
SHADOW_PRESETS_INNER_LEFT = 15,
SHADOW_PRESETS_INNER_TOP_RIGHT = 16,
SHADOW_PRESETS_INNER_TOP = 17,
SHADOW_PRESETS_INNER_TOP_LEFT = 18,
SHADOW_PRESETS_PERSPECTIVE_BELOW = 19,
SHADOW_PRESETS_PERSPECTIVE_UPPER_RIGHT = 20,
SHADOW_PRESETS_PERSPECTIVE_UPPER_LEFT = 21,
SHADOW_PRESETS_PERSPECTIVE_LOWER_RIGHT = 22,
SHADOW_PRESETS_PERSPECTIVE_LOWER_LEFT = 23;
protected function getExcelPointsWidth($width)
{
return $width * 12700;
}
protected function getExcelPointsAngle($angle)
{
return $angle * 60000;
}
protected function getTrueAlpha($alpha)
{
return (string) 100 - $alpha . '000';
}
protected function setColorProperties($color, $alpha, $type)
{
return array(
'type' => (string) $type,
'value' => (string) $color,
'alpha' => (string) $this->getTrueAlpha($alpha)
);
}
protected function getLineStyleArrowSize($array_selector, $array_kay_selector)
{
$sizes = array(
1 => array('w' => 'sm', 'len' => 'sm'),
2 => array('w' => 'sm', 'len' => 'med'),
3 => array('w' => 'sm', 'len' => 'lg'),
4 => array('w' => 'med', 'len' => 'sm'),
5 => array('w' => 'med', 'len' => 'med'),
6 => array('w' => 'med', 'len' => 'lg'),
7 => array('w' => 'lg', 'len' => 'sm'),
8 => array('w' => 'lg', 'len' => 'med'),
9 => array('w' => 'lg', 'len' => 'lg')
);
return $sizes[$array_selector][$array_kay_selector];
}
protected function getShadowPresetsMap($shadow_presets_option)
{
$presets_options = array(
//OUTER
1 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'direction' => '2700000',
'algn' => 'tl',
'rotWithShape' => '0'
),
2 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'direction' => '5400000',
'algn' => 't',
'rotWithShape' => '0'
),
3 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'direction' => '8100000',
'algn' => 'tr',
'rotWithShape' => '0'
),
4 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'algn' => 'l',
'rotWithShape' => '0'
),
5 => array(
'effect' => 'outerShdw',
'size' => array(
'sx' => '102000',
'sy' => '102000'
)
,
'blur' => '63500',
'distance' => '38100',
'algn' => 'ctr',
'rotWithShape' => '0'
),
6 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'direction' => '10800000',
'algn' => 'r',
'rotWithShape' => '0'
),
7 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'direction' => '18900000',
'algn' => 'bl',
'rotWithShape' => '0'
),
8 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'direction' => '16200000',
'rotWithShape' => '0'
),
9 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'direction' => '13500000',
'algn' => 'br',
'rotWithShape' => '0'
),
//INNER
10 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
'direction' => '2700000',
),
11 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
'direction' => '5400000',
),
12 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
'direction' => '8100000',
),
13 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
),
14 => array(
'effect' => 'innerShdw',
'blur' => '114300',
),
15 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
'direction' => '10800000',
),
16 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
'direction' => '18900000',
),
17 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
'direction' => '16200000',
),
18 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
'direction' => '13500000',
),
//perspective
19 => array(
'effect' => 'outerShdw',
'blur' => '152400',
'distance' => '317500',
'size' => array(
'sx' => '90000',
'sy' => '-19000',
),
'direction' => '5400000',
'rotWithShape' => '0',
),
20 => array(
'effect' => 'outerShdw',
'blur' => '76200',
'direction' => '18900000',
'size' => array(
'sy' => '23000',
'kx' => '-1200000',
),
'algn' => 'bl',
'rotWithShape' => '0',
),
21 => array(
'effect' => 'outerShdw',
'blur' => '76200',
'direction' => '13500000',
'size' => array(
'sy' => '23000',
'kx' => '1200000',
),
'algn' => 'br',
'rotWithShape' => '0',
),
22 => array(
'effect' => 'outerShdw',
'blur' => '76200',
'distance' => '12700',
'direction' => '2700000',
'size' => array(
'sy' => '-23000',
'kx' => '-800400',
),
'algn' => 'bl',
'rotWithShape' => '0',
),
23 => array(
'effect' => 'outerShdw',
'blur' => '76200',
'distance' => '12700',
'direction' => '8100000',
'size' => array(
'sy' => '-23000',
'kx' => '800400',
),
'algn' => 'br',
'rotWithShape' => '0',
),
);
return $presets_options[$shadow_presets_option];
}
protected function getArrayElementsValue($properties, $elements)
{
$reference = & $properties;
if (!is_array($elements)) {
return $reference[$elements];
} else {
foreach ($elements as $keys) {
$reference = & $reference[$keys];
}
return $reference;
}
return $this;
}
}

View file

@ -15,3 +15,6 @@ pChart
TeeChart
http://www.steema.com/products/teechart/overview.html
PHPGraphLib
http://www.ebrueggeman.com/phpgraphlib

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Chart_Title
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -18,72 +19,68 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Chart_Title
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Chart_Title
{
/**
* Title Caption
*
* @var string
*/
private $_caption = null;
/**
* Title Caption
*
* @var string
*/
private $caption = null;
/**
* Title Layout
*
* @var PHPExcel_Chart_Layout
*/
private $_layout = null;
/**
* Title Layout
*
* @var PHPExcel_Chart_Layout
*/
private $layout = null;
/**
* Create a new PHPExcel_Chart_Title
*/
public function __construct($caption = null, PHPExcel_Chart_Layout $layout = null)
{
$this->_caption = $caption;
$this->_layout = $layout;
}
/**
* Create a new PHPExcel_Chart_Title
*/
public function __construct($caption = null, PHPExcel_Chart_Layout $layout = null)
{
$this->caption = $caption;
$this->layout = $layout;
}
/**
* Get caption
*
* @return string
*/
public function getCaption() {
return $this->_caption;
}
/**
* Get caption
*
* @return string
*/
public function getCaption()
{
return $this->caption;
}
/**
* Set caption
*
* @param string $caption
*/
public function setCaption($caption = null) {
$this->_caption = $caption;
}
/**
* Get Layout
*
* @return PHPExcel_Chart_Layout
*/
public function getLayout() {
return $this->_layout;
}
/**
* Set caption
*
* @param string $caption
* @return PHPExcel_Chart_Title
*/
public function setCaption($caption = null)
{
$this->caption = $caption;
return $this;
}
/**
* Get Layout
*
* @return PHPExcel_Chart_Layout
*/
public function getLayout()
{
return $this->layout;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Comment
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,19 +21,10 @@
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Comment
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Comment implements PHPExcel_IComparable
{
/**
@ -40,63 +32,63 @@ class PHPExcel_Comment implements PHPExcel_IComparable
*
* @var string
*/
private $_author;
private $author;
/**
* Rich text comment
*
* @var PHPExcel_RichText
*/
private $_text;
private $text;
/**
* Comment width (CSS style, i.e. XXpx or YYpt)
*
* @var string
*/
private $_width = '96pt';
private $width = '96pt';
/**
* Left margin (CSS style, i.e. XXpx or YYpt)
*
* @var string
*/
private $_marginLeft = '59.25pt';
private $marginLeft = '59.25pt';
/**
* Top margin (CSS style, i.e. XXpx or YYpt)
*
* @var string
*/
private $_marginTop = '1.5pt';
private $marginTop = '1.5pt';
/**
* Visible
*
* @var boolean
*/
private $_visible = false;
private $visible = false;
/**
* Comment height (CSS style, i.e. XXpx or YYpt)
*
* @var string
*/
private $_height = '55.5pt';
private $height = '55.5pt';
/**
* Comment fill color
*
* @var PHPExcel_Style_Color
*/
private $_fillColor;
private $fillColor;
/**
* Alignment
*
* @var string
*/
private $_alignment;
private $alignment;
/**
* Create a new PHPExcel_Comment
@ -106,10 +98,10 @@ class PHPExcel_Comment implements PHPExcel_IComparable
public function __construct()
{
// Initialise variables
$this->_author = 'Author';
$this->_text = new PHPExcel_RichText();
$this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1');
$this->_alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
$this->author = 'Author';
$this->text = new PHPExcel_RichText();
$this->fillColor = new PHPExcel_Style_Color('FFFFFFE1');
$this->alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
}
/**
@ -117,8 +109,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
*
* @return string
*/
public function getAuthor() {
return $this->_author;
public function getAuthor()
{
return $this->author;
}
/**
@ -127,8 +120,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* @param string $pValue
* @return PHPExcel_Comment
*/
public function setAuthor($pValue = '') {
$this->_author = $pValue;
public function setAuthor($pValue = '')
{
$this->author = $pValue;
return $this;
}
@ -137,8 +131,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
*
* @return PHPExcel_RichText
*/
public function getText() {
return $this->_text;
public function getText()
{
return $this->text;
}
/**
@ -147,8 +142,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* @param PHPExcel_RichText $pValue
* @return PHPExcel_Comment
*/
public function setText(PHPExcel_RichText $pValue) {
$this->_text = $pValue;
public function setText(PHPExcel_RichText $pValue)
{
$this->text = $pValue;
return $this;
}
@ -157,8 +153,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
*
* @return string
*/
public function getWidth() {
return $this->_width;
public function getWidth()
{
return $this->width;
}
/**
@ -167,8 +164,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* @param string $value
* @return PHPExcel_Comment
*/
public function setWidth($value = '96pt') {
$this->_width = $value;
public function setWidth($value = '96pt')
{
$this->width = $value;
return $this;
}
@ -177,8 +175,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
*
* @return string
*/
public function getHeight() {
return $this->_height;
public function getHeight()
{
return $this->height;
}
/**
@ -187,8 +186,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* @param string $value
* @return PHPExcel_Comment
*/
public function setHeight($value = '55.5pt') {
$this->_height = $value;
public function setHeight($value = '55.5pt')
{
$this->height = $value;
return $this;
}
@ -197,8 +197,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
*
* @return string
*/
public function getMarginLeft() {
return $this->_marginLeft;
public function getMarginLeft()
{
return $this->marginLeft;
}
/**
@ -207,8 +208,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* @param string $value
* @return PHPExcel_Comment
*/
public function setMarginLeft($value = '59.25pt') {
$this->_marginLeft = $value;
public function setMarginLeft($value = '59.25pt')
{
$this->marginLeft = $value;
return $this;
}
@ -217,8 +219,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
*
* @return string
*/
public function getMarginTop() {
return $this->_marginTop;
public function getMarginTop()
{
return $this->marginTop;
}
/**
@ -227,8 +230,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* @param string $value
* @return PHPExcel_Comment
*/
public function setMarginTop($value = '1.5pt') {
$this->_marginTop = $value;
public function setMarginTop($value = '1.5pt')
{
$this->marginTop = $value;
return $this;
}
@ -237,8 +241,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
*
* @return boolean
*/
public function getVisible() {
return $this->_visible;
public function getVisible()
{
return $this->visible;
}
/**
@ -247,8 +252,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* @param boolean $value
* @return PHPExcel_Comment
*/
public function setVisible($value = false) {
$this->_visible = $value;
public function setVisible($value = false)
{
$this->visible = $value;
return $this;
}
@ -257,8 +263,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
*
* @return PHPExcel_Style_Color
*/
public function getFillColor() {
return $this->_fillColor;
public function getFillColor()
{
return $this->fillColor;
}
/**
@ -267,8 +274,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* @param string $pValue
* @return PHPExcel_Comment
*/
public function setAlignment($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL) {
$this->_alignment = $pValue;
public function setAlignment($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL)
{
$this->alignment = $pValue;
return $this;
}
@ -277,8 +285,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
*
* @return string
*/
public function getAlignment() {
return $this->_alignment;
public function getAlignment()
{
return $this->alignment;
}
/**
@ -286,25 +295,27 @@ class PHPExcel_Comment implements PHPExcel_IComparable
*
* @return string Hash code
*/
public function getHashCode() {
public function getHashCode()
{
return md5(
$this->_author
. $this->_text->getHashCode()
. $this->_width
. $this->_height
. $this->_marginLeft
. $this->_marginTop
. ($this->_visible ? 1 : 0)
. $this->_fillColor->getHashCode()
. $this->_alignment
. __CLASS__
$this->author .
$this->text->getHashCode() .
$this->width .
$this->height .
$this->marginLeft .
$this->marginTop .
($this->visible ? 1 : 0) .
$this->fillColor->getHashCode() .
$this->alignment .
__CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
public function __clone()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
@ -314,4 +325,14 @@ class PHPExcel_Comment implements PHPExcel_IComparable
}
}
}
/**
* Convert to string
*
* @return string
*/
public function __toString()
{
return $this->text->getPlainText();
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_DocumentProperties
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,23 +21,14 @@
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_DocumentProperties
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_DocumentProperties
{
/** constants */
const PROPERTY_TYPE_BOOLEAN = 'b';
const PROPERTY_TYPE_BOOLEAN = 'b';
const PROPERTY_TYPE_INTEGER = 'i';
const PROPERTY_TYPE_FLOAT = 'f';
const PROPERTY_TYPE_DATE = 'd';
@ -48,84 +40,84 @@ class PHPExcel_DocumentProperties
*
* @var string
*/
private $_creator = 'Unknown Creator';
private $creator = 'Unknown Creator';
/**
* LastModifiedBy
*
* @var string
*/
private $_lastModifiedBy;
private $lastModifiedBy;
/**
* Created
*
* @var datetime
*/
private $_created;
private $created;
/**
* Modified
*
* @var datetime
*/
private $_modified;
private $modified;
/**
* Title
*
* @var string
*/
private $_title = 'Untitled Spreadsheet';
private $title = 'Untitled Spreadsheet';
/**
* Description
*
* @var string
*/
private $_description = '';
private $description = '';
/**
* Subject
*
* @var string
*/
private $_subject = '';
private $subject = '';
/**
* Keywords
*
* @var string
*/
private $_keywords = '';
private $keywords = '';
/**
* Category
*
* @var string
*/
private $_category = '';
private $category = '';
/**
* Manager
*
* @var string
*/
private $_manager = '';
private $manager = '';
/**
* Company
*
* @var string
*/
private $_company = 'Microsoft Corporation';
private $company = 'Microsoft Corporation';
/**
* Custom Properties
*
* @var string
*/
private $_customProperties = array();
private $customProperties = array();
/**
@ -134,9 +126,9 @@ class PHPExcel_DocumentProperties
public function __construct()
{
// Initialise values
$this->_lastModifiedBy = $this->_creator;
$this->_created = time();
$this->_modified = time();
$this->lastModifiedBy = $this->creator;
$this->created = time();
$this->modified = time();
}
/**
@ -144,8 +136,9 @@ class PHPExcel_DocumentProperties
*
* @return string
*/
public function getCreator() {
return $this->_creator;
public function getCreator()
{
return $this->creator;
}
/**
@ -154,8 +147,9 @@ class PHPExcel_DocumentProperties
* @param string $pValue
* @return PHPExcel_DocumentProperties
*/
public function setCreator($pValue = '') {
$this->_creator = $pValue;
public function setCreator($pValue = '')
{
$this->creator = $pValue;
return $this;
}
@ -164,8 +158,9 @@ class PHPExcel_DocumentProperties
*
* @return string
*/
public function getLastModifiedBy() {
return $this->_lastModifiedBy;
public function getLastModifiedBy()
{
return $this->lastModifiedBy;
}
/**
@ -174,8 +169,9 @@ class PHPExcel_DocumentProperties
* @param string $pValue
* @return PHPExcel_DocumentProperties
*/
public function setLastModifiedBy($pValue = '') {
$this->_lastModifiedBy = $pValue;
public function setLastModifiedBy($pValue = '')
{
$this->lastModifiedBy = $pValue;
return $this;
}
@ -184,8 +180,9 @@ class PHPExcel_DocumentProperties
*
* @return datetime
*/
public function getCreated() {
return $this->_created;
public function getCreated()
{
return $this->created;
}
/**
@ -194,8 +191,9 @@ class PHPExcel_DocumentProperties
* @param datetime $pValue
* @return PHPExcel_DocumentProperties
*/
public function setCreated($pValue = null) {
if ($pValue === NULL) {
public function setCreated($pValue = null)
{
if ($pValue === null) {
$pValue = time();
} elseif (is_string($pValue)) {
if (is_numeric($pValue)) {
@ -205,7 +203,7 @@ class PHPExcel_DocumentProperties
}
}
$this->_created = $pValue;
$this->created = $pValue;
return $this;
}
@ -214,8 +212,9 @@ class PHPExcel_DocumentProperties
*
* @return datetime
*/
public function getModified() {
return $this->_modified;
public function getModified()
{
return $this->modified;
}
/**
@ -224,8 +223,9 @@ class PHPExcel_DocumentProperties
* @param datetime $pValue
* @return PHPExcel_DocumentProperties
*/
public function setModified($pValue = null) {
if ($pValue === NULL) {
public function setModified($pValue = null)
{
if ($pValue === null) {
$pValue = time();
} elseif (is_string($pValue)) {
if (is_numeric($pValue)) {
@ -235,7 +235,7 @@ class PHPExcel_DocumentProperties
}
}
$this->_modified = $pValue;
$this->modified = $pValue;
return $this;
}
@ -244,8 +244,9 @@ class PHPExcel_DocumentProperties
*
* @return string
*/
public function getTitle() {
return $this->_title;
public function getTitle()
{
return $this->title;
}
/**
@ -254,8 +255,9 @@ class PHPExcel_DocumentProperties
* @param string $pValue
* @return PHPExcel_DocumentProperties
*/
public function setTitle($pValue = '') {
$this->_title = $pValue;
public function setTitle($pValue = '')
{
$this->title = $pValue;
return $this;
}
@ -264,8 +266,9 @@ class PHPExcel_DocumentProperties
*
* @return string
*/
public function getDescription() {
return $this->_description;
public function getDescription()
{
return $this->description;
}
/**
@ -274,8 +277,9 @@ class PHPExcel_DocumentProperties
* @param string $pValue
* @return PHPExcel_DocumentProperties
*/
public function setDescription($pValue = '') {
$this->_description = $pValue;
public function setDescription($pValue = '')
{
$this->description = $pValue;
return $this;
}
@ -284,8 +288,9 @@ class PHPExcel_DocumentProperties
*
* @return string
*/
public function getSubject() {
return $this->_subject;
public function getSubject()
{
return $this->subject;
}
/**
@ -294,8 +299,9 @@ class PHPExcel_DocumentProperties
* @param string $pValue
* @return PHPExcel_DocumentProperties
*/
public function setSubject($pValue = '') {
$this->_subject = $pValue;
public function setSubject($pValue = '')
{
$this->subject = $pValue;
return $this;
}
@ -304,8 +310,9 @@ class PHPExcel_DocumentProperties
*
* @return string
*/
public function getKeywords() {
return $this->_keywords;
public function getKeywords()
{
return $this->keywords;
}
/**
@ -314,8 +321,9 @@ class PHPExcel_DocumentProperties
* @param string $pValue
* @return PHPExcel_DocumentProperties
*/
public function setKeywords($pValue = '') {
$this->_keywords = $pValue;
public function setKeywords($pValue = '')
{
$this->keywords = $pValue;
return $this;
}
@ -324,8 +332,9 @@ class PHPExcel_DocumentProperties
*
* @return string
*/
public function getCategory() {
return $this->_category;
public function getCategory()
{
return $this->category;
}
/**
@ -334,8 +343,9 @@ class PHPExcel_DocumentProperties
* @param string $pValue
* @return PHPExcel_DocumentProperties
*/
public function setCategory($pValue = '') {
$this->_category = $pValue;
public function setCategory($pValue = '')
{
$this->category = $pValue;
return $this;
}
@ -344,8 +354,9 @@ class PHPExcel_DocumentProperties
*
* @return string
*/
public function getCompany() {
return $this->_company;
public function getCompany()
{
return $this->company;
}
/**
@ -354,8 +365,9 @@ class PHPExcel_DocumentProperties
* @param string $pValue
* @return PHPExcel_DocumentProperties
*/
public function setCompany($pValue = '') {
$this->_company = $pValue;
public function setCompany($pValue = '')
{
$this->company = $pValue;
return $this;
}
@ -364,8 +376,9 @@ class PHPExcel_DocumentProperties
*
* @return string
*/
public function getManager() {
return $this->_manager;
public function getManager()
{
return $this->manager;
}
/**
@ -374,8 +387,9 @@ class PHPExcel_DocumentProperties
* @param string $pValue
* @return PHPExcel_DocumentProperties
*/
public function setManager($pValue = '') {
$this->_manager = $pValue;
public function setManager($pValue = '')
{
$this->manager = $pValue;
return $this;
}
@ -384,8 +398,9 @@ class PHPExcel_DocumentProperties
*
* @return array of string
*/
public function getCustomProperties() {
return array_keys($this->_customProperties);
public function getCustomProperties()
{
return array_keys($this->customProperties);
}
/**
@ -394,8 +409,9 @@ class PHPExcel_DocumentProperties
* @param string $propertyName
* @return boolean
*/
public function isCustomPropertySet($propertyName) {
return isset($this->_customProperties[$propertyName]);
public function isCustomPropertySet($propertyName)
{
return isset($this->customProperties[$propertyName]);
}
/**
@ -404,9 +420,10 @@ class PHPExcel_DocumentProperties
* @param string $propertyName
* @return string
*/
public function getCustomPropertyValue($propertyName) {
if (isset($this->_customProperties[$propertyName])) {
return $this->_customProperties[$propertyName]['value'];
public function getCustomPropertyValue($propertyName)
{
if (isset($this->customProperties[$propertyName])) {
return $this->customProperties[$propertyName]['value'];
}
}
@ -417,9 +434,10 @@ class PHPExcel_DocumentProperties
* @param string $propertyName
* @return string
*/
public function getCustomPropertyType($propertyName) {
if (isset($this->_customProperties[$propertyName])) {
return $this->_customProperties[$propertyName]['type'];
public function getCustomPropertyType($propertyName)
{
if (isset($this->customProperties[$propertyName])) {
return $this->customProperties[$propertyName]['type'];
}
}
@ -430,24 +448,25 @@ class PHPExcel_DocumentProperties
* @param string $propertyName
* @param mixed $propertyValue
* @param string $propertyType
* 'i' : Integer
* 'i' : Integer
* 'f' : Floating Point
* 's' : String
* 'd' : Date/Time
* 'b' : Boolean
* @return PHPExcel_DocumentProperties
*/
public function setCustomProperty($propertyName,$propertyValue='',$propertyType=NULL) {
if (($propertyType === NULL) || (!in_array($propertyType,array(self::PROPERTY_TYPE_INTEGER,
self::PROPERTY_TYPE_FLOAT,
self::PROPERTY_TYPE_STRING,
self::PROPERTY_TYPE_DATE,
self::PROPERTY_TYPE_BOOLEAN)))) {
if ($propertyValue === NULL) {
public function setCustomProperty($propertyName, $propertyValue = '', $propertyType = null)
{
if (($propertyType === null) || (!in_array($propertyType, array(self::PROPERTY_TYPE_INTEGER,
self::PROPERTY_TYPE_FLOAT,
self::PROPERTY_TYPE_STRING,
self::PROPERTY_TYPE_DATE,
self::PROPERTY_TYPE_BOOLEAN)))) {
if ($propertyValue === null) {
$propertyType = self::PROPERTY_TYPE_STRING;
} elseif (is_float($propertyValue)) {
$propertyType = self::PROPERTY_TYPE_FLOAT;
} elseif(is_int($propertyValue)) {
} elseif (is_int($propertyValue)) {
$propertyType = self::PROPERTY_TYPE_INTEGER;
} elseif (is_bool($propertyValue)) {
$propertyType = self::PROPERTY_TYPE_BOOLEAN;
@ -456,14 +475,18 @@ class PHPExcel_DocumentProperties
}
}
$this->_customProperties[$propertyName] = array('value' => $propertyValue, 'type' => $propertyType);
$this->customProperties[$propertyName] = array(
'value' => $propertyValue,
'type' => $propertyType
);
return $this;
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
public function __clone()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
@ -474,114 +497,115 @@ class PHPExcel_DocumentProperties
}
}
public static function convertProperty($propertyValue,$propertyType) {
public static function convertProperty($propertyValue, $propertyType)
{
switch ($propertyType) {
case 'empty' : // Empty
case 'empty': // Empty
return '';
break;
case 'null' : // Null
return NULL;
case 'null': // Null
return null;
break;
case 'i1' : // 1-Byte Signed Integer
case 'i2' : // 2-Byte Signed Integer
case 'i4' : // 4-Byte Signed Integer
case 'i8' : // 8-Byte Signed Integer
case 'int' : // Integer
case 'i1': // 1-Byte Signed Integer
case 'i2': // 2-Byte Signed Integer
case 'i4': // 4-Byte Signed Integer
case 'i8': // 8-Byte Signed Integer
case 'int': // Integer
return (int) $propertyValue;
break;
case 'ui1' : // 1-Byte Unsigned Integer
case 'ui2' : // 2-Byte Unsigned Integer
case 'ui4' : // 4-Byte Unsigned Integer
case 'ui8' : // 8-Byte Unsigned Integer
case 'uint' : // Unsigned Integer
case 'ui1': // 1-Byte Unsigned Integer
case 'ui2': // 2-Byte Unsigned Integer
case 'ui4': // 4-Byte Unsigned Integer
case 'ui8': // 8-Byte Unsigned Integer
case 'uint': // Unsigned Integer
return abs((int) $propertyValue);
break;
case 'r4' : // 4-Byte Real Number
case 'r8' : // 8-Byte Real Number
case 'decimal' : // Decimal
case 'r4': // 4-Byte Real Number
case 'r8': // 8-Byte Real Number
case 'decimal': // Decimal
return (float) $propertyValue;
break;
case 'lpstr' : // LPSTR
case 'lpwstr' : // LPWSTR
case 'bstr' : // Basic String
case 'lpstr': // LPSTR
case 'lpwstr': // LPWSTR
case 'bstr': // Basic String
return $propertyValue;
break;
case 'date' : // Date and Time
case 'filetime' : // File Time
case 'date': // Date and Time
case 'filetime': // File Time
return strtotime($propertyValue);
break;
case 'bool' : // Boolean
return ($propertyValue == 'true') ? True : False;
case 'bool': // Boolean
return ($propertyValue == 'true') ? true : false;
break;
case 'cy' : // Currency
case 'error' : // Error Status Code
case 'vector' : // Vector
case 'array' : // Array
case 'blob' : // Binary Blob
case 'oblob' : // Binary Blob Object
case 'stream' : // Binary Stream
case 'ostream' : // Binary Stream Object
case 'storage' : // Binary Storage
case 'ostorage' : // Binary Storage Object
case 'vstream' : // Binary Versioned Stream
case 'clsid' : // Class ID
case 'cf' : // Clipboard Data
case 'cy': // Currency
case 'error': // Error Status Code
case 'vector': // Vector
case 'array': // Array
case 'blob': // Binary Blob
case 'oblob': // Binary Blob Object
case 'stream': // Binary Stream
case 'ostream': // Binary Stream Object
case 'storage': // Binary Storage
case 'ostorage': // Binary Storage Object
case 'vstream': // Binary Versioned Stream
case 'clsid': // Class ID
case 'cf': // Clipboard Data
return $propertyValue;
break;
}
return $propertyValue;
}
public static function convertPropertyType($propertyType) {
public static function convertPropertyType($propertyType)
{
switch ($propertyType) {
case 'i1' : // 1-Byte Signed Integer
case 'i2' : // 2-Byte Signed Integer
case 'i4' : // 4-Byte Signed Integer
case 'i8' : // 8-Byte Signed Integer
case 'int' : // Integer
case 'ui1' : // 1-Byte Unsigned Integer
case 'ui2' : // 2-Byte Unsigned Integer
case 'ui4' : // 4-Byte Unsigned Integer
case 'ui8' : // 8-Byte Unsigned Integer
case 'uint' : // Unsigned Integer
case 'i1': // 1-Byte Signed Integer
case 'i2': // 2-Byte Signed Integer
case 'i4': // 4-Byte Signed Integer
case 'i8': // 8-Byte Signed Integer
case 'int': // Integer
case 'ui1': // 1-Byte Unsigned Integer
case 'ui2': // 2-Byte Unsigned Integer
case 'ui4': // 4-Byte Unsigned Integer
case 'ui8': // 8-Byte Unsigned Integer
case 'uint': // Unsigned Integer
return self::PROPERTY_TYPE_INTEGER;
break;
case 'r4' : // 4-Byte Real Number
case 'r8' : // 8-Byte Real Number
case 'decimal' : // Decimal
case 'r4': // 4-Byte Real Number
case 'r8': // 8-Byte Real Number
case 'decimal': // Decimal
return self::PROPERTY_TYPE_FLOAT;
break;
case 'empty' : // Empty
case 'null' : // Null
case 'lpstr' : // LPSTR
case 'lpwstr' : // LPWSTR
case 'bstr' : // Basic String
case 'empty': // Empty
case 'null': // Null
case 'lpstr': // LPSTR
case 'lpwstr': // LPWSTR
case 'bstr': // Basic String
return self::PROPERTY_TYPE_STRING;
break;
case 'date' : // Date and Time
case 'filetime' : // File Time
case 'date': // Date and Time
case 'filetime': // File Time
return self::PROPERTY_TYPE_DATE;
break;
case 'bool' : // Boolean
case 'bool': // Boolean
return self::PROPERTY_TYPE_BOOLEAN;
break;
case 'cy' : // Currency
case 'error' : // Error Status Code
case 'vector' : // Vector
case 'array' : // Array
case 'blob' : // Binary Blob
case 'oblob' : // Binary Blob Object
case 'stream' : // Binary Stream
case 'ostream' : // Binary Stream Object
case 'storage' : // Binary Storage
case 'ostorage' : // Binary Storage Object
case 'vstream' : // Binary Versioned Stream
case 'clsid' : // Class ID
case 'cf' : // Clipboard Data
case 'cy': // Currency
case 'error': // Error Status Code
case 'vector': // Vector
case 'array': // Array
case 'blob': // Binary Blob
case 'oblob': // Binary Blob Object
case 'stream': // Binary Stream
case 'ostream': // Binary Stream Object
case 'storage': // Binary Storage
case 'ostorage': // Binary Storage Object
case 'vstream': // Binary Versioned Stream
case 'clsid': // Class ID
case 'cf': // Clipboard Data
return self::PROPERTY_TYPE_UNKNOWN;
break;
}
return self::PROPERTY_TYPE_UNKNOWN;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_DocumentSecurity
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,78 +21,70 @@
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_DocumentSecurity
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_DocumentSecurity
{
/**
* LockRevision
*
* @var boolean
*/
private $_lockRevision;
/**
* LockRevision
*
* @var boolean
*/
private $lockRevision;
/**
* LockStructure
*
* @var boolean
*/
private $_lockStructure;
/**
* LockStructure
*
* @var boolean
*/
private $lockStructure;
/**
* LockWindows
*
* @var boolean
*/
private $_lockWindows;
/**
* LockWindows
*
* @var boolean
*/
private $lockWindows;
/**
* RevisionsPassword
*
* @var string
*/
private $_revisionsPassword;
/**
* RevisionsPassword
*
* @var string
*/
private $revisionsPassword;
/**
* WorkbookPassword
*
* @var string
*/
private $_workbookPassword;
/**
* WorkbookPassword
*
* @var string
*/
private $workbookPassword;
/**
* Create a new PHPExcel_DocumentSecurity
*/
public function __construct()
{
// Initialise values
$this->_lockRevision = false;
$this->_lockStructure = false;
$this->_lockWindows = false;
$this->_revisionsPassword = '';
$this->_workbookPassword = '';
// Initialise values
$this->lockRevision = false;
$this->lockStructure = false;
$this->lockWindows = false;
$this->revisionsPassword = '';
$this->workbookPassword = '';
}
/**
* Is some sort of dcument security enabled?
* Is some sort of document security enabled?
*
* @return boolean
*/
function isSecurityEnabled() {
return $this->_lockRevision ||
$this->_lockStructure ||
$this->_lockWindows;
public function isSecurityEnabled()
{
return $this->lockRevision ||
$this->lockStructure ||
$this->lockWindows;
}
/**
@ -99,8 +92,9 @@ class PHPExcel_DocumentSecurity
*
* @return boolean
*/
function getLockRevision() {
return $this->_lockRevision;
public function getLockRevision()
{
return $this->lockRevision;
}
/**
@ -109,9 +103,10 @@ class PHPExcel_DocumentSecurity
* @param boolean $pValue
* @return PHPExcel_DocumentSecurity
*/
function setLockRevision($pValue = false) {
$this->_lockRevision = $pValue;
return $this;
public function setLockRevision($pValue = false)
{
$this->lockRevision = $pValue;
return $this;
}
/**
@ -119,8 +114,9 @@ class PHPExcel_DocumentSecurity
*
* @return boolean
*/
function getLockStructure() {
return $this->_lockStructure;
public function getLockStructure()
{
return $this->lockStructure;
}
/**
@ -129,9 +125,10 @@ class PHPExcel_DocumentSecurity
* @param boolean $pValue
* @return PHPExcel_DocumentSecurity
*/
function setLockStructure($pValue = false) {
$this->_lockStructure = $pValue;
return $this;
public function setLockStructure($pValue = false)
{
$this->lockStructure = $pValue;
return $this;
}
/**
@ -139,8 +136,9 @@ class PHPExcel_DocumentSecurity
*
* @return boolean
*/
function getLockWindows() {
return $this->_lockWindows;
public function getLockWindows()
{
return $this->lockWindows;
}
/**
@ -149,9 +147,10 @@ class PHPExcel_DocumentSecurity
* @param boolean $pValue
* @return PHPExcel_DocumentSecurity
*/
function setLockWindows($pValue = false) {
$this->_lockWindows = $pValue;
return $this;
public function setLockWindows($pValue = false)
{
$this->lockWindows = $pValue;
return $this;
}
/**
@ -159,23 +158,25 @@ class PHPExcel_DocumentSecurity
*
* @return string
*/
function getRevisionsPassword() {
return $this->_revisionsPassword;
public function getRevisionsPassword()
{
return $this->revisionsPassword;
}
/**
* Set RevisionsPassword
*
* @param string $pValue
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
* @param string $pValue
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
* @return PHPExcel_DocumentSecurity
*/
function setRevisionsPassword($pValue = '', $pAlreadyHashed = false) {
if (!$pAlreadyHashed) {
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
}
$this->_revisionsPassword = $pValue;
return $this;
public function setRevisionsPassword($pValue = '', $pAlreadyHashed = false)
{
if (!$pAlreadyHashed) {
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
}
$this->revisionsPassword = $pValue;
return $this;
}
/**
@ -183,36 +184,39 @@ class PHPExcel_DocumentSecurity
*
* @return string
*/
function getWorkbookPassword() {
return $this->_workbookPassword;
public function getWorkbookPassword()
{
return $this->workbookPassword;
}
/**
* Set WorkbookPassword
*
* @param string $pValue
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
* @param string $pValue
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
* @return PHPExcel_DocumentSecurity
*/
function setWorkbookPassword($pValue = '', $pAlreadyHashed = false) {
if (!$pAlreadyHashed) {
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
}
$this->_workbookPassword = $pValue;
return $this;
public function setWorkbookPassword($pValue = '', $pAlreadyHashed = false)
{
if (!$pAlreadyHashed) {
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
}
$this->workbookPassword = $pValue;
return $this;
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
}

View file

@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,7 +20,7 @@
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
@ -31,9 +31,10 @@
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Exception extends Exception {
class PHPExcel_Exception extends Exception
{
/**
* Error handler callback
*
@ -43,7 +44,8 @@ class PHPExcel_Exception extends Exception {
* @param mixed $line
* @param mixed $context
*/
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
public static function errorHandlerCallback($code, $string, $file, $line, $context)
{
$e = new self($string, $code);
$e->line = $line;
$e->file = $file;

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_HashTable
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -19,184 +20,185 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_HashTable
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_HashTable
{
/**
* HashTable elements
*
* @var array
*/
public $_items = array();
/**
* HashTable elements
*
* @var array
*/
protected $items = array();
/**
* HashTable key map
*
* @var array
*/
public $_keyMap = array();
/**
* HashTable key map
*
* @var array
*/
protected $keyMap = array();
/**
* Create a new PHPExcel_HashTable
*
* @param PHPExcel_IComparable[] $pSource Optional source array to create HashTable from
* @throws PHPExcel_Exception
*/
public function __construct($pSource = null)
{
if ($pSource !== NULL) {
// Create HashTable
$this->addFromSource($pSource);
}
}
/**
* Create a new PHPExcel_HashTable
*
* @param PHPExcel_IComparable[] $pSource Optional source array to create HashTable from
* @throws PHPExcel_Exception
*/
public function __construct($pSource = null)
{
if ($pSource !== null) {
// Create HashTable
$this->addFromSource($pSource);
}
}
/**
* Add HashTable items from source
*
* @param PHPExcel_IComparable[] $pSource Source array to create HashTable from
* @throws PHPExcel_Exception
*/
public function addFromSource($pSource = null) {
// Check if an array was passed
if ($pSource == null) {
return;
} else if (!is_array($pSource)) {
throw new PHPExcel_Exception('Invalid array parameter passed.');
}
/**
* Add HashTable items from source
*
* @param PHPExcel_IComparable[] $pSource Source array to create HashTable from
* @throws PHPExcel_Exception
*/
public function addFromSource($pSource = null)
{
// Check if an array was passed
if ($pSource == null) {
return;
} elseif (!is_array($pSource)) {
throw new PHPExcel_Exception('Invalid array parameter passed.');
}
foreach ($pSource as $item) {
$this->add($item);
}
}
foreach ($pSource as $item) {
$this->add($item);
}
}
/**
* Add HashTable item
*
* @param PHPExcel_IComparable $pSource Item to add
* @throws PHPExcel_Exception
*/
public function add(PHPExcel_IComparable $pSource = null) {
$hash = $pSource->getHashCode();
if (!isset($this->_items[$hash])) {
$this->_items[$hash] = $pSource;
$this->_keyMap[count($this->_items) - 1] = $hash;
}
}
/**
* Add HashTable item
*
* @param PHPExcel_IComparable $pSource Item to add
* @throws PHPExcel_Exception
*/
public function add(PHPExcel_IComparable $pSource = null)
{
$hash = $pSource->getHashCode();
if (!isset($this->items[$hash])) {
$this->items[$hash] = $pSource;
$this->keyMap[count($this->items) - 1] = $hash;
}
}
/**
* Remove HashTable item
*
* @param PHPExcel_IComparable $pSource Item to remove
* @throws PHPExcel_Exception
*/
public function remove(PHPExcel_IComparable $pSource = null) {
$hash = $pSource->getHashCode();
if (isset($this->_items[$hash])) {
unset($this->_items[$hash]);
/**
* Remove HashTable item
*
* @param PHPExcel_IComparable $pSource Item to remove
* @throws PHPExcel_Exception
*/
public function remove(PHPExcel_IComparable $pSource = null)
{
$hash = $pSource->getHashCode();
if (isset($this->items[$hash])) {
unset($this->items[$hash]);
$deleteKey = -1;
foreach ($this->_keyMap as $key => $value) {
if ($deleteKey >= 0) {
$this->_keyMap[$key - 1] = $value;
}
$deleteKey = -1;
foreach ($this->keyMap as $key => $value) {
if ($deleteKey >= 0) {
$this->keyMap[$key - 1] = $value;
}
if ($value == $hash) {
$deleteKey = $key;
}
}
unset($this->_keyMap[count($this->_keyMap) - 1]);
}
}
if ($value == $hash) {
$deleteKey = $key;
}
}
unset($this->keyMap[count($this->keyMap) - 1]);
}
}
/**
* Clear HashTable
*
*/
public function clear() {
$this->_items = array();
$this->_keyMap = array();
}
/**
* Clear HashTable
*
*/
public function clear()
{
$this->items = array();
$this->keyMap = array();
}
/**
* Count
*
* @return int
*/
public function count() {
return count($this->_items);
}
/**
* Count
*
* @return int
*/
public function count()
{
return count($this->items);
}
/**
* Get index for hash code
*
* @param string $pHashCode
* @return int Index
*/
public function getIndexForHashCode($pHashCode = '') {
return array_search($pHashCode, $this->_keyMap);
}
/**
* Get index for hash code
*
* @param string $pHashCode
* @return int Index
*/
public function getIndexForHashCode($pHashCode = '')
{
return array_search($pHashCode, $this->keyMap);
}
/**
* Get by index
*
* @param int $pIndex
* @return PHPExcel_IComparable
*
*/
public function getByIndex($pIndex = 0) {
if (isset($this->_keyMap[$pIndex])) {
return $this->getByHashCode( $this->_keyMap[$pIndex] );
}
/**
* Get by index
*
* @param int $pIndex
* @return PHPExcel_IComparable
*
*/
public function getByIndex($pIndex = 0)
{
if (isset($this->keyMap[$pIndex])) {
return $this->getByHashCode($this->keyMap[$pIndex]);
}
return null;
}
return null;
}
/**
* Get by hashcode
*
* @param string $pHashCode
* @return PHPExcel_IComparable
*
*/
public function getByHashCode($pHashCode = '') {
if (isset($this->_items[$pHashCode])) {
return $this->_items[$pHashCode];
}
/**
* Get by hashcode
*
* @param string $pHashCode
* @return PHPExcel_IComparable
*
*/
public function getByHashCode($pHashCode = '')
{
if (isset($this->items[$pHashCode])) {
return $this->items[$pHashCode];
}
return null;
}
return null;
}
/**
* HashTable to array
*
* @return PHPExcel_IComparable[]
*/
public function toArray() {
return $this->_items;
}
/**
* HashTable to array
*
* @return PHPExcel_IComparable[]
*/
public function toArray()
{
return $this->items;
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
}
}
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
}
}
}
}

View file

@ -0,0 +1,808 @@
<?php
class PHPExcel_Helper_HTML
{
protected static $colourMap = array(
'aliceblue' => 'f0f8ff',
'antiquewhite' => 'faebd7',
'antiquewhite1' => 'ffefdb',
'antiquewhite2' => 'eedfcc',
'antiquewhite3' => 'cdc0b0',
'antiquewhite4' => '8b8378',
'aqua' => '00ffff',
'aquamarine1' => '7fffd4',
'aquamarine2' => '76eec6',
'aquamarine4' => '458b74',
'azure1' => 'f0ffff',
'azure2' => 'e0eeee',
'azure3' => 'c1cdcd',
'azure4' => '838b8b',
'beige' => 'f5f5dc',
'bisque1' => 'ffe4c4',
'bisque2' => 'eed5b7',
'bisque3' => 'cdb79e',
'bisque4' => '8b7d6b',
'black' => '000000',
'blanchedalmond' => 'ffebcd',
'blue' => '0000ff',
'blue1' => '0000ff',
'blue2' => '0000ee',
'blue4' => '00008b',
'blueviolet' => '8a2be2',
'brown' => 'a52a2a',
'brown1' => 'ff4040',
'brown2' => 'ee3b3b',
'brown3' => 'cd3333',
'brown4' => '8b2323',
'burlywood' => 'deb887',
'burlywood1' => 'ffd39b',
'burlywood2' => 'eec591',
'burlywood3' => 'cdaa7d',
'burlywood4' => '8b7355',
'cadetblue' => '5f9ea0',
'cadetblue1' => '98f5ff',
'cadetblue2' => '8ee5ee',
'cadetblue3' => '7ac5cd',
'cadetblue4' => '53868b',
'chartreuse1' => '7fff00',
'chartreuse2' => '76ee00',
'chartreuse3' => '66cd00',
'chartreuse4' => '458b00',
'chocolate' => 'd2691e',
'chocolate1' => 'ff7f24',
'chocolate2' => 'ee7621',
'chocolate3' => 'cd661d',
'coral' => 'ff7f50',
'coral1' => 'ff7256',
'coral2' => 'ee6a50',
'coral3' => 'cd5b45',
'coral4' => '8b3e2f',
'cornflowerblue' => '6495ed',
'cornsilk1' => 'fff8dc',
'cornsilk2' => 'eee8cd',
'cornsilk3' => 'cdc8b1',
'cornsilk4' => '8b8878',
'cyan1' => '00ffff',
'cyan2' => '00eeee',
'cyan3' => '00cdcd',
'cyan4' => '008b8b',
'darkgoldenrod' => 'b8860b',
'darkgoldenrod1' => 'ffb90f',
'darkgoldenrod2' => 'eead0e',
'darkgoldenrod3' => 'cd950c',
'darkgoldenrod4' => '8b6508',
'darkgreen' => '006400',
'darkkhaki' => 'bdb76b',
'darkolivegreen' => '556b2f',
'darkolivegreen1' => 'caff70',
'darkolivegreen2' => 'bcee68',
'darkolivegreen3' => 'a2cd5a',
'darkolivegreen4' => '6e8b3d',
'darkorange' => 'ff8c00',
'darkorange1' => 'ff7f00',
'darkorange2' => 'ee7600',
'darkorange3' => 'cd6600',
'darkorange4' => '8b4500',
'darkorchid' => '9932cc',
'darkorchid1' => 'bf3eff',
'darkorchid2' => 'b23aee',
'darkorchid3' => '9a32cd',
'darkorchid4' => '68228b',
'darksalmon' => 'e9967a',
'darkseagreen' => '8fbc8f',
'darkseagreen1' => 'c1ffc1',
'darkseagreen2' => 'b4eeb4',
'darkseagreen3' => '9bcd9b',
'darkseagreen4' => '698b69',
'darkslateblue' => '483d8b',
'darkslategray' => '2f4f4f',
'darkslategray1' => '97ffff',
'darkslategray2' => '8deeee',
'darkslategray3' => '79cdcd',
'darkslategray4' => '528b8b',
'darkturquoise' => '00ced1',
'darkviolet' => '9400d3',
'deeppink1' => 'ff1493',
'deeppink2' => 'ee1289',
'deeppink3' => 'cd1076',
'deeppink4' => '8b0a50',
'deepskyblue1' => '00bfff',
'deepskyblue2' => '00b2ee',
'deepskyblue3' => '009acd',
'deepskyblue4' => '00688b',
'dimgray' => '696969',
'dodgerblue1' => '1e90ff',
'dodgerblue2' => '1c86ee',
'dodgerblue3' => '1874cd',
'dodgerblue4' => '104e8b',
'firebrick' => 'b22222',
'firebrick1' => 'ff3030',
'firebrick2' => 'ee2c2c',
'firebrick3' => 'cd2626',
'firebrick4' => '8b1a1a',
'floralwhite' => 'fffaf0',
'forestgreen' => '228b22',
'fuchsia' => 'ff00ff',
'gainsboro' => 'dcdcdc',
'ghostwhite' => 'f8f8ff',
'gold1' => 'ffd700',
'gold2' => 'eec900',
'gold3' => 'cdad00',
'gold4' => '8b7500',
'goldenrod' => 'daa520',
'goldenrod1' => 'ffc125',
'goldenrod2' => 'eeb422',
'goldenrod3' => 'cd9b1d',
'goldenrod4' => '8b6914',
'gray' => 'bebebe',
'gray1' => '030303',
'gray10' => '1a1a1a',
'gray11' => '1c1c1c',
'gray12' => '1f1f1f',
'gray13' => '212121',
'gray14' => '242424',
'gray15' => '262626',
'gray16' => '292929',
'gray17' => '2b2b2b',
'gray18' => '2e2e2e',
'gray19' => '303030',
'gray2' => '050505',
'gray20' => '333333',
'gray21' => '363636',
'gray22' => '383838',
'gray23' => '3b3b3b',
'gray24' => '3d3d3d',
'gray25' => '404040',
'gray26' => '424242',
'gray27' => '454545',
'gray28' => '474747',
'gray29' => '4a4a4a',
'gray3' => '080808',
'gray30' => '4d4d4d',
'gray31' => '4f4f4f',
'gray32' => '525252',
'gray33' => '545454',
'gray34' => '575757',
'gray35' => '595959',
'gray36' => '5c5c5c',
'gray37' => '5e5e5e',
'gray38' => '616161',
'gray39' => '636363',
'gray4' => '0a0a0a',
'gray40' => '666666',
'gray41' => '696969',
'gray42' => '6b6b6b',
'gray43' => '6e6e6e',
'gray44' => '707070',
'gray45' => '737373',
'gray46' => '757575',
'gray47' => '787878',
'gray48' => '7a7a7a',
'gray49' => '7d7d7d',
'gray5' => '0d0d0d',
'gray50' => '7f7f7f',
'gray51' => '828282',
'gray52' => '858585',
'gray53' => '878787',
'gray54' => '8a8a8a',
'gray55' => '8c8c8c',
'gray56' => '8f8f8f',
'gray57' => '919191',
'gray58' => '949494',
'gray59' => '969696',
'gray6' => '0f0f0f',
'gray60' => '999999',
'gray61' => '9c9c9c',
'gray62' => '9e9e9e',
'gray63' => 'a1a1a1',
'gray64' => 'a3a3a3',
'gray65' => 'a6a6a6',
'gray66' => 'a8a8a8',
'gray67' => 'ababab',
'gray68' => 'adadad',
'gray69' => 'b0b0b0',
'gray7' => '121212',
'gray70' => 'b3b3b3',
'gray71' => 'b5b5b5',
'gray72' => 'b8b8b8',
'gray73' => 'bababa',
'gray74' => 'bdbdbd',
'gray75' => 'bfbfbf',
'gray76' => 'c2c2c2',
'gray77' => 'c4c4c4',
'gray78' => 'c7c7c7',
'gray79' => 'c9c9c9',
'gray8' => '141414',
'gray80' => 'cccccc',
'gray81' => 'cfcfcf',
'gray82' => 'd1d1d1',
'gray83' => 'd4d4d4',
'gray84' => 'd6d6d6',
'gray85' => 'd9d9d9',
'gray86' => 'dbdbdb',
'gray87' => 'dedede',
'gray88' => 'e0e0e0',
'gray89' => 'e3e3e3',
'gray9' => '171717',
'gray90' => 'e5e5e5',
'gray91' => 'e8e8e8',
'gray92' => 'ebebeb',
'gray93' => 'ededed',
'gray94' => 'f0f0f0',
'gray95' => 'f2f2f2',
'gray97' => 'f7f7f7',
'gray98' => 'fafafa',
'gray99' => 'fcfcfc',
'green' => '00ff00',
'green1' => '00ff00',
'green2' => '00ee00',
'green3' => '00cd00',
'green4' => '008b00',
'greenyellow' => 'adff2f',
'honeydew1' => 'f0fff0',
'honeydew2' => 'e0eee0',
'honeydew3' => 'c1cdc1',
'honeydew4' => '838b83',
'hotpink' => 'ff69b4',
'hotpink1' => 'ff6eb4',
'hotpink2' => 'ee6aa7',
'hotpink3' => 'cd6090',
'hotpink4' => '8b3a62',
'indianred' => 'cd5c5c',
'indianred1' => 'ff6a6a',
'indianred2' => 'ee6363',
'indianred3' => 'cd5555',
'indianred4' => '8b3a3a',
'ivory1' => 'fffff0',
'ivory2' => 'eeeee0',
'ivory3' => 'cdcdc1',
'ivory4' => '8b8b83',
'khaki' => 'f0e68c',
'khaki1' => 'fff68f',
'khaki2' => 'eee685',
'khaki3' => 'cdc673',
'khaki4' => '8b864e',
'lavender' => 'e6e6fa',
'lavenderblush1' => 'fff0f5',
'lavenderblush2' => 'eee0e5',
'lavenderblush3' => 'cdc1c5',
'lavenderblush4' => '8b8386',
'lawngreen' => '7cfc00',
'lemonchiffon1' => 'fffacd',
'lemonchiffon2' => 'eee9bf',
'lemonchiffon3' => 'cdc9a5',
'lemonchiffon4' => '8b8970',
'light' => 'eedd82',
'lightblue' => 'add8e6',
'lightblue1' => 'bfefff',
'lightblue2' => 'b2dfee',
'lightblue3' => '9ac0cd',
'lightblue4' => '68838b',
'lightcoral' => 'f08080',
'lightcyan1' => 'e0ffff',
'lightcyan2' => 'd1eeee',
'lightcyan3' => 'b4cdcd',
'lightcyan4' => '7a8b8b',
'lightgoldenrod1' => 'ffec8b',
'lightgoldenrod2' => 'eedc82',
'lightgoldenrod3' => 'cdbe70',
'lightgoldenrod4' => '8b814c',
'lightgoldenrodyellow' => 'fafad2',
'lightgray' => 'd3d3d3',
'lightpink' => 'ffb6c1',
'lightpink1' => 'ffaeb9',
'lightpink2' => 'eea2ad',
'lightpink3' => 'cd8c95',
'lightpink4' => '8b5f65',
'lightsalmon1' => 'ffa07a',
'lightsalmon2' => 'ee9572',
'lightsalmon3' => 'cd8162',
'lightsalmon4' => '8b5742',
'lightseagreen' => '20b2aa',
'lightskyblue' => '87cefa',
'lightskyblue1' => 'b0e2ff',
'lightskyblue2' => 'a4d3ee',
'lightskyblue3' => '8db6cd',
'lightskyblue4' => '607b8b',
'lightslateblue' => '8470ff',
'lightslategray' => '778899',
'lightsteelblue' => 'b0c4de',
'lightsteelblue1' => 'cae1ff',
'lightsteelblue2' => 'bcd2ee',
'lightsteelblue3' => 'a2b5cd',
'lightsteelblue4' => '6e7b8b',
'lightyellow1' => 'ffffe0',
'lightyellow2' => 'eeeed1',
'lightyellow3' => 'cdcdb4',
'lightyellow4' => '8b8b7a',
'lime' => '00ff00',
'limegreen' => '32cd32',
'linen' => 'faf0e6',
'magenta' => 'ff00ff',
'magenta2' => 'ee00ee',
'magenta3' => 'cd00cd',
'magenta4' => '8b008b',
'maroon' => 'b03060',
'maroon1' => 'ff34b3',
'maroon2' => 'ee30a7',
'maroon3' => 'cd2990',
'maroon4' => '8b1c62',
'medium' => '66cdaa',
'mediumaquamarine' => '66cdaa',
'mediumblue' => '0000cd',
'mediumorchid' => 'ba55d3',
'mediumorchid1' => 'e066ff',
'mediumorchid2' => 'd15fee',
'mediumorchid3' => 'b452cd',
'mediumorchid4' => '7a378b',
'mediumpurple' => '9370db',
'mediumpurple1' => 'ab82ff',
'mediumpurple2' => '9f79ee',
'mediumpurple3' => '8968cd',
'mediumpurple4' => '5d478b',
'mediumseagreen' => '3cb371',
'mediumslateblue' => '7b68ee',
'mediumspringgreen' => '00fa9a',
'mediumturquoise' => '48d1cc',
'mediumvioletred' => 'c71585',
'midnightblue' => '191970',
'mintcream' => 'f5fffa',
'mistyrose1' => 'ffe4e1',
'mistyrose2' => 'eed5d2',
'mistyrose3' => 'cdb7b5',
'mistyrose4' => '8b7d7b',
'moccasin' => 'ffe4b5',
'navajowhite1' => 'ffdead',
'navajowhite2' => 'eecfa1',
'navajowhite3' => 'cdb38b',
'navajowhite4' => '8b795e',
'navy' => '000080',
'navyblue' => '000080',
'oldlace' => 'fdf5e6',
'olive' => '808000',
'olivedrab' => '6b8e23',
'olivedrab1' => 'c0ff3e',
'olivedrab2' => 'b3ee3a',
'olivedrab4' => '698b22',
'orange' => 'ffa500',
'orange1' => 'ffa500',
'orange2' => 'ee9a00',
'orange3' => 'cd8500',
'orange4' => '8b5a00',
'orangered1' => 'ff4500',
'orangered2' => 'ee4000',
'orangered3' => 'cd3700',
'orangered4' => '8b2500',
'orchid' => 'da70d6',
'orchid1' => 'ff83fa',
'orchid2' => 'ee7ae9',
'orchid3' => 'cd69c9',
'orchid4' => '8b4789',
'pale' => 'db7093',
'palegoldenrod' => 'eee8aa',
'palegreen' => '98fb98',
'palegreen1' => '9aff9a',
'palegreen2' => '90ee90',
'palegreen3' => '7ccd7c',
'palegreen4' => '548b54',
'paleturquoise' => 'afeeee',
'paleturquoise1' => 'bbffff',
'paleturquoise2' => 'aeeeee',
'paleturquoise3' => '96cdcd',
'paleturquoise4' => '668b8b',
'palevioletred' => 'db7093',
'palevioletred1' => 'ff82ab',
'palevioletred2' => 'ee799f',
'palevioletred3' => 'cd6889',
'palevioletred4' => '8b475d',
'papayawhip' => 'ffefd5',
'peachpuff1' => 'ffdab9',
'peachpuff2' => 'eecbad',
'peachpuff3' => 'cdaf95',
'peachpuff4' => '8b7765',
'pink' => 'ffc0cb',
'pink1' => 'ffb5c5',
'pink2' => 'eea9b8',
'pink3' => 'cd919e',
'pink4' => '8b636c',
'plum' => 'dda0dd',
'plum1' => 'ffbbff',
'plum2' => 'eeaeee',
'plum3' => 'cd96cd',
'plum4' => '8b668b',
'powderblue' => 'b0e0e6',
'purple' => 'a020f0',
'rebeccapurple' => '663399',
'purple1' => '9b30ff',
'purple2' => '912cee',
'purple3' => '7d26cd',
'purple4' => '551a8b',
'red' => 'ff0000',
'red1' => 'ff0000',
'red2' => 'ee0000',
'red3' => 'cd0000',
'red4' => '8b0000',
'rosybrown' => 'bc8f8f',
'rosybrown1' => 'ffc1c1',
'rosybrown2' => 'eeb4b4',
'rosybrown3' => 'cd9b9b',
'rosybrown4' => '8b6969',
'royalblue' => '4169e1',
'royalblue1' => '4876ff',
'royalblue2' => '436eee',
'royalblue3' => '3a5fcd',
'royalblue4' => '27408b',
'saddlebrown' => '8b4513',
'salmon' => 'fa8072',
'salmon1' => 'ff8c69',
'salmon2' => 'ee8262',
'salmon3' => 'cd7054',
'salmon4' => '8b4c39',
'sandybrown' => 'f4a460',
'seagreen1' => '54ff9f',
'seagreen2' => '4eee94',
'seagreen3' => '43cd80',
'seagreen4' => '2e8b57',
'seashell1' => 'fff5ee',
'seashell2' => 'eee5de',
'seashell3' => 'cdc5bf',
'seashell4' => '8b8682',
'sienna' => 'a0522d',
'sienna1' => 'ff8247',
'sienna2' => 'ee7942',
'sienna3' => 'cd6839',
'sienna4' => '8b4726',
'silver' => 'c0c0c0',
'skyblue' => '87ceeb',
'skyblue1' => '87ceff',
'skyblue2' => '7ec0ee',
'skyblue3' => '6ca6cd',
'skyblue4' => '4a708b',
'slateblue' => '6a5acd',
'slateblue1' => '836fff',
'slateblue2' => '7a67ee',
'slateblue3' => '6959cd',
'slateblue4' => '473c8b',
'slategray' => '708090',
'slategray1' => 'c6e2ff',
'slategray2' => 'b9d3ee',
'slategray3' => '9fb6cd',
'slategray4' => '6c7b8b',
'snow1' => 'fffafa',
'snow2' => 'eee9e9',
'snow3' => 'cdc9c9',
'snow4' => '8b8989',
'springgreen1' => '00ff7f',
'springgreen2' => '00ee76',
'springgreen3' => '00cd66',
'springgreen4' => '008b45',
'steelblue' => '4682b4',
'steelblue1' => '63b8ff',
'steelblue2' => '5cacee',
'steelblue3' => '4f94cd',
'steelblue4' => '36648b',
'tan' => 'd2b48c',
'tan1' => 'ffa54f',
'tan2' => 'ee9a49',
'tan3' => 'cd853f',
'tan4' => '8b5a2b',
'teal' => '008080',
'thistle' => 'd8bfd8',
'thistle1' => 'ffe1ff',
'thistle2' => 'eed2ee',
'thistle3' => 'cdb5cd',
'thistle4' => '8b7b8b',
'tomato1' => 'ff6347',
'tomato2' => 'ee5c42',
'tomato3' => 'cd4f39',
'tomato4' => '8b3626',
'turquoise' => '40e0d0',
'turquoise1' => '00f5ff',
'turquoise2' => '00e5ee',
'turquoise3' => '00c5cd',
'turquoise4' => '00868b',
'violet' => 'ee82ee',
'violetred' => 'd02090',
'violetred1' => 'ff3e96',
'violetred2' => 'ee3a8c',
'violetred3' => 'cd3278',
'violetred4' => '8b2252',
'wheat' => 'f5deb3',
'wheat1' => 'ffe7ba',
'wheat2' => 'eed8ae',
'wheat3' => 'cdba96',
'wheat4' => '8b7e66',
'white' => 'ffffff',
'whitesmoke' => 'f5f5f5',
'yellow' => 'ffff00',
'yellow1' => 'ffff00',
'yellow2' => 'eeee00',
'yellow3' => 'cdcd00',
'yellow4' => '8b8b00',
'yellowgreen' => '9acd32',
);
protected $face;
protected $size;
protected $color;
protected $bold = false;
protected $italic = false;
protected $underline = false;
protected $superscript = false;
protected $subscript = false;
protected $strikethrough = false;
protected $startTagCallbacks = array(
'font' => 'startFontTag',
'b' => 'startBoldTag',
'strong' => 'startBoldTag',
'i' => 'startItalicTag',
'em' => 'startItalicTag',
'u' => 'startUnderlineTag',
'ins' => 'startUnderlineTag',
'del' => 'startStrikethruTag',
'sup' => 'startSuperscriptTag',
'sub' => 'startSubscriptTag',
);
protected $endTagCallbacks = array(
'font' => 'endFontTag',
'b' => 'endBoldTag',
'strong' => 'endBoldTag',
'i' => 'endItalicTag',
'em' => 'endItalicTag',
'u' => 'endUnderlineTag',
'ins' => 'endUnderlineTag',
'del' => 'endStrikethruTag',
'sup' => 'endSuperscriptTag',
'sub' => 'endSubscriptTag',
'br' => 'breakTag',
'p' => 'breakTag',
'h1' => 'breakTag',
'h2' => 'breakTag',
'h3' => 'breakTag',
'h4' => 'breakTag',
'h5' => 'breakTag',
'h6' => 'breakTag',
);
protected $stack = array();
protected $stringData = '';
protected $richTextObject;
protected function initialise()
{
$this->face = $this->size = $this->color = null;
$this->bold = $this->italic = $this->underline = $this->superscript = $this->subscript = $this->strikethrough = false;
$this->stack = array();
$this->stringData = '';
}
public function toRichTextObject($html)
{
$this->initialise();
// Create a new DOM object
$dom = new \DOMDocument;
// Load the HTML file into the DOM object
// Note the use of error suppression, because typically this will be an html fragment, so not fully valid markup
$loaded = @$dom->loadHTML($html);
// Discard excess white space
$dom->preserveWhiteSpace = false;
$this->richTextObject = new PHPExcel_RichText();;
$this->parseElements($dom);
// Clean any further spurious whitespace
$this->cleanWhitespace();
return $this->richTextObject;
}
protected function cleanWhitespace()
{
foreach ($this->richTextObject->getRichTextElements() as $key => $element) {
$text = $element->getText();
// Trim any leading spaces on the first run
if ($key == 0) {
$text = ltrim($text);
}
// Trim any spaces immediately after a line break
$text = preg_replace('/\n */mu', "\n", $text);
$element->setText($text);
}
}
protected function buildTextRun()
{
$text = $this->stringData;
if (trim($text) === '') {
return;
}
$richtextRun = $this->richTextObject->createTextRun($this->stringData);
if ($this->face) {
$richtextRun->getFont()->setName($this->face);
}
if ($this->size) {
$richtextRun->getFont()->setSize($this->size);
}
if ($this->color) {
$richtextRun->getFont()->setColor(new PHPExcel_Style_Color('ff' . $this->color));
}
if ($this->bold) {
$richtextRun->getFont()->setBold(true);
}
if ($this->italic) {
$richtextRun->getFont()->setItalic(true);
}
if ($this->underline) {
$richtextRun->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
}
if ($this->superscript) {
$richtextRun->getFont()->setSuperScript(true);
}
if ($this->subscript) {
$richtextRun->getFont()->setSubScript(true);
}
if ($this->strikethrough) {
$richtextRun->getFont()->setStrikethrough(true);
}
$this->stringData = '';
}
protected function rgbToColour($rgb)
{
preg_match_all('/\d+/', $rgb, $values);
foreach ($values[0] as &$value) {
$value = str_pad(dechex($value), 2, '0', STR_PAD_LEFT);
}
return implode($values[0]);
}
protected function colourNameLookup($rgb)
{
return self::$colourMap[$rgb];
}
protected function startFontTag($tag)
{
foreach ($tag->attributes as $attribute) {
$attributeName = strtolower($attribute->name);
$attributeValue = $attribute->value;
if ($attributeName == 'color') {
if (preg_match('/rgb\s*\(/', $attributeValue)) {
$this->$attributeName = $this->rgbToColour($attributeValue);
} elseif (strpos(trim($attributeValue), '#') === 0) {
$this->$attributeName = ltrim($attributeValue, '#');
} else {
$this->$attributeName = $this->colourNameLookup($attributeValue);
}
} else {
$this->$attributeName = $attributeValue;
}
}
}
protected function endFontTag()
{
$this->face = $this->size = $this->color = null;
}
protected function startBoldTag()
{
$this->bold = true;
}
protected function endBoldTag()
{
$this->bold = false;
}
protected function startItalicTag()
{
$this->italic = true;
}
protected function endItalicTag()
{
$this->italic = false;
}
protected function startUnderlineTag()
{
$this->underline = true;
}
protected function endUnderlineTag()
{
$this->underline = false;
}
protected function startSubscriptTag()
{
$this->subscript = true;
}
protected function endSubscriptTag()
{
$this->subscript = false;
}
protected function startSuperscriptTag()
{
$this->superscript = true;
}
protected function endSuperscriptTag()
{
$this->superscript = false;
}
protected function startStrikethruTag()
{
$this->strikethrough = true;
}
protected function endStrikethruTag()
{
$this->strikethrough = false;
}
protected function breakTag()
{
$this->stringData .= "\n";
}
protected function parseTextNode(DOMText $textNode)
{
$domText = preg_replace(
'/\s+/u',
' ',
str_replace(array("\r", "\n"), ' ', $textNode->nodeValue)
);
$this->stringData .= $domText;
$this->buildTextRun();
}
protected function handleCallback($element, $callbackTag, $callbacks)
{
if (isset($callbacks[$callbackTag])) {
$elementHandler = $callbacks[$callbackTag];
if (method_exists($this, $elementHandler)) {
call_user_func(array($this, $elementHandler), $element);
}
}
}
protected function parseElementNode(DOMElement $element)
{
$callbackTag = strtolower($element->nodeName);
$this->stack[] = $callbackTag;
$this->handleCallback($element, $callbackTag, $this->startTagCallbacks);
$this->parseElements($element);
array_pop($this->stack);
$this->handleCallback($element, $callbackTag, $this->endTagCallbacks);
}
protected function parseElements(DOMNode $element)
{
foreach ($element->childNodes as $child) {
if ($child instanceof DOMText) {
$this->parseTextNode($child);
} elseif ($child instanceof DOMElement) {
$this->parseElementNode($child);
}
}
}
}

View file

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_IComparable
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -18,26 +19,16 @@
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_IComparable
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
interface PHPExcel_IComparable
{
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode();
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode();
}

View file

@ -1,8 +1,18 @@
<?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel
* PHPExcel_IOFactory
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,269 +30,260 @@
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_IOFactory
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_IOFactory
{
/**
* Search locations
*
* @var array
* @access private
* @static
*/
private static $_searchLocations = array(
array( 'type' => 'IWriter', 'path' => 'PHPExcel/Writer/{0}.php', 'class' => 'PHPExcel_Writer_{0}' ),
array( 'type' => 'IReader', 'path' => 'PHPExcel/Reader/{0}.php', 'class' => 'PHPExcel_Reader_{0}' )
);
/**
* Autoresolve classes
*
* @var array
* @access private
* @static
*/
private static $_autoResolveClasses = array(
'Excel2007',
'Excel5',
'Excel2003XML',
'OOCalc',
'SYLK',
'Gnumeric',
'HTML',
'CSV',
);
/**
* Search locations
*
* @var array
* @access private
* @static
*/
private static $searchLocations = array(
array( 'type' => 'IWriter', 'path' => 'PHPExcel/Writer/{0}.php', 'class' => 'PHPExcel_Writer_{0}' ),
array( 'type' => 'IReader', 'path' => 'PHPExcel/Reader/{0}.php', 'class' => 'PHPExcel_Reader_{0}' )
);
/**
* Private constructor for PHPExcel_IOFactory
* Autoresolve classes
*
* @var array
* @access private
* @static
*/
private function __construct() { }
private static $autoResolveClasses = array(
'Excel2007',
'Excel5',
'Excel2003XML',
'OOCalc',
'SYLK',
'Gnumeric',
'HTML',
'CSV',
);
/**
* Private constructor for PHPExcel_IOFactory
*/
private function __construct()
{
}
/**
* Get search locations
*
* @static
* @access public
* @return array
* @static
* @access public
* @return array
*/
public static function getSearchLocations() {
return self::$_searchLocations;
} // function getSearchLocations()
public static function getSearchLocations()
{
return self::$searchLocations;
}
/**
* Set search locations
*
* @static
* @access public
* @param array $value
* @throws PHPExcel_Reader_Exception
*/
public static function setSearchLocations($value) {
if (is_array($value)) {
self::$_searchLocations = $value;
} else {
throw new PHPExcel_Reader_Exception('Invalid parameter passed.');
}
} // function setSearchLocations()
/**
* Set search locations
*
* @static
* @access public
* @param array $value
* @throws PHPExcel_Reader_Exception
*/
public static function setSearchLocations($value)
{
if (is_array($value)) {
self::$searchLocations = $value;
} else {
throw new PHPExcel_Reader_Exception('Invalid parameter passed.');
}
}
/**
* Add search location
*
* @static
* @access public
* @param string $type Example: IWriter
* @param string $location Example: PHPExcel/Writer/{0}.php
* @param string $classname Example: PHPExcel_Writer_{0}
*/
public static function addSearchLocation($type = '', $location = '', $classname = '') {
self::$_searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname );
} // function addSearchLocation()
/**
* Add search location
*
* @static
* @access public
* @param string $type Example: IWriter
* @param string $location Example: PHPExcel/Writer/{0}.php
* @param string $classname Example: PHPExcel_Writer_{0}
*/
public static function addSearchLocation($type = '', $location = '', $classname = '')
{
self::$searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname );
}
/**
* Create PHPExcel_Writer_IWriter
*
* @static
* @access public
* @param PHPExcel $phpExcel
* @param string $writerType Example: Excel2007
* @return PHPExcel_Writer_IWriter
* @throws PHPExcel_Reader_Exception
*/
public static function createWriter(PHPExcel $phpExcel, $writerType = '') {
// Search type
$searchType = 'IWriter';
/**
* Create PHPExcel_Writer_IWriter
*
* @static
* @access public
* @param PHPExcel $phpExcel
* @param string $writerType Example: Excel2007
* @return PHPExcel_Writer_IWriter
* @throws PHPExcel_Reader_Exception
*/
public static function createWriter(PHPExcel $phpExcel, $writerType = '')
{
// Search type
$searchType = 'IWriter';
// Include class
foreach (self::$_searchLocations as $searchLocation) {
if ($searchLocation['type'] == $searchType) {
$className = str_replace('{0}', $writerType, $searchLocation['class']);
// Include class
foreach (self::$searchLocations as $searchLocation) {
if ($searchLocation['type'] == $searchType) {
$className = str_replace('{0}', $writerType, $searchLocation['class']);
$instance = new $className($phpExcel);
if ($instance !== NULL) {
return $instance;
}
}
}
$instance = new $className($phpExcel);
if ($instance !== null) {
return $instance;
}
}
}
// Nothing found...
throw new PHPExcel_Reader_Exception("No $searchType found for type $writerType");
} // function createWriter()
// Nothing found...
throw new PHPExcel_Reader_Exception("No $searchType found for type $writerType");
}
/**
* Create PHPExcel_Reader_IReader
*
* @static
* @access public
* @param string $readerType Example: Excel2007
* @return PHPExcel_Reader_IReader
* @throws PHPExcel_Reader_Exception
*/
public static function createReader($readerType = '') {
// Search type
$searchType = 'IReader';
/**
* Create PHPExcel_Reader_IReader
*
* @static
* @access public
* @param string $readerType Example: Excel2007
* @return PHPExcel_Reader_IReader
* @throws PHPExcel_Reader_Exception
*/
public static function createReader($readerType = '')
{
// Search type
$searchType = 'IReader';
// Include class
foreach (self::$_searchLocations as $searchLocation) {
if ($searchLocation['type'] == $searchType) {
$className = str_replace('{0}', $readerType, $searchLocation['class']);
// Include class
foreach (self::$searchLocations as $searchLocation) {
if ($searchLocation['type'] == $searchType) {
$className = str_replace('{0}', $readerType, $searchLocation['class']);
$instance = new $className();
if ($instance !== NULL) {
return $instance;
}
}
}
$instance = new $className();
if ($instance !== null) {
return $instance;
}
}
}
// Nothing found...
throw new PHPExcel_Reader_Exception("No $searchType found for type $readerType");
} // function createReader()
// Nothing found...
throw new PHPExcel_Reader_Exception("No $searchType found for type $readerType");
}
/**
* Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution
*
* @static
* @access public
* @param string $pFileName The name of the spreadsheet file
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
*/
public static function load($pFilename) {
$reader = self::createReaderForFile($pFilename);
return $reader->load($pFilename);
} // function load()
/**
* Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution
*
* @static
* @access public
* @param string $pFilename The name of the spreadsheet file
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
*/
public static function load($pFilename)
{
$reader = self::createReaderForFile($pFilename);
return $reader->load($pFilename);
}
/**
* Identify file type using automatic PHPExcel_Reader_IReader resolution
*
* @static
* @access public
* @param string $pFileName The name of the spreadsheet file to identify
* @return string
* @throws PHPExcel_Reader_Exception
*/
public static function identify($pFilename) {
$reader = self::createReaderForFile($pFilename);
$className = get_class($reader);
$classType = explode('_',$className);
unset($reader);
return array_pop($classType);
} // function identify()
/**
* Identify file type using automatic PHPExcel_Reader_IReader resolution
*
* @static
* @access public
* @param string $pFilename The name of the spreadsheet file to identify
* @return string
* @throws PHPExcel_Reader_Exception
*/
public static function identify($pFilename)
{
$reader = self::createReaderForFile($pFilename);
$className = get_class($reader);
$classType = explode('_', $className);
unset($reader);
return array_pop($classType);
}
/**
* Create PHPExcel_Reader_IReader for file using automatic PHPExcel_Reader_IReader resolution
*
* @static
* @access public
* @param string $pFileName The name of the spreadsheet file
* @return PHPExcel_Reader_IReader
* @throws PHPExcel_Reader_Exception
*/
public static function createReaderForFile($pFilename) {
/**
* Create PHPExcel_Reader_IReader for file using automatic PHPExcel_Reader_IReader resolution
*
* @static
* @access public
* @param string $pFilename The name of the spreadsheet file
* @return PHPExcel_Reader_IReader
* @throws PHPExcel_Reader_Exception
*/
public static function createReaderForFile($pFilename)
{
// First, lucky guess by inspecting file extension
$pathinfo = pathinfo($pFilename);
// First, lucky guess by inspecting file extension
$pathinfo = pathinfo($pFilename);
$extensionType = null;
if (isset($pathinfo['extension'])) {
switch (strtolower($pathinfo['extension'])) {
case 'xlsx': // Excel (OfficeOpenXML) Spreadsheet
case 'xlsm': // Excel (OfficeOpenXML) Macro Spreadsheet (macros will be discarded)
case 'xltx': // Excel (OfficeOpenXML) Template
case 'xltm': // Excel (OfficeOpenXML) Macro Template (macros will be discarded)
$extensionType = 'Excel2007';
break;
case 'xls': // Excel (BIFF) Spreadsheet
case 'xlt': // Excel (BIFF) Template
$extensionType = 'Excel5';
break;
case 'ods': // Open/Libre Offic Calc
case 'ots': // Open/Libre Offic Calc Template
$extensionType = 'OOCalc';
break;
case 'slk':
$extensionType = 'SYLK';
break;
case 'xml': // Excel 2003 SpreadSheetML
$extensionType = 'Excel2003XML';
break;
case 'gnumeric':
$extensionType = 'Gnumeric';
break;
case 'htm':
case 'html':
$extensionType = 'HTML';
break;
case 'csv':
// Do nothing
// We must not try to use CSV reader since it loads
// all files including Excel files etc.
break;
default:
break;
}
$extensionType = NULL;
if (isset($pathinfo['extension'])) {
switch (strtolower($pathinfo['extension'])) {
case 'xlsx': // Excel (OfficeOpenXML) Spreadsheet
case 'xlsm': // Excel (OfficeOpenXML) Macro Spreadsheet (macros will be discarded)
case 'xltx': // Excel (OfficeOpenXML) Template
case 'xltm': // Excel (OfficeOpenXML) Macro Template (macros will be discarded)
$extensionType = 'Excel2007';
break;
case 'xls': // Excel (BIFF) Spreadsheet
case 'xlt': // Excel (BIFF) Template
$extensionType = 'Excel5';
break;
case 'ods': // Open/Libre Offic Calc
case 'ots': // Open/Libre Offic Calc Template
$extensionType = 'OOCalc';
break;
case 'slk':
$extensionType = 'SYLK';
break;
case 'xml': // Excel 2003 SpreadSheetML
$extensionType = 'Excel2003XML';
break;
case 'gnumeric':
$extensionType = 'Gnumeric';
break;
case 'htm':
case 'html':
$extensionType = 'HTML';
break;
case 'csv':
// Do nothing
// We must not try to use CSV reader since it loads
// all files including Excel files etc.
break;
default:
break;
}
if ($extensionType !== null) {
$reader = self::createReader($extensionType);
// Let's see if we are lucky
if (isset($reader) && $reader->canRead($pFilename)) {
return $reader;
}
}
}
if ($extensionType !== NULL) {
$reader = self::createReader($extensionType);
// Let's see if we are lucky
if (isset($reader) && $reader->canRead($pFilename)) {
return $reader;
}
}
}
// If we reach here then "lucky guess" didn't give any result
// Try walking through all the options in self::$autoResolveClasses
foreach (self::$autoResolveClasses as $autoResolveClass) {
// Ignore our original guess, we know that won't work
if ($autoResolveClass !== $extensionType) {
$reader = self::createReader($autoResolveClass);
if ($reader->canRead($pFilename)) {
return $reader;
}
}
}
// If we reach here then "lucky guess" didn't give any result
// Try walking through all the options in self::$_autoResolveClasses
foreach (self::$_autoResolveClasses as $autoResolveClass) {
// Ignore our original guess, we know that won't work
if ($autoResolveClass !== $extensionType) {
$reader = self::createReader($autoResolveClass);
if ($reader->canRead($pFilename)) {
return $reader;
}
}
}
throw new PHPExcel_Reader_Exception('Unable to identify a reader for this file');
} // function createReaderForFile()
throw new PHPExcel_Reader_Exception('Unable to identify a reader for this file');
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_NamedRange
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,55 +21,46 @@
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_NamedRange
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_NamedRange
{
/**
* Range name
*
* @var string
*/
private $_name;
/**
* Range name
*
* @var string
*/
private $name;
/**
* Worksheet on which the named range can be resolved
*
* @var PHPExcel_Worksheet
*/
private $_worksheet;
/**
* Worksheet on which the named range can be resolved
*
* @var PHPExcel_Worksheet
*/
private $worksheet;
/**
* Range of the referenced cells
*
* @var string
*/
private $_range;
/**
* Range of the referenced cells
*
* @var string
*/
private $range;
/**
* Is the named range local? (i.e. can only be used on $this->_worksheet)
*
* @var bool
*/
private $_localOnly;
/**
* Is the named range local? (i.e. can only be used on $this->worksheet)
*
* @var bool
*/
private $localOnly;
/**
* Scope
*
* @var PHPExcel_Worksheet
*/
private $_scope;
/**
* Scope
*
* @var PHPExcel_Worksheet
*/
private $scope;
/**
* Create a new NamedRange
@ -77,23 +69,22 @@ class PHPExcel_NamedRange
* @param PHPExcel_Worksheet $pWorksheet
* @param string $pRange
* @param bool $pLocalOnly
* @param PHPExcel_Worksheet|null $pScope Scope. Only applies when $pLocalOnly = true. Null for global scope.
* @param PHPExcel_Worksheet|null $pScope Scope. Only applies when $pLocalOnly = true. Null for global scope.
* @throws PHPExcel_Exception
*/
public function __construct($pName = null, PHPExcel_Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null)
{
// Validate data
if (($pName === NULL) || ($pWorksheet === NULL) || ($pRange === NULL)) {
throw new PHPExcel_Exception('Parameters can not be null.');
}
// Validate data
if (($pName === null) || ($pWorksheet === null) || ($pRange === null)) {
throw new PHPExcel_Exception('Parameters can not be null.');
}
// Set local members
$this->_name = $pName;
$this->_worksheet = $pWorksheet;
$this->_range = $pRange;
$this->_localOnly = $pLocalOnly;
$this->_scope = ($pLocalOnly == true) ?
(($pScope == null) ? $pWorksheet : $pScope) : null;
// Set local members
$this->name = $pName;
$this->worksheet = $pWorksheet;
$this->range = $pRange;
$this->localOnly = $pLocalOnly;
$this->scope = ($pLocalOnly == true) ? (($pScope == null) ? $pWorksheet : $pScope) : null;
}
/**
@ -101,8 +92,9 @@ class PHPExcel_NamedRange
*
* @return string
*/
public function getName() {
return $this->_name;
public function getName()
{
return $this->name;
}
/**
@ -111,26 +103,27 @@ class PHPExcel_NamedRange
* @param string $value
* @return PHPExcel_NamedRange
*/
public function setName($value = null) {
if ($value !== NULL) {
// Old title
$oldTitle = $this->_name;
public function setName($value = null)
{
if ($value !== null) {
// Old title
$oldTitle = $this->name;
// Re-attach
if ($this->_worksheet !== NULL) {
$this->_worksheet->getParent()->removeNamedRange($this->_name,$this->_worksheet);
}
$this->_name = $value;
// Re-attach
if ($this->worksheet !== null) {
$this->worksheet->getParent()->removeNamedRange($this->name, $this->worksheet);
}
$this->name = $value;
if ($this->_worksheet !== NULL) {
$this->_worksheet->getParent()->addNamedRange($this);
}
if ($this->worksheet !== null) {
$this->worksheet->getParent()->addNamedRange($this);
}
// New title
$newTitle = $this->_name;
PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->_worksheet->getParent(), $oldTitle, $newTitle);
}
return $this;
// New title
$newTitle = $this->name;
PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->worksheet->getParent(), $oldTitle, $newTitle);
}
return $this;
}
/**
@ -138,8 +131,9 @@ class PHPExcel_NamedRange
*
* @return PHPExcel_Worksheet
*/
public function getWorksheet() {
return $this->_worksheet;
public function getWorksheet()
{
return $this->worksheet;
}
/**
@ -148,11 +142,12 @@ class PHPExcel_NamedRange
* @param PHPExcel_Worksheet $value
* @return PHPExcel_NamedRange
*/
public function setWorksheet(PHPExcel_Worksheet $value = null) {
if ($value !== NULL) {
$this->_worksheet = $value;
}
return $this;
public function setWorksheet(PHPExcel_Worksheet $value = null)
{
if ($value !== null) {
$this->worksheet = $value;
}
return $this;
}
/**
@ -160,8 +155,9 @@ class PHPExcel_NamedRange
*
* @return string
*/
public function getRange() {
return $this->_range;
public function getRange()
{
return $this->range;
}
/**
@ -170,11 +166,12 @@ class PHPExcel_NamedRange
* @param string $value
* @return PHPExcel_NamedRange
*/
public function setRange($value = null) {
if ($value !== NULL) {
$this->_range = $value;
}
return $this;
public function setRange($value = null)
{
if ($value !== null) {
$this->range = $value;
}
return $this;
}
/**
@ -182,8 +179,9 @@ class PHPExcel_NamedRange
*
* @return bool
*/
public function getLocalOnly() {
return $this->_localOnly;
public function getLocalOnly()
{
return $this->localOnly;
}
/**
@ -192,10 +190,11 @@ class PHPExcel_NamedRange
* @param bool $value
* @return PHPExcel_NamedRange
*/
public function setLocalOnly($value = false) {
$this->_localOnly = $value;
$this->_scope = $value ? $this->_worksheet : null;
return $this;
public function setLocalOnly($value = false)
{
$this->localOnly = $value;
$this->scope = $value ? $this->worksheet : null;
return $this;
}
/**
@ -203,8 +202,9 @@ class PHPExcel_NamedRange
*
* @return PHPExcel_Worksheet|null
*/
public function getScope() {
return $this->_scope;
public function getScope()
{
return $this->scope;
}
/**
@ -213,10 +213,11 @@ class PHPExcel_NamedRange
* @param PHPExcel_Worksheet|null $value
* @return PHPExcel_NamedRange
*/
public function setScope(PHPExcel_Worksheet $value = null) {
$this->_scope = $value;
$this->_localOnly = ($value == null) ? false : true;
return $this;
public function setScope(PHPExcel_Worksheet $value = null)
{
$this->scope = $value;
$this->localOnly = ($value == null) ? false : true;
return $this;
}
/**
@ -226,21 +227,23 @@ class PHPExcel_NamedRange
* @param PHPExcel_Worksheet|null $pSheet Scope. Use null for global scope
* @return PHPExcel_NamedRange
*/
public static function resolveRange($pNamedRange = '', PHPExcel_Worksheet $pSheet) {
return $pSheet->getParent()->getNamedRange($pNamedRange, $pSheet);
public static function resolveRange($pNamedRange = '', PHPExcel_Worksheet $pSheet)
{
return $pSheet->getParent()->getNamedRange($pNamedRange, $pSheet);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Reader_Abstract
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,173 +21,269 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Reader_Abstract
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
{
/**
* Read data only?
* Identifies whether the Reader should only read data values for cells, and ignore any formatting information;
* or whether it should read both data and formatting
*
* @var boolean
*/
protected $_readDataOnly = FALSE;
/**
* Read data only?
* Identifies whether the Reader should only read data values for cells, and ignore any formatting information;
* or whether it should read both data and formatting
*
* @var boolean
*/
protected $readDataOnly = false;
/**
* Read charts that are defined in the workbook?
* Identifies whether the Reader should read the definitions for any charts that exist in the workbook;
*
* @var boolean
*/
protected $_includeCharts = FALSE;
/**
* Read empty cells?
* Identifies whether the Reader should read data values for cells all cells, or should ignore cells containing
* null value or empty string
*
* @var boolean
*/
protected $readEmptyCells = true;
/**
* Restrict which sheets should be loaded?
* This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
*
* @var array of string
*/
protected $_loadSheetsOnly = NULL;
/**
* Read charts that are defined in the workbook?
* Identifies whether the Reader should read the definitions for any charts that exist in the workbook;
*
* @var boolean
*/
protected $includeCharts = false;
/**
* PHPExcel_Reader_IReadFilter instance
*
* @var PHPExcel_Reader_IReadFilter
*/
protected $_readFilter = NULL;
/**
* Restrict which sheets should be loaded?
* This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
*
* @var array of string
*/
protected $loadSheetsOnly;
/**
* PHPExcel_Reader_IReadFilter instance
*
* @var PHPExcel_Reader_IReadFilter
*/
protected $readFilter;
protected $fileHandle = null;
/**
* Read data only?
* If this is true, then the Reader will only read data values for cells, it will not read any formatting information.
* If false (the default) it will read data and formatting.
*
* @return boolean
*/
public function getReadDataOnly() {
return $this->_readDataOnly;
}
/**
* Read data only?
* If this is true, then the Reader will only read data values for cells, it will not read any formatting information.
* If false (the default) it will read data and formatting.
*
* @return boolean
*/
public function getReadDataOnly()
{
return $this->readDataOnly;
}
/**
* Set read data only
* Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information.
* Set to false (the default) to advise the Reader to read both data and formatting for cells.
*
* @param boolean $pValue
*
* @return PHPExcel_Reader_IReader
*/
public function setReadDataOnly($pValue = false)
{
$this->readDataOnly = $pValue;
return $this;
}
/**
* Set read data only
* Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information.
* Set to false (the default) to advise the Reader to read both data and formatting for cells.
*
* @param boolean $pValue
*
* @return PHPExcel_Reader_IReader
*/
public function setReadDataOnly($pValue = FALSE) {
$this->_readDataOnly = $pValue;
return $this;
}
/**
* Read empty cells?
* If this is true (the default), then the Reader will read data values for all cells, irrespective of value.
* If false it will not read data for cells containing a null value or an empty string.
*
* @return boolean
*/
public function getReadEmptyCells()
{
return $this->readEmptyCells;
}
/**
* Set read empty cells
* Set to true (the default) to advise the Reader read data values for all cells, irrespective of value.
* Set to false to advise the Reader to ignore cells containing a null value or an empty string.
*
* @param boolean $pValue
*
* @return PHPExcel_Reader_IReader
*/
public function setReadEmptyCells($pValue = true)
{
$this->readEmptyCells = $pValue;
return $this;
}
/**
* Read charts in workbook?
* If this is true, then the Reader will include any charts that exist in the workbook.
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
* If false (the default) it will ignore any charts defined in the workbook file.
*
* @return boolean
*/
public function getIncludeCharts() {
return $this->_includeCharts;
}
/**
* Read charts in workbook?
* If this is true, then the Reader will include any charts that exist in the workbook.
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
* If false (the default) it will ignore any charts defined in the workbook file.
*
* @return boolean
*/
public function getIncludeCharts()
{
return $this->includeCharts;
}
/**
* Set read charts in workbook
* Set to true, to advise the Reader to include any charts that exist in the workbook.
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
* Set to false (the default) to discard charts.
*
* @param boolean $pValue
*
* @return PHPExcel_Reader_IReader
*/
public function setIncludeCharts($pValue = false)
{
$this->includeCharts = (boolean) $pValue;
return $this;
}
/**
* Set read charts in workbook
* Set to true, to advise the Reader to include any charts that exist in the workbook.
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
* Set to false (the default) to discard charts.
*
* @param boolean $pValue
*
* @return PHPExcel_Reader_IReader
*/
public function setIncludeCharts($pValue = FALSE) {
$this->_includeCharts = (boolean) $pValue;
return $this;
}
/**
* Get which sheets to load
* Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null
* indicating that all worksheets in the workbook should be loaded.
*
* @return mixed
*/
public function getLoadSheetsOnly()
{
return $this->loadSheetsOnly;
}
/**
* Set which sheets to load
*
* @param mixed $value
* This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name.
* If NULL, then it tells the Reader to read all worksheets in the workbook
*
* @return PHPExcel_Reader_IReader
*/
public function setLoadSheetsOnly($value = null)
{
if ($value === null) {
return $this->setLoadAllSheets();
}
/**
* Get which sheets to load
* Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null
* indicating that all worksheets in the workbook should be loaded.
*
* @return mixed
*/
public function getLoadSheetsOnly()
{
return $this->_loadSheetsOnly;
}
$this->loadSheetsOnly = is_array($value) ? $value : array($value);
return $this;
}
/**
* Set all sheets to load
* Tells the Reader to load all worksheets from the workbook.
*
* @return PHPExcel_Reader_IReader
*/
public function setLoadAllSheets()
{
$this->loadSheetsOnly = null;
return $this;
}
/**
* Set which sheets to load
*
* @param mixed $value
* This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name.
* If NULL, then it tells the Reader to read all worksheets in the workbook
*
* @return PHPExcel_Reader_IReader
*/
public function setLoadSheetsOnly($value = NULL)
{
$this->_loadSheetsOnly = is_array($value) ?
$value : array($value);
return $this;
}
/**
* Read filter
*
* @return PHPExcel_Reader_IReadFilter
*/
public function getReadFilter()
{
return $this->readFilter;
}
/**
* Set read filter
*
* @param PHPExcel_Reader_IReadFilter $pValue
* @return PHPExcel_Reader_IReader
*/
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue)
{
$this->readFilter = $pValue;
return $this;
}
/**
* Set all sheets to load
* Tells the Reader to load all worksheets from the workbook.
*
* @return PHPExcel_Reader_IReader
*/
public function setLoadAllSheets()
{
$this->_loadSheetsOnly = NULL;
return $this;
}
/**
* Open file for reading
*
* @param string $pFilename
* @throws PHPExcel_Reader_Exception
* @return resource
*/
protected function openFile($pFilename)
{
// Check if file exists
if (!file_exists($pFilename) || !is_readable($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// Open file
$this->fileHandle = fopen($pFilename, 'r');
if ($this->fileHandle === false) {
throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading.");
}
}
/**
* Read filter
*
* @return PHPExcel_Reader_IReadFilter
*/
public function getReadFilter() {
return $this->_readFilter;
}
/**
* Can the current PHPExcel_Reader_IReader read the file?
*
* @param string $pFilename
* @return boolean
* @throws PHPExcel_Reader_Exception
*/
public function canRead($pFilename)
{
// Check if file exists
try {
$this->openFile($pFilename);
} catch (Exception $e) {
return false;
}
$readable = $this->isValidFormat();
fclose($this->fileHandle);
return $readable;
}
/**
* Set read filter
*
* @param PHPExcel_Reader_IReadFilter $pValue
* @return PHPExcel_Reader_IReader
*/
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
$this->_readFilter = $pValue;
return $this;
}
/**
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
*
* @param string $xml
* @throws PHPExcel_Reader_Exception
*/
public function securityScan($xml)
{
$pattern = '/\\0?' . implode('\\0?', str_split('<!DOCTYPE')) . '\\0?/';
if (preg_match($pattern, $xml)) {
throw new PHPExcel_Reader_Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks');
}
return $xml;
}
/**
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
*
* @param string $filestream
* @throws PHPExcel_Reader_Exception
*/
public function securityScanFile($filestream)
{
return $this->securityScan(file_get_contents($filestream));
}
}

View file

@ -1,8 +1,18 @@
<?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel
* PHPExcel_Reader_CSV
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,454 +30,377 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Reader_CSV
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
{
/**
* Input encoding
*
* @access private
* @var string
*/
private $_inputEncoding = 'UTF-8';
/**
* Delimiter
*
* @access private
* @var string
*/
private $_delimiter = ',';
/**
* Enclosure
*
* @access private
* @var string
*/
private $_enclosure = '"';
/**
* Line ending
*
* @access private
* @var string
*/
private $_lineEnding = PHP_EOL;
/**
* Sheet index to read
*
* @access private
* @var int
*/
private $_sheetIndex = 0;
/**
* Load rows contiguously
*
* @access private
* @var int
*/
private $_contiguous = false;
/**
* Row counter for loading rows contiguously
*
* @access private
* @var int
*/
private $_contiguousRow = -1;
/**
* Create a new PHPExcel_Reader_CSV
*/
public function __construct() {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
} // function __construct()
/**
* Can the current PHPExcel_Reader_IReader read the file?
*
* @access public
* @param string $pFileName
* @return boolean
* @throws PHPExcel_Reader_Exception
*/
public function canRead($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
return true;
} // function canRead()
/**
* Set input encoding
*
* @access public
* @param string $pValue Input encoding
*/
public function setInputEncoding($pValue = 'UTF-8')
{
$this->_inputEncoding = $pValue;
return $this;
} // function setInputEncoding()
/**
* Get input encoding
*
* @access public
* @return string
*/
public function getInputEncoding()
{
return $this->_inputEncoding;
} // function getInputEncoding()
/**
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
*
* @access public
* @param string $pFilename
* @throws PHPExcel_Reader_Exception
*/
public function listWorksheetInfo($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// Open file
$fileHandle = fopen($pFilename, 'r');
if ($fileHandle === false) {
throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading.");
}
// Skip BOM, if any
switch ($this->_inputEncoding) {
case 'UTF-8':
fgets($fileHandle, 4) == "\xEF\xBB\xBF" ?
fseek($fileHandle, 3) : fseek($fileHandle, 0);
break;
case 'UTF-16LE':
fgets($fileHandle, 3) == "\xFF\xFE" ?
fseek($fileHandle, 2) : fseek($fileHandle, 0);
break;
case 'UTF-16BE':
fgets($fileHandle, 3) == "\xFE\xFF" ?
fseek($fileHandle, 2) : fseek($fileHandle, 0);
break;
case 'UTF-32LE':
fgets($fileHandle, 5) == "\xFF\xFE\x00\x00" ?
fseek($fileHandle, 4) : fseek($fileHandle, 0);
break;
case 'UTF-32BE':
fgets($fileHandle, 5) == "\x00\x00\xFE\xFF" ?
fseek($fileHandle, 4) : fseek($fileHandle, 0);
break;
default:
break;
}
$escapeEnclosures = array( "\\" . $this->_enclosure, $this->_enclosure . $this->_enclosure );
$worksheetInfo = array();
$worksheetInfo[0]['worksheetName'] = 'Worksheet';
$worksheetInfo[0]['lastColumnLetter'] = 'A';
$worksheetInfo[0]['lastColumnIndex'] = 0;
$worksheetInfo[0]['totalRows'] = 0;
$worksheetInfo[0]['totalColumns'] = 0;
// Loop through each line of the file in turn
while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
$worksheetInfo[0]['totalRows']++;
$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], count($rowData) - 1);
}
$worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
// Close file
fclose($fileHandle);
return $worksheetInfo;
}
/**
* Loads PHPExcel from file
*
* @access public
* @param string $pFilename
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
*/
public function load($pFilename)
{
// Create new PHPExcel
$objPHPExcel = new PHPExcel();
// Load into this instance
return $this->loadIntoExisting($pFilename, $objPHPExcel);
} // function load()
/**
* Loads PHPExcel from file into PHPExcel instance
*
* @access public
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// Create new PHPExcel
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
$objPHPExcel->createSheet();
}
$sheet = $objPHPExcel->setActiveSheetIndex( $this->_sheetIndex );
$lineEnding = ini_get('auto_detect_line_endings');
ini_set('auto_detect_line_endings', true);
// Open file
$fileHandle = fopen($pFilename, 'r');
if ($fileHandle === false) {
throw new PHPExcel_Reader_Exception("Could not open file $pFilename for reading.");
}
// Skip BOM, if any
switch ($this->_inputEncoding) {
case 'UTF-8':
fgets($fileHandle, 4) == "\xEF\xBB\xBF" ?
fseek($fileHandle, 3) : fseek($fileHandle, 0);
break;
case 'UTF-16LE':
fgets($fileHandle, 3) == "\xFF\xFE" ?
fseek($fileHandle, 2) : fseek($fileHandle, 0);
break;
case 'UTF-16BE':
fgets($fileHandle, 3) == "\xFE\xFF" ?
fseek($fileHandle, 2) : fseek($fileHandle, 0);
break;
case 'UTF-32LE':
fgets($fileHandle, 5) == "\xFF\xFE\x00\x00" ?
fseek($fileHandle, 4) : fseek($fileHandle, 0);
break;
case 'UTF-32BE':
fgets($fileHandle, 5) == "\x00\x00\xFE\xFF" ?
fseek($fileHandle, 4) : fseek($fileHandle, 0);
break;
default:
break;
}
$escapeEnclosures = array( "\\" . $this->_enclosure,
$this->_enclosure . $this->_enclosure
);
// Set our starting row based on whether we're in contiguous mode or not
$currentRow = 1;
if ($this->_contiguous) {
$currentRow = ($this->_contiguousRow == -1) ? $sheet->getHighestRow(): $this->_contiguousRow;
}
// Loop through each line of the file in turn
while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
$columnLetter = 'A';
foreach($rowData as $rowDatum) {
if ($rowDatum != '' && $this->_readFilter->readCell($columnLetter, $currentRow)) {
// Unescape enclosures
$rowDatum = str_replace($escapeEnclosures, $this->_enclosure, $rowDatum);
// Convert encoding if necessary
if ($this->_inputEncoding !== 'UTF-8') {
$rowDatum = PHPExcel_Shared_String::ConvertEncoding($rowDatum, 'UTF-8', $this->_inputEncoding);
}
// Set cell value
$sheet->getCell($columnLetter . $currentRow)->setValue($rowDatum);
}
++$columnLetter;
}
++$currentRow;
}
// Close file
fclose($fileHandle);
if ($this->_contiguous) {
$this->_contiguousRow = $currentRow;
}
ini_set('auto_detect_line_endings', $lineEnding);
// Return
return $objPHPExcel;
} // function loadIntoExisting()
/**
* Get delimiter
*
* @access public
* @return string
*/
public function getDelimiter() {
return $this->_delimiter;
} // function getDelimiter()
/**
* Set delimiter
*
* @access public
* @param string $pValue Delimiter, defaults to ,
* @return PHPExcel_Reader_CSV
*/
public function setDelimiter($pValue = ',') {
$this->_delimiter = $pValue;
return $this;
} // function setDelimiter()
/**
* Get enclosure
*
* @access public
* @return string
*/
public function getEnclosure() {
return $this->_enclosure;
} // function getEnclosure()
/**
* Set enclosure
*
* @access public
* @param string $pValue Enclosure, defaults to "
* @return PHPExcel_Reader_CSV
*/
public function setEnclosure($pValue = '"') {
if ($pValue == '') {
$pValue = '"';
}
$this->_enclosure = $pValue;
return $this;
} // function setEnclosure()
/**
* Get line ending
*
* @access public
* @return string
*/
public function getLineEnding() {
return $this->_lineEnding;
} // function getLineEnding()
/**
* Set line ending
*
* @access public
* @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
* @return PHPExcel_Reader_CSV
*/
public function setLineEnding($pValue = PHP_EOL) {
$this->_lineEnding = $pValue;
return $this;
} // function setLineEnding()
/**
* Get sheet index
*
* @access public
* @return int
*/
public function getSheetIndex() {
return $this->_sheetIndex;
} // function getSheetIndex()
/**
* Set sheet index
*
* @access public
* @param int $pValue Sheet index
* @return PHPExcel_Reader_CSV
*/
public function setSheetIndex($pValue = 0) {
$this->_sheetIndex = $pValue;
return $this;
} // function setSheetIndex()
/**
* Set Contiguous
*
* @access public
* @param string $pValue Input encoding
*/
public function setContiguous($contiguous = false)
{
$this->_contiguous = (bool)$contiguous;
if (!$contiguous) {
$this->_contiguousRow = -1;
}
return $this;
} // function setInputEncoding()
/**
* Get Contiguous
*
* @access public
* @return boolean
*/
public function getContiguous() {
return $this->_contiguous;
} // function getSheetIndex()
/**
* Input encoding
*
* @access private
* @var string
*/
private $inputEncoding = 'UTF-8';
/**
* Delimiter
*
* @access private
* @var string
*/
private $delimiter = ',';
/**
* Enclosure
*
* @access private
* @var string
*/
private $enclosure = '"';
/**
* Sheet index to read
*
* @access private
* @var int
*/
private $sheetIndex = 0;
/**
* Load rows contiguously
*
* @access private
* @var int
*/
private $contiguous = false;
/**
* Row counter for loading rows contiguously
*
* @var int
*/
private $contiguousRow = -1;
/**
* Create a new PHPExcel_Reader_CSV
*/
public function __construct()
{
$this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
}
/**
* Validate that the current file is a CSV file
*
* @return boolean
*/
protected function isValidFormat()
{
return true;
}
/**
* Set input encoding
*
* @param string $pValue Input encoding
*/
public function setInputEncoding($pValue = 'UTF-8')
{
$this->inputEncoding = $pValue;
return $this;
}
/**
* Get input encoding
*
* @return string
*/
public function getInputEncoding()
{
return $this->inputEncoding;
}
/**
* Move filepointer past any BOM marker
*
*/
protected function skipBOM()
{
rewind($this->fileHandle);
switch ($this->inputEncoding) {
case 'UTF-8':
fgets($this->fileHandle, 4) == "\xEF\xBB\xBF" ?
fseek($this->fileHandle, 3) : fseek($this->fileHandle, 0);
break;
case 'UTF-16LE':
fgets($this->fileHandle, 3) == "\xFF\xFE" ?
fseek($this->fileHandle, 2) : fseek($this->fileHandle, 0);
break;
case 'UTF-16BE':
fgets($this->fileHandle, 3) == "\xFE\xFF" ?
fseek($this->fileHandle, 2) : fseek($this->fileHandle, 0);
break;
case 'UTF-32LE':
fgets($this->fileHandle, 5) == "\xFF\xFE\x00\x00" ?
fseek($this->fileHandle, 4) : fseek($this->fileHandle, 0);
break;
case 'UTF-32BE':
fgets($this->fileHandle, 5) == "\x00\x00\xFE\xFF" ?
fseek($this->fileHandle, 4) : fseek($this->fileHandle, 0);
break;
default:
break;
}
}
/**
* Identify any separator that is explicitly set in the file
*
*/
protected function checkSeparator()
{
$line = fgets($this->fileHandle);
if ($line === false) {
return;
}
if ((strlen(trim($line, "\r\n")) == 5) && (stripos($line, 'sep=') === 0)) {
$this->delimiter = substr($line, 4, 1);
return;
}
return $this->skipBOM();
}
/**
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
*
* @param string $pFilename
* @throws PHPExcel_Reader_Exception
*/
public function listWorksheetInfo($pFilename)
{
// Open file
$this->openFile($pFilename);
if (!$this->isValidFormat()) {
fclose($this->fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
}
$fileHandle = $this->fileHandle;
// Skip BOM, if any
$this->skipBOM();
$this->checkSeparator();
$escapeEnclosures = array( "\\" . $this->enclosure, $this->enclosure . $this->enclosure );
$worksheetInfo = array();
$worksheetInfo[0]['worksheetName'] = 'Worksheet';
$worksheetInfo[0]['lastColumnLetter'] = 'A';
$worksheetInfo[0]['lastColumnIndex'] = 0;
$worksheetInfo[0]['totalRows'] = 0;
$worksheetInfo[0]['totalColumns'] = 0;
// Loop through each line of the file in turn
while (($rowData = fgetcsv($fileHandle, 0, $this->delimiter, $this->enclosure)) !== false) {
$worksheetInfo[0]['totalRows']++;
$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], count($rowData) - 1);
}
$worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
// Close file
fclose($fileHandle);
return $worksheetInfo;
}
/**
* Loads PHPExcel from file
*
* @param string $pFilename
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
*/
public function load($pFilename)
{
// Create new PHPExcel
$objPHPExcel = new PHPExcel();
// Load into this instance
return $this->loadIntoExisting($pFilename, $objPHPExcel);
}
/**
* Loads PHPExcel from file into PHPExcel instance
*
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
$lineEnding = ini_get('auto_detect_line_endings');
ini_set('auto_detect_line_endings', true);
// Open file
$this->openFile($pFilename);
if (!$this->isValidFormat()) {
fclose($this->fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
}
$fileHandle = $this->fileHandle;
// Skip BOM, if any
$this->skipBOM();
$this->checkSeparator();
// Create new PHPExcel object
while ($objPHPExcel->getSheetCount() <= $this->sheetIndex) {
$objPHPExcel->createSheet();
}
$sheet = $objPHPExcel->setActiveSheetIndex($this->sheetIndex);
$escapeEnclosures = array( "\\" . $this->enclosure,
$this->enclosure . $this->enclosure
);
// Set our starting row based on whether we're in contiguous mode or not
$currentRow = 1;
if ($this->contiguous) {
$currentRow = ($this->contiguousRow == -1) ? $sheet->getHighestRow(): $this->contiguousRow;
}
// Loop through each line of the file in turn
while (($rowData = fgetcsv($fileHandle, 0, $this->delimiter, $this->enclosure)) !== false) {
$columnLetter = 'A';
foreach ($rowData as $rowDatum) {
if ($rowDatum != '' && $this->readFilter->readCell($columnLetter, $currentRow)) {
// Unescape enclosures
$rowDatum = str_replace($escapeEnclosures, $this->enclosure, $rowDatum);
// Convert encoding if necessary
if ($this->inputEncoding !== 'UTF-8') {
$rowDatum = PHPExcel_Shared_String::ConvertEncoding($rowDatum, 'UTF-8', $this->inputEncoding);
}
// Set cell value
$sheet->getCell($columnLetter . $currentRow)->setValue($rowDatum);
}
++$columnLetter;
}
++$currentRow;
}
// Close file
fclose($fileHandle);
if ($this->contiguous) {
$this->contiguousRow = $currentRow;
}
ini_set('auto_detect_line_endings', $lineEnding);
// Return
return $objPHPExcel;
}
/**
* Get delimiter
*
* @return string
*/
public function getDelimiter()
{
return $this->delimiter;
}
/**
* Set delimiter
*
* @param string $pValue Delimiter, defaults to ,
* @return PHPExcel_Reader_CSV
*/
public function setDelimiter($pValue = ',')
{
$this->delimiter = $pValue;
return $this;
}
/**
* Get enclosure
*
* @return string
*/
public function getEnclosure()
{
return $this->enclosure;
}
/**
* Set enclosure
*
* @param string $pValue Enclosure, defaults to "
* @return PHPExcel_Reader_CSV
*/
public function setEnclosure($pValue = '"')
{
if ($pValue == '') {
$pValue = '"';
}
$this->enclosure = $pValue;
return $this;
}
/**
* Get sheet index
*
* @return integer
*/
public function getSheetIndex()
{
return $this->sheetIndex;
}
/**
* Set sheet index
*
* @param integer $pValue Sheet index
* @return PHPExcel_Reader_CSV
*/
public function setSheetIndex($pValue = 0)
{
$this->sheetIndex = $pValue;
return $this;
}
/**
* Set Contiguous
*
* @param boolean $contiguous
*/
public function setContiguous($contiguous = false)
{
$this->contiguous = (bool) $contiguous;
if (!$contiguous) {
$this->contiguousRow = -1;
}
return $this;
}
/**
* Get Contiguous
*
* @return boolean
*/
public function getContiguous()
{
return $this->contiguous;
}
}

View file

@ -1,8 +1,18 @@
<?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel
* PHPExcel_Reader_DefaultReadFilter
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,39 +30,22 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Reader_DefaultReadFilter
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_DefaultReadFilter implements PHPExcel_Reader_IReadFilter
{
/**
* Should this cell be read?
*
* @param $column String column index
* @param $row Row index
* @param $worksheetName Optional worksheet name
* @return boolean
*/
public function readCell($column, $row, $worksheetName = '') {
return true;
}
/**
* Should this cell be read?
*
* @param $column Column address (as a string value like "A", or "IV")
* @param $row Row number
* @param $worksheetName Optional worksheet name
* @return boolean
*/
public function readCell($column, $row, $worksheetName = '')
{
return true;
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -18,500 +18,503 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Reader_Excel2007
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
* @category PHPExcel
* @package PHPExcel_Reader_Excel2007
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Reader_Excel2007_Chart
*
* @category PHPExcel
* @package PHPExcel_Reader_Excel2007
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @category PHPExcel
* @package PHPExcel_Reader_Excel2007
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_Excel2007_Chart
{
private static function _getAttribute($component, $name, $format) {
$attributes = $component->attributes();
if (isset($attributes[$name])) {
if ($format == 'string') {
return (string) $attributes[$name];
} elseif ($format == 'integer') {
return (integer) $attributes[$name];
} elseif ($format == 'boolean') {
return (boolean) ($attributes[$name] === '0' || $attributes[$name] !== 'true') ? false : true;
} else {
return (float) $attributes[$name];
}
}
return null;
} // function _getAttribute()
private static function getAttribute($component, $name, $format)
{
$attributes = $component->attributes();
if (isset($attributes[$name])) {
if ($format == 'string') {
return (string) $attributes[$name];
} elseif ($format == 'integer') {
return (integer) $attributes[$name];
} elseif ($format == 'boolean') {
return (boolean) ($attributes[$name] === '0' || $attributes[$name] !== 'true') ? false : true;
} else {
return (float) $attributes[$name];
}
}
return null;
}
private static function _readColor($color,$background=false) {
if (isset($color["rgb"])) {
return (string)$color["rgb"];
} else if (isset($color["indexed"])) {
return PHPExcel_Style_Color::indexedColor($color["indexed"]-7,$background)->getARGB();
}
}
private static function readColor($color, $background = false)
{
if (isset($color["rgb"])) {
return (string)$color["rgb"];
} elseif (isset($color["indexed"])) {
return PHPExcel_Style_Color::indexedColor($color["indexed"]-7, $background)->getARGB();
}
}
public static function readChart($chartElements, $chartName)
{
$namespacesChartMeta = $chartElements->getNamespaces(true);
$chartElementsC = $chartElements->children($namespacesChartMeta['c']);
$XaxisLabel = $YaxisLabel = $legend = $title = null;
$dispBlanksAs = $plotVisOnly = null;
foreach ($chartElementsC as $chartElementKey => $chartElement) {
switch ($chartElementKey) {
case "chart":
foreach ($chartElement as $chartDetailsKey => $chartDetails) {
$chartDetailsC = $chartDetails->children($namespacesChartMeta['c']);
switch ($chartDetailsKey) {
case "plotArea":
$plotAreaLayout = $XaxisLable = $YaxisLable = null;
$plotSeries = $plotAttributes = array();
foreach ($chartDetails as $chartDetailKey => $chartDetail) {
switch ($chartDetailKey) {
case "layout":
$plotAreaLayout = self::chartLayoutDetails($chartDetail, $namespacesChartMeta, 'plotArea');
break;
case "catAx":
if (isset($chartDetail->title)) {
$XaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta, 'cat');
}
break;
case "dateAx":
if (isset($chartDetail->title)) {
$XaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta, 'cat');
}
break;
case "valAx":
if (isset($chartDetail->title)) {
$YaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta, 'cat');
}
break;
case "barChart":
case "bar3DChart":
$barDirection = self::getAttribute($chartDetail->barDir, 'val', 'string');
$plotSer = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotDirection($barDirection);
$plotSeries[] = $plotSer;
$plotAttributes = self::readChartAttributes($chartDetail);
break;
case "lineChart":
case "line3DChart":
$plotSeries[] = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotAttributes = self::readChartAttributes($chartDetail);
break;
case "areaChart":
case "area3DChart":
$plotSeries[] = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotAttributes = self::readChartAttributes($chartDetail);
break;
case "doughnutChart":
case "pieChart":
case "pie3DChart":
$explosion = isset($chartDetail->ser->explosion);
$plotSer = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($explosion);
$plotSeries[] = $plotSer;
$plotAttributes = self::readChartAttributes($chartDetail);
break;
case "scatterChart":
$scatterStyle = self::getAttribute($chartDetail->scatterStyle, 'val', 'string');
$plotSer = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($scatterStyle);
$plotSeries[] = $plotSer;
$plotAttributes = self::readChartAttributes($chartDetail);
break;
case "bubbleChart":
$bubbleScale = self::getAttribute($chartDetail->bubbleScale, 'val', 'integer');
$plotSer = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($bubbleScale);
$plotSeries[] = $plotSer;
$plotAttributes = self::readChartAttributes($chartDetail);
break;
case "radarChart":
$radarStyle = self::getAttribute($chartDetail->radarStyle, 'val', 'string');
$plotSer = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($radarStyle);
$plotSeries[] = $plotSer;
$plotAttributes = self::readChartAttributes($chartDetail);
break;
case "surfaceChart":
case "surface3DChart":
$wireFrame = self::getAttribute($chartDetail->wireframe, 'val', 'boolean');
$plotSer = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($wireFrame);
$plotSeries[] = $plotSer;
$plotAttributes = self::readChartAttributes($chartDetail);
break;
case "stockChart":
$plotSeries[] = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotAttributes = self::readChartAttributes($plotAreaLayout);
break;
}
}
if ($plotAreaLayout == null) {
$plotAreaLayout = new PHPExcel_Chart_Layout();
}
$plotArea = new PHPExcel_Chart_PlotArea($plotAreaLayout, $plotSeries);
self::setChartAttributes($plotAreaLayout, $plotAttributes);
break;
case "plotVisOnly":
$plotVisOnly = self::getAttribute($chartDetails, 'val', 'string');
break;
case "dispBlanksAs":
$dispBlanksAs = self::getAttribute($chartDetails, 'val', 'string');
break;
case "title":
$title = self::chartTitle($chartDetails, $namespacesChartMeta, 'title');
break;
case "legend":
$legendPos = 'r';
$legendLayout = null;
$legendOverlay = false;
foreach ($chartDetails as $chartDetailKey => $chartDetail) {
switch ($chartDetailKey) {
case "legendPos":
$legendPos = self::getAttribute($chartDetail, 'val', 'string');
break;
case "overlay":
$legendOverlay = self::getAttribute($chartDetail, 'val', 'boolean');
break;
case "layout":
$legendLayout = self::chartLayoutDetails($chartDetail, $namespacesChartMeta, 'legend');
break;
}
}
$legend = new PHPExcel_Chart_Legend($legendPos, $legendLayout, $legendOverlay);
break;
}
}
}
}
$chart = new PHPExcel_Chart($chartName, $title, $legend, $plotArea, $plotVisOnly, $dispBlanksAs, $XaxisLabel, $YaxisLabel);
return $chart;
}
private static function chartTitle($titleDetails, $namespacesChartMeta, $type)
{
$caption = array();
$titleLayout = null;
foreach ($titleDetails as $titleDetailKey => $chartDetail) {
switch ($titleDetailKey) {
case "tx":
$titleDetails = $chartDetail->rich->children($namespacesChartMeta['a']);
foreach ($titleDetails as $titleKey => $titleDetail) {
switch ($titleKey) {
case "p":
$titleDetailPart = $titleDetail->children($namespacesChartMeta['a']);
$caption[] = self::parseRichText($titleDetailPart);
}
}
break;
case "layout":
$titleLayout = self::chartLayoutDetails($chartDetail, $namespacesChartMeta);
break;
}
}
return new PHPExcel_Chart_Title($caption, $titleLayout);
}
private static function chartLayoutDetails($chartDetail, $namespacesChartMeta)
{
if (!isset($chartDetail->manualLayout)) {
return null;
}
$details = $chartDetail->manualLayout->children($namespacesChartMeta['c']);
if (is_null($details)) {
return null;
}
$layout = array();
foreach ($details as $detailKey => $detail) {
// echo $detailKey, ' => ',self::getAttribute($detail, 'val', 'string'),PHP_EOL;
$layout[$detailKey] = self::getAttribute($detail, 'val', 'string');
}
return new PHPExcel_Chart_Layout($layout);
}
private static function chartDataSeries($chartDetail, $namespacesChartMeta, $plotType)
{
$multiSeriesType = null;
$smoothLine = false;
$seriesLabel = $seriesCategory = $seriesValues = $plotOrder = array();
$seriesDetailSet = $chartDetail->children($namespacesChartMeta['c']);
foreach ($seriesDetailSet as $seriesDetailKey => $seriesDetails) {
switch ($seriesDetailKey) {
case "grouping":
$multiSeriesType = self::getAttribute($chartDetail->grouping, 'val', 'string');
break;
case "ser":
$marker = null;
foreach ($seriesDetails as $seriesKey => $seriesDetail) {
switch ($seriesKey) {
case "idx":
$seriesIndex = self::getAttribute($seriesDetail, 'val', 'integer');
break;
case "order":
$seriesOrder = self::getAttribute($seriesDetail, 'val', 'integer');
$plotOrder[$seriesIndex] = $seriesOrder;
break;
case "tx":
$seriesLabel[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta);
break;
case "marker":
$marker = self::getAttribute($seriesDetail->symbol, 'val', 'string');
break;
case "smooth":
$smoothLine = self::getAttribute($seriesDetail, 'val', 'boolean');
break;
case "cat":
$seriesCategory[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta);
break;
case "val":
$seriesValues[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
break;
case "xVal":
$seriesCategory[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
break;
case "yVal":
$seriesValues[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
break;
}
}
}
}
return new PHPExcel_Chart_DataSeries($plotType, $multiSeriesType, $plotOrder, $seriesLabel, $seriesCategory, $seriesValues, $smoothLine);
}
public static function readChart($chartElements,$chartName) {
$namespacesChartMeta = $chartElements->getNamespaces(true);
$chartElementsC = $chartElements->children($namespacesChartMeta['c']);
private static function chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker = null, $smoothLine = false)
{
if (isset($seriesDetail->strRef)) {
$seriesSource = (string) $seriesDetail->strRef->f;
$seriesData = self::chartDataSeriesValues($seriesDetail->strRef->strCache->children($namespacesChartMeta['c']), 's');
$XaxisLabel = $YaxisLabel = $legend = $title = NULL;
$dispBlanksAs = $plotVisOnly = NULL;
return new PHPExcel_Chart_DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine);
} elseif (isset($seriesDetail->numRef)) {
$seriesSource = (string) $seriesDetail->numRef->f;
$seriesData = self::chartDataSeriesValues($seriesDetail->numRef->numCache->children($namespacesChartMeta['c']));
foreach($chartElementsC as $chartElementKey => $chartElement) {
switch ($chartElementKey) {
case "chart":
foreach($chartElement as $chartDetailsKey => $chartDetails) {
$chartDetailsC = $chartDetails->children($namespacesChartMeta['c']);
switch ($chartDetailsKey) {
case "plotArea":
$plotAreaLayout = $XaxisLable = $YaxisLable = null;
$plotSeries = $plotAttributes = array();
foreach($chartDetails as $chartDetailKey => $chartDetail) {
switch ($chartDetailKey) {
case "layout":
$plotAreaLayout = self::_chartLayoutDetails($chartDetail,$namespacesChartMeta,'plotArea');
break;
case "catAx":
if (isset($chartDetail->title)) {
$XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']),$namespacesChartMeta,'cat');
}
break;
case "dateAx":
if (isset($chartDetail->title)) {
$XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']),$namespacesChartMeta,'cat');
}
break;
case "valAx":
if (isset($chartDetail->title)) {
$YaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']),$namespacesChartMeta,'cat');
}
break;
case "barChart":
case "bar3DChart":
$barDirection = self::_getAttribute($chartDetail->barDir, 'val', 'string');
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
$plotSer->setPlotDirection($barDirection);
$plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail);
break;
case "lineChart":
case "line3DChart":
$plotSeries[] = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
$plotAttributes = self::_readChartAttributes($chartDetail);
break;
case "areaChart":
case "area3DChart":
$plotSeries[] = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
$plotAttributes = self::_readChartAttributes($chartDetail);
break;
case "doughnutChart":
case "pieChart":
case "pie3DChart":
$explosion = isset($chartDetail->ser->explosion);
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
$plotSer->setPlotStyle($explosion);
$plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail);
break;
case "scatterChart":
$scatterStyle = self::_getAttribute($chartDetail->scatterStyle, 'val', 'string');
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
$plotSer->setPlotStyle($scatterStyle);
$plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail);
break;
case "bubbleChart":
$bubbleScale = self::_getAttribute($chartDetail->bubbleScale, 'val', 'integer');
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
$plotSer->setPlotStyle($bubbleScale);
$plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail);
break;
case "radarChart":
$radarStyle = self::_getAttribute($chartDetail->radarStyle, 'val', 'string');
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
$plotSer->setPlotStyle($radarStyle);
$plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail);
break;
case "surfaceChart":
case "surface3DChart":
$wireFrame = self::_getAttribute($chartDetail->wireframe, 'val', 'boolean');
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
$plotSer->setPlotStyle($wireFrame);
$plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail);
break;
case "stockChart":
$plotSeries[] = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
$plotAttributes = self::_readChartAttributes($plotAreaLayout);
break;
}
}
if ($plotAreaLayout == NULL) {
$plotAreaLayout = new PHPExcel_Chart_Layout();
}
$plotArea = new PHPExcel_Chart_PlotArea($plotAreaLayout,$plotSeries);
self::_setChartAttributes($plotAreaLayout,$plotAttributes);
break;
case "plotVisOnly":
$plotVisOnly = self::_getAttribute($chartDetails, 'val', 'string');
break;
case "dispBlanksAs":
$dispBlanksAs = self::_getAttribute($chartDetails, 'val', 'string');
break;
case "title":
$title = self::_chartTitle($chartDetails,$namespacesChartMeta,'title');
break;
case "legend":
$legendPos = 'r';
$legendLayout = null;
$legendOverlay = false;
foreach($chartDetails as $chartDetailKey => $chartDetail) {
switch ($chartDetailKey) {
case "legendPos":
$legendPos = self::_getAttribute($chartDetail, 'val', 'string');
break;
case "overlay":
$legendOverlay = self::_getAttribute($chartDetail, 'val', 'boolean');
break;
case "layout":
$legendLayout = self::_chartLayoutDetails($chartDetail,$namespacesChartMeta,'legend');
break;
}
}
$legend = new PHPExcel_Chart_Legend($legendPos, $legendLayout, $legendOverlay);
break;
}
}
}
}
$chart = new PHPExcel_Chart($chartName,$title,$legend,$plotArea,$plotVisOnly,$dispBlanksAs,$XaxisLabel,$YaxisLabel);
return new PHPExcel_Chart_DataSeriesValues('Number', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine);
} elseif (isset($seriesDetail->multiLvlStrRef)) {
$seriesSource = (string) $seriesDetail->multiLvlStrRef->f;
$seriesData = self::chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlStrRef->multiLvlStrCache->children($namespacesChartMeta['c']), 's');
$seriesData['pointCount'] = count($seriesData['dataValues']);
return $chart;
} // function readChart()
return new PHPExcel_Chart_DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine);
} elseif (isset($seriesDetail->multiLvlNumRef)) {
$seriesSource = (string) $seriesDetail->multiLvlNumRef->f;
$seriesData = self::chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlNumRef->multiLvlNumCache->children($namespacesChartMeta['c']), 's');
$seriesData['pointCount'] = count($seriesData['dataValues']);
return new PHPExcel_Chart_DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine);
}
return null;
}
private static function _chartTitle($titleDetails,$namespacesChartMeta,$type) {
$caption = array();
$titleLayout = null;
foreach($titleDetails as $titleDetailKey => $chartDetail) {
switch ($titleDetailKey) {
case "tx":
$titleDetails = $chartDetail->rich->children($namespacesChartMeta['a']);
foreach($titleDetails as $titleKey => $titleDetail) {
switch ($titleKey) {
case "p":
$titleDetailPart = $titleDetail->children($namespacesChartMeta['a']);
$caption[] = self::_parseRichText($titleDetailPart);
}
}
break;
case "layout":
$titleLayout = self::_chartLayoutDetails($chartDetail,$namespacesChartMeta);
break;
}
}
private static function chartDataSeriesValues($seriesValueSet, $dataType = 'n')
{
$seriesVal = array();
$formatCode = '';
$pointCount = 0;
return new PHPExcel_Chart_Title($caption, $titleLayout);
} // function _chartTitle()
foreach ($seriesValueSet as $seriesValueIdx => $seriesValue) {
switch ($seriesValueIdx) {
case 'ptCount':
$pointCount = self::getAttribute($seriesValue, 'val', 'integer');
break;
case 'formatCode':
$formatCode = (string) $seriesValue;
break;
case 'pt':
$pointVal = self::getAttribute($seriesValue, 'idx', 'integer');
if ($dataType == 's') {
$seriesVal[$pointVal] = (string) $seriesValue->v;
} else {
$seriesVal[$pointVal] = (float) $seriesValue->v;
}
break;
}
}
return array(
'formatCode' => $formatCode,
'pointCount' => $pointCount,
'dataValues' => $seriesVal
);
}
private static function _chartLayoutDetails($chartDetail,$namespacesChartMeta) {
if (!isset($chartDetail->manualLayout)) {
return null;
}
$details = $chartDetail->manualLayout->children($namespacesChartMeta['c']);
if (is_null($details)) {
return null;
}
$layout = array();
foreach($details as $detailKey => $detail) {
// echo $detailKey,' => ',self::_getAttribute($detail, 'val', 'string'),PHP_EOL;
$layout[$detailKey] = self::_getAttribute($detail, 'val', 'string');
}
return new PHPExcel_Chart_Layout($layout);
} // function _chartLayoutDetails()
private static function chartDataSeriesValuesMultiLevel($seriesValueSet, $dataType = 'n')
{
$seriesVal = array();
$formatCode = '';
$pointCount = 0;
foreach ($seriesValueSet->lvl as $seriesLevelIdx => $seriesLevel) {
foreach ($seriesLevel as $seriesValueIdx => $seriesValue) {
switch ($seriesValueIdx) {
case 'ptCount':
$pointCount = self::getAttribute($seriesValue, 'val', 'integer');
break;
case 'formatCode':
$formatCode = (string) $seriesValue;
break;
case 'pt':
$pointVal = self::getAttribute($seriesValue, 'idx', 'integer');
if ($dataType == 's') {
$seriesVal[$pointVal][] = (string) $seriesValue->v;
} else {
$seriesVal[$pointVal][] = (float) $seriesValue->v;
}
break;
}
}
}
private static function _chartDataSeries($chartDetail,$namespacesChartMeta,$plotType) {
$multiSeriesType = NULL;
$smoothLine = false;
$seriesLabel = $seriesCategory = $seriesValues = $plotOrder = array();
return array(
'formatCode' => $formatCode,
'pointCount' => $pointCount,
'dataValues' => $seriesVal
);
}
$seriesDetailSet = $chartDetail->children($namespacesChartMeta['c']);
foreach($seriesDetailSet as $seriesDetailKey => $seriesDetails) {
switch ($seriesDetailKey) {
case "grouping":
$multiSeriesType = self::_getAttribute($chartDetail->grouping, 'val', 'string');
break;
case "ser":
$marker = NULL;
foreach($seriesDetails as $seriesKey => $seriesDetail) {
switch ($seriesKey) {
case "idx":
$seriesIndex = self::_getAttribute($seriesDetail, 'val', 'integer');
break;
case "order":
$seriesOrder = self::_getAttribute($seriesDetail, 'val', 'integer');
$plotOrder[$seriesIndex] = $seriesOrder;
break;
case "tx":
$seriesLabel[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta);
break;
case "marker":
$marker = self::_getAttribute($seriesDetail->symbol, 'val', 'string');
break;
case "smooth":
$smoothLine = self::_getAttribute($seriesDetail, 'val', 'boolean');
break;
case "cat":
$seriesCategory[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta);
break;
case "val":
$seriesValues[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta,$marker);
break;
case "xVal":
$seriesCategory[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta,$marker);
break;
case "yVal":
$seriesValues[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta,$marker);
break;
}
}
}
}
return new PHPExcel_Chart_DataSeries($plotType,$multiSeriesType,$plotOrder,$seriesLabel,$seriesCategory,$seriesValues,$smoothLine);
} // function _chartDataSeries()
private static function parseRichText($titleDetailPart = null)
{
$value = new PHPExcel_RichText();
foreach ($titleDetailPart as $titleDetailElementKey => $titleDetailElement) {
if (isset($titleDetailElement->t)) {
$objText = $value->createTextRun((string) $titleDetailElement->t);
}
if (isset($titleDetailElement->rPr)) {
if (isset($titleDetailElement->rPr->rFont["val"])) {
$objText->getFont()->setName((string) $titleDetailElement->rPr->rFont["val"]);
}
private static function _chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker = null, $smoothLine = false) {
if (isset($seriesDetail->strRef)) {
$seriesSource = (string) $seriesDetail->strRef->f;
$seriesData = self::_chartDataSeriesValues($seriesDetail->strRef->strCache->children($namespacesChartMeta['c']),'s');
$fontSize = (self::getAttribute($titleDetailElement->rPr, 'sz', 'integer'));
if (!is_null($fontSize)) {
$objText->getFont()->setSize(floor($fontSize / 100));
}
return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
} elseif (isset($seriesDetail->numRef)) {
$seriesSource = (string) $seriesDetail->numRef->f;
$seriesData = self::_chartDataSeriesValues($seriesDetail->numRef->numCache->children($namespacesChartMeta['c']));
$fontColor = (self::getAttribute($titleDetailElement->rPr, 'color', 'string'));
if (!is_null($fontColor)) {
$objText->getFont()->setColor(new PHPExcel_Style_Color(self::readColor($fontColor)));
}
return new PHPExcel_Chart_DataSeriesValues('Number',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
} elseif (isset($seriesDetail->multiLvlStrRef)) {
$seriesSource = (string) $seriesDetail->multiLvlStrRef->f;
$seriesData = self::_chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlStrRef->multiLvlStrCache->children($namespacesChartMeta['c']),'s');
$seriesData['pointCount'] = count($seriesData['dataValues']);
$bold = self::getAttribute($titleDetailElement->rPr, 'b', 'boolean');
if (!is_null($bold)) {
$objText->getFont()->setBold($bold);
}
return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
} elseif (isset($seriesDetail->multiLvlNumRef)) {
$seriesSource = (string) $seriesDetail->multiLvlNumRef->f;
$seriesData = self::_chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlNumRef->multiLvlNumCache->children($namespacesChartMeta['c']),'s');
$seriesData['pointCount'] = count($seriesData['dataValues']);
$italic = self::getAttribute($titleDetailElement->rPr, 'i', 'boolean');
if (!is_null($italic)) {
$objText->getFont()->setItalic($italic);
}
return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
}
return null;
} // function _chartDataSeriesValueSet()
$baseline = self::getAttribute($titleDetailElement->rPr, 'baseline', 'integer');
if (!is_null($baseline)) {
if ($baseline > 0) {
$objText->getFont()->setSuperScript(true);
} elseif ($baseline < 0) {
$objText->getFont()->setSubScript(true);
}
}
$underscore = (self::getAttribute($titleDetailElement->rPr, 'u', 'string'));
if (!is_null($underscore)) {
if ($underscore == 'sng') {
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
} elseif ($underscore == 'dbl') {
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_DOUBLE);
} else {
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_NONE);
}
}
private static function _chartDataSeriesValues($seriesValueSet,$dataType='n') {
$seriesVal = array();
$formatCode = '';
$pointCount = 0;
$strikethrough = (self::getAttribute($titleDetailElement->rPr, 's', 'string'));
if (!is_null($strikethrough)) {
if ($strikethrough == 'noStrike') {
$objText->getFont()->setStrikethrough(false);
} else {
$objText->getFont()->setStrikethrough(true);
}
}
}
}
foreach($seriesValueSet as $seriesValueIdx => $seriesValue) {
switch ($seriesValueIdx) {
case 'ptCount':
$pointCount = self::_getAttribute($seriesValue, 'val', 'integer');
break;
case 'formatCode':
$formatCode = (string) $seriesValue;
break;
case 'pt':
$pointVal = self::_getAttribute($seriesValue, 'idx', 'integer');
if ($dataType == 's') {
$seriesVal[$pointVal] = (string) $seriesValue->v;
} else {
$seriesVal[$pointVal] = (float) $seriesValue->v;
}
break;
}
}
return $value;
}
if (empty($seriesVal)) {
$seriesVal = NULL;
}
private static function readChartAttributes($chartDetail)
{
$plotAttributes = array();
if (isset($chartDetail->dLbls)) {
if (isset($chartDetail->dLbls->howLegendKey)) {
$plotAttributes['showLegendKey'] = self::getAttribute($chartDetail->dLbls->showLegendKey, 'val', 'string');
}
if (isset($chartDetail->dLbls->showVal)) {
$plotAttributes['showVal'] = self::getAttribute($chartDetail->dLbls->showVal, 'val', 'string');
}
if (isset($chartDetail->dLbls->showCatName)) {
$plotAttributes['showCatName'] = self::getAttribute($chartDetail->dLbls->showCatName, 'val', 'string');
}
if (isset($chartDetail->dLbls->showSerName)) {
$plotAttributes['showSerName'] = self::getAttribute($chartDetail->dLbls->showSerName, 'val', 'string');
}
if (isset($chartDetail->dLbls->showPercent)) {
$plotAttributes['showPercent'] = self::getAttribute($chartDetail->dLbls->showPercent, 'val', 'string');
}
if (isset($chartDetail->dLbls->showBubbleSize)) {
$plotAttributes['showBubbleSize'] = self::getAttribute($chartDetail->dLbls->showBubbleSize, 'val', 'string');
}
if (isset($chartDetail->dLbls->showLeaderLines)) {
$plotAttributes['showLeaderLines'] = self::getAttribute($chartDetail->dLbls->showLeaderLines, 'val', 'string');
}
}
return array( 'formatCode' => $formatCode,
'pointCount' => $pointCount,
'dataValues' => $seriesVal
);
} // function _chartDataSeriesValues()
private static function _chartDataSeriesValuesMultiLevel($seriesValueSet,$dataType='n') {
$seriesVal = array();
$formatCode = '';
$pointCount = 0;
foreach($seriesValueSet->lvl as $seriesLevelIdx => $seriesLevel) {
foreach($seriesLevel as $seriesValueIdx => $seriesValue) {
switch ($seriesValueIdx) {
case 'ptCount':
$pointCount = self::_getAttribute($seriesValue, 'val', 'integer');
break;
case 'formatCode':
$formatCode = (string) $seriesValue;
break;
case 'pt':
$pointVal = self::_getAttribute($seriesValue, 'idx', 'integer');
if ($dataType == 's') {
$seriesVal[$pointVal][] = (string) $seriesValue->v;
} else {
$seriesVal[$pointVal][] = (float) $seriesValue->v;
}
break;
}
}
}
return array( 'formatCode' => $formatCode,
'pointCount' => $pointCount,
'dataValues' => $seriesVal
);
} // function _chartDataSeriesValuesMultiLevel()
private static function _parseRichText($titleDetailPart = null) {
$value = new PHPExcel_RichText();
foreach($titleDetailPart as $titleDetailElementKey => $titleDetailElement) {
if (isset($titleDetailElement->t)) {
$objText = $value->createTextRun( (string) $titleDetailElement->t );
}
if (isset($titleDetailElement->rPr)) {
if (isset($titleDetailElement->rPr->rFont["val"])) {
$objText->getFont()->setName((string) $titleDetailElement->rPr->rFont["val"]);
}
$fontSize = (self::_getAttribute($titleDetailElement->rPr, 'sz', 'integer'));
if (!is_null($fontSize)) {
$objText->getFont()->setSize(floor($fontSize / 100));
}
$fontColor = (self::_getAttribute($titleDetailElement->rPr, 'color', 'string'));
if (!is_null($fontColor)) {
$objText->getFont()->setColor( new PHPExcel_Style_Color( self::_readColor($fontColor) ) );
}
$bold = self::_getAttribute($titleDetailElement->rPr, 'b', 'boolean');
if (!is_null($bold)) {
$objText->getFont()->setBold($bold);
}
$italic = self::_getAttribute($titleDetailElement->rPr, 'i', 'boolean');
if (!is_null($italic)) {
$objText->getFont()->setItalic($italic);
}
$baseline = self::_getAttribute($titleDetailElement->rPr, 'baseline', 'integer');
if (!is_null($baseline)) {
if ($baseline > 0) {
$objText->getFont()->setSuperScript(true);
} elseif($baseline < 0) {
$objText->getFont()->setSubScript(true);
}
}
$underscore = (self::_getAttribute($titleDetailElement->rPr, 'u', 'string'));
if (!is_null($underscore)) {
if ($underscore == 'sng') {
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
} elseif($underscore == 'dbl') {
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_DOUBLE);
} else {
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_NONE);
}
}
$strikethrough = (self::_getAttribute($titleDetailElement->rPr, 's', 'string'));
if (!is_null($strikethrough)) {
if ($strikethrough == 'noStrike') {
$objText->getFont()->setStrikethrough(false);
} else {
$objText->getFont()->setStrikethrough(true);
}
}
}
}
return $value;
}
private static function _readChartAttributes($chartDetail) {
$plotAttributes = array();
if (isset($chartDetail->dLbls)) {
if (isset($chartDetail->dLbls->howLegendKey)) {
$plotAttributes['showLegendKey'] = self::_getAttribute($chartDetail->dLbls->showLegendKey, 'val', 'string');
}
if (isset($chartDetail->dLbls->showVal)) {
$plotAttributes['showVal'] = self::_getAttribute($chartDetail->dLbls->showVal, 'val', 'string');
}
if (isset($chartDetail->dLbls->showCatName)) {
$plotAttributes['showCatName'] = self::_getAttribute($chartDetail->dLbls->showCatName, 'val', 'string');
}
if (isset($chartDetail->dLbls->showSerName)) {
$plotAttributes['showSerName'] = self::_getAttribute($chartDetail->dLbls->showSerName, 'val', 'string');
}
if (isset($chartDetail->dLbls->showPercent)) {
$plotAttributes['showPercent'] = self::_getAttribute($chartDetail->dLbls->showPercent, 'val', 'string');
}
if (isset($chartDetail->dLbls->showBubbleSize)) {
$plotAttributes['showBubbleSize'] = self::_getAttribute($chartDetail->dLbls->showBubbleSize, 'val', 'string');
}
if (isset($chartDetail->dLbls->showLeaderLines)) {
$plotAttributes['showLeaderLines'] = self::_getAttribute($chartDetail->dLbls->showLeaderLines, 'val', 'string');
}
}
return $plotAttributes;
}
private static function _setChartAttributes($plotArea,$plotAttributes)
{
foreach($plotAttributes as $plotAttributeKey => $plotAttributeValue) {
switch($plotAttributeKey) {
case 'showLegendKey' :
$plotArea->setShowLegendKey($plotAttributeValue);
break;
case 'showVal' :
$plotArea->setShowVal($plotAttributeValue);
break;
case 'showCatName' :
$plotArea->setShowCatName($plotAttributeValue);
break;
case 'showSerName' :
$plotArea->setShowSerName($plotAttributeValue);
break;
case 'showPercent' :
$plotArea->setShowPercent($plotAttributeValue);
break;
case 'showBubbleSize' :
$plotArea->setShowBubbleSize($plotAttributeValue);
break;
case 'showLeaderLines' :
$plotArea->setShowLeaderLines($plotAttributeValue);
break;
}
}
}
return $plotAttributes;
}
private static function setChartAttributes($plotArea, $plotAttributes)
{
foreach ($plotAttributes as $plotAttributeKey => $plotAttributeValue) {
switch ($plotAttributeKey) {
case 'showLegendKey':
$plotArea->setShowLegendKey($plotAttributeValue);
break;
case 'showVal':
$plotArea->setShowVal($plotAttributeValue);
break;
case 'showCatName':
$plotArea->setShowCatName($plotAttributeValue);
break;
case 'showSerName':
$plotArea->setShowSerName($plotAttributeValue);
break;
case 'showPercent':
$plotArea->setShowPercent($plotAttributeValue);
break;
case 'showBubbleSize':
$plotArea->setShowBubbleSize($plotAttributeValue);
break;
case 'showLeaderLines':
$plotArea->setShowLeaderLines($plotAttributeValue);
break;
}
}
}
}

View file

@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,8 +20,8 @@
*
* @category PHPExcel
* @package PHPExcel_Reader_Excel2007
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
@ -31,69 +31,70 @@
*
* @category PHPExcel
* @package PHPExcel_Reader_Excel2007
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_Excel2007_Theme
{
/**
* Theme Name
*
* @var string
*/
private $_themeName;
/**
* Theme Name
*
* @var string
*/
private $themeName;
/**
* Colour Scheme Name
*
* @var string
*/
private $_colourSchemeName;
/**
* Colour Scheme Name
*
* @var string
*/
private $colourSchemeName;
/**
* Colour Map indexed by position
*
* @var array of string
*/
private $_colourMapValues;
/**
* Colour Map indexed by position
*
* @var array of string
*/
private $colourMapValues;
/**
* Colour Map
*
* @var array of string
*/
private $_colourMap;
/**
* Colour Map
*
* @var array of string
*/
private $colourMap;
/**
* Create a new PHPExcel_Theme
*
*
*/
public function __construct($themeName,$colourSchemeName,$colourMap)
public function __construct($themeName, $colourSchemeName, $colourMap)
{
// Initialise values
$this->_themeName = $themeName;
$this->_colourSchemeName = $colourSchemeName;
$this->_colourMap = $colourMap;
// Initialise values
$this->themeName = $themeName;
$this->colourSchemeName = $colourSchemeName;
$this->colourMap = $colourMap;
}
/**
* Get Theme Name
*
* @return string
*/
public function getThemeName()
{
return $this->_themeName;
}
/**
* Get Theme Name
*
* @return string
*/
public function getThemeName()
{
return $this->themeName;
}
/**
* Get colour Scheme Name
*
* @return string
*/
public function getColourSchemeName() {
return $this->_colourSchemeName;
public function getColourSchemeName()
{
return $this->colourSchemeName;
}
/**
@ -101,24 +102,26 @@ class PHPExcel_Reader_Excel2007_Theme
*
* @return string
*/
public function getColourByIndex($index=0) {
if (isset($this->_colourMap[$index])) {
return $this->_colourMap[$index];
}
return null;
public function getColourByIndex($index = 0)
{
if (isset($this->colourMap[$index])) {
return $this->colourMap[$index];
}
return null;
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if ((is_object($value)) && ($key != '_parent')) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if ((is_object($value)) && ($key != '_parent')) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,32 @@
<?php
class PHPExcel_Reader_Excel5_Color
{
/**
* Read color
*
* @param int $color Indexed color
* @param array $palette Color palette
* @return array RGB color value, example: array('rgb' => 'FF0000')
*/
public static function map($color, $palette, $version)
{
if ($color <= 0x07 || $color >= 0x40) {
// special built-in color
return PHPExcel_Reader_Excel5_Color_BuiltIn::lookup($color);
} elseif (isset($palette) && isset($palette[$color - 8])) {
// palette color, color index 0x08 maps to pallete index 0
return $palette[$color - 8];
} else {
// default color table
if ($version == PHPExcel_Reader_Excel5::XLS_BIFF8) {
return PHPExcel_Reader_Excel5_Color_BIFF8::lookup($color);
} else {
// BIFF5
return PHPExcel_Reader_Excel5_Color_BIFF5::lookup($color);
}
}
return $color;
}
}

View file

@ -0,0 +1,77 @@
<?php
class PHPExcel_Reader_Excel5_Color_BIFF5
{
protected static $map = array(
0x08 => '000000',
0x09 => 'FFFFFF',
0x0A => 'FF0000',
0x0B => '00FF00',
0x0C => '0000FF',
0x0D => 'FFFF00',
0x0E => 'FF00FF',
0x0F => '00FFFF',
0x10 => '800000',
0x11 => '008000',
0x12 => '000080',
0x13 => '808000',
0x14 => '800080',
0x15 => '008080',
0x16 => 'C0C0C0',
0x17 => '808080',
0x18 => '8080FF',
0x19 => '802060',
0x1A => 'FFFFC0',
0x1B => 'A0E0F0',
0x1C => '600080',
0x1D => 'FF8080',
0x1E => '0080C0',
0x1F => 'C0C0FF',
0x20 => '000080',
0x21 => 'FF00FF',
0x22 => 'FFFF00',
0x23 => '00FFFF',
0x24 => '800080',
0x25 => '800000',
0x26 => '008080',
0x27 => '0000FF',
0x28 => '00CFFF',
0x29 => '69FFFF',
0x2A => 'E0FFE0',
0x2B => 'FFFF80',
0x2C => 'A6CAF0',
0x2D => 'DD9CB3',
0x2E => 'B38FEE',
0x2F => 'E3E3E3',
0x30 => '2A6FF9',
0x31 => '3FB8CD',
0x32 => '488436',
0x33 => '958C41',
0x34 => '8E5E42',
0x35 => 'A0627A',
0x36 => '624FAC',
0x37 => '969696',
0x38 => '1D2FBE',
0x39 => '286676',
0x3A => '004500',
0x3B => '453E01',
0x3C => '6A2813',
0x3D => '85396A',
0x3E => '4A3285',
0x3F => '424242',
);
/**
* Map color array from BIFF5 built-in color index
*
* @param int $color
* @return array
*/
public static function lookup($color)
{
if (isset(self::$map[$color])) {
return array('rgb' => self::$map[$color]);
}
return array('rgb' => '000000');
}
}

View file

@ -0,0 +1,77 @@
<?php
class PHPExcel_Reader_Excel5_Color_BIFF8
{
protected static $map = array(
0x08 => '000000',
0x09 => 'FFFFFF',
0x0A => 'FF0000',
0x0B => '00FF00',
0x0C => '0000FF',
0x0D => 'FFFF00',
0x0E => 'FF00FF',
0x0F => '00FFFF',
0x10 => '800000',
0x11 => '008000',
0x12 => '000080',
0x13 => '808000',
0x14 => '800080',
0x15 => '008080',
0x16 => 'C0C0C0',
0x17 => '808080',
0x18 => '9999FF',
0x19 => '993366',
0x1A => 'FFFFCC',
0x1B => 'CCFFFF',
0x1C => '660066',
0x1D => 'FF8080',
0x1E => '0066CC',
0x1F => 'CCCCFF',
0x20 => '000080',
0x21 => 'FF00FF',
0x22 => 'FFFF00',
0x23 => '00FFFF',
0x24 => '800080',
0x25 => '800000',
0x26 => '008080',
0x27 => '0000FF',
0x28 => '00CCFF',
0x29 => 'CCFFFF',
0x2A => 'CCFFCC',
0x2B => 'FFFF99',
0x2C => '99CCFF',
0x2D => 'FF99CC',
0x2E => 'CC99FF',
0x2F => 'FFCC99',
0x30 => '3366FF',
0x31 => '33CCCC',
0x32 => '99CC00',
0x33 => 'FFCC00',
0x34 => 'FF9900',
0x35 => 'FF6600',
0x36 => '666699',
0x37 => '969696',
0x38 => '003366',
0x39 => '339966',
0x3A => '003300',
0x3B => '333300',
0x3C => '993300',
0x3D => '993366',
0x3E => '333399',
0x3F => '333333',
);
/**
* Map color array from BIFF8 built-in color index
*
* @param int $color
* @return array
*/
public static function lookup($color)
{
if (isset(self::$map[$color])) {
return array('rgb' => self::$map[$color]);
}
return array('rgb' => '000000');
}
}

View file

@ -0,0 +1,31 @@
<?php
class PHPExcel_Reader_Excel5_Color_BuiltIn
{
protected static $map = array(
0x00 => '000000',
0x01 => 'FFFFFF',
0x02 => 'FF0000',
0x03 => '00FF00',
0x04 => '0000FF',
0x05 => 'FFFF00',
0x06 => 'FF00FF',
0x07 => '00FFFF',
0x40 => '000000', // system window text color
0x41 => 'FFFFFF', // system window background color
);
/**
* Map built-in color to RGB value
*
* @param int $color Indexed color
* @return array
*/
public static function lookup($color)
{
if (isset(self::$map[$color])) {
return array('rgb' => self::$map[$color]);
}
return array('rgb' => '000000');
}
}

View file

@ -0,0 +1,28 @@
<?php
class PHPExcel_Reader_Excel5_ErrorCode
{
protected static $map = array(
0x00 => '#NULL!',
0x07 => '#DIV/0!',
0x0F => '#VALUE!',
0x17 => '#REF!',
0x1D => '#NAME?',
0x24 => '#NUM!',
0x2A => '#N/A',
);
/**
* Map error code, e.g. '#N/A'
*
* @param int $code
* @return string
*/
public static function lookup($code)
{
if (isset(self::$map[$code])) {
return self::$map[$code];
}
return false;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,203 @@
<?php
/**
* PHPExcel_Reader_Excel5_MD5
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Reader_Excel5
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Reader_Excel5_MD5
{
// Context
private $a;
private $b;
private $c;
private $d;
/**
* MD5 stream constructor
*/
public function __construct()
{
$this->reset();
}
/**
* Reset the MD5 stream context
*/
public function reset()
{
$this->a = 0x67452301;
$this->b = 0xEFCDAB89;
$this->c = 0x98BADCFE;
$this->d = 0x10325476;
}
/**
* Get MD5 stream context
*
* @return string
*/
public function getContext()
{
$s = '';
foreach (array('a', 'b', 'c', 'd') as $i) {
$v = $this->{$i};
$s .= chr($v & 0xff);
$s .= chr(($v >> 8) & 0xff);
$s .= chr(($v >> 16) & 0xff);
$s .= chr(($v >> 24) & 0xff);
}
return $s;
}
/**
* Add data to context
*
* @param string $data Data to add
*/
public function add($data)
{
$words = array_values(unpack('V16', $data));
$A = $this->a;
$B = $this->b;
$C = $this->c;
$D = $this->d;
$F = array('PHPExcel_Reader_Excel5_MD5','f');
$G = array('PHPExcel_Reader_Excel5_MD5','g');
$H = array('PHPExcel_Reader_Excel5_MD5','h');
$I = array('PHPExcel_Reader_Excel5_MD5','i');
/* ROUND 1 */
self::step($F, $A, $B, $C, $D, $words[0], 7, 0xd76aa478);
self::step($F, $D, $A, $B, $C, $words[1], 12, 0xe8c7b756);
self::step($F, $C, $D, $A, $B, $words[2], 17, 0x242070db);
self::step($F, $B, $C, $D, $A, $words[3], 22, 0xc1bdceee);
self::step($F, $A, $B, $C, $D, $words[4], 7, 0xf57c0faf);
self::step($F, $D, $A, $B, $C, $words[5], 12, 0x4787c62a);
self::step($F, $C, $D, $A, $B, $words[6], 17, 0xa8304613);
self::step($F, $B, $C, $D, $A, $words[7], 22, 0xfd469501);
self::step($F, $A, $B, $C, $D, $words[8], 7, 0x698098d8);
self::step($F, $D, $A, $B, $C, $words[9], 12, 0x8b44f7af);
self::step($F, $C, $D, $A, $B, $words[10], 17, 0xffff5bb1);
self::step($F, $B, $C, $D, $A, $words[11], 22, 0x895cd7be);
self::step($F, $A, $B, $C, $D, $words[12], 7, 0x6b901122);
self::step($F, $D, $A, $B, $C, $words[13], 12, 0xfd987193);
self::step($F, $C, $D, $A, $B, $words[14], 17, 0xa679438e);
self::step($F, $B, $C, $D, $A, $words[15], 22, 0x49b40821);
/* ROUND 2 */
self::step($G, $A, $B, $C, $D, $words[1], 5, 0xf61e2562);
self::step($G, $D, $A, $B, $C, $words[6], 9, 0xc040b340);
self::step($G, $C, $D, $A, $B, $words[11], 14, 0x265e5a51);
self::step($G, $B, $C, $D, $A, $words[0], 20, 0xe9b6c7aa);
self::step($G, $A, $B, $C, $D, $words[5], 5, 0xd62f105d);
self::step($G, $D, $A, $B, $C, $words[10], 9, 0x02441453);
self::step($G, $C, $D, $A, $B, $words[15], 14, 0xd8a1e681);
self::step($G, $B, $C, $D, $A, $words[4], 20, 0xe7d3fbc8);
self::step($G, $A, $B, $C, $D, $words[9], 5, 0x21e1cde6);
self::step($G, $D, $A, $B, $C, $words[14], 9, 0xc33707d6);
self::step($G, $C, $D, $A, $B, $words[3], 14, 0xf4d50d87);
self::step($G, $B, $C, $D, $A, $words[8], 20, 0x455a14ed);
self::step($G, $A, $B, $C, $D, $words[13], 5, 0xa9e3e905);
self::step($G, $D, $A, $B, $C, $words[2], 9, 0xfcefa3f8);
self::step($G, $C, $D, $A, $B, $words[7], 14, 0x676f02d9);
self::step($G, $B, $C, $D, $A, $words[12], 20, 0x8d2a4c8a);
/* ROUND 3 */
self::step($H, $A, $B, $C, $D, $words[5], 4, 0xfffa3942);
self::step($H, $D, $A, $B, $C, $words[8], 11, 0x8771f681);
self::step($H, $C, $D, $A, $B, $words[11], 16, 0x6d9d6122);
self::step($H, $B, $C, $D, $A, $words[14], 23, 0xfde5380c);
self::step($H, $A, $B, $C, $D, $words[1], 4, 0xa4beea44);
self::step($H, $D, $A, $B, $C, $words[4], 11, 0x4bdecfa9);
self::step($H, $C, $D, $A, $B, $words[7], 16, 0xf6bb4b60);
self::step($H, $B, $C, $D, $A, $words[10], 23, 0xbebfbc70);
self::step($H, $A, $B, $C, $D, $words[13], 4, 0x289b7ec6);
self::step($H, $D, $A, $B, $C, $words[0], 11, 0xeaa127fa);
self::step($H, $C, $D, $A, $B, $words[3], 16, 0xd4ef3085);
self::step($H, $B, $C, $D, $A, $words[6], 23, 0x04881d05);
self::step($H, $A, $B, $C, $D, $words[9], 4, 0xd9d4d039);
self::step($H, $D, $A, $B, $C, $words[12], 11, 0xe6db99e5);
self::step($H, $C, $D, $A, $B, $words[15], 16, 0x1fa27cf8);
self::step($H, $B, $C, $D, $A, $words[2], 23, 0xc4ac5665);
/* ROUND 4 */
self::step($I, $A, $B, $C, $D, $words[0], 6, 0xf4292244);
self::step($I, $D, $A, $B, $C, $words[7], 10, 0x432aff97);
self::step($I, $C, $D, $A, $B, $words[14], 15, 0xab9423a7);
self::step($I, $B, $C, $D, $A, $words[5], 21, 0xfc93a039);
self::step($I, $A, $B, $C, $D, $words[12], 6, 0x655b59c3);
self::step($I, $D, $A, $B, $C, $words[3], 10, 0x8f0ccc92);
self::step($I, $C, $D, $A, $B, $words[10], 15, 0xffeff47d);
self::step($I, $B, $C, $D, $A, $words[1], 21, 0x85845dd1);
self::step($I, $A, $B, $C, $D, $words[8], 6, 0x6fa87e4f);
self::step($I, $D, $A, $B, $C, $words[15], 10, 0xfe2ce6e0);
self::step($I, $C, $D, $A, $B, $words[6], 15, 0xa3014314);
self::step($I, $B, $C, $D, $A, $words[13], 21, 0x4e0811a1);
self::step($I, $A, $B, $C, $D, $words[4], 6, 0xf7537e82);
self::step($I, $D, $A, $B, $C, $words[11], 10, 0xbd3af235);
self::step($I, $C, $D, $A, $B, $words[2], 15, 0x2ad7d2bb);
self::step($I, $B, $C, $D, $A, $words[9], 21, 0xeb86d391);
$this->a = ($this->a + $A) & 0xffffffff;
$this->b = ($this->b + $B) & 0xffffffff;
$this->c = ($this->c + $C) & 0xffffffff;
$this->d = ($this->d + $D) & 0xffffffff;
}
private static function f($X, $Y, $Z)
{
return (($X & $Y) | ((~ $X) & $Z)); // X AND Y OR NOT X AND Z
}
private static function g($X, $Y, $Z)
{
return (($X & $Z) | ($Y & (~ $Z))); // X AND Z OR Y AND NOT Z
}
private static function h($X, $Y, $Z)
{
return ($X ^ $Y ^ $Z); // X XOR Y XOR Z
}
private static function i($X, $Y, $Z)
{
return ($Y ^ ($X | (~ $Z))) ; // Y XOR (X OR NOT Z)
}
private static function step($func, &$A, $B, $C, $D, $M, $s, $t)
{
$A = ($A + call_user_func($func, $B, $C, $D) + $M + $t) & 0xffffffff;
$A = self::rotate($A, $s);
$A = ($B + $A) & 0xffffffff;
}
private static function rotate($decimal, $bits)
{
$binary = str_pad(decbin($decimal), 32, "0", STR_PAD_LEFT);
return bindec(substr($binary, $bits).substr($binary, 0, $bits));
}
}

View file

@ -0,0 +1,81 @@
<?php
/**
* PHPExcel_Reader_Excel5_RC4
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Reader_Excel5
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Reader_Excel5_RC4
{
// Context
protected $s = array();
protected $i = 0;
protected $j = 0;
/**
* RC4 stream decryption/encryption constrcutor
*
* @param string $key Encryption key/passphrase
*/
public function __construct($key)
{
$len = strlen($key);
for ($this->i = 0; $this->i < 256; $this->i++) {
$this->s[$this->i] = $this->i;
}
$this->j = 0;
for ($this->i = 0; $this->i < 256; $this->i++) {
$this->j = ($this->j + $this->s[$this->i] + ord($key[$this->i % $len])) % 256;
$t = $this->s[$this->i];
$this->s[$this->i] = $this->s[$this->j];
$this->s[$this->j] = $t;
}
$this->i = $this->j = 0;
}
/**
* Symmetric decryption/encryption function
*
* @param string $data Data to encrypt/decrypt
*
* @return string
*/
public function RC4($data)
{
$len = strlen($data);
for ($c = 0; $c < $len; $c++) {
$this->i = ($this->i + 1) % 256;
$this->j = ($this->j + $this->s[$this->i]) % 256;
$t = $this->s[$this->i];
$this->s[$this->i] = $this->s[$this->j];
$this->s[$this->j] = $t;
$t = ($this->s[$this->i] + $this->s[$this->j]) % 256;
$data[$c] = chr(ord($data[$c]) ^ $this->s[$t]);
}
return $data;
}
}

View file

@ -0,0 +1,36 @@
<?php
class PHPExcel_Reader_Excel5_Style_Border
{
protected static $map = array(
0x00 => PHPExcel_Style_Border::BORDER_NONE,
0x01 => PHPExcel_Style_Border::BORDER_THIN,
0x02 => PHPExcel_Style_Border::BORDER_MEDIUM,
0x03 => PHPExcel_Style_Border::BORDER_DASHED,
0x04 => PHPExcel_Style_Border::BORDER_DOTTED,
0x05 => PHPExcel_Style_Border::BORDER_THICK,
0x06 => PHPExcel_Style_Border::BORDER_DOUBLE,
0x07 => PHPExcel_Style_Border::BORDER_HAIR,
0x08 => PHPExcel_Style_Border::BORDER_MEDIUMDASHED,
0x09 => PHPExcel_Style_Border::BORDER_DASHDOT,
0x0A => PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT,
0x0B => PHPExcel_Style_Border::BORDER_DASHDOTDOT,
0x0C => PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT,
0x0D => PHPExcel_Style_Border::BORDER_SLANTDASHDOT,
);
/**
* Map border style
* OpenOffice documentation: 2.5.11
*
* @param int $index
* @return string
*/
public static function lookup($index)
{
if (isset(self::$map[$index])) {
return self::$map[$index];
}
return PHPExcel_Style_Border::BORDER_NONE;
}
}

View file

@ -0,0 +1,41 @@
<?php
class PHPExcel_Reader_Excel5_Style_FillPattern
{
protected static $map = array(
0x00 => PHPExcel_Style_Fill::FILL_NONE,
0x01 => PHPExcel_Style_Fill::FILL_SOLID,
0x02 => PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY,
0x03 => PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY,
0x04 => PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY,
0x05 => PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL,
0x06 => PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL,
0x07 => PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN,
0x08 => PHPExcel_Style_Fill::FILL_PATTERN_DARKUP,
0x09 => PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID,
0x0A => PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS,
0x0B => PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL,
0x0C => PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL,
0x0D => PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN,
0x0E => PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP,
0x0F => PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID,
0x10 => PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS,
0x11 => PHPExcel_Style_Fill::FILL_PATTERN_GRAY125,
0x12 => PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625,
);
/**
* Get fill pattern from index
* OpenOffice documentation: 2.5.12
*
* @param int $index
* @return string
*/
public static function lookup($index)
{
if (isset(self::$map[$index])) {
return self::$map[$index];
}
return PHPExcel_Style_Fill::FILL_NONE;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Reader_Exception
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,33 +21,26 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Reader_Exception
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_Exception extends PHPExcel_Exception {
/**
* Error handler callback
*
* @param mixed $code
* @param mixed $string
* @param mixed $file
* @param mixed $line
* @param mixed $context
*/
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
$e = new self($string, $code);
$e->line = $line;
$e->file = $file;
throw $e;
}
class PHPExcel_Reader_Exception extends PHPExcel_Exception
{
/**
* Error handler callback
*
* @param mixed $code
* @param mixed $string
* @param mixed $file
* @param mixed $line
* @param mixed $context
*/
public static function errorHandlerCallback($code, $string, $file, $line, $context)
{
$e = new self($string, $code);
$e->line = $line;
$e->file = $file;
throw $e;
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,17 @@
<?php
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel
* PHPExcel_Reader_HTML
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,459 +29,521 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Reader_HTML
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
{
/**
* Input encoding
*
* @var string
*/
private $_inputEncoding = 'ANSI';
/**
* Sheet index to read
*
* @var int
*/
private $_sheetIndex = 0;
/**
* Input encoding
*
* @var string
*/
protected $inputEncoding = 'ANSI';
/**
* Formats
*
* @var array
*/
private $_formats = array( 'h1' => array( 'font' => array( 'bold' => true,
'size' => 24,
),
), // Bold, 24pt
'h2' => array( 'font' => array( 'bold' => true,
'size' => 18,
),
), // Bold, 18pt
'h3' => array( 'font' => array( 'bold' => true,
'size' => 13.5,
),
), // Bold, 13.5pt
'h4' => array( 'font' => array( 'bold' => true,
'size' => 12,
),
), // Bold, 12pt
'h5' => array( 'font' => array( 'bold' => true,
'size' => 10,
),
), // Bold, 10pt
'h6' => array( 'font' => array( 'bold' => true,
'size' => 7.5,
),
), // Bold, 7.5pt
'a' => array( 'font' => array( 'underline' => true,
'color' => array( 'argb' => PHPExcel_Style_Color::COLOR_BLUE,
),
),
), // Blue underlined
'hr' => array( 'borders' => array( 'bottom' => array( 'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array( PHPExcel_Style_Color::COLOR_BLACK,
),
),
),
), // Bottom border
);
/**
* Sheet index to read
*
* @var int
*/
protected $sheetIndex = 0;
/**
* Formats
*
* @var array
*/
protected $formats = array(
'h1' => array(
'font' => array(
'bold' => true,
'size' => 24,
),
), // Bold, 24pt
'h2' => array(
'font' => array(
'bold' => true,
'size' => 18,
),
), // Bold, 18pt
'h3' => array(
'font' => array(
'bold' => true,
'size' => 13.5,
),
), // Bold, 13.5pt
'h4' => array(
'font' => array(
'bold' => true,
'size' => 12,
),
), // Bold, 12pt
'h5' => array(
'font' => array(
'bold' => true,
'size' => 10,
),
), // Bold, 10pt
'h6' => array(
'font' => array(
'bold' => true,
'size' => 7.5,
),
), // Bold, 7.5pt
'a' => array(
'font' => array(
'underline' => true,
'color' => array(
'argb' => PHPExcel_Style_Color::COLOR_BLUE,
),
),
), // Blue underlined
'hr' => array(
'borders' => array(
'bottom' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array(
PHPExcel_Style_Color::COLOR_BLACK,
),
),
),
), // Bottom border
);
/**
* Create a new PHPExcel_Reader_HTML
*/
public function __construct() {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
}
protected $rowspan = array();
/**
* Can the current PHPExcel_Reader_IReader read the file?
*
* @param string $pFileName
* @return boolean
* @throws PHPExcel_Reader_Exception
*/
public function canRead($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
/**
* Create a new PHPExcel_Reader_HTML
*/
public function __construct()
{
$this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
}
// Read sample data (first 2 KB will do)
$fh = fopen($pFilename, 'r');
$data = fread($fh, 2048);
fclose($fh);
/**
* Validate that the current file is an HTML file
*
* @return boolean
*/
protected function isValidFormat()
{
// Reading 2048 bytes should be enough to validate that the format is HTML
$data = fread($this->fileHandle, 2048);
if ((strpos($data, '<') !== false) &&
(strlen($data) !== strlen(strip_tags($data)))) {
return true;
}
if ((strpos('<',$data) !== FALSE) &&
(strlen($data) !== strlen(strip_tags($data)))) {
return TRUE;
}
return false;
}
return FALSE;
}
/**
* Loads PHPExcel from file
*
* @param string $pFilename
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
*/
public function load($pFilename)
{
// Create new PHPExcel
$objPHPExcel = new PHPExcel();
/**
* Loads PHPExcel from file
*
* @param string $pFilename
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
*/
public function load($pFilename)
{
// Create new PHPExcel
$objPHPExcel = new PHPExcel();
// Load into this instance
return $this->loadIntoExisting($pFilename, $objPHPExcel);
}
// Load into this instance
return $this->loadIntoExisting($pFilename, $objPHPExcel);
}
/**
* Set input encoding
*
* @param string $pValue Input encoding
*/
public function setInputEncoding($pValue = 'ANSI')
{
$this->inputEncoding = $pValue;
/**
* Set input encoding
*
* @param string $pValue Input encoding
*/
public function setInputEncoding($pValue = 'ANSI')
{
$this->_inputEncoding = $pValue;
return $this;
}
return $this;
}
/**
* Get input encoding
*
* @return string
*/
public function getInputEncoding()
{
return $this->_inputEncoding;
}
/**
* Get input encoding
*
* @return string
*/
public function getInputEncoding()
{
return $this->inputEncoding;
}
// Data Array used for testing only, should write to PHPExcel object on completion of tests
private $_dataArray = array();
// Data Array used for testing only, should write to PHPExcel object on completion of tests
protected $dataArray = array();
protected $tableLevel = 0;
protected $nestedColumn = array('A');
private $_tableLevel = 0;
private $_nestedColumn = array('A');
protected function setTableStartColumn($column)
{
if ($this->tableLevel == 0) {
$column = 'A';
}
++$this->tableLevel;
$this->nestedColumn[$this->tableLevel] = $column;
private function _setTableStartColumn($column) {
if ($this->_tableLevel == 0)
$column = 'A';
++$this->_tableLevel;
$this->_nestedColumn[$this->_tableLevel] = $column;
return $this->nestedColumn[$this->tableLevel];
}
return $this->_nestedColumn[$this->_tableLevel];
}
protected function getTableStartColumn()
{
return $this->nestedColumn[$this->tableLevel];
}
private function _getTableStartColumn() {
return $this->_nestedColumn[$this->_tableLevel];
}
protected function releaseTableStartColumn()
{
--$this->tableLevel;
private function _releaseTableStartColumn() {
--$this->_tableLevel;
return array_pop($this->_nestedColumn);
}
return array_pop($this->nestedColumn);
}
private function _flushCell($sheet,$column,$row,&$cellContent) {
if (is_string($cellContent)) {
// Simple String content
if (trim($cellContent) > '') {
// Only actually write it if there's content in the string
// echo 'FLUSH CELL: ' , $column , $row , ' => ' , $cellContent , '<br />';
// Write to worksheet to be done here...
// ... we return the cell so we can mess about with styles more easily
$cell = $sheet->setCellValue($column.$row,$cellContent,true);
$this->_dataArray[$row][$column] = $cellContent;
}
} else {
// We have a Rich Text run
// TODO
$this->_dataArray[$row][$column] = 'RICH TEXT: ' . $cellContent;
}
$cellContent = (string) '';
}
protected function flushCell($sheet, $column, $row, &$cellContent)
{
if (is_string($cellContent)) {
// Simple String content
if (trim($cellContent) > '') {
// Only actually write it if there's content in the string
// echo 'FLUSH CELL: ' , $column , $row , ' => ' , $cellContent , '<br />';
// Write to worksheet to be done here...
// ... we return the cell so we can mess about with styles more easily
$sheet->setCellValue($column . $row, $cellContent, true);
$this->dataArray[$row][$column] = $cellContent;
}
} else {
// We have a Rich Text run
// TODO
$this->dataArray[$row][$column] = 'RICH TEXT: ' . $cellContent;
}
$cellContent = (string) '';
}
private function _processDomElement(DOMNode $element, $sheet, &$row, &$column, &$cellContent){
foreach($element->childNodes as $child){
if ($child instanceof DOMText) {
$domText = preg_replace('/\s+/',' ',trim($child->nodeValue));
if (is_string($cellContent)) {
// simply append the text if the cell content is a plain text string
$cellContent .= $domText;
} else {
// but if we have a rich text run instead, we need to append it correctly
// TODO
}
} elseif($child instanceof DOMElement) {
// echo '<b>DOM ELEMENT: </b>' , strtoupper($child->nodeName) , '<br />';
protected function processDomElement(DOMNode $element, $sheet, &$row, &$column, &$cellContent, $format = null)
{
foreach ($element->childNodes as $child) {
if ($child instanceof DOMText) {
$domText = preg_replace('/\s+/u', ' ', trim($child->nodeValue));
if (is_string($cellContent)) {
// simply append the text if the cell content is a plain text string
$cellContent .= $domText;
} else {
// but if we have a rich text run instead, we need to append it correctly
// TODO
}
} elseif ($child instanceof DOMElement) {
// echo '<b>DOM ELEMENT: </b>' , strtoupper($child->nodeName) , '<br />';
$attributeArray = array();
foreach($child->attributes as $attribute) {
// echo '<b>ATTRIBUTE: </b>' , $attribute->name , ' => ' , $attribute->value , '<br />';
$attributeArray[$attribute->name] = $attribute->value;
}
$attributeArray = array();
foreach ($child->attributes as $attribute) {
// echo '<b>ATTRIBUTE: </b>' , $attribute->name , ' => ' , $attribute->value , '<br />';
$attributeArray[$attribute->name] = $attribute->value;
}
switch($child->nodeName) {
case 'meta' :
foreach($attributeArray as $attributeName => $attributeValue) {
switch($attributeName) {
case 'content':
// TODO
// Extract character set, so we can convert to UTF-8 if required
break;
}
}
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
break;
case 'title' :
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
$sheet->setTitle($cellContent);
$cellContent = '';
break;
case 'span' :
case 'div' :
case 'font' :
case 'i' :
case 'em' :
case 'strong':
case 'b' :
// echo 'STYLING, SPAN OR DIV<br />';
if ($cellContent > '')
$cellContent .= ' ';
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
if ($cellContent > '')
$cellContent .= ' ';
// echo 'END OF STYLING, SPAN OR DIV<br />';
break;
case 'hr' :
$this->_flushCell($sheet,$column,$row,$cellContent);
++$row;
if (isset($this->_formats[$child->nodeName])) {
$sheet->getStyle($column.$row)->applyFromArray($this->_formats[$child->nodeName]);
} else {
$cellContent = '----------';
$this->_flushCell($sheet,$column,$row,$cellContent);
}
++$row;
case 'br' :
if ($this->_tableLevel > 0) {
// If we're inside a table, replace with a \n
$cellContent .= "\n";
} else {
// Otherwise flush our existing content and move the row cursor on
$this->_flushCell($sheet,$column,$row,$cellContent);
++$row;
}
// echo 'HARD LINE BREAK: ' , '<br />';
break;
case 'a' :
// echo 'START OF HYPERLINK: ' , '<br />';
foreach($attributeArray as $attributeName => $attributeValue) {
switch($attributeName) {
case 'href':
// echo 'Link to ' , $attributeValue , '<br />';
$sheet->getCell($column.$row)->getHyperlink()->setUrl($attributeValue);
if (isset($this->_formats[$child->nodeName])) {
$sheet->getStyle($column.$row)->applyFromArray($this->_formats[$child->nodeName]);
}
break;
}
}
$cellContent .= ' ';
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
// echo 'END OF HYPERLINK:' , '<br />';
break;
case 'h1' :
case 'h2' :
case 'h3' :
case 'h4' :
case 'h5' :
case 'h6' :
case 'ol' :
case 'ul' :
case 'p' :
if ($this->_tableLevel > 0) {
// If we're inside a table, replace with a \n
$cellContent .= "\n";
// echo 'LIST ENTRY: ' , '<br />';
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
// echo 'END OF LIST ENTRY:' , '<br />';
} else {
if ($cellContent > '') {
$this->_flushCell($sheet,$column,$row,$cellContent);
$row += 2;
}
// echo 'START OF PARAGRAPH: ' , '<br />';
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
// echo 'END OF PARAGRAPH:' , '<br />';
$this->_flushCell($sheet,$column,$row,$cellContent);
switch ($child->nodeName) {
case 'meta':
foreach ($attributeArray as $attributeName => $attributeValue) {
switch ($attributeName) {
case 'content':
// TODO
// Extract character set, so we can convert to UTF-8 if required
break;
}
}
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
break;
case 'title':
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
$sheet->setTitle($cellContent);
$cellContent = '';
break;
case 'span':
case 'div':
case 'font':
case 'i':
case 'em':
case 'strong':
case 'b':
// echo 'STYLING, SPAN OR DIV<br />';
if ($cellContent > '') {
$cellContent .= ' ';
}
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
if ($cellContent > '') {
$cellContent .= ' ';
}
// echo 'END OF STYLING, SPAN OR DIV<br />';
break;
case 'hr':
$this->flushCell($sheet, $column, $row, $cellContent);
++$row;
if (isset($this->formats[$child->nodeName])) {
$sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]);
} else {
$cellContent = '----------';
$this->flushCell($sheet, $column, $row, $cellContent);
}
++$row;
// Add a break after a horizontal rule, simply by allowing the code to dropthru
case 'br':
if ($this->tableLevel > 0) {
// If we're inside a table, replace with a \n
$cellContent .= "\n";
} else {
// Otherwise flush our existing content and move the row cursor on
$this->flushCell($sheet, $column, $row, $cellContent);
++$row;
}
// echo 'HARD LINE BREAK: ' , '<br />';
break;
case 'a':
// echo 'START OF HYPERLINK: ' , '<br />';
foreach ($attributeArray as $attributeName => $attributeValue) {
switch ($attributeName) {
case 'href':
// echo 'Link to ' , $attributeValue , '<br />';
$sheet->getCell($column . $row)->getHyperlink()->setUrl($attributeValue);
if (isset($this->formats[$child->nodeName])) {
$sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]);
}
break;
}
}
$cellContent .= ' ';
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF HYPERLINK:' , '<br />';
break;
case 'h1':
case 'h2':
case 'h3':
case 'h4':
case 'h5':
case 'h6':
case 'ol':
case 'ul':
case 'p':
if ($this->tableLevel > 0) {
// If we're inside a table, replace with a \n
$cellContent .= "\n";
// echo 'LIST ENTRY: ' , '<br />';
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF LIST ENTRY:' , '<br />';
} else {
if ($cellContent > '') {
$this->flushCell($sheet, $column, $row, $cellContent);
$row++;
}
// echo 'START OF PARAGRAPH: ' , '<br />';
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF PARAGRAPH:' , '<br />';
$this->flushCell($sheet, $column, $row, $cellContent);
if (isset($this->_formats[$child->nodeName])) {
$sheet->getStyle($column.$row)->applyFromArray($this->_formats[$child->nodeName]);
}
if (isset($this->formats[$child->nodeName])) {
$sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]);
}
$row += 2;
$column = 'A';
}
break;
case 'li' :
if ($this->_tableLevel > 0) {
// If we're inside a table, replace with a \n
$cellContent .= "\n";
// echo 'LIST ENTRY: ' , '<br />';
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
// echo 'END OF LIST ENTRY:' , '<br />';
} else {
if ($cellContent > '') {
$this->_flushCell($sheet,$column,$row,$cellContent);
}
++$row;
// echo 'LIST ENTRY: ' , '<br />';
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
// echo 'END OF LIST ENTRY:' , '<br />';
$this->_flushCell($sheet,$column,$row,$cellContent);
$column = 'A';
}
break;
case 'table' :
$this->_flushCell($sheet,$column,$row,$cellContent);
$column = $this->_setTableStartColumn($column);
// echo 'START OF TABLE LEVEL ' , $this->_tableLevel , '<br />';
if ($this->_tableLevel > 1)
--$row;
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
// echo 'END OF TABLE LEVEL ' , $this->_tableLevel , '<br />';
$column = $this->_releaseTableStartColumn();
if ($this->_tableLevel > 1) {
++$column;
} else {
++$row;
}
break;
case 'thead' :
case 'tbody' :
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
break;
case 'tr' :
++$row;
$column = $this->_getTableStartColumn();
$cellContent = '';
// echo 'START OF TABLE ' , $this->_tableLevel , ' ROW<br />';
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
// echo 'END OF TABLE ' , $this->_tableLevel , ' ROW<br />';
break;
case 'th' :
case 'td' :
// echo 'START OF TABLE ' , $this->_tableLevel , ' CELL<br />';
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
// echo 'END OF TABLE ' , $this->_tableLevel , ' CELL<br />';
$this->_flushCell($sheet,$column,$row,$cellContent);
++$column;
break;
case 'body' :
$row = 1;
$column = 'A';
$content = '';
$this->_tableLevel = 0;
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
break;
default:
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
}
}
}
}
$row++;
$column = 'A';
}
break;
case 'li':
if ($this->tableLevel > 0) {
// If we're inside a table, replace with a \n
$cellContent .= "\n";
// echo 'LIST ENTRY: ' , '<br />';
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF LIST ENTRY:' , '<br />';
} else {
if ($cellContent > '') {
$this->flushCell($sheet, $column, $row, $cellContent);
}
++$row;
// echo 'LIST ENTRY: ' , '<br />';
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF LIST ENTRY:' , '<br />';
$this->flushCell($sheet, $column, $row, $cellContent);
$column = 'A';
}
break;
case 'table':
$this->flushCell($sheet, $column, $row, $cellContent);
$column = $this->setTableStartColumn($column);
// echo 'START OF TABLE LEVEL ' , $this->tableLevel , '<br />';
if ($this->tableLevel > 1) {
--$row;
}
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF TABLE LEVEL ' , $this->tableLevel , '<br />';
$column = $this->releaseTableStartColumn();
if ($this->tableLevel > 1) {
++$column;
} else {
++$row;
}
break;
case 'thead':
case 'tbody':
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
break;
case 'tr':
$column = $this->getTableStartColumn();
$cellContent = '';
// echo 'START OF TABLE ' , $this->tableLevel , ' ROW<br />';
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
++$row;
// echo 'END OF TABLE ' , $this->tableLevel , ' ROW<br />';
break;
case 'th':
case 'td':
// echo 'START OF TABLE ' , $this->tableLevel , ' CELL<br />';
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF TABLE ' , $this->tableLevel , ' CELL<br />';
/**
* Loads PHPExcel from file into PHPExcel instance
*
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
while (isset($this->rowspan[$column . $row])) {
++$column;
}
if (!is_file($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! The given file is not a regular file.");
}
$this->flushCell($sheet, $column, $row, $cellContent);
// Create new PHPExcel
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
$objPHPExcel->createSheet();
}
$objPHPExcel->setActiveSheetIndex( $this->_sheetIndex );
// if (isset($attributeArray['style']) && !empty($attributeArray['style'])) {
// $styleAry = $this->getPhpExcelStyleArray($attributeArray['style']);
//
// if (!empty($styleAry)) {
// $sheet->getStyle($column . $row)->applyFromArray($styleAry);
// }
// }
// Create a new DOM object
$dom = new domDocument;
// Load the HTML file into the DOM object
$loaded = $dom->loadHTMLFile($pFilename);
if ($loaded === false) {
throw new PHPExcel_Reader_Exception('Failed to load ',$pFilename,' as a DOM Document');
}
if (isset($attributeArray['rowspan']) && isset($attributeArray['colspan'])) {
//create merging rowspan and colspan
$columnTo = $column;
for ($i = 0; $i < $attributeArray['colspan'] - 1; $i++) {
++$columnTo;
}
$range = $column . $row . ':' . $columnTo . ($row + $attributeArray['rowspan'] - 1);
foreach (\PHPExcel_Cell::extractAllCellReferencesInRange($range) as $value) {
$this->rowspan[$value] = true;
}
$sheet->mergeCells($range);
$column = $columnTo;
} elseif (isset($attributeArray['rowspan'])) {
//create merging rowspan
$range = $column . $row . ':' . $column . ($row + $attributeArray['rowspan'] - 1);
foreach (\PHPExcel_Cell::extractAllCellReferencesInRange($range) as $value) {
$this->rowspan[$value] = true;
}
$sheet->mergeCells($range);
} elseif (isset($attributeArray['colspan'])) {
//create merging colspan
$columnTo = $column;
for ($i = 0; $i < $attributeArray['colspan'] - 1; $i++) {
++$columnTo;
}
$sheet->mergeCells($column . $row . ':' . $columnTo . $row);
$column = $columnTo;
}
++$column;
break;
case 'body':
$row = 1;
$column = 'A';
$content = '';
$this->tableLevel = 0;
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
break;
default:
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
}
}
}
}
// Discard white space
$dom->preserveWhiteSpace = false;
/**
* Loads PHPExcel from file into PHPExcel instance
*
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
// Open file to validate
$this->openFile($pFilename);
if (!$this->isValidFormat()) {
fclose($this->fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid HTML file.");
}
// Close after validating
fclose($this->fileHandle);
// Create new PHPExcel
while ($objPHPExcel->getSheetCount() <= $this->sheetIndex) {
$objPHPExcel->createSheet();
}
$objPHPExcel->setActiveSheetIndex($this->sheetIndex);
$row = 0;
$column = 'A';
$content = '';
$this->_processDomElement($dom,$objPHPExcel->getActiveSheet(),$row,$column,$content);
// Create a new DOM object
$dom = new domDocument;
// Reload the HTML file into the DOM object
$loaded = $dom->loadHTML(mb_convert_encoding($this->securityScanFile($pFilename), 'HTML-ENTITIES', 'UTF-8'));
if ($loaded === false) {
throw new PHPExcel_Reader_Exception('Failed to load ' . $pFilename . ' as a DOM Document');
}
// echo '<hr />';
// var_dump($this->_dataArray);
// Discard white space
$dom->preserveWhiteSpace = false;
// Return
return $objPHPExcel;
}
$row = 0;
$column = 'A';
$content = '';
$this->processDomElement($dom, $objPHPExcel->getActiveSheet(), $row, $column, $content);
/**
* Get sheet index
*
* @return int
*/
public function getSheetIndex() {
return $this->_sheetIndex;
}
// Return
return $objPHPExcel;
}
/**
* Set sheet index
*
* @param int $pValue Sheet index
* @return PHPExcel_Reader_HTML
*/
public function setSheetIndex($pValue = 0) {
$this->_sheetIndex = $pValue;
return $this;
}
/**
* Get sheet index
*
* @return int
*/
public function getSheetIndex()
{
return $this->sheetIndex;
}
/**
* Set sheet index
*
* @param int $pValue Sheet index
* @return PHPExcel_Reader_HTML
*/
public function setSheetIndex($pValue = 0)
{
$this->sheetIndex = $pValue;
return $this;
}
/**
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
*
* @param string $xml
* @throws PHPExcel_Reader_Exception
*/
public function securityScan($xml)
{
$pattern = '/\\0?' . implode('\\0?', str_split('<!ENTITY')) . '\\0?/';
if (preg_match($pattern, $xml)) {
throw new PHPExcel_Reader_Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks');
}
return $xml;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Reader_IReadFilter
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,28 +21,19 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Reader_IReadFilter
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
interface PHPExcel_Reader_IReadFilter
{
/**
* Should this cell be read?
*
* @param $column String column index
* @param $row Row index
* @param $worksheetName Optional worksheet name
* @return boolean
*/
public function readCell($column, $row, $worksheetName = '');
/**
* Should this cell be read?
*
* @param $column Column address (as a string value like "A", or "IV")
* @param $row Row number
* @param $worksheetName Optional worksheet name
* @return boolean
*/
public function readCell($column, $row, $worksheetName = '');
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Reader_IReader
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,34 +21,26 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Reader_IReader
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
interface PHPExcel_Reader_IReader
{
/**
* Can the current PHPExcel_Reader_IReader read the file?
*
* @param string $pFileName
* @return boolean
*/
public function canRead($pFilename);
/**
* Can the current PHPExcel_Reader_IReader read the file?
*
* @param string $pFilename
* @return boolean
*/
public function canRead($pFilename);
/**
* Loads PHPExcel from file
*
* @param string $pFileName
* @throws PHPExcel_Reader_Exception
*/
public function load($pFilename);
/**
* Loads PHPExcel from file
*
* @param string $pFilename
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
*/
public function load($pFilename);
}

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,18 @@
<?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel
* PHPExcel_Reader_SYLK
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,450 +30,449 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Reader_SYLK
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
{
/**
* Input encoding
*
* @var string
*/
private $_inputEncoding = 'ANSI';
/**
* Input encoding
*
* @var string
*/
private $inputEncoding = 'ANSI';
/**
* Sheet index to read
*
* @var int
*/
private $_sheetIndex = 0;
/**
* Sheet index to read
*
* @var int
*/
private $sheetIndex = 0;
/**
* Formats
*
* @var array
*/
private $_formats = array();
/**
* Formats
*
* @var array
*/
private $formats = array();
/**
* Format Count
*
* @var int
*/
private $_format = 0;
/**
* Format Count
*
* @var int
*/
private $format = 0;
/**
* Create a new PHPExcel_Reader_SYLK
*/
public function __construct() {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
}
/**
* Create a new PHPExcel_Reader_SYLK
*/
public function __construct()
{
$this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
}
/**
* Validate that the current file is a SYLK file
*
* @return boolean
*/
protected function isValidFormat()
{
// Read sample data (first 2 KB will do)
$data = fread($this->fileHandle, 2048);
/**
* Can the current PHPExcel_Reader_IReader read the file?
*
* @param string $pFileName
* @return boolean
* @throws PHPExcel_Reader_Exception
*/
public function canRead($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// Count delimiters in file
$delimiterCount = substr_count($data, ';');
if ($delimiterCount < 1) {
return false;
}
// Read sample data (first 2 KB will do)
$fh = fopen($pFilename, 'r');
$data = fread($fh, 2048);
fclose($fh);
// Analyze first line looking for ID; signature
$lines = explode("\n", $data);
if (substr($lines[0], 0, 4) != 'ID;P') {
return false;
}
// Count delimiters in file
$delimiterCount = substr_count($data, ';');
if ($delimiterCount < 1) {
return false;
}
return true;
}
// Analyze first line looking for ID; signature
$lines = explode("\n", $data);
if (substr($lines[0],0,4) != 'ID;P') {
return false;
}
/**
* Set input encoding
*
* @param string $pValue Input encoding
*/
public function setInputEncoding($pValue = 'ANSI')
{
$this->inputEncoding = $pValue;
return $this;
}
return true;
}
/**
* Get input encoding
*
* @return string
*/
public function getInputEncoding()
{
return $this->inputEncoding;
}
/**
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
*
* @param string $pFilename
* @throws PHPExcel_Reader_Exception
*/
public function listWorksheetInfo($pFilename)
{
// Open file
$this->openFile($pFilename);
if (!$this->isValidFormat()) {
fclose($this->fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
}
$fileHandle = $this->fileHandle;
rewind($fileHandle);
/**
* Set input encoding
*
* @param string $pValue Input encoding
*/
public function setInputEncoding($pValue = 'ANSI')
{
$this->_inputEncoding = $pValue;
return $this;
}
$worksheetInfo = array();
$worksheetInfo[0]['worksheetName'] = 'Worksheet';
$worksheetInfo[0]['lastColumnLetter'] = 'A';
$worksheetInfo[0]['lastColumnIndex'] = 0;
$worksheetInfo[0]['totalRows'] = 0;
$worksheetInfo[0]['totalColumns'] = 0;
// Loop through file
$rowData = array();
/**
* Get input encoding
*
* @return string
*/
public function getInputEncoding()
{
return $this->_inputEncoding;
}
// loop through one row (line) at a time in the file
$rowIndex = 0;
while (($rowData = fgets($fileHandle)) !== false) {
$columnIndex = 0;
// convert SYLK encoded $rowData to UTF-8
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
/**
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
*
* @param string $pFilename
* @throws PHPExcel_Reader_Exception
*/
public function listWorksheetInfo($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// explode each row at semicolons while taking into account that literal semicolon (;)
// is escaped like this (;;)
$rowData = explode("\t", str_replace('¤', ';', str_replace(';', "\t", str_replace(';;', '¤', rtrim($rowData)))));
// Open file
$fileHandle = fopen($pFilename, 'r');
if ($fileHandle === false) {
throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading.");
}
$dataType = array_shift($rowData);
if ($dataType == 'C') {
// Read cell value data
foreach ($rowData as $rowDatum) {
switch ($rowDatum{0}) {
case 'C':
case 'X':
$columnIndex = substr($rowDatum, 1) - 1;
break;
case 'R':
case 'Y':
$rowIndex = substr($rowDatum, 1);
break;
}
$worksheetInfo = array();
$worksheetInfo[0]['worksheetName'] = 'Worksheet';
$worksheetInfo[0]['lastColumnLetter'] = 'A';
$worksheetInfo[0]['lastColumnIndex'] = 0;
$worksheetInfo[0]['totalRows'] = 0;
$worksheetInfo[0]['totalColumns'] = 0;
$worksheetInfo[0]['totalRows'] = max($worksheetInfo[0]['totalRows'], $rowIndex);
$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], $columnIndex);
}
}
}
// Loop through file
$rowData = array();
$worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
// loop through one row (line) at a time in the file
$rowIndex = 0;
while (($rowData = fgets($fileHandle)) !== FALSE) {
$columnIndex = 0;
// Close file
fclose($fileHandle);
// convert SYLK encoded $rowData to UTF-8
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
return $worksheetInfo;
}
// explode each row at semicolons while taking into account that literal semicolon (;)
// is escaped like this (;;)
$rowData = explode("\t",str_replace('?',';',str_replace(';',"\t",str_replace(';;','?',rtrim($rowData)))));
/**
* Loads PHPExcel from file
*
* @param string $pFilename
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
*/
public function load($pFilename)
{
// Create new PHPExcel
$objPHPExcel = new PHPExcel();
$dataType = array_shift($rowData);
if ($dataType == 'C') {
// Read cell value data
foreach($rowData as $rowDatum) {
switch($rowDatum{0}) {
case 'C' :
case 'X' :
$columnIndex = substr($rowDatum,1) - 1;
break;
case 'R' :
case 'Y' :
$rowIndex = substr($rowDatum,1);
break;
}
// Load into this instance
return $this->loadIntoExisting($pFilename, $objPHPExcel);
}
$worksheetInfo[0]['totalRows'] = max($worksheetInfo[0]['totalRows'], $rowIndex);
$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], $columnIndex);
}
}
}
/**
* Loads PHPExcel from file into PHPExcel instance
*
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
// Open file
$this->openFile($pFilename);
if (!$this->isValidFormat()) {
fclose($this->fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
}
$fileHandle = $this->fileHandle;
rewind($fileHandle);
$worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
// Create new PHPExcel
while ($objPHPExcel->getSheetCount() <= $this->sheetIndex) {
$objPHPExcel->createSheet();
}
$objPHPExcel->setActiveSheetIndex($this->sheetIndex);
// Close file
fclose($fileHandle);
$fromFormats = array('\-', '\ ');
$toFormats = array('-', ' ');
return $worksheetInfo;
}
// Loop through file
$rowData = array();
$column = $row = '';
// loop through one row (line) at a time in the file
while (($rowData = fgets($fileHandle)) !== false) {
// convert SYLK encoded $rowData to UTF-8
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
/**
* Loads PHPExcel from file
*
* @param string $pFilename
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
*/
public function load($pFilename)
{
// Create new PHPExcel
$objPHPExcel = new PHPExcel();
// explode each row at semicolons while taking into account that literal semicolon (;)
// is escaped like this (;;)
$rowData = explode("\t", str_replace('¤', ';', str_replace(';', "\t", str_replace(';;', '¤', rtrim($rowData)))));
// Load into this instance
return $this->loadIntoExisting($pFilename, $objPHPExcel);
}
$dataType = array_shift($rowData);
// Read shared styles
if ($dataType == 'P') {
$formatArray = array();
foreach ($rowData as $rowDatum) {
switch ($rowDatum{0}) {
case 'P':
$formatArray['numberformat']['code'] = str_replace($fromFormats, $toFormats, substr($rowDatum, 1));
break;
case 'E':
case 'F':
$formatArray['font']['name'] = substr($rowDatum, 1);
break;
case 'L':
$formatArray['font']['size'] = substr($rowDatum, 1);
break;
case 'S':
$styleSettings = substr($rowDatum, 1);
for ($i=0; $i<strlen($styleSettings); ++$i) {
switch ($styleSettings{$i}) {
case 'I':
$formatArray['font']['italic'] = true;
break;
case 'D':
$formatArray['font']['bold'] = true;
break;
case 'T':
$formatArray['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'B':
$formatArray['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'L':
$formatArray['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'R':
$formatArray['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
}
}
break;
}
}
$this->formats['P'.$this->format++] = $formatArray;
// Read cell value data
} elseif ($dataType == 'C') {
$hasCalculatedValue = false;
$cellData = $cellDataFormula = '';
foreach ($rowData as $rowDatum) {
switch ($rowDatum{0}) {
case 'C':
case 'X':
$column = substr($rowDatum, 1);
break;
case 'R':
case 'Y':
$row = substr($rowDatum, 1);
break;
case 'K':
$cellData = substr($rowDatum, 1);
break;
case 'E':
$cellDataFormula = '='.substr($rowDatum, 1);
// Convert R1C1 style references to A1 style references (but only when not quoted)
$temp = explode('"', $cellDataFormula);
$key = false;
foreach ($temp as &$value) {
// Only count/replace in alternate array entries
if ($key = !$key) {
preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/', $value, $cellReferences, PREG_SET_ORDER+PREG_OFFSET_CAPTURE);
// Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way
// through the formula from left to right. Reversing means that we work right to left.through
// the formula
$cellReferences = array_reverse($cellReferences);
// Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent,
// then modify the formula to use that new reference
foreach ($cellReferences as $cellReference) {
$rowReference = $cellReference[2][0];
// Empty R reference is the current row
if ($rowReference == '') {
$rowReference = $row;
}
// Bracketed R references are relative to the current row
if ($rowReference{0} == '[') {
$rowReference = $row + trim($rowReference, '[]');
}
$columnReference = $cellReference[4][0];
// Empty C reference is the current column
if ($columnReference == '') {
$columnReference = $column;
}
// Bracketed C references are relative to the current column
if ($columnReference{0} == '[') {
$columnReference = $column + trim($columnReference, '[]');
}
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference;
$value = substr_replace($value, $A1CellReference, $cellReference[0][1], strlen($cellReference[0][0]));
}
}
}
unset($value);
// Then rebuild the formula string
$cellDataFormula = implode('"', $temp);
$hasCalculatedValue = true;
break;
}
}
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
$cellData = PHPExcel_Calculation::unwrapResult($cellData);
/**
* Loads PHPExcel from file into PHPExcel instance
*
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// Set cell value
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setValue(($hasCalculatedValue) ? $cellDataFormula : $cellData);
if ($hasCalculatedValue) {
$cellData = PHPExcel_Calculation::unwrapResult($cellData);
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setCalculatedValue($cellData);
}
// Read cell formatting
} elseif ($dataType == 'F') {
$formatStyle = $columnWidth = $styleSettings = '';
$styleData = array();
foreach ($rowData as $rowDatum) {
switch ($rowDatum{0}) {
case 'C':
case 'X':
$column = substr($rowDatum, 1);
break;
case 'R':
case 'Y':
$row = substr($rowDatum, 1);
break;
case 'P':
$formatStyle = $rowDatum;
break;
case 'W':
list($startCol, $endCol, $columnWidth) = explode(' ', substr($rowDatum, 1));
break;
case 'S':
$styleSettings = substr($rowDatum, 1);
for ($i=0; $i<strlen($styleSettings); ++$i) {
switch ($styleSettings{$i}) {
case 'I':
$styleData['font']['italic'] = true;
break;
case 'D':
$styleData['font']['bold'] = true;
break;
case 'T':
$styleData['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'B':
$styleData['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'L':
$styleData['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'R':
$styleData['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
}
}
break;
}
}
if (($formatStyle > '') && ($column > '') && ($row > '')) {
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
if (isset($this->formats[$formatStyle])) {
$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($this->formats[$formatStyle]);
}
}
if ((!empty($styleData)) && ($column > '') && ($row > '')) {
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($styleData);
}
if ($columnWidth > '') {
if ($startCol == $endCol) {
$startCol = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
$objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth);
} else {
$startCol = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
$endCol = PHPExcel_Cell::stringFromColumnIndex($endCol-1);
$objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth);
do {
$objPHPExcel->getActiveSheet()->getColumnDimension(++$startCol)->setWidth($columnWidth);
} while ($startCol != $endCol);
}
}
} else {
foreach ($rowData as $rowDatum) {
switch ($rowDatum{0}) {
case 'C':
case 'X':
$column = substr($rowDatum, 1);
break;
case 'R':
case 'Y':
$row = substr($rowDatum, 1);
break;
}
}
}
}
// Create new PHPExcel
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
$objPHPExcel->createSheet();
}
$objPHPExcel->setActiveSheetIndex( $this->_sheetIndex );
// Close file
fclose($fileHandle);
$fromFormats = array('\-', '\ ');
$toFormats = array('-', ' ');
// Return
return $objPHPExcel;
}
// Open file
$fileHandle = fopen($pFilename, 'r');
if ($fileHandle === false) {
throw new PHPExcel_Reader_Exception("Could not open file $pFilename for reading.");
}
// Loop through file
$rowData = array();
$column = $row = '';
// loop through one row (line) at a time in the file
while (($rowData = fgets($fileHandle)) !== FALSE) {
// convert SYLK encoded $rowData to UTF-8
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
// explode each row at semicolons while taking into account that literal semicolon (;)
// is escaped like this (;;)
$rowData = explode("\t",str_replace('¤',';',str_replace(';',"\t",str_replace(';;','¤',rtrim($rowData)))));
$dataType = array_shift($rowData);
// Read shared styles
if ($dataType == 'P') {
$formatArray = array();
foreach($rowData as $rowDatum) {
switch($rowDatum{0}) {
case 'P' : $formatArray['numberformat']['code'] = str_replace($fromFormats,$toFormats,substr($rowDatum,1));
break;
case 'E' :
case 'F' : $formatArray['font']['name'] = substr($rowDatum,1);
break;
case 'L' : $formatArray['font']['size'] = substr($rowDatum,1);
break;
case 'S' : $styleSettings = substr($rowDatum,1);
for ($i=0;$i<strlen($styleSettings);++$i) {
switch ($styleSettings{$i}) {
case 'I' : $formatArray['font']['italic'] = true;
break;
case 'D' : $formatArray['font']['bold'] = true;
break;
case 'T' : $formatArray['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'B' : $formatArray['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'L' : $formatArray['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'R' : $formatArray['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
}
}
break;
}
}
$this->_formats['P'.$this->_format++] = $formatArray;
// Read cell value data
} elseif ($dataType == 'C') {
$hasCalculatedValue = false;
$cellData = $cellDataFormula = '';
foreach($rowData as $rowDatum) {
switch($rowDatum{0}) {
case 'C' :
case 'X' : $column = substr($rowDatum,1);
break;
case 'R' :
case 'Y' : $row = substr($rowDatum,1);
break;
case 'K' : $cellData = substr($rowDatum,1);
break;
case 'E' : $cellDataFormula = '='.substr($rowDatum,1);
// Convert R1C1 style references to A1 style references (but only when not quoted)
$temp = explode('"',$cellDataFormula);
$key = false;
foreach($temp as &$value) {
// Only count/replace in alternate array entries
if ($key = !$key) {
preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/',$value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE);
// Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way
// through the formula from left to right. Reversing means that we work right to left.through
// the formula
$cellReferences = array_reverse($cellReferences);
// Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent,
// then modify the formula to use that new reference
foreach($cellReferences as $cellReference) {
$rowReference = $cellReference[2][0];
// Empty R reference is the current row
if ($rowReference == '') $rowReference = $row;
// Bracketed R references are relative to the current row
if ($rowReference{0} == '[') $rowReference = $row + trim($rowReference,'[]');
$columnReference = $cellReference[4][0];
// Empty C reference is the current column
if ($columnReference == '') $columnReference = $column;
// Bracketed C references are relative to the current column
if ($columnReference{0} == '[') $columnReference = $column + trim($columnReference,'[]');
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference;
$value = substr_replace($value,$A1CellReference,$cellReference[0][1],strlen($cellReference[0][0]));
}
}
}
unset($value);
// Then rebuild the formula string
$cellDataFormula = implode('"',$temp);
$hasCalculatedValue = true;
break;
}
}
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
$cellData = PHPExcel_Calculation::_unwrapResult($cellData);
// Set cell value
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setValue(($hasCalculatedValue) ? $cellDataFormula : $cellData);
if ($hasCalculatedValue) {
$cellData = PHPExcel_Calculation::_unwrapResult($cellData);
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setCalculatedValue($cellData);
}
// Read cell formatting
} elseif ($dataType == 'F') {
$formatStyle = $columnWidth = $styleSettings = '';
$styleData = array();
foreach($rowData as $rowDatum) {
switch($rowDatum{0}) {
case 'C' :
case 'X' : $column = substr($rowDatum,1);
break;
case 'R' :
case 'Y' : $row = substr($rowDatum,1);
break;
case 'P' : $formatStyle = $rowDatum;
break;
case 'W' : list($startCol,$endCol,$columnWidth) = explode(' ',substr($rowDatum,1));
break;
case 'S' : $styleSettings = substr($rowDatum,1);
for ($i=0;$i<strlen($styleSettings);++$i) {
switch ($styleSettings{$i}) {
case 'I' : $styleData['font']['italic'] = true;
break;
case 'D' : $styleData['font']['bold'] = true;
break;
case 'T' : $styleData['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'B' : $styleData['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'L' : $styleData['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'R' : $styleData['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
}
}
break;
}
}
if (($formatStyle > '') && ($column > '') && ($row > '')) {
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($this->_formats[$formatStyle]);
}
if ((!empty($styleData)) && ($column > '') && ($row > '')) {
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($styleData);
}
if ($columnWidth > '') {
if ($startCol == $endCol) {
$startCol = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
$objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth);
} else {
$startCol = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
$endCol = PHPExcel_Cell::stringFromColumnIndex($endCol-1);
$objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth);
do {
$objPHPExcel->getActiveSheet()->getColumnDimension(++$startCol)->setWidth($columnWidth);
} while ($startCol != $endCol);
}
}
} else {
foreach($rowData as $rowDatum) {
switch($rowDatum{0}) {
case 'C' :
case 'X' : $column = substr($rowDatum,1);
break;
case 'R' :
case 'Y' : $row = substr($rowDatum,1);
break;
}
}
}
}
// Close file
fclose($fileHandle);
// Return
return $objPHPExcel;
}
/**
* Get sheet index
*
* @return int
*/
public function getSheetIndex() {
return $this->_sheetIndex;
}
/**
* Set sheet index
*
* @param int $pValue Sheet index
* @return PHPExcel_Reader_SYLK
*/
public function setSheetIndex($pValue = 0) {
$this->_sheetIndex = $pValue;
return $this;
}
/**
* Get sheet index
*
* @return int
*/
public function getSheetIndex()
{
return $this->sheetIndex;
}
/**
* Set sheet index
*
* @param int $pValue Sheet index
* @return PHPExcel_Reader_SYLK
*/
public function setSheetIndex($pValue = 0)
{
$this->sheetIndex = $pValue;
return $this;
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_RichText
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,19 +21,10 @@
*
* @category PHPExcel
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_RichText
*
* @category PHPExcel
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_RichText implements PHPExcel_IComparable
{
/**
@ -40,21 +32,21 @@ class PHPExcel_RichText implements PHPExcel_IComparable
*
* @var PHPExcel_RichText_ITextElement[]
*/
private $_richTextElements;
private $richTextElements;
/**
* Create a new PHPExcel_RichText instance
*
* @param PHPExcel_Cell $pParent
* @param PHPExcel_Cell $pCell
* @throws PHPExcel_Exception
*/
public function __construct(PHPExcel_Cell $pCell = null)
{
// Initialise variables
$this->_richTextElements = array();
$this->richTextElements = array();
// Rich-Text string attached to cell?
if ($pCell !== NULL) {
if ($pCell !== null) {
// Add cell text and style
if ($pCell->getValue() != "") {
$objRun = new PHPExcel_RichText_Run($pCell->getValue());
@ -76,7 +68,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
*/
public function addText(PHPExcel_RichText_ITextElement $pText = null)
{
$this->_richTextElements[] = $pText;
$this->richTextElements[] = $pText;
return $this;
}
@ -119,7 +111,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
$returnValue = '';
// Loop through all PHPExcel_RichText_ITextElement
foreach ($this->_richTextElements as $text) {
foreach ($this->richTextElements as $text) {
$returnValue .= $text->getText();
}
@ -144,7 +136,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
*/
public function getRichTextElements()
{
return $this->_richTextElements;
return $this->richTextElements;
}
/**
@ -157,7 +149,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
public function setRichTextElements($pElements = null)
{
if (is_array($pElements)) {
$this->_richTextElements = $pElements;
$this->richTextElements = $pElements;
} else {
throw new PHPExcel_Exception("Invalid PHPExcel_RichText_ITextElement[] array passed.");
}
@ -172,13 +164,13 @@ class PHPExcel_RichText implements PHPExcel_IComparable
public function getHashCode()
{
$hashElements = '';
foreach ($this->_richTextElements as $element) {
foreach ($this->richTextElements as $element) {
$hashElements .= $element->getHashCode();
}
return md5(
$hashElements
. __CLASS__
$hashElements .
__CLASS__
);
}

View file

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_RichText_ITextElement
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -18,47 +19,38 @@
*
* @category PHPExcel
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_RichText_ITextElement
*
* @category PHPExcel
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
interface PHPExcel_RichText_ITextElement
{
/**
* Get text
*
* @return string Text
*/
public function getText();
/**
* Get text
*
* @return string Text
*/
public function getText();
/**
* Set text
*
* @param $pText string Text
* @return PHPExcel_RichText_ITextElement
*/
public function setText($pText = '');
/**
* Set text
*
* @param $pText string Text
* @return PHPExcel_RichText_ITextElement
*/
public function setText($pText = '');
/**
* Get font
*
* @return PHPExcel_Style_Font
*/
public function getFont();
/**
* Get font
*
* @return PHPExcel_Style_Font
*/
public function getFont();
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode();
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode();
}

View file

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_RichText_Run
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -18,85 +19,80 @@
*
* @category PHPExcel
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_RichText_Run
*
* @category PHPExcel
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
{
/**
* Font
*
* @var PHPExcel_Style_Font
*/
private $_font;
/**
* Font
*
* @var PHPExcel_Style_Font
*/
private $font;
/**
* Create a new PHPExcel_RichText_Run instance
*
* @param string $pText Text
* @param string $pText Text
*/
public function __construct($pText = '')
{
// Initialise variables
$this->setText($pText);
$this->_font = new PHPExcel_Style_Font();
// Initialise variables
$this->setText($pText);
$this->font = new PHPExcel_Style_Font();
}
/**
* Get font
*
* @return PHPExcel_Style_Font
*/
public function getFont() {
return $this->_font;
}
/**
* Set font
*
* @param PHPExcel_Style_Font $pFont Font
* @throws PHPExcel_Exception
* @return PHPExcel_RichText_ITextElement
*/
public function setFont(PHPExcel_Style_Font $pFont = null) {
$this->_font = $pFont;
return $this;
}
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode() {
return md5(
$this->getText()
. $this->_font->getHashCode()
. __CLASS__
);
/**
* Get font
*
* @return PHPExcel_Style_Font
*/
public function getFont()
{
return $this->font;
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
/**
* Set font
*
* @param PHPExcel_Style_Font $pFont Font
* @throws PHPExcel_Exception
* @return PHPExcel_RichText_ITextElement
*/
public function setFont(PHPExcel_Style_Font $pFont = null)
{
$this->font = $pFont;
return $this;
}
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode()
{
return md5(
$this->getText() .
$this->font->getHashCode() .
__CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
}

View file

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_RichText_TextElement
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -18,91 +19,87 @@
*
* @category PHPExcel
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_RichText_TextElement
*
* @category PHPExcel
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
{
/**
* Text
*
* @var string
*/
private $_text;
/**
* Text
*
* @var string
*/
private $text;
/**
* Create a new PHPExcel_RichText_TextElement instance
*
* @param string $pText Text
* @param string $pText Text
*/
public function __construct($pText = '')
{
// Initialise variables
$this->_text = $pText;
// Initialise variables
$this->text = $pText;
}
/**
* Get text
*
* @return string Text
*/
public function getText() {
return $this->_text;
}
/**
* Set text
*
* @param $pText string Text
* @return PHPExcel_RichText_ITextElement
*/
public function setText($pText = '') {
$this->_text = $pText;
return $this;
}
/**
* Get font
*
* @return PHPExcel_Style_Font
*/
public function getFont() {
return null;
}
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode() {
return md5(
$this->_text
. __CLASS__
);
/**
* Get text
*
* @return string Text
*/
public function getText()
{
return $this->text;
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
/**
* Set text
*
* @param $pText string Text
* @return PHPExcel_RichText_ITextElement
*/
public function setText($pText = '')
{
$this->text = $pText;
return $this;
}
/**
* Get font
*
* @return PHPExcel_Style_Font
*/
public function getFont()
{
return null;
}
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode()
{
return md5(
$this->text .
__CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
}

View file

@ -1,8 +1,18 @@
<?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel
* PHPExcel_Settings
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,42 +30,31 @@
*
* @category PHPExcel
* @package PHPExcel_Settings
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
class PHPExcel_Settings
{
/** constants */
/** Available Zip library classes */
const PCLZIP = 'PHPExcel_Shared_ZipArchive';
const ZIPARCHIVE = 'ZipArchive';
const PCLZIP = 'PHPExcel_Shared_ZipArchive';
const ZIPARCHIVE = 'ZipArchive';
/** Optional Chart Rendering libraries */
const CHART_RENDERER_JPGRAPH = 'jpgraph';
const CHART_RENDERER_JPGRAPH = 'jpgraph';
/** Optional PDF Rendering libraries */
const PDF_RENDERER_TCPDF = 'tcPDF';
const PDF_RENDERER_DOMPDF = 'DomPDF';
const PDF_RENDERER_MPDF = 'mPDF';
const PDF_RENDERER_TCPDF = 'tcPDF';
const PDF_RENDERER_DOMPDF = 'DomPDF';
const PDF_RENDERER_MPDF = 'mPDF';
private static $_chartRenderers = array(
private static $chartRenderers = array(
self::CHART_RENDERER_JPGRAPH,
);
private static $_pdfRenderers = array(
private static $pdfRenderers = array(
self::PDF_RENDERER_TCPDF,
self::PDF_RENDERER_DOMPDF,
self::PDF_RENDERER_MPDF,
@ -64,78 +63,84 @@ class PHPExcel_Settings
/**
* Name of the class used for Zip file management
* e.g.
* ZipArchive
* e.g.
* ZipArchive
*
* @var string
*/
private static $_zipClass = self::ZIPARCHIVE;
private static $zipClass = self::ZIPARCHIVE;
/**
* Name of the external Library used for rendering charts
* e.g.
* jpgraph
* e.g.
* jpgraph
*
* @var string
*/
private static $_chartRendererName = NULL;
private static $chartRendererName;
/**
* Directory Path to the external Library used for rendering charts
*
* @var string
*/
private static $_chartRendererPath = NULL;
private static $chartRendererPath;
/**
* Name of the external Library used for rendering PDF files
* e.g.
* mPDF
* e.g.
* mPDF
*
* @var string
*/
private static $_pdfRendererName = NULL;
private static $pdfRendererName;
/**
* Directory Path to the external Library used for rendering PDF files
*
* @var string
*/
private static $_pdfRendererPath = NULL;
private static $pdfRendererPath;
/**
* Default options for libxml loader
*
* @var int
*/
private static $libXmlLoaderOptions = null;
/**
* Set the Zip handler Class that PHPExcel should use for Zip file management (PCLZip or ZipArchive)
*
* @param string $zipClass The Zip handler class that PHPExcel should use for Zip file management
* e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
* @return boolean Success or failure
* @param string $zipClass The Zip handler class that PHPExcel should use for Zip file management
* e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
* @return boolean Success or failure
*/
public static function setZipClass($zipClass)
{
if (($zipClass === self::PCLZIP) ||
($zipClass === self::ZIPARCHIVE)) {
self::$_zipClass = $zipClass;
return TRUE;
self::$zipClass = $zipClass;
return true;
}
return FALSE;
} // function setZipClass()
return false;
}
/**
* Return the name of the Zip handler Class that PHPExcel is configured to use (PCLZip or ZipArchive)
* or Zip file management
* or Zip file management
*
* @return string Name of the Zip handler Class that PHPExcel is configured to use
* for Zip file management
* e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
* for Zip file management
* e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
*/
public static function getZipClass()
{
return self::$_zipClass;
} // function getZipClass()
return self::$zipClass;
}
/**
@ -146,7 +151,7 @@ class PHPExcel_Settings
public static function getCacheStorageMethod()
{
return PHPExcel_CachedObjectStorageFactory::getCacheStorageMethod();
} // function getCacheStorageMethod()
}
/**
@ -157,7 +162,7 @@ class PHPExcel_Settings
public static function getCacheStorageClass()
{
return PHPExcel_CachedObjectStorageFactory::getCacheStorageClass();
} // function getCacheStorageClass()
}
/**
@ -167,13 +172,10 @@ class PHPExcel_Settings
* @param array $arguments Optional configuration arguments for the cacheing method
* @return boolean Success or failure
*/
public static function setCacheStorageMethod(
$method = PHPExcel_CachedObjectStorageFactory::cache_in_memory,
$arguments = array()
)
public static function setCacheStorageMethod($method = PHPExcel_CachedObjectStorageFactory::cache_in_memory, $arguments = array())
{
return PHPExcel_CachedObjectStorageFactory::initialize($method, $arguments);
} // function setCacheStorageMethod()
}
/**
@ -182,97 +184,97 @@ class PHPExcel_Settings
* @param string $locale The locale code to use (e.g. "fr" or "pt_br" or "en_uk")
* @return boolean Success or failure
*/
public static function setLocale($locale='en_us')
public static function setLocale($locale = 'en_us')
{
return PHPExcel_Calculation::getInstance()->setLocale($locale);
} // function setLocale()
}
/**
* Set details of the external library that PHPExcel should use for rendering charts
*
* @param string $libraryName Internal reference name of the library
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
* @param string $libraryName Internal reference name of the library
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
* @param string $libraryBaseDir Directory path to the library's base folder
*
* @return boolean Success or failure
* @return boolean Success or failure
*/
public static function setChartRenderer($libraryName, $libraryBaseDir)
{
if (!self::setChartRendererName($libraryName))
return FALSE;
if (!self::setChartRendererName($libraryName)) {
return false;
}
return self::setChartRendererPath($libraryBaseDir);
} // function setChartRenderer()
}
/**
* Identify to PHPExcel the external library to use for rendering charts
*
* @param string $libraryName Internal reference name of the library
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
* @param string $libraryName Internal reference name of the library
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
*
* @return boolean Success or failure
* @return boolean Success or failure
*/
public static function setChartRendererName($libraryName)
{
if (!in_array($libraryName,self::$_chartRenderers)) {
return FALSE;
if (!in_array($libraryName, self::$chartRenderers)) {
return false;
}
self::$chartRendererName = $libraryName;
self::$_chartRendererName = $libraryName;
return TRUE;
} // function setChartRendererName()
return true;
}
/**
* Tell PHPExcel where to find the external library to use for rendering charts
*
* @param string $libraryBaseDir Directory path to the library's base folder
* @return boolean Success or failure
* @param string $libraryBaseDir Directory path to the library's base folder
* @return boolean Success or failure
*/
public static function setChartRendererPath($libraryBaseDir)
{
if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
return FALSE;
return false;
}
self::$_chartRendererPath = $libraryBaseDir;
self::$chartRendererPath = $libraryBaseDir;
return TRUE;
} // function setChartRendererPath()
return true;
}
/**
* Return the Chart Rendering Library that PHPExcel is currently configured to use (e.g. jpgraph)
*
* @return string|NULL Internal reference name of the Chart Rendering Library that PHPExcel is
* currently configured to use
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
* currently configured to use
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
*/
public static function getChartRendererName()
{
return self::$_chartRendererName;
} // function getChartRendererName()
return self::$chartRendererName;
}
/**
* Return the directory path to the Chart Rendering Library that PHPExcel is currently configured to use
*
* @return string|NULL Directory Path to the Chart Rendering Library that PHPExcel is
* currently configured to use
* currently configured to use
*/
public static function getChartRendererPath()
{
return self::$_chartRendererPath;
} // function getChartRendererPath()
return self::$chartRendererPath;
}
/**
* Set details of the external library that PHPExcel should use for rendering PDF files
*
* @param string $libraryName Internal reference name of the library
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
* or PHPExcel_Settings::PDF_RENDERER_MPDF
* @param string $libraryBaseDir Directory path to the library's base folder
*
@ -280,32 +282,32 @@ class PHPExcel_Settings
*/
public static function setPdfRenderer($libraryName, $libraryBaseDir)
{
if (!self::setPdfRendererName($libraryName))
return FALSE;
if (!self::setPdfRendererName($libraryName)) {
return false;
}
return self::setPdfRendererPath($libraryBaseDir);
} // function setPdfRenderer()
}
/**
* Identify to PHPExcel the external library to use for rendering PDF files
*
* @param string $libraryName Internal reference name of the library
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
* or PHPExcel_Settings::PDF_RENDERER_MPDF
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
* or PHPExcel_Settings::PDF_RENDERER_MPDF
*
* @return boolean Success or failure
*/
public static function setPdfRendererName($libraryName)
{
if (!in_array($libraryName,self::$_pdfRenderers)) {
return FALSE;
if (!in_array($libraryName, self::$pdfRenderers)) {
return false;
}
self::$pdfRendererName = $libraryName;
self::$_pdfRendererName = $libraryName;
return TRUE;
} // function setPdfRendererName()
return true;
}
/**
@ -317,38 +319,71 @@ class PHPExcel_Settings
public static function setPdfRendererPath($libraryBaseDir)
{
if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
return FALSE;
return false;
}
self::$_pdfRendererPath = $libraryBaseDir;
self::$pdfRendererPath = $libraryBaseDir;
return TRUE;
} // function setPdfRendererPath()
return true;
}
/**
* Return the PDF Rendering Library that PHPExcel is currently configured to use (e.g. dompdf)
*
* @return string|NULL Internal reference name of the PDF Rendering Library that PHPExcel is
* currently configured to use
* currently configured to use
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
* or PHPExcel_Settings::PDF_RENDERER_MPDF
*/
public static function getPdfRendererName()
{
return self::$_pdfRendererName;
} // function getPdfRendererName()
return self::$pdfRendererName;
}
/**
* Return the directory path to the PDF Rendering Library that PHPExcel is currently configured to use
*
* @return string|NULL Directory Path to the PDF Rendering Library that PHPExcel is
* currently configured to use
* currently configured to use
*/
public static function getPdfRendererPath()
{
return self::$_pdfRendererPath;
} // function getPdfRendererPath()
return self::$pdfRendererPath;
}
}
/**
* Set options for libxml loader
*
* @param int $options Options for libxml loader
*/
public static function setLibXmlLoaderOptions($options = null)
{
if (is_null($options) && defined('LIBXML_DTDLOAD')) {
$options = LIBXML_DTDLOAD | LIBXML_DTDATTR;
}
if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
@libxml_disable_entity_loader((bool) $options);
}
self::$libXmlLoaderOptions = $options;
}
/**
* Get defined options for libxml loader.
* Defaults to LIBXML_DTDLOAD | LIBXML_DTDATTR when not set explicitly.
*
* @return int Default options for libxml loader
*/
public static function getLibXmlLoaderOptions()
{
if (is_null(self::$libXmlLoaderOptions) && defined('LIBXML_DTDLOAD')) {
self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR);
} elseif (is_null(self::$libXmlLoaderOptions)) {
self::$libXmlLoaderOptions = true;
}
if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
@libxml_disable_entity_loader((bool) self::$libXmlLoaderOptions);
}
return self::$libXmlLoaderOptions;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Shared_CodePage
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,82 +21,136 @@
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Shared_CodePage
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_CodePage
{
/**
* Convert Microsoft Code Page Identifier to Code Page Name which iconv
* and mbstring understands
*
* @param integer $codePage Microsoft Code Page Indentifier
* @return string Code Page Name
* @throws PHPExcel_Exception
*/
public static function NumberToName($codePage = 1252)
{
switch ($codePage) {
case 367: return 'ASCII'; break; // ASCII
case 437: return 'CP437'; break; // OEM US
case 720: throw new PHPExcel_Exception('Code page 720 not supported.');
break; // OEM Arabic
case 737: return 'CP737'; break; // OEM Greek
case 775: return 'CP775'; break; // OEM Baltic
case 850: return 'CP850'; break; // OEM Latin I
case 852: return 'CP852'; break; // OEM Latin II (Central European)
case 855: return 'CP855'; break; // OEM Cyrillic
case 857: return 'CP857'; break; // OEM Turkish
case 858: return 'CP858'; break; // OEM Multilingual Latin I with Euro
case 860: return 'CP860'; break; // OEM Portugese
case 861: return 'CP861'; break; // OEM Icelandic
case 862: return 'CP862'; break; // OEM Hebrew
case 863: return 'CP863'; break; // OEM Canadian (French)
case 864: return 'CP864'; break; // OEM Arabic
case 865: return 'CP865'; break; // OEM Nordic
case 866: return 'CP866'; break; // OEM Cyrillic (Russian)
case 869: return 'CP869'; break; // OEM Greek (Modern)
case 874: return 'CP874'; break; // ANSI Thai
case 932: return 'CP932'; break; // ANSI Japanese Shift-JIS
case 936: return 'CP936'; break; // ANSI Chinese Simplified GBK
case 949: return 'CP949'; break; // ANSI Korean (Wansung)
case 950: return 'CP950'; break; // ANSI Chinese Traditional BIG5
case 1200: return 'UTF-16LE'; break; // UTF-16 (BIFF8)
case 1250: return 'CP1250'; break; // ANSI Latin II (Central European)
case 1251: return 'CP1251'; break; // ANSI Cyrillic
case 0: // CodePage is not always correctly set when the xls file was saved by Apple's Numbers program
case 1252: return 'CP1252'; break; // ANSI Latin I (BIFF4-BIFF7)
case 1253: return 'CP1253'; break; // ANSI Greek
case 1254: return 'CP1254'; break; // ANSI Turkish
case 1255: return 'CP1255'; break; // ANSI Hebrew
case 1256: return 'CP1256'; break; // ANSI Arabic
case 1257: return 'CP1257'; break; // ANSI Baltic
case 1258: return 'CP1258'; break; // ANSI Vietnamese
case 1361: return 'CP1361'; break; // ANSI Korean (Johab)
case 10000: return 'MAC'; break; // Apple Roman
case 10006: return 'MACGREEK'; break; // Macintosh Greek
case 10007: return 'MACCYRILLIC'; break; // Macintosh Cyrillic
case 10029: return 'MACCENTRALEUROPE'; break; // Macintosh Central Europe
case 10079: return 'MACICELAND'; break; // Macintosh Icelandic
case 10081: return 'MACTURKISH'; break; // Macintosh Turkish
case 32768: return 'MAC'; break; // Apple Roman
case 32769: throw new PHPExcel_Exception('Code page 32769 not supported.');
break; // ANSI Latin I (BIFF2-BIFF3)
case 65000: return 'UTF-7'; break; // Unicode (UTF-7)
case 65001: return 'UTF-8'; break; // Unicode (UTF-8)
}
throw new PHPExcel_Exception('Unknown codepage: ' . $codePage);
}
/**
* Convert Microsoft Code Page Identifier to Code Page Name which iconv
* and mbstring understands
*
* @param integer $codePage Microsoft Code Page Indentifier
* @return string Code Page Name
* @throws PHPExcel_Exception
*/
public static function NumberToName($codePage = 1252)
{
switch ($codePage) {
case 367:
return 'ASCII'; // ASCII
case 437:
return 'CP437'; // OEM US
case 720:
throw new PHPExcel_Exception('Code page 720 not supported.'); // OEM Arabic
case 737:
return 'CP737'; // OEM Greek
case 775:
return 'CP775'; // OEM Baltic
case 850:
return 'CP850'; // OEM Latin I
case 852:
return 'CP852'; // OEM Latin II (Central European)
case 855:
return 'CP855'; // OEM Cyrillic
case 857:
return 'CP857'; // OEM Turkish
case 858:
return 'CP858'; // OEM Multilingual Latin I with Euro
case 860:
return 'CP860'; // OEM Portugese
case 861:
return 'CP861'; // OEM Icelandic
case 862:
return 'CP862'; // OEM Hebrew
case 863:
return 'CP863'; // OEM Canadian (French)
case 864:
return 'CP864'; // OEM Arabic
case 865:
return 'CP865'; // OEM Nordic
case 866:
return 'CP866'; // OEM Cyrillic (Russian)
case 869:
return 'CP869'; // OEM Greek (Modern)
case 874:
return 'CP874'; // ANSI Thai
case 932:
return 'CP932'; // ANSI Japanese Shift-JIS
case 936:
return 'CP936'; // ANSI Chinese Simplified GBK
case 949:
return 'CP949'; // ANSI Korean (Wansung)
case 950:
return 'CP950'; // ANSI Chinese Traditional BIG5
case 1200:
return 'UTF-16LE'; // UTF-16 (BIFF8)
case 1250:
return 'CP1250'; // ANSI Latin II (Central European)
case 1251:
return 'CP1251'; // ANSI Cyrillic
case 0:
// CodePage is not always correctly set when the xls file was saved by Apple's Numbers program
case 1252:
return 'CP1252'; // ANSI Latin I (BIFF4-BIFF7)
case 1253:
return 'CP1253'; // ANSI Greek
case 1254:
return 'CP1254'; // ANSI Turkish
case 1255:
return 'CP1255'; // ANSI Hebrew
case 1256:
return 'CP1256'; // ANSI Arabic
case 1257:
return 'CP1257'; // ANSI Baltic
case 1258:
return 'CP1258'; // ANSI Vietnamese
case 1361:
return 'CP1361'; // ANSI Korean (Johab)
case 10000:
return 'MAC'; // Apple Roman
case 10001:
return 'CP932'; // Macintosh Japanese
case 10002:
return 'CP950'; // Macintosh Chinese Traditional
case 10003:
return 'CP1361'; // Macintosh Korean
case 10004:
return 'MACARABIC'; // Apple Arabic
case 10005:
return 'MACHEBREW'; // Apple Hebrew
case 10006:
return 'MACGREEK'; // Macintosh Greek
case 10007:
return 'MACCYRILLIC'; // Macintosh Cyrillic
case 10008:
return 'CP936'; // Macintosh - Simplified Chinese (GB 2312)
case 10010:
return 'MACROMANIA'; // Macintosh Romania
case 10017:
return 'MACUKRAINE'; // Macintosh Ukraine
case 10021:
return 'MACTHAI'; // Macintosh Thai
case 10029:
return 'MACCENTRALEUROPE'; // Macintosh Central Europe
case 10079:
return 'MACICELAND'; // Macintosh Icelandic
case 10081:
return 'MACTURKISH'; // Macintosh Turkish
case 10082:
return 'MACCROATIAN'; // Macintosh Croatian
case 21010:
return 'UTF-16LE'; // UTF-16 (BIFF8) This isn't correct, but some Excel writer libraries erroneously use Codepage 21010 for UTF-16LE
case 32768:
return 'MAC'; // Apple Roman
case 32769:
throw new PHPExcel_Exception('Code page 32769 not supported.'); // ANSI Latin I (BIFF2-BIFF3)
case 65000:
return 'UTF-7'; // Unicode (UTF-7)
case 65001:
return 'UTF-8'; // Unicode (UTF-8)
}
throw new PHPExcel_Exception('Unknown codepage: ' . $codePage);
}
}

View file

@ -1,9 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Shared_Date
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,357 +20,379 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Shared_Date
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Shared_Date
{
/** constants */
const CALENDAR_WINDOWS_1900 = 1900; // Base date of 1st Jan 1900 = 1.0
const CALENDAR_MAC_1904 = 1904; // Base date of 2nd Jan 1904 = 1.0
/** constants */
const CALENDAR_WINDOWS_1900 = 1900; // Base date of 1st Jan 1900 = 1.0
const CALENDAR_MAC_1904 = 1904; // Base date of 2nd Jan 1904 = 1.0
/*
* Names of the months of the year, indexed by shortname
* Planned usage for locale settings
*
* @public
* @var string[]
*/
public static $_monthNames = array( 'Jan' => 'January',
'Feb' => 'February',
'Mar' => 'March',
'Apr' => 'April',
'May' => 'May',
'Jun' => 'June',
'Jul' => 'July',
'Aug' => 'August',
'Sep' => 'September',
'Oct' => 'October',
'Nov' => 'November',
'Dec' => 'December',
);
/*
* Names of the months of the year, indexed by shortname
* Planned usage for locale settings
*
* @public
* @var string[]
*/
public static $monthNames = array(
'Jan' => 'January',
'Feb' => 'February',
'Mar' => 'March',
'Apr' => 'April',
'May' => 'May',
'Jun' => 'June',
'Jul' => 'July',
'Aug' => 'August',
'Sep' => 'September',
'Oct' => 'October',
'Nov' => 'November',
'Dec' => 'December',
);
/*
* Names of the months of the year, indexed by shortname
* Planned usage for locale settings
*
* @public
* @var string[]
*/
public static $_numberSuffixes = array( 'st',
'nd',
'rd',
'th',
);
/*
* Names of the months of the year, indexed by shortname
* Planned usage for locale settings
*
* @public
* @var string[]
*/
public static $numberSuffixes = array(
'st',
'nd',
'rd',
'th',
);
/*
* Base calendar year to use for calculations
*
* @private
* @var int
*/
protected static $_excelBaseDate = self::CALENDAR_WINDOWS_1900;
/*
* Base calendar year to use for calculations
*
* @private
* @var int
*/
protected static $excelBaseDate = self::CALENDAR_WINDOWS_1900;
/**
* Set the Excel calendar (Windows 1900 or Mac 1904)
*
* @param integer $baseDate Excel base date (1900 or 1904)
* @return boolean Success or failure
*/
public static function setExcelCalendar($baseDate) {
if (($baseDate == self::CALENDAR_WINDOWS_1900) ||
($baseDate == self::CALENDAR_MAC_1904)) {
self::$_excelBaseDate = $baseDate;
return TRUE;
}
return FALSE;
} // function setExcelCalendar()
/**
* Set the Excel calendar (Windows 1900 or Mac 1904)
*
* @param integer $baseDate Excel base date (1900 or 1904)
* @return boolean Success or failure
*/
public static function setExcelCalendar($baseDate)
{
if (($baseDate == self::CALENDAR_WINDOWS_1900) ||
($baseDate == self::CALENDAR_MAC_1904)) {
self::$excelBaseDate = $baseDate;
return true;
}
return false;
}
/**
* Return the Excel calendar (Windows 1900 or Mac 1904)
*
* @return integer Excel base date (1900 or 1904)
*/
public static function getExcelCalendar() {
return self::$_excelBaseDate;
} // function getExcelCalendar()
/**
* Return the Excel calendar (Windows 1900 or Mac 1904)
*
* @return integer Excel base date (1900 or 1904)
*/
public static function getExcelCalendar()
{
return self::$excelBaseDate;
}
/**
* Convert a date from Excel to PHP
*
* @param long $dateValue Excel date/time value
* @param boolean $adjustToTimezone Flag indicating whether $dateValue should be treated as
* a UST timestamp, or adjusted to UST
* @param string $timezone The timezone for finding the adjustment from UST
* @return long PHP serialized date/time
*/
public static function ExcelToPHP($dateValue = 0, $adjustToTimezone = FALSE, $timezone = NULL) {
if (self::$_excelBaseDate == self::CALENDAR_WINDOWS_1900) {
$my_excelBaseDate = 25569;
// Adjust for the spurious 29-Feb-1900 (Day 60)
if ($dateValue < 60) {
--$my_excelBaseDate;
}
} else {
$my_excelBaseDate = 24107;
}
/**
* Convert a date from Excel to PHP
*
* @param integer $dateValue Excel date/time value
* @param boolean $adjustToTimezone Flag indicating whether $dateValue should be treated as
* a UST timestamp, or adjusted to UST
* @param string $timezone The timezone for finding the adjustment from UST
* @return integer PHP serialized date/time
*/
public static function ExcelToPHP($dateValue = 0, $adjustToTimezone = false, $timezone = null)
{
if (self::$excelBaseDate == self::CALENDAR_WINDOWS_1900) {
$myexcelBaseDate = 25569;
// Adjust for the spurious 29-Feb-1900 (Day 60)
if ($dateValue < 60) {
--$myexcelBaseDate;
}
} else {
$myexcelBaseDate = 24107;
}
// Perform conversion
if ($dateValue >= 1) {
$utcDays = $dateValue - $my_excelBaseDate;
$returnValue = round($utcDays * 86400);
if (($returnValue <= PHP_INT_MAX) && ($returnValue >= -PHP_INT_MAX)) {
$returnValue = (integer) $returnValue;
}
} else {
$hours = round($dateValue * 24);
$mins = round($dateValue * 1440) - round($hours * 60);
$secs = round($dateValue * 86400) - round($hours * 3600) - round($mins * 60);
$returnValue = (integer) gmmktime($hours, $mins, $secs);
}
// Perform conversion
if ($dateValue >= 1) {
$utcDays = $dateValue - $myexcelBaseDate;
$returnValue = round($utcDays * 86400);
if (($returnValue <= PHP_INT_MAX) && ($returnValue >= -PHP_INT_MAX)) {
$returnValue = (integer) $returnValue;
}
} else {
$hours = round($dateValue * 24);
$mins = round($dateValue * 1440) - round($hours * 60);
$secs = round($dateValue * 86400) - round($hours * 3600) - round($mins * 60);
$returnValue = (integer) gmmktime($hours, $mins, $secs);
}
$timezoneAdjustment = ($adjustToTimezone) ?
PHPExcel_Shared_TimeZone::getTimezoneAdjustment($timezone, $returnValue) :
0;
$timezoneAdjustment = ($adjustToTimezone) ?
PHPExcel_Shared_TimeZone::getTimezoneAdjustment($timezone, $returnValue) :
0;
// Return
return $returnValue + $timezoneAdjustment;
} // function ExcelToPHP()
return $returnValue + $timezoneAdjustment;
}
/**
* Convert a date from Excel to a PHP Date/Time object
*
* @param integer $dateValue Excel date/time value
* @return integer PHP date/time object
*/
public static function ExcelToPHPObject($dateValue = 0) {
$dateTime = self::ExcelToPHP($dateValue);
$days = floor($dateTime / 86400);
$time = round((($dateTime / 86400) - $days) * 86400);
$hours = round($time / 3600);
$minutes = round($time / 60) - ($hours * 60);
$seconds = round($time) - ($hours * 3600) - ($minutes * 60);
/**
* Convert a date from Excel to a PHP Date/Time object
*
* @param integer $dateValue Excel date/time value
* @return DateTime PHP date/time object
*/
public static function ExcelToPHPObject($dateValue = 0)
{
$dateTime = self::ExcelToPHP($dateValue);
$days = floor($dateTime / 86400);
$time = round((($dateTime / 86400) - $days) * 86400);
$hours = round($time / 3600);
$minutes = round($time / 60) - ($hours * 60);
$seconds = round($time) - ($hours * 3600) - ($minutes * 60);
$dateObj = date_create('1-Jan-1970+'.$days.' days');
$dateObj->setTime($hours,$minutes,$seconds);
$dateObj = date_create('1-Jan-1970+'.$days.' days');
$dateObj->setTime($hours, $minutes, $seconds);
return $dateObj;
} // function ExcelToPHPObject()
return $dateObj;
}
/**
* Convert a date from PHP to Excel
*
* @param mixed $dateValue PHP serialized date/time or date object
* @param boolean $adjustToTimezone Flag indicating whether $dateValue should be treated as
* a UST timestamp, or adjusted to UST
* @param string $timezone The timezone for finding the adjustment from UST
* @return mixed Excel date/time value
* or boolean FALSE on failure
*/
public static function PHPToExcel($dateValue = 0, $adjustToTimezone = FALSE, $timezone = NULL) {
$saveTimeZone = date_default_timezone_get();
date_default_timezone_set('UTC');
$retValue = FALSE;
if ((is_object($dateValue)) && ($dateValue instanceof DateTime)) {
$retValue = self::FormattedPHPToExcel( $dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'),
$dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s')
);
} elseif (is_numeric($dateValue)) {
$retValue = self::FormattedPHPToExcel( date('Y',$dateValue), date('m',$dateValue), date('d',$dateValue),
date('H',$dateValue), date('i',$dateValue), date('s',$dateValue)
);
}
date_default_timezone_set($saveTimeZone);
/**
* Convert a date from PHP to Excel
*
* @param mixed $dateValue PHP serialized date/time or date object
* @param boolean $adjustToTimezone Flag indicating whether $dateValue should be treated as
* a UST timestamp, or adjusted to UST
* @param string $timezone The timezone for finding the adjustment from UST
* @return mixed Excel date/time value
* or boolean FALSE on failure
*/
public static function PHPToExcel($dateValue = 0, $adjustToTimezone = false, $timezone = null)
{
$saveTimeZone = date_default_timezone_get();
date_default_timezone_set('UTC');
return $retValue;
} // function PHPToExcel()
$timezoneAdjustment = ($adjustToTimezone) ?
PHPExcel_Shared_TimeZone::getTimezoneAdjustment($timezone ? $timezone : $saveTimeZone, $dateValue) :
0;
$retValue = false;
if ((is_object($dateValue)) && ($dateValue instanceof DateTime)) {
$dateValue->add(new DateInterval('PT' . $timezoneAdjustment . 'S'));
$retValue = self::FormattedPHPToExcel($dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'), $dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s'));
} elseif (is_numeric($dateValue)) {
$dateValue += $timezoneAdjustment;
$retValue = self::FormattedPHPToExcel(date('Y', $dateValue), date('m', $dateValue), date('d', $dateValue), date('H', $dateValue), date('i', $dateValue), date('s', $dateValue));
} elseif (is_string($dateValue)) {
$retValue = self::stringToExcel($dateValue);
}
date_default_timezone_set($saveTimeZone);
return $retValue;
}
/**
* FormattedPHPToExcel
*
* @param long $year
* @param long $month
* @param long $day
* @param long $hours
* @param long $minutes
* @param long $seconds
* @return long Excel date/time value
*/
public static function FormattedPHPToExcel($year, $month, $day, $hours=0, $minutes=0, $seconds=0) {
if (self::$_excelBaseDate == self::CALENDAR_WINDOWS_1900) {
//
// Fudge factor for the erroneous fact that the year 1900 is treated as a Leap Year in MS Excel
// This affects every date following 28th February 1900
//
$excel1900isLeapYear = TRUE;
if (($year == 1900) && ($month <= 2)) { $excel1900isLeapYear = FALSE; }
$my_excelBaseDate = 2415020;
} else {
$my_excelBaseDate = 2416481;
$excel1900isLeapYear = FALSE;
}
/**
* FormattedPHPToExcel
*
* @param integer $year
* @param integer $month
* @param integer $day
* @param integer $hours
* @param integer $minutes
* @param integer $seconds
* @return integer Excel date/time value
*/
public static function FormattedPHPToExcel($year, $month, $day, $hours = 0, $minutes = 0, $seconds = 0)
{
if (self::$excelBaseDate == self::CALENDAR_WINDOWS_1900) {
//
// Fudge factor for the erroneous fact that the year 1900 is treated as a Leap Year in MS Excel
// This affects every date following 28th February 1900
//
$excel1900isLeapYear = true;
if (($year == 1900) && ($month <= 2)) {
$excel1900isLeapYear = false;
}
$myexcelBaseDate = 2415020;
} else {
$myexcelBaseDate = 2416481;
$excel1900isLeapYear = false;
}
// Julian base date Adjustment
if ($month > 2) {
$month -= 3;
} else {
$month += 9;
--$year;
}
// Julian base date Adjustment
if ($month > 2) {
$month -= 3;
} else {
$month += 9;
--$year;
}
// Calculate the Julian Date, then subtract the Excel base date (JD 2415020 = 31-Dec-1899 Giving Excel Date of 0)
$century = substr($year,0,2);
$decade = substr($year,2,2);
$excelDate = floor((146097 * $century) / 4) + floor((1461 * $decade) / 4) + floor((153 * $month + 2) / 5) + $day + 1721119 - $my_excelBaseDate + $excel1900isLeapYear;
// Calculate the Julian Date, then subtract the Excel base date (JD 2415020 = 31-Dec-1899 Giving Excel Date of 0)
$century = substr($year, 0, 2);
$decade = substr($year, 2, 2);
$excelDate = floor((146097 * $century) / 4) + floor((1461 * $decade) / 4) + floor((153 * $month + 2) / 5) + $day + 1721119 - $myexcelBaseDate + $excel1900isLeapYear;
$excelTime = (($hours * 3600) + ($minutes * 60) + $seconds) / 86400;
$excelTime = (($hours * 3600) + ($minutes * 60) + $seconds) / 86400;
return (float) $excelDate + $excelTime;
} // function FormattedPHPToExcel()
return (float) $excelDate + $excelTime;
}
/**
* Is a given cell a date/time?
*
* @param PHPExcel_Cell $pCell
* @return boolean
*/
public static function isDateTime(PHPExcel_Cell $pCell) {
return self::isDateTimeFormat(
$pCell->getWorksheet()->getStyle(
$pCell->getCoordinate()
)->getNumberFormat()
);
} // function isDateTime()
/**
* Is a given cell a date/time?
*
* @param PHPExcel_Cell $pCell
* @return boolean
*/
public static function isDateTime(PHPExcel_Cell $pCell)
{
return self::isDateTimeFormat(
$pCell->getWorksheet()->getStyle(
$pCell->getCoordinate()
)->getNumberFormat()
);
}
/**
* Is a given number format a date/time?
*
* @param PHPExcel_Style_NumberFormat $pFormat
* @return boolean
*/
public static function isDateTimeFormat(PHPExcel_Style_NumberFormat $pFormat) {
return self::isDateTimeFormatCode($pFormat->getFormatCode());
} // function isDateTimeFormat()
/**
* Is a given number format a date/time?
*
* @param PHPExcel_Style_NumberFormat $pFormat
* @return boolean
*/
public static function isDateTimeFormat(PHPExcel_Style_NumberFormat $pFormat)
{
return self::isDateTimeFormatCode($pFormat->getFormatCode());
}
private static $possibleDateFormatCharacters = 'eymdHs';
private static $possibleDateFormatCharacters = 'eymdHs';
/**
* Is a given number format code a date/time?
*
* @param string $pFormatCode
* @return boolean
*/
public static function isDateTimeFormatCode($pFormatCode = '') {
// Switch on formatcode
switch ($pFormatCode) {
// General contains an epoch letter 'e', so we trap for it explicitly here
case PHPExcel_Style_NumberFormat::FORMAT_GENERAL:
return FALSE;
// Explicitly defined date formats
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DDMMYYYY:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMYSLASH:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMYMINUS:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMMINUS:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_MYMINUS:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DATETIME:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME1:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME2:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME5:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME6:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME7:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME8:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDDSLASH:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX14:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX16:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX17:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX22:
return TRUE;
}
/**
* Is a given number format code a date/time?
*
* @param string $pFormatCode
* @return boolean
*/
public static function isDateTimeFormatCode($pFormatCode = '')
{
if (strtolower($pFormatCode) === strtolower(PHPExcel_Style_NumberFormat::FORMAT_GENERAL)) {
// "General" contains an epoch letter 'e', so we trap for it explicitly here (case-insensitive check)
return false;
}
if (preg_match('/[0#]E[+-]0/i', $pFormatCode)) {
// Scientific format
return false;
}
// Typically number, currency or accounting (or occasionally fraction) formats
if ((substr($pFormatCode,0,1) == '_') || (substr($pFormatCode,0,2) == '0 ')) {
return FALSE;
}
// Try checking for any of the date formatting characters that don't appear within square braces
if (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$pFormatCode)) {
// We might also have a format mask containing quoted strings...
// we don't want to test for any of our characters within the quoted blocks
if (strpos($pFormatCode,'"') !== FALSE) {
$segMatcher = FALSE;
foreach(explode('"',$pFormatCode) as $subVal) {
// Only test in alternate array entries (the non-quoted blocks)
if (($segMatcher = !$segMatcher) &&
(preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$subVal))) {
return TRUE;
}
}
return FALSE;
}
return TRUE;
}
// Switch on formatcode
switch ($pFormatCode) {
// Explicitly defined date formats
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DDMMYYYY:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMYSLASH:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMYMINUS:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMMINUS:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_MYMINUS:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DATETIME:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME1:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME2:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME5:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME6:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME7:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME8:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDDSLASH:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX14:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX16:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX17:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX22:
return true;
}
// No date...
return FALSE;
} // function isDateTimeFormatCode()
// Typically number, currency or accounting (or occasionally fraction) formats
if ((substr($pFormatCode, 0, 1) == '_') || (substr($pFormatCode, 0, 2) == '0 ')) {
return false;
}
// Try checking for any of the date formatting characters that don't appear within square braces
if (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i', $pFormatCode)) {
// We might also have a format mask containing quoted strings...
// we don't want to test for any of our characters within the quoted blocks
if (strpos($pFormatCode, '"') !== false) {
$segMatcher = false;
foreach (explode('"', $pFormatCode) as $subVal) {
// Only test in alternate array entries (the non-quoted blocks)
if (($segMatcher = !$segMatcher) &&
(preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i', $subVal))) {
return true;
}
}
return false;
}
return true;
}
// No date...
return false;
}
/**
* Convert a date/time string to Excel time
*
* @param string $dateValue Examples: '2009-12-31', '2009-12-31 15:59', '2009-12-31 15:59:10'
* @return float|FALSE Excel date/time serial value
*/
public static function stringToExcel($dateValue = '') {
if (strlen($dateValue) < 2)
return FALSE;
if (!preg_match('/^(\d{1,4}[ \.\/\-][A-Z]{3,9}([ \.\/\-]\d{1,4})?|[A-Z]{3,9}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?|\d{1,4}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?)( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/iu', $dateValue))
return FALSE;
/**
* Convert a date/time string to Excel time
*
* @param string $dateValue Examples: '2009-12-31', '2009-12-31 15:59', '2009-12-31 15:59:10'
* @return float|FALSE Excel date/time serial value
*/
public static function stringToExcel($dateValue = '')
{
if (strlen($dateValue) < 2) {
return false;
}
if (!preg_match('/^(\d{1,4}[ \.\/\-][A-Z]{3,9}([ \.\/\-]\d{1,4})?|[A-Z]{3,9}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?|\d{1,4}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?)( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/iu', $dateValue)) {
return false;
}
$dateValueNew = PHPExcel_Calculation_DateTime::DATEVALUE($dateValue);
$dateValueNew = PHPExcel_Calculation_DateTime::DATEVALUE($dateValue);
if ($dateValueNew === PHPExcel_Calculation_Functions::VALUE()) {
return FALSE;
} else {
if (strpos($dateValue, ':') !== FALSE) {
$timeValue = PHPExcel_Calculation_DateTime::TIMEVALUE($dateValue);
if ($timeValue === PHPExcel_Calculation_Functions::VALUE()) {
return FALSE;
}
$dateValueNew += $timeValue;
}
return $dateValueNew;
}
if ($dateValueNew === PHPExcel_Calculation_Functions::VALUE()) {
return false;
}
if (strpos($dateValue, ':') !== false) {
$timeValue = PHPExcel_Calculation_DateTime::TIMEVALUE($dateValue);
if ($timeValue === PHPExcel_Calculation_Functions::VALUE()) {
return false;
}
$dateValueNew += $timeValue;
}
return $dateValueNew;
}
}
public static function monthStringToNumber($month) {
/**
* Converts a month name (either a long or a short name) to a month number
*
* @param string $month Month name or abbreviation
* @return integer|string Month number (1 - 12), or the original string argument if it isn't a valid month name
*/
public static function monthStringToNumber($month)
{
$monthIndex = 1;
foreach(self::$_monthNames as $shortMonthName => $longMonthName) {
foreach (self::$monthNames as $shortMonthName => $longMonthName) {
if (($month === $longMonthName) || ($month === $shortMonthName)) {
return $monthIndex;
}
@ -379,12 +401,18 @@ class PHPExcel_Shared_Date
return $month;
}
public static function dayStringToNumber($day) {
$strippedDayValue = (str_replace(self::$_numberSuffixes,'',$day));
if (is_numeric($strippedDayValue)) {
return $strippedDayValue;
}
return $day;
/**
* Strips an ordinal froma numeric value
*
* @param string $day Day number with an ordinal
* @return integer|string The integer value with any ordinal stripped, or the original string argument if it isn't a valid numeric
*/
public static function dayStringToNumber($day)
{
$strippedDayValue = (str_replace(self::$numberSuffixes, '', $day));
if (is_numeric($strippedDayValue)) {
return (integer) $strippedDayValue;
}
return $day;
}
}

Some files were not shown because too many files have changed in this diff Show more