Compare commits

...

172 commits
1.8.1 ... 1.8

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
359 changed files with 88600 additions and 86615 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,19 +1,28 @@
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:
## PHP_CodeSniffer
- ./vendor/bin/phpcs --report-width=200 --report-summary --report-full Classes/ unitTests/ --standard=PSR2 -n
## PHPUnit
- phpunit -c ./unitTests/
notifications:

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 - 2014 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,70 +31,51 @@
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2014 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 - 2014 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
spl_autoload_register('__autoload');
}
// Register ourselves with SPL
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'), true, true);
return spl_autoload_register(array('PHPExcel_Autoloader', 'load'), true, true);
} else {
return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));
return spl_autoload_register(array('PHPExcel_Autoloader', 'load'));
}
}
} // function Register()
/**
* 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)) {
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;
return false;
}
$pClassFilePath = PHPEXCEL_ROOT .
str_replace('_',DIRECTORY_SEPARATOR,$pClassName) .
str_replace('_', DIRECTORY_SEPARATOR, $pClassName) .
'.php';
if ((file_exists($pClassFilePath) === FALSE) || (is_readable($pClassFilePath) === FALSE)) {
if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) {
// Can't load
return FALSE;
return false;
}
require($pClassFilePath);
} // function Load()
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_CachedObjectStorage_APC
*
* Copyright (c) 2006 - 2014 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 - 2014 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 - 2014 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 && !empty($this->_currentObjectID)) {
$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;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
@ -83,19 +78,19 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
* @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?
@ -105,15 +100,16 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
* @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,30 +148,29 @@ 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();
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
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,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_CachedObjectStorage_CacheBase
*
* Copyright (c) 2006 - 2014 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,49 +21,39 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 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_CacheBase
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
abstract class PHPExcel_CachedObjectStorage_CacheBase {
abstract class PHPExcel_CachedObjectStorage_CacheBase
{
/**
* Parent worksheet
*
* @var PHPExcel_Worksheet
*/
protected $_parent;
protected $parent;
/**
* The currently active Cell
*
* @var PHPExcel_Cell
*/
protected $_currentObject = null;
protected $currentObject = null;
/**
* Coordinate address of the currently active Cell
*
* @var string
*/
protected $_currentObjectID = null;
protected $currentObjectID = null;
/**
* Flag indicating whether the currently active Cell requires saving
*
* @var boolean
*/
protected $_currentCellIsDirty = true;
protected $currentCellIsDirty = true;
/**
* An array of cells or cell pointers for the worksheet cells held in this cache,
@ -70,21 +61,20 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
*
* @var array of mixed
*/
protected $_cellCache = array();
protected $cellCache = array();
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
*/
public function __construct(PHPExcel_Worksheet $parent) {
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()
$this->parent = $parent;
}
/**
* Return the parent worksheet for this cell collection
@ -93,7 +83,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
*/
public function getParent()
{
return $this->_parent;
return $this->parent;
}
/**
@ -102,14 +92,14 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
*/
public function isDataSet($pCoord) {
if ($pCoord === $this->_currentObjectID) {
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()
return isset($this->cellCache[$pCoord]);
}
/**
* Move a cell object from one address to another
@ -118,19 +108,19 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
* @param string $toAddress Destination address of the cell to move
* @return boolean
*/
public function moveCell($fromAddress, $toAddress) {
if ($fromAddress === $this->_currentObjectID) {
$this->_currentObjectID = $toAddress;
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]);
$this->currentCellIsDirty = true;
if (isset($this->cellCache[$fromAddress])) {
$this->cellCache[$toAddress] = &$this->cellCache[$fromAddress];
unset($this->cellCache[$fromAddress]);
}
return TRUE;
} // function moveCell()
return true;
}
/**
* Add or Update a cell in cache
@ -139,10 +129,10 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function updateCacheData(PHPExcel_Cell $cell) {
return $this->addCacheData($cell->getCoordinate(),$cell);
} // function updateCacheData()
public function updateCacheData(PHPExcel_Cell $cell)
{
return $this->addCacheData($cell->getCoordinate(), $cell);
}
/**
* Delete a cell in cache identified by coordinate address
@ -150,47 +140,46 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
* @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;
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]);
if (is_object($this->cellCache[$pCoord])) {
$this->cellCache[$pCoord]->detach();
unset($this->cellCache[$pCoord]);
}
$this->currentCellIsDirty = false;
}
$this->_currentCellIsDirty = false;
} // function deleteCacheData()
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList() {
return array_keys($this->_cellCache);
} // function getCellList()
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() {
public function getSortedCellList()
{
$sortKeys = array();
foreach ($this->getCellList() as $coord) {
sscanf($coord,'%[A-Z]%d', $column, $row);
$sortKeys[sprintf('%09d%3s',$row,$column)] = $coord;
sscanf($coord, '%[A-Z]%d', $column, $row);
$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
@ -203,22 +192,22 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
$col = array('A' => '1A');
$row = array(1);
foreach ($this->getCellList() as $coord) {
sscanf($coord,'%[A-Z]%d', $c, $r);
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);
$highestColumn = substr(max($col), 1);
}
return array( 'row' => $highestRow,
return array(
'row' => $highestRow,
'column' => $highestColumn
);
}
/**
* Return the cell address of the currently active cell object
*
@ -226,7 +215,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
*/
public function getCurrentAddress()
{
return $this->_currentObjectID;
return $this->currentObjectID;
}
/**
@ -236,7 +225,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
*/
public function getCurrentColumn()
{
sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row);
sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row);
return $column;
}
@ -247,7 +236,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
*/
public function getCurrentRow()
{
sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row);
sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row);
return (integer) $row;
}
@ -267,7 +256,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
$columnList = array(1);
foreach ($this->getCellList() as $coord) {
sscanf($coord,'%[A-Z]%d', $c, $r);
sscanf($coord, '%[A-Z]%d', $c, $r);
if ($r != $row) {
continue;
}
@ -292,7 +281,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
$rowList = array(0);
foreach ($this->getCellList() as $coord) {
sscanf($coord,'%[A-Z]%d', $c, $r);
sscanf($coord, '%[A-Z]%d', $c, $r);
if ($c != $column) {
continue;
}
@ -302,19 +291,19 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
return max($rowList);
}
/**
* Generate a unique ID for cache referencing
*
* @return string Unique Reference
*/
protected function _getUniqueID() {
protected function getUniqueID()
{
if (function_exists('posix_getpid')) {
$baseUnique = posix_getpid();
} else {
$baseUnique = mt_rand();
}
return uniqid($baseUnique,true);
return uniqid($baseUnique, true);
}
/**
@ -323,13 +312,14 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
$this->_currentCellIsDirty;
$this->_storeData();
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);
$this->parent = $parent;
if (($this->currentObject !== null) && (is_object($this->currentObject))) {
$this->currentObject->attach($this);
}
} // function copyCellCollection()
@ -339,9 +329,10 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
* @param string $row Row number to remove
* @return void
*/
public function removeRow($row) {
public function removeRow($row)
{
foreach ($this->getCellList() as $coord) {
sscanf($coord,'%[A-Z]%d', $c, $r);
sscanf($coord, '%[A-Z]%d', $c, $r);
if ($r == $row) {
$this->deleteCacheData($coord);
}
@ -354,9 +345,10 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
* @param string $column Column ID to remove
* @return void
*/
public function removeColumn($column) {
public function removeColumn($column)
{
foreach ($this->getCellList() as $coord) {
sscanf($coord,'%[A-Z]%d', $c, $r);
sscanf($coord, '%[A-Z]%d', $c, $r);
if ($c == $column) {
$this->deleteCacheData($coord);
}
@ -369,8 +361,8 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
*
* @return boolean
*/
public static function cacheMethodIsAvailable() {
public static function cacheMethodIsAvailable()
{
return true;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_CachedObjectStorage_DiscISAM
*
* Copyright (c) 2006 - 2014 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 +21,32 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 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_DiscISAM
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Name of the file for this cache
*
* @var string
*/
private $_fileName = NULL;
private $fileName = null;
/**
* File handle for this cache file
*
* @var resource
*/
private $_fileHandle = NULL;
private $fileHandle = null;
/**
* Directory/Folder where the cache file is located
*
* @var string
*/
private $_cacheDirectory = NULL;
private $cacheDirectory = null;
/**
* Store cell data in cache for the current cell object if it's "dirty",
@ -64,21 +55,21 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
$this->_currentObject->detach();
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
fseek($this->_fileHandle,0,SEEK_END);
fseek($this->fileHandle, 0, SEEK_END);
$this->_cellCache[$this->_currentObjectID] = array(
'ptr' => ftell($this->_fileHandle),
'sz' => fwrite($this->_fileHandle, serialize($this->_currentObject))
$this->cellCache[$this->currentObjectID] = array(
'ptr' => ftell($this->fileHandle),
'sz' => fwrite($this->fileHandle, serialize($this->currentObject))
);
$this->_currentCellIsDirty = false;
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
@ -88,18 +79,18 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
* @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->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
$this->_currentCellIsDirty = true;
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
} // function addCacheData()
}
/**
* Get cell at a specific coordinate
@ -108,82 +99,80 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
* @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 (!isset($this->_cellCache[$pCoord])) {
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']));
$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);
$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();
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) {
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';
$baseUnique = $this->getUniqueID();
$newFileName = $this->cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
// Copy the existing cell cache file
copy ($this->_fileName,$newFileName);
$this->_fileName = $newFileName;
copy($this->fileName, $newFileName);
$this->fileName = $newFileName;
// Open the copied cell cache file
$this->_fileHandle = fopen($this->_fileName,'a+');
} // function copyCellCollection()
$this->fileHandle = fopen($this->fileName, 'a+');
}
/**
* 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;
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
$this->_cellCache = array();
$this->cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
$this->parent = null;
// Close down the temporary cache file
$this->__destruct();
} // function unsetWorksheetCells()
}
/**
* Initialise this new cell collection
@ -191,29 +180,29 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
* @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))
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+');
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);
public function __destruct()
{
if (!is_null($this->fileHandle)) {
fclose($this->fileHandle);
unlink($this->fileName);
}
$this->fileHandle = null;
}
$this->_fileHandle = null;
} // function __destruct()
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_CachedObjectStorage_ICache
*
* Copyright (c) 2006 - 2014 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_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 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_ICache
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
interface PHPExcel_CachedObjectStorage_ICache
{
/**
@ -108,5 +100,4 @@ interface PHPExcel_CachedObjectStorage_ICache
* @return boolean
*/
public static function cacheMethodIsAvailable();
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_CachedObjectStorage_Igbinary
*
* Copyright (c) 2006 - 2014 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,21 +21,12 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 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_Igbinary
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
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
@ -42,14 +34,15 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
$this->_currentObject->detach();
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
$this->_cellCache[$this->_currentObjectID] = igbinary_serialize($this->_currentObject);
$this->_currentCellIsDirty = false;
$this->cellCache[$this->currentObjectID] = igbinary_serialize($this->currentObject);
$this->currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
$this->currentObjectID = $this->currentObject = null;
} // function _storeData()
@ -61,14 +54,15 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage
* @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->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
$this->_currentCellIsDirty = true;
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
} // function addCacheData()
@ -81,26 +75,27 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage
* @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 (!isset($this->_cellCache[$pCoord])) {
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]);
$this->currentObjectID = $pCoord;
$this->currentObject = igbinary_unserialize($this->cellCache[$pCoord]);
// Re-attach this as the cell's parent
$this->_currentObject->attach($this);
$this->currentObject->attach($this);
// Return requested entry
return $this->_currentObject;
return $this->currentObject;
} // function getCacheData()
@ -109,9 +104,10 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage
*
* @return string[]
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {
$this->_storeData();
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
return parent::getCellList();
@ -123,15 +119,16 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage
*
* @return void
*/
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
$this->_cellCache = array();
$this->cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
$this->parent = null;
} // function unsetWorksheetCells()
@ -141,12 +138,12 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage
*
* @return boolean
*/
public static function cacheMethodIsAvailable() {
public static function cacheMethodIsAvailable()
{
if (!function_exists('igbinary_serialize')) {
return false;
}
return true;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_CachedObjectStorage_Memcache
*
* Copyright (c) 2006 - 2014 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,41 +21,32 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 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_Memcache
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
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;
private $cachePrefix = null;
/**
* Cache timeout
*
* @var integer
*/
private $_cacheTime = 600;
private $cacheTime = 600;
/**
* Memcache interface
*
* @var resource
*/
private $_memcache = null;
private $memcache = null;
/**
@ -64,20 +56,21 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
$this->_currentObject->detach();
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)) {
$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');
throw new PHPExcel_Exception("Failed to store cell {$this->currentObjectID} in MemCache");
}
}
$this->_currentCellIsDirty = false;
$this->currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
$this->currentObjectID = $this->currentObject = null;
} // function _storeData()
@ -89,15 +82,16 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
* @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()
@ -110,14 +104,15 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
* @return boolean
* @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 Memcache
$success = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
$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);
@ -126,7 +121,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
return true;
}
return false;
} // function isDataSet()
}
/**
@ -136,19 +131,20 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
* @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 = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
$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');
throw new PHPExcel_Exception("Cell entry {$pCoord} no longer exists in MemCache");
}
} else {
// Return null if requested entry doesn't exist in cache
@ -156,44 +152,43 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
}
// 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();
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) {
public function deleteCacheData($pCoord)
{
// Delete the entry from Memcache
$this->_memcache->delete($this->_cachePrefix.$pCoord.'.cache');
$this->memcache->delete($this->cachePrefix . $pCoord . '.cache');
// Delete the entry from our cell address array
parent::deleteCacheData($pCoord);
} // function deleteCacheData()
}
/**
* Clone the cell collection
@ -201,50 +196,50 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
* @param PHPExcel_Worksheet $parent The new worksheet
* @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 = $this->_memcache->get($this->_cachePrefix.$cellID.'.cache');
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');
throw new PHPExcel_Exception("Cell entry {$cellID} no longer exists in MemCache");
}
if (!$this->_memcache->add($newCachePrefix.$cellID.'.cache',$obj,NULL,$this->_cacheTime)) {
if (!$this->memcache->add($newCachePrefix . $cellID . '.cache', $obj, null, $this->cacheTime)) {
$this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in MemCache');
throw new PHPExcel_Exception("Failed to store cell {$cellID} in MemCache");
}
}
}
$this->_cachePrefix = $newCachePrefix;
} // function copyCellCollection()
$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;
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();
$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
@ -252,26 +247,26 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
* @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)
{
$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).'.';
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->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;
$this->cacheTime = $cacheTime;
parent::__construct($parent);
}
} // function __construct()
}
/**
* Memcache error handler
@ -280,20 +275,21 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
* @param integer $port Memcache port
* @throws PHPExcel_Exception
*/
public function failureCallback($host, $port) {
throw new PHPExcel_Exception('memcache '.$host.':'.$port.' failed');
public function failureCallback($host, $port)
{
throw new PHPExcel_Exception("memcache {$host}:{$port} failed");
}
/**
* Destroy this cell collection
*/
public function __destruct() {
public function __destruct()
{
$cacheList = $this->getCellList();
foreach($cacheList as $cellID) {
$this->_memcache->delete($this->_cachePrefix.$cellID.'.cache');
foreach ($cacheList as $cellID) {
$this->memcache->delete($this->cachePrefix.$cellID . '.cache');
}
}
} // function __destruct()
/**
* Identify whether the caching method is currently available
@ -301,12 +297,12 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
*
* @return boolean
*/
public static function cacheMethodIsAvailable() {
public static function cacheMethodIsAvailable()
{
if (!function_exists('memcache_add')) {
return false;
}
return true;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_CachedObjectStorage_Memory
*
* Copyright (c) 2006 - 2014 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,20 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 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_Memory
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
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()
protected function storeData()
{
}
/**
* Add or Update a cell in cache identified by coordinate address
@ -51,14 +44,15 @@ class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_C
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
$this->_cellCache[$pCoord] = $cell;
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
$this->cellCache[$pCoord] = $cell;
// Set current entry to the new/updated entry
$this->_currentObjectID = $pCoord;
$this->currentObjectID = $pCoord;
return $cell;
} // function addCacheData()
}
/**
@ -68,58 +62,57 @@ class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_C
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
public function getCacheData($pCoord)
{
// Check if the entry that has been requested actually exists
if (!isset($this->_cellCache[$pCoord])) {
$this->_currentObjectID = NULL;
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;
$this->currentObjectID = $pCoord;
// Return requested entry
return $this->_cellCache[$pCoord];
} // function getCacheData()
return $this->cellCache[$pCoord];
}
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
public function copyCellCollection(PHPExcel_Worksheet $parent)
{
parent::copyCellCollection($parent);
$newCollection = array();
foreach($this->_cellCache as $k => &$cell) {
foreach ($this->cellCache as $k => &$cell) {
$newCollection[$k] = clone $cell;
$newCollection[$k]->attach($this);
}
$this->_cellCache = $newCollection;
$this->cellCache = $newCollection;
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() {
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) {
foreach ($this->cellCache as $k => &$cell) {
$cell->detach();
$this->_cellCache[$k] = null;
$this->cellCache[$k] = null;
}
unset($cell);
$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;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_CachedObjectStorage_MemoryGZip
*
* Copyright (c) 2006 - 2014 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,21 +21,12 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 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_MemoryGZip
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
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
@ -42,15 +34,16 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
$this->_currentObject->detach();
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
$this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject));
$this->_currentCellIsDirty = false;
$this->cellCache[$this->currentObjectID] = gzdeflate(serialize($this->currentObject));
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
@ -61,17 +54,18 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora
* @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->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
$this->_currentCellIsDirty = true;
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
} // function addCacheData()
}
/**
@ -81,27 +75,28 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora
* @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 (!isset($this->_cellCache[$pCoord])) {
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]));
$this->currentObjectID = $pCoord;
$this->currentObject = unserialize(gzinflate($this->cellCache[$pCoord]));
// 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;
}
/**
@ -109,9 +104,10 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora
*
* @return string[]
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {
$this->_storeData();
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
return parent::getCellList();
@ -123,15 +119,15 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora
*
* @return void
*/
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
$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;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_CachedObjectStorage_MemorySerialized
*
* Copyright (c) 2006 - 2014 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,21 +21,12 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 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_MemorySerialized
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
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
@ -42,16 +34,16 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
$this->_currentObject->detach();
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
$this->_cellCache[$this->_currentObjectID] = serialize($this->_currentObject);
$this->_currentCellIsDirty = false;
$this->cellCache[$this->currentObjectID] = serialize($this->currentObject);
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
@ -61,18 +53,18 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec
* @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->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
$this->_currentCellIsDirty = true;
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
} // function addCacheData()
}
/**
* Get cell at a specific coordinate
@ -81,57 +73,57 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec
* @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 (!isset($this->_cellCache[$pCoord])) {
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]);
$this->currentObjectID = $pCoord;
$this->currentObject = unserialize($this->cellCache[$pCoord]);
// 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();
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;
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
$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;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_CachedObjectStorage_PHPTemp
*
* Copyright (c) 2006 - 2014 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,25 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 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_PHPTemp
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Name of the file for this cache
*
* @var string
*/
private $_fileHandle = null;
private $fileHandle = null;
/**
* Memory limit to use before reverting to file cache
*
* @var integer
*/
private $_memoryCacheSize = null;
private $memoryCacheSize = null;
/**
* Store cell data in cache for the current cell object if it's "dirty",
@ -56,20 +48,21 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
$this->_currentObject->detach();
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
fseek($this->_fileHandle,0,SEEK_END);
fseek($this->fileHandle, 0, SEEK_END);
$this->_cellCache[$this->_currentObjectID] = array(
'ptr' => ftell($this->_fileHandle),
'sz' => fwrite($this->_fileHandle, serialize($this->_currentObject))
$this->cellCache[$this->currentObjectID] = array(
'ptr' => ftell($this->fileHandle),
'sz' => fwrite($this->fileHandle, serialize($this->currentObject))
);
$this->_currentCellIsDirty = false;
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
@ -80,17 +73,18 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_
* @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->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
$this->_currentCellIsDirty = true;
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
} // function addCacheData()
}
/**
@ -100,82 +94,82 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_
* @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 (!isset($this->_cellCache[$pCoord])) {
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']));
$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);
$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();
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) {
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+');
$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));
fseek($this->fileHandle, 0);
while (!feof($this->fileHandle)) {
fwrite($newFileHandle, fread($this->fileHandle, 1024));
}
$this->fileHandle = $newFileHandle;
}
$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;
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
$this->_cellCache = array();
$this->cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
$this->parent = null;
// Close down the php://temp file
$this->__destruct();
} // function unsetWorksheetCells()
}
/**
* Initialise this new cell collection
@ -183,24 +177,24 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_
* @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';
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+');
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);
public function __destruct()
{
if (!is_null($this->fileHandle)) {
fclose($this->fileHandle);
}
$this->fileHandle = null;
}
$this->_fileHandle = null;
} // function __destruct()
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_CachedObjectStorage_SQLite
*
* Copyright (c) 2006 - 2014 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,25 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 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_SQLite
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Database table name
*
* @var string
*/
private $_TableName = null;
private $TableName = null;
/**
* Database handle
*
* @var resource
*/
private $_DBHandle = null;
private $DBHandle = null;
/**
* Store cell data in cache for the current cell object if it's "dirty",
@ -56,17 +48,18 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
$this->_currentObject->detach();
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;
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;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
@ -76,18 +69,18 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
* @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->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
$this->_currentCellIsDirty = true;
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
} // function addCacheData()
}
/**
* Get cell at a specific coordinate
@ -96,33 +89,33 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
* @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();
$query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
$cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
$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()));
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;
$this->currentObjectID = $pCoord;
$cellResult = $cellResultSet->fetchSingle();
$this->_currentObject = unserialize($cellResult);
$this->currentObject = unserialize($cellResult);
// 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;
}
/**
* Is a value set for an indexed cell?
@ -130,23 +123,23 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
*/
public function isDataSet($pCoord) {
if ($pCoord === $this->_currentObjectID) {
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);
$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()));
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
@ -154,20 +147,21 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
* @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;
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()
$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
@ -176,48 +170,51 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
* @param string $toAddress Destination address of the cell to move
* @return boolean
*/
public function moveCell($fromAddress, $toAddress) {
if ($fromAddress === $this->_currentObjectID) {
$this->_currentObjectID = $toAddress;
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 = "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()
$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();
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()));
$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) {
foreach ($cellIdsResult as $row) {
$cellKeys[] = $row['id'];
}
return $cellKeys;
} // function getCellList()
}
/**
* Clone the cell collection
@ -225,69 +222,73 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
$this->_currentCellIsDirty;
$this->_storeData();
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()));
$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()
$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;
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;
$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) {
public function __construct(PHPExcel_Worksheet $parent)
{
parent::__construct($parent);
if (is_null($this->_DBHandle)) {
$this->_TableName = str_replace('.','_',$this->_getUniqueID());
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()));
$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);
public function __destruct()
{
if (!is_null($this->DBHandle)) {
$this->DBHandle->queryExec('DROP TABLE kvp_'.$this->TableName);
}
$this->DBHandle = null;
}
$this->_DBHandle = null;
} // function __destruct()
/**
* Identify whether the caching method is currently available
@ -295,12 +296,12 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
*
* @return boolean
*/
public static function cacheMethodIsAvailable() {
public static function cacheMethodIsAvailable()
{
if (!function_exists('sqlite_open')) {
return false;
}
return true;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_CachedObjectStorage_SQLite3
*
* Copyright (c) 2006 - 2014 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,62 +21,53 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 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_SQLite3
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Database table name
*
* @var string
*/
private $_TableName = null;
private $TableName = null;
/**
* Database handle
*
* @var resource
*/
private $_DBHandle = null;
private $DBHandle = null;
/**
* Prepared statement for a SQLite3 select query
*
* @var SQLite3Stmt
*/
private $_selectQuery;
private $selectQuery;
/**
* Prepared statement for a SQLite3 insert query
*
* @var SQLite3Stmt
*/
private $_insertQuery;
private $insertQuery;
/**
* Prepared statement for a SQLite3 update query
*
* @var SQLite3Stmt
*/
private $_updateQuery;
private $updateQuery;
/**
* Prepared statement for a SQLite3 delete query
*
* @var SQLite3Stmt
*/
private $_deleteQuery;
private $deleteQuery;
/**
* Store cell data in cache for the current cell object if it's "dirty",
@ -84,20 +76,21 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
$this->_currentObject->detach();
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->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;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
@ -107,18 +100,18 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
* @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->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
$this->_currentCellIsDirty = true;
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
} // function addCacheData()
}
/**
* Get cell at a specific coordinate
@ -127,34 +120,34 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
* @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();
$this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
$cellResult = $this->_selectQuery->execute();
if ($cellResult === FALSE) {
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
$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) {
if ($cellData === false) {
// Return null if requested entry doesn't exist in cache
return NULL;
return null;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
$this->currentObjectID = $pCoord;
$this->_currentObject = unserialize($cellData['value']);
$this->currentObject = unserialize($cellData['value']);
// 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;
}
/**
* Is a value set for an indexed cell?
@ -162,22 +155,22 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
*/
public function isDataSet($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return TRUE;
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());
$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()
return ($cellData === false) ? false : true;
}
/**
* Delete a cell in cache identified by coordinate address
@ -185,21 +178,22 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
* @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;
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()
$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
@ -208,40 +202,44 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
* @param string $toAddress Destination address of the cell to move
* @return boolean
*/
public function moveCell($fromAddress, $toAddress) {
if ($fromAddress === $this->_currentObjectID) {
$this->_currentObjectID = $toAddress;
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->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()
$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();
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());
$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)) {
@ -249,8 +247,7 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
}
return $cellKeys;
} // function getCellList()
}
/**
* Clone the cell collection
@ -258,75 +255,79 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
$this->_currentCellIsDirty;
$this->_storeData();
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());
$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()
$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;
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;
$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) {
public function __construct(PHPExcel_Worksheet $parent)
{
parent::__construct($parent);
if (is_null($this->_DBHandle)) {
$this->_TableName = str_replace('.','_',$this->_getUniqueID());
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->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()
$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();
public function __destruct()
{
if (!is_null($this->DBHandle)) {
$this->DBHandle->exec('DROP TABLE kvp_'.$this->TableName);
$this->DBHandle->close();
}
$this->DBHandle = null;
}
$this->_DBHandle = null;
} // function __destruct()
/**
* Identify whether the caching method is currently available
@ -334,12 +335,12 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
*
* @return boolean
*/
public static function cacheMethodIsAvailable() {
if (!class_exists('SQLite3',FALSE)) {
public static function cacheMethodIsAvailable()
{
if (!class_exists('SQLite3', false)) {
return false;
}
return true;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_CachedObjectStorage_Wincache
*
* Copyright (c) 2006 - 2014 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,25 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 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_Wincache
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
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;
private $cachePrefix = null;
/**
* Cache timeout
*
* @var integer
*/
private $_cacheTime = 600;
private $cacheTime = 600;
/**
@ -57,28 +49,28 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
$this->_currentObject->detach();
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)) {
$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');
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)) {
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');
throw new PHPExcel_Exception('Failed to store cell '.$this->currentObjectID.' in WinCache');
}
}
$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
@ -88,19 +80,19 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
* @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?
@ -108,14 +100,15 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
* @param string $pCoord Coordinate address of the cell to check
* @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 cache
$success = wincache_ucache_exists($this->_cachePrefix.$pCoord.'.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);
@ -124,7 +117,7 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
return true;
}
return false;
} // function isDataSet()
}
/**
@ -134,17 +127,18 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
* @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
$obj = null;
if (parent::isDataSet($pCoord)) {
$success = false;
$obj = wincache_ucache_get($this->_cachePrefix.$pCoord.'.cache', $success);
$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);
@ -156,14 +150,14 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
}
// 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;
}
/**
@ -171,29 +165,29 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
*
* @return string[]
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {
$this->_storeData();
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) {
public function deleteCacheData($pCoord)
{
// Delete the entry from Wincache
wincache_ucache_delete($this->_cachePrefix.$pCoord.'.cache');
wincache_ucache_delete($this->cachePrefix.$pCoord.'.cache');
// Delete the entry from our cell address array
parent::deleteCacheData($pCoord);
} // function deleteCacheData()
}
/**
* Clone the cell collection
@ -201,29 +195,30 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
* @param PHPExcel_Worksheet $parent The new worksheet
* @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) {
foreach ($cacheList as $cellID) {
if ($cellID != $this->currentObjectID) {
$success = false;
$obj = wincache_ucache_get($this->_cachePrefix.$cellID.'.cache', $success);
$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)) {
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()
$this->cachePrefix = $newCachePrefix;
}
/**
@ -231,21 +226,21 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
*
* @return void
*/
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
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();
$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
@ -253,29 +248,29 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
* @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 (is_null($this->_cachePrefix)) {
$baseUnique = $this->_getUniqueID();
$this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
$this->_cacheTime = $cacheTime;
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() {
public function __destruct()
{
$cacheList = $this->getCellList();
foreach($cacheList as $cellID) {
wincache_ucache_delete($this->_cachePrefix.$cellID.'.cache');
foreach ($cacheList as $cellID) {
wincache_ucache_delete($this->cachePrefix.$cellID.'.cache');
}
}
} // function __destruct()
/**
* Identify whether the caching method is currently available
@ -283,12 +278,12 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
*
* @return boolean
*/
public static function cacheMethodIsAvailable() {
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 - 2014 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 - 2014 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 - 2014 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;
}
return TRUE;
} // function initialize()
/**
* Initialise the cache storage
@ -219,23 +200,23 @@ 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]
$instance = new self::$cacheStorageClass(
$parent,
self::$storageMethodParameters[self::$cacheStorageMethod]
);
if ($instance !== NULL) {
if ($instance !== null) {
return $instance;
}
}
return FALSE;
} // function getInstance()
return false;
}
/**
* Clear the cache storage
@ -243,9 +224,8 @@ class PHPExcel_CachedObjectStorageFactory
**/
public static function finalize()
{
self::$_cacheStorageMethod = NULL;
self::$_cacheStorageClass = NULL;
self::$_storageMethodParameters = array();
self::$cacheStorageMethod = null;
self::$cacheStorageClass = null;
self::$storageMethodParameters = array();
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_CalcEngine_CyclicReferenceStack
*
* Copyright (c) 2006 - 2014 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,36 +21,27 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2014 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_CalcEngine_CyclicReferenceStack
*
* @category PHPExcel_CalcEngine_CyclicReferenceStack
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CalcEngine_CyclicReferenceStack {
class PHPExcel_CalcEngine_CyclicReferenceStack
{
/**
* The call stack for calculated cells
*
* @var mixed[]
*/
private $_stack = array();
private $stack = array();
/**
* Return the number of entries on the stack
*
* @return integer
*/
public function count() {
return count($this->_stack);
public function count()
{
return count($this->stack);
}
/**
@ -57,8 +49,9 @@ class PHPExcel_CalcEngine_CyclicReferenceStack {
*
* @param mixed $value
*/
public function push($value) {
$this->_stack[$value] = $value;
public function push($value)
{
$this->stack[$value] = $value;
}
/**
@ -66,8 +59,9 @@ class PHPExcel_CalcEngine_CyclicReferenceStack {
*
* @return mixed
*/
public function pop() {
return array_pop($this->_stack);
public function pop()
{
return array_pop($this->stack);
}
/**
@ -75,15 +69,17 @@ class PHPExcel_CalcEngine_CyclicReferenceStack {
*
* @param mixed $value The value to test
*/
public function onStack($value) {
return isset($this->_stack[$value]);
public function onStack($value)
{
return isset($this->stack[$value]);
}
/**
* Clear the stack
*/
public function clear() {
$this->_stack = array();
public function clear()
{
$this->stack = array();
}
/**
@ -91,8 +87,8 @@ class PHPExcel_CalcEngine_CyclicReferenceStack {
*
* @return mixed[]
*/
public function showStack() {
return $this->_stack;
public function showStack()
{
return $this->stack;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_CalcEngine_Logger
*
* Copyright (c) 2006 - 2014 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,20 +21,12 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2014 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_CalcEngine_Logger
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CalcEngine_Logger {
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
@ -41,7 +34,7 @@ class PHPExcel_CalcEngine_Logger {
*
* @var boolean
*/
private $_writeDebugLog = FALSE;
private $writeDebugLog = false;
/**
* Flag to determine whether a debug log should be echoed by the calculation engine
@ -51,30 +44,30 @@ class PHPExcel_CalcEngine_Logger {
*
* @var boolean
*/
private $_echoDebugLog = FALSE;
private $echoDebugLog = false;
/**
* The debug log generated by the calculation engine
*
* @var string[]
*/
private $_debugLog = array();
private $debugLog = array();
/**
* The calculation engine cell reference stack
*
* @var PHPExcel_CalcEngine_CyclicReferenceStack
*/
private $_cellStack;
private $cellStack;
/**
* Instantiate a Calculation engine logger
*
* @param PHPExcel_CalcEngine_CyclicReferenceStack $stack
*/
public function __construct(PHPExcel_CalcEngine_CyclicReferenceStack $stack) {
$this->_cellStack = $stack;
public function __construct(PHPExcel_CalcEngine_CyclicReferenceStack $stack)
{
$this->cellStack = $stack;
}
/**
@ -82,8 +75,9 @@ class PHPExcel_CalcEngine_Logger {
*
* @param boolean $pValue
*/
public function setWriteDebugLog($pValue = FALSE) {
$this->_writeDebugLog = $pValue;
public function setWriteDebugLog($pValue = false)
{
$this->writeDebugLog = $pValue;
}
/**
@ -91,8 +85,9 @@ class PHPExcel_CalcEngine_Logger {
*
* @return boolean
*/
public function getWriteDebugLog() {
return $this->_writeDebugLog;
public function getWriteDebugLog()
{
return $this->writeDebugLog;
}
/**
@ -100,8 +95,9 @@ class PHPExcel_CalcEngine_Logger {
*
* @param boolean $pValue
*/
public function setEchoDebugLog($pValue = FALSE) {
$this->_echoDebugLog = $pValue;
public function setEchoDebugLog($pValue = false)
{
$this->echoDebugLog = $pValue;
}
/**
@ -109,45 +105,47 @@ class PHPExcel_CalcEngine_Logger {
*
* @return boolean
*/
public function getEchoDebugLog() {
return $this->_echoDebugLog;
public function getEchoDebugLog()
{
return $this->echoDebugLog;
}
/**
* Write an entry to the calculation engine debug log
*/
public function writeDebugLog() {
public function writeDebugLog()
{
// Only write the debug log if logging is enabled
if ($this->_writeDebugLog) {
if ($this->writeDebugLog) {
$message = implode(func_get_args());
$cellReference = implode(' -> ', $this->_cellStack->showStack());
if ($this->_echoDebugLog) {
$cellReference = implode(' -> ', $this->cellStack->showStack());
if ($this->echoDebugLog) {
echo $cellReference,
($this->_cellStack->count() > 0 ? ' => ' : ''),
($this->cellStack->count() > 0 ? ' => ' : ''),
$message,
PHP_EOL;
}
$this->_debugLog[] = $cellReference .
($this->_cellStack->count() > 0 ? ' => ' : '') .
$this->debugLog[] = $cellReference .
($this->cellStack->count() > 0 ? ' => ' : '') .
$message;
}
} // function _writeDebug()
}
/**
* Clear the calculation engine debug log
*/
public function clearLog() {
$this->_debugLog = array();
} // function flushLogger()
public function clearLog()
{
$this->debugLog = array();
}
/**
* Return the calculation engine debug log
*
* @return string[]
*/
public function getLog() {
return $this->_debugLog;
} // function flushLogger()
} // class PHPExcel_CalcEngine_Logger
public function getLog()
{
return $this->debugLog;
}
}

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_Database
*
* Copyright (c) 2006 - 2014 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 +30,14 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2014 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')) {
class PHPExcel_Calculation_Database
{
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Calculation_Database
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Database {
/**
* __fieldExtract
* fieldExtract
*
* Extracts the column ID to use for the data field.
*
@ -64,20 +54,21 @@ class PHPExcel_Calculation_Database {
* @return string|NULL
*
*/
private static function __fieldExtract($database,$field) {
private static function fieldExtract($database, $field)
{
$field = strtoupper(PHPExcel_Calculation_Functions::flattenSingleValue($field));
$fieldNames = array_map('strtoupper',array_shift($database));
$fieldNames = array_map('strtoupper', array_shift($database));
if (is_numeric($field)) {
$keys = array_keys($fieldNames);
return $keys[$field-1];
}
$key = array_search($field,$fieldNames);
return ($key) ? $key : NULL;
$key = array_search($field, $fieldNames);
return ($key) ? $key : null;
}
/**
* __filter
* filter
*
* Parses the selection criteria, extracts the database rows that match those criteria, and
* returns that subset of rows.
@ -95,47 +86,48 @@ class PHPExcel_Calculation_Database {
* @return array of mixed
*
*/
private static function __filter($database,$criteria) {
private static function filter($database, $criteria)
{
$fieldNames = array_shift($database);
$criteriaNames = array_shift($criteria);
// Convert the criteria into a set of AND/OR conditions with [:placeholders]
$testConditions = $testValues = array();
$testConditionsCount = 0;
foreach($criteriaNames as $key => $criteriaName) {
foreach ($criteriaNames as $key => $criteriaName) {
$testCondition = array();
$testConditionCount = 0;
foreach($criteria as $row => $criterion) {
foreach ($criteria as $row => $criterion) {
if ($criterion[$key] > '') {
$testCondition[] = '[:'.$criteriaName.']'.PHPExcel_Calculation_Functions::_ifCondition($criterion[$key]);
$testCondition[] = '[:'.$criteriaName.']'.PHPExcel_Calculation_Functions::ifCondition($criterion[$key]);
$testConditionCount++;
}
}
if ($testConditionCount > 1) {
$testConditions[] = 'OR('.implode(',',$testCondition).')';
$testConditions[] = 'OR(' . implode(',', $testCondition) . ')';
$testConditionsCount++;
} elseif($testConditionCount == 1) {
} elseif ($testConditionCount == 1) {
$testConditions[] = $testCondition[0];
$testConditionsCount++;
}
}
if ($testConditionsCount > 1) {
$testConditionSet = 'AND('.implode(',',$testConditions).')';
} elseif($testConditionsCount == 1) {
$testConditionSet = 'AND(' . implode(',', $testConditions) . ')';
} elseif ($testConditionsCount == 1) {
$testConditionSet = $testConditions[0];
}
// Loop through each row of the database
foreach($database as $dataRow => $dataValues) {
foreach ($database as $dataRow => $dataValues) {
// Substitute actual values from the database row for our [:placeholders]
$testConditionList = $testConditionSet;
foreach($criteriaNames as $key => $criteriaName) {
$k = array_search($criteriaName,$fieldNames);
foreach ($criteriaNames as $key => $criteriaName) {
$k = array_search($criteriaName, $fieldNames);
if (isset($dataValues[$k])) {
$dataValue = $dataValues[$k];
$dataValue = (is_string($dataValue)) ? PHPExcel_Calculation::_wrapResult(strtoupper($dataValue)) : $dataValue;
$testConditionList = str_replace('[:'.$criteriaName.']',$dataValue,$testConditionList);
$dataValue = (is_string($dataValue)) ? PHPExcel_Calculation::wrapResult(strtoupper($dataValue)) : $dataValue;
$testConditionList = str_replace('[:' . $criteriaName . ']', $dataValue, $testConditionList);
}
}
// evaluate the criteria against the row data
@ -150,6 +142,19 @@ class PHPExcel_Calculation_Database {
}
private static function getFilteredColumn($database, $field, $criteria)
{
// reduce the database to a set of rows that match all the criteria
$database = self::filter($database, $criteria);
// extract an array of values for the requested column
$colData = array();
foreach ($database as $row) {
$colData[] = $row[$field];
}
return $colData;
}
/**
* DAVERAGE
*
@ -177,22 +182,18 @@ class PHPExcel_Calculation_Database {
* @return float
*
*/
public static function DAVERAGE($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
public static function DAVERAGE($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
return null;
}
// Return
return PHPExcel_Calculation_Statistical::AVERAGE($colData);
} // function DAVERAGE()
return PHPExcel_Calculation_Statistical::AVERAGE(
self::getFilteredColumn($database, $field, $criteria)
);
}
/**
@ -229,23 +230,18 @@ class PHPExcel_Calculation_Database {
* database that match the criteria.
*
*/
public static function DCOUNT($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
public static function DCOUNT($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
return null;
}
// Return
return PHPExcel_Calculation_Statistical::COUNT($colData);
} // function DCOUNT()
return PHPExcel_Calculation_Statistical::COUNT(
self::getFilteredColumn($database, $field, $criteria)
);
}
/**
@ -278,23 +274,26 @@ class PHPExcel_Calculation_Database {
* database that match the criteria.
*
*/
public static function DCOUNTA($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
public static function DCOUNTA($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return NULL;
return null;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
$database = self::filter($database, $criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
foreach ($database as $row) {
$colData[] = $row[$field];
}
// Return
return PHPExcel_Calculation_Statistical::COUNTA($colData);
} // function DCOUNTA()
return PHPExcel_Calculation_Statistical::COUNTA(
self::getFilteredColumn($database, $field, $criteria)
);
}
/**
@ -325,27 +324,21 @@ class PHPExcel_Calculation_Database {
* @return mixed
*
*/
public static function DGET($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
public static function DGET($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
return null;
}
// Return
$colData = self::getFilteredColumn($database, $field, $criteria);
if (count($colData) > 1) {
return PHPExcel_Calculation_Functions::NaN();
}
return $colData[0];
} // function DGET()
}
/**
@ -376,23 +369,18 @@ class PHPExcel_Calculation_Database {
* @return float
*
*/
public static function DMAX($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
public static function DMAX($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
return null;
}
// Return
return PHPExcel_Calculation_Statistical::MAX($colData);
} // function DMAX()
return PHPExcel_Calculation_Statistical::MAX(
self::getFilteredColumn($database, $field, $criteria)
);
}
/**
@ -423,23 +411,18 @@ class PHPExcel_Calculation_Database {
* @return float
*
*/
public static function DMIN($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
public static function DMIN($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
return null;
}
// Return
return PHPExcel_Calculation_Statistical::MIN($colData);
} // function DMIN()
return PHPExcel_Calculation_Statistical::MIN(
self::getFilteredColumn($database, $field, $criteria)
);
}
/**
@ -469,23 +452,18 @@ class PHPExcel_Calculation_Database {
* @return float
*
*/
public static function DPRODUCT($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
public static function DPRODUCT($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
return null;
}
// Return
return PHPExcel_Calculation_MathTrig::PRODUCT($colData);
} // function DPRODUCT()
return PHPExcel_Calculation_MathTrig::PRODUCT(
self::getFilteredColumn($database, $field, $criteria)
);
}
/**
@ -516,23 +494,18 @@ class PHPExcel_Calculation_Database {
* @return float
*
*/
public static function DSTDEV($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
public static function DSTDEV($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
return null;
}
// Return
return PHPExcel_Calculation_Statistical::STDEV($colData);
} // function DSTDEV()
return PHPExcel_Calculation_Statistical::STDEV(
self::getFilteredColumn($database, $field, $criteria)
);
}
/**
@ -563,23 +536,18 @@ class PHPExcel_Calculation_Database {
* @return float
*
*/
public static function DSTDEVP($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
public static function DSTDEVP($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
return null;
}
// Return
return PHPExcel_Calculation_Statistical::STDEVP($colData);
} // function DSTDEVP()
return PHPExcel_Calculation_Statistical::STDEVP(
self::getFilteredColumn($database, $field, $criteria)
);
}
/**
@ -609,23 +577,18 @@ class PHPExcel_Calculation_Database {
* @return float
*
*/
public static function DSUM($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
public static function DSUM($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
return null;
}
// Return
return PHPExcel_Calculation_MathTrig::SUM($colData);
} // function DSUM()
return PHPExcel_Calculation_MathTrig::SUM(
self::getFilteredColumn($database, $field, $criteria)
);
}
/**
@ -656,23 +619,18 @@ class PHPExcel_Calculation_Database {
* @return float
*
*/
public static function DVAR($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
public static function DVAR($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
return null;
}
// Return
return PHPExcel_Calculation_Statistical::VARFunc($colData);
} // function DVAR()
return PHPExcel_Calculation_Statistical::VARFunc(
self::getFilteredColumn($database, $field, $criteria)
);
}
/**
@ -703,23 +661,16 @@ class PHPExcel_Calculation_Database {
* @return float
*
*/
public static function DVARP($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
public static function DVARP($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
return null;
}
// Return
return PHPExcel_Calculation_Statistical::VARP($colData);
} // function DVARP()
} // class PHPExcel_Calculation_Database
return PHPExcel_Calculation_Statistical::VARP(
self::getFilteredColumn($database, $field, $criteria)
);
}
}

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 - 2014 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,20 +21,12 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2014 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_Calculation_Exception
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Exception extends PHPExcel_Exception {
class PHPExcel_Calculation_Exception extends PHPExcel_Exception
{
/**
* Error handler callback
*
@ -43,7 +36,8 @@ class PHPExcel_Calculation_Exception extends PHPExcel_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_Calculation_ExceptionHandler
*
* Copyright (c) 2006 - 2014 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 - 2014 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_Calculation_ExceptionHandler
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_ExceptionHandler {
class PHPExcel_Calculation_ExceptionHandler
{
/**
* Register errorhandler
*/
public function __construct() {
public function __construct()
{
set_error_handler(array('PHPExcel_Calculation_Exception', 'errorHandlerCallback'), E_ALL);
}
/**
* Unregister errorhandler
*/
public function __destruct() {
public function __destruct()
{
restore_error_handler();
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,30 +1,4 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 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_Calculation
* @copyright Copyright (c) 2006 - 2014 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:
@ -52,11 +26,32 @@ PARTLY BASED ON:
/**
* PHPExcel_Calculation_FormulaParser
*
* 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_Calculation
* @copyright Copyright (c) 2006 - 2014 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##
*/
class PHPExcel_Calculation_FormulaParser {
class PHPExcel_Calculation_FormulaParser
{
/* Character constants */
const QUOTE_DOUBLE = '"';
const QUOTE_SINGLE = '\'';
@ -80,14 +75,14 @@ class PHPExcel_Calculation_FormulaParser {
*
* @var string
*/
private $_formula;
private $formula;
/**
* Tokens
*
* @var PHPExcel_Calculation_FormulaToken[]
*/
private $_tokens = array();
private $tokens = array();
/**
* Create a new PHPExcel_Calculation_FormulaParser
@ -103,9 +98,9 @@ class PHPExcel_Calculation_FormulaParser {
}
// Initialise values
$this->_formula = trim($pFormula);
$this->formula = trim($pFormula);
// Parse!
$this->_parseToTokens();
$this->parseToTokens();
}
/**
@ -113,8 +108,9 @@ class PHPExcel_Calculation_FormulaParser {
*
* @return string
*/
public function getFormula() {
return $this->_formula;
public function getFormula()
{
return $this->formula;
}
/**
@ -124,9 +120,10 @@ class PHPExcel_Calculation_FormulaParser {
* @return string
* @throws PHPExcel_Calculation_Exception
*/
public function getToken($pId = 0) {
if (isset($this->_tokens[$pId])) {
return $this->_tokens[$pId];
public function getToken($pId = 0)
{
if (isset($this->tokens[$pId])) {
return $this->tokens[$pId];
} else {
throw new PHPExcel_Calculation_Exception("Token with id $pId does not exist.");
}
@ -137,8 +134,9 @@ class PHPExcel_Calculation_FormulaParser {
*
* @return string
*/
public function getTokenCount() {
return count($this->_tokens);
public function getTokenCount()
{
return count($this->tokens);
}
/**
@ -146,20 +144,24 @@ class PHPExcel_Calculation_FormulaParser {
*
* @return PHPExcel_Calculation_FormulaToken[]
*/
public function getTokens() {
return $this->_tokens;
public function getTokens()
{
return $this->tokens;
}
/**
* Parse to tokens
*/
private function _parseToTokens() {
private function parseToTokens()
{
// No attempt is made to verify formulas; assumes formulas are derived from Excel, where
// they can only exist if valid; stack overflows/underflows sunk as nulls without exceptions.
// Check if the formula has a valid starting =
$formulaLength = strlen($this->_formula);
if ($formulaLength < 2 || $this->_formula{0} != '=') return;
$formulaLength = strlen($this->formula);
if ($formulaLength < 2 || $this->formula{0} != '=') {
return;
}
// Helper variables
$tokens1 = $tokens2 = $stack = array();
@ -179,8 +181,8 @@ class PHPExcel_Calculation_FormulaParser {
// embeds are doubled
// end marks token
if ($inString) {
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) {
if ((($index + 2) <= $formulaLength) && ($this->_formula{$index + 1} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE)) {
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) {
if ((($index + 2) <= $formulaLength) && ($this->formula{$index + 1} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE)) {
$value .= PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE;
++$index;
} else {
@ -189,7 +191,7 @@ class PHPExcel_Calculation_FormulaParser {
$value = "";
}
} else {
$value .= $this->_formula{$index};
$value .= $this->formula{$index};
}
++$index;
continue;
@ -199,15 +201,15 @@ class PHPExcel_Calculation_FormulaParser {
// embeds are double
// end does not mark a token
if ($inPath) {
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) {
if ((($index + 2) <= $formulaLength) && ($this->_formula{$index + 1} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE)) {
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) {
if ((($index + 2) <= $formulaLength) && ($this->formula{$index + 1} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE)) {
$value .= PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE;
++$index;
} else {
$inPath = false;
}
} else {
$value .= $this->_formula{$index};
$value .= $this->formula{$index};
}
++$index;
continue;
@ -217,10 +219,10 @@ class PHPExcel_Calculation_FormulaParser {
// no embeds (changed to "()" by Excel)
// end does not mark a token
if ($inRange) {
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_CLOSE) {
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_CLOSE) {
$inRange = false;
}
$value .= $this->_formula{$index};
$value .= $this->formula{$index};
++$index;
continue;
}
@ -228,7 +230,7 @@ class PHPExcel_Calculation_FormulaParser {
// error values
// end marks a token, determined from absolute list of values
if ($inError) {
$value .= $this->_formula{$index};
$value .= $this->formula{$index};
++$index;
if (in_array($value, $ERRORS)) {
$inError = false;
@ -239,10 +241,10 @@ class PHPExcel_Calculation_FormulaParser {
}
// scientific notation check
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_SN, $this->_formula{$index}) !== false) {
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_SN, $this->formula{$index}) !== false) {
if (strlen($value) > 1) {
if (preg_match("/^[1-9]{1}(\.[0-9]+)?E{1}$/", $this->_formula{$index}) != 0) {
$value .= $this->_formula{$index};
if (preg_match("/^[1-9]{1}(\.[0-9]+)?E{1}$/", $this->formula{$index}) != 0) {
$value .= $this->formula{$index};
++$index;
continue;
}
@ -252,8 +254,9 @@ class PHPExcel_Calculation_FormulaParser {
// independent character evaluation (order not important)
// establish state-dependent character evaluations
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) {
if (strlen($value > 0)) { // unexpected
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) {
if (strlen($value > 0)) {
// unexpected
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
$value = "";
}
@ -262,8 +265,9 @@ class PHPExcel_Calculation_FormulaParser {
continue;
}
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) {
if (strlen($value) > 0) { // unexpected
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) {
if (strlen($value) > 0) {
// unexpected
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
$value = "";
}
@ -272,15 +276,16 @@ class PHPExcel_Calculation_FormulaParser {
continue;
}
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_OPEN) {
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_OPEN) {
$inRange = true;
$value .= PHPExcel_Calculation_FormulaParser::BRACKET_OPEN;
++$index;
continue;
}
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::ERROR_START) {
if (strlen($value) > 0) { // unexpected
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::ERROR_START) {
if (strlen($value) > 0) {
// unexpected
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
$value = "";
}
@ -291,8 +296,9 @@ class PHPExcel_Calculation_FormulaParser {
}
// mark start and end of arrays and array rows
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_OPEN) {
if (strlen($value) > 0) { // unexpected
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_OPEN) {
if (strlen($value) > 0) {
// unexpected
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
$value = "";
}
@ -309,7 +315,7 @@ class PHPExcel_Calculation_FormulaParser {
continue;
}
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::SEMICOLON) {
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::SEMICOLON) {
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
@ -331,7 +337,7 @@ class PHPExcel_Calculation_FormulaParser {
continue;
}
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_CLOSE) {
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_CLOSE) {
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
@ -352,14 +358,14 @@ class PHPExcel_Calculation_FormulaParser {
}
// trim white-space
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) {
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) {
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
}
$tokens1[] = new PHPExcel_Calculation_FormulaToken("", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_WHITESPACE);
++$index;
while (($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) && ($index < $formulaLength)) {
while (($this->formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) && ($index < $formulaLength)) {
++$index;
}
continue;
@ -367,41 +373,41 @@ class PHPExcel_Calculation_FormulaParser {
// multi-character comparators
if (($index + 2) <= $formulaLength) {
if (in_array(substr($this->_formula, $index, 2), $COMPARATORS_MULTI)) {
if (in_array(substr($this->formula, $index, 2), $COMPARATORS_MULTI)) {
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
}
$tokens1[] = new PHPExcel_Calculation_FormulaToken(substr($this->_formula, $index, 2), PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
$tokens1[] = new PHPExcel_Calculation_FormulaToken(substr($this->formula, $index, 2), PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
$index += 2;
continue;
}
}
// standard infix operators
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_INFIX, $this->_formula{$index}) !== false) {
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_INFIX, $this->formula{$index}) !== false) {
if (strlen($value) > 0) {
$tokens1[] =new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
}
$tokens1[] = new PHPExcel_Calculation_FormulaToken($this->_formula{$index}, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX);
$tokens1[] = new PHPExcel_Calculation_FormulaToken($this->formula{$index}, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX);
++$index;
continue;
}
// standard postfix operators (only one)
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_POSTFIX, $this->_formula{$index}) !== false) {
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_POSTFIX, $this->formula{$index}) !== false) {
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
}
$tokens1[] = new PHPExcel_Calculation_FormulaToken($this->_formula{$index}, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX);
$tokens1[] = new PHPExcel_Calculation_FormulaToken($this->formula{$index}, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX);
++$index;
continue;
}
// start subexpression or function
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::PAREN_OPEN) {
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::PAREN_OPEN) {
if (strlen($value) > 0) {
$tmp = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
$tokens1[] = $tmp;
@ -417,7 +423,7 @@ class PHPExcel_Calculation_FormulaParser {
}
// function, subexpression, or array parameters, or operand unions
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::COMMA) {
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::COMMA) {
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
@ -438,7 +444,7 @@ class PHPExcel_Calculation_FormulaParser {
}
// stop subexpression
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::PAREN_CLOSE) {
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::PAREN_CLOSE) {
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
@ -454,7 +460,7 @@ class PHPExcel_Calculation_FormulaParser {
}
// token accumulation
$value .= $this->_formula{$index};
$value .= $this->formula{$index};
++$index;
}
@ -516,7 +522,7 @@ class PHPExcel_Calculation_FormulaParser {
// move tokens to final list, switching infix "-" operators to prefix when appropriate, switching infix "+" operators
// to noop when appropriate, identifying operand and infix-operator subtypes, and pulling "@" from function names
$this->_tokens = array();
$this->tokens = array();
$tokenCount = count($tokens2);
for ($i = 0; $i < $tokenCount; ++$i) {
@ -539,53 +545,55 @@ class PHPExcel_Calculation_FormulaParser {
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == "-") {
if ($i == 0) {
$token->setTokenType(PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
} else if (
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
} elseif ((($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) &&
($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) &&
($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)
) {
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)) {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
} else {
$token->setTokenType(PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
}
$this->_tokens[] = $token;
$this->tokens[] = $token;
continue;
}
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == "+") {
if ($i == 0) {
continue;
} else if (
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
} elseif ((($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) &&
($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) &&
($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)
) {
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)) {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
} else {
continue;
}
$this->_tokens[] = $token;
$this->tokens[] = $token;
continue;
}
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX &&
$token->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
if (strpos("<>=", substr($token->getValue(), 0, 1)) !== false) {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
} else if ($token->getValue() == "&") {
} elseif ($token->getValue() == "&") {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_CONCATENATION);
} else {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
}
$this->_tokens[] = $token;
$this->tokens[] = $token;
continue;
}
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND && $token->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND &&
$token->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
if (!is_numeric($token->getValue())) {
if (strtoupper($token->getValue()) == "TRUE" || strtoupper($token->getValue() == "FALSE")) {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
@ -596,7 +604,7 @@ class PHPExcel_Calculation_FormulaParser {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NUMBER);
}
$this->_tokens[] = $token;
$this->tokens[] = $token;
continue;
}
@ -608,7 +616,7 @@ class PHPExcel_Calculation_FormulaParser {
}
}
$this->_tokens[] = $token;
$this->tokens[] = $token;
}
}
}

View file

@ -1,30 +1,4 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 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_Calculation
* @copyright Copyright (c) 2006 - 2014 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:
@ -49,15 +23,35 @@ PARTLY BASED ON:
http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html
*/
/**
* PHPExcel_Calculation_FormulaToken
*
* 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_Calculation
* @copyright Copyright (c) 2006 - 2014 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##
*/
class PHPExcel_Calculation_FormulaToken {
class PHPExcel_Calculation_FormulaToken
{
/* Token types */
const TOKEN_TYPE_NOOP = 'Noop';
const TOKEN_TYPE_OPERAND = 'Operand';
@ -89,21 +83,21 @@ class PHPExcel_Calculation_FormulaToken {
*
* @var string
*/
private $_value;
private $value;
/**
* Token Type (represented by TOKEN_TYPE_*)
*
* @var string
*/
private $_tokenType;
private $tokenType;
/**
* Token SubType (represented by TOKEN_SUBTYPE_*)
*
* @var string
*/
private $_tokenSubType;
private $tokenSubType;
/**
* Create a new PHPExcel_Calculation_FormulaToken
@ -115,9 +109,9 @@ class PHPExcel_Calculation_FormulaToken {
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;
$this->value = $pValue;
$this->tokenType = $pTokenType;
$this->tokenSubType = $pTokenSubType;
}
/**
@ -125,8 +119,9 @@ class PHPExcel_Calculation_FormulaToken {
*
* @return string
*/
public function getValue() {
return $this->_value;
public function getValue()
{
return $this->value;
}
/**
@ -134,8 +129,9 @@ class PHPExcel_Calculation_FormulaToken {
*
* @param string $value
*/
public function setValue($value) {
$this->_value = $value;
public function setValue($value)
{
$this->value = $value;
}
/**
@ -143,8 +139,9 @@ class PHPExcel_Calculation_FormulaToken {
*
* @return string
*/
public function getTokenType() {
return $this->_tokenType;
public function getTokenType()
{
return $this->tokenType;
}
/**
@ -152,8 +149,9 @@ class PHPExcel_Calculation_FormulaToken {
*
* @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,8 +159,9 @@ class PHPExcel_Calculation_FormulaToken {
*
* @return string
*/
public function getTokenSubType() {
return $this->_tokenSubType;
public function getTokenSubType()
{
return $this->tokenSubType;
}
/**
@ -170,7 +169,8 @@ class PHPExcel_Calculation_FormulaToken {
*
* @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 - 2014 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,20 +21,12 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2014 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_Calculation_Function
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Function {
class PHPExcel_Calculation_Function
{
/* Function categories */
const CATEGORY_CUBE = 'Cube';
const CATEGORY_DATABASE = 'Database';
@ -52,21 +45,21 @@ class PHPExcel_Calculation_Function {
*
* @var string
*/
private $_category;
private $category;
/**
* Excel name
*
* @var string
*/
private $_excelName;
private $excelName;
/**
* PHPExcel name
*
* @var string
*/
private $_phpExcelName;
private $phpExcelName;
/**
* Create a new PHPExcel_Calculation_Function
@ -76,13 +69,13 @@ class PHPExcel_Calculation_Function {
* @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)) {
if (($pCategory !== null) && ($pExcelName !== null) && ($pPHPExcelName !== null)) {
// Initialise values
$this->_category = $pCategory;
$this->_excelName = $pExcelName;
$this->_phpExcelName = $pPHPExcelName;
$this->category = $pCategory;
$this->excelName = $pExcelName;
$this->phpExcelName = $pPHPExcelName;
} else {
throw new PHPExcel_Calculation_Exception("Invalid parameters passed.");
}
@ -93,8 +86,9 @@ class PHPExcel_Calculation_Function {
*
* @return string
*/
public function getCategory() {
return $this->_category;
public function getCategory()
{
return $this->category;
}
/**
@ -103,9 +97,10 @@ class PHPExcel_Calculation_Function {
* @param string $value
* @throws PHPExcel_Calculation_Exception
*/
public function setCategory($value = null) {
public function setCategory($value = null)
{
if (!is_null($value)) {
$this->_category = $value;
$this->category = $value;
} else {
throw new PHPExcel_Calculation_Exception("Invalid parameter passed.");
}
@ -116,8 +111,9 @@ class PHPExcel_Calculation_Function {
*
* @return string
*/
public function getExcelName() {
return $this->_excelName;
public function getExcelName()
{
return $this->excelName;
}
/**
@ -125,8 +121,9 @@ class PHPExcel_Calculation_Function {
*
* @param string $value
*/
public function setExcelName($value) {
$this->_excelName = $value;
public function setExcelName($value)
{
$this->excelName = $value;
}
/**
@ -134,8 +131,9 @@ class PHPExcel_Calculation_Function {
*
* @return string
*/
public function getPHPExcelName() {
return $this->_phpExcelName;
public function getPHPExcelName()
{
return $this->phpExcelName;
}
/**
@ -143,7 +141,8 @@ class PHPExcel_Calculation_Function {
*
* @param string $value
*/
public function setPHPExcelName($value) {
$this->_phpExcelName = $value;
public function setPHPExcelName($value)
{
$this->phpExcelName = $value;
}
}

View file

@ -1,30 +1,4 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 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_Calculation
* @copyright Copyright (c) 2006 - 2014 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')) {
@ -52,11 +26,30 @@ define('PRECISION', 8.88E-016);
/**
* PHPExcel_Calculation_Functions
*
* 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_Calculation
* @copyright Copyright (c) 2006 - 2014 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##
*/
class PHPExcel_Calculation_Functions {
class PHPExcel_Calculation_Functions
{
/** constants */
const COMPATIBILITY_EXCEL = 'Excel';
@ -82,7 +75,7 @@ class PHPExcel_Calculation_Functions {
* @access private
* @var string
*/
protected static $ReturnDateType = self::RETURNDATE_EXCEL;
protected static $returnDateType = self::RETURNDATE_EXCEL;
/**
* List of error codes
@ -90,7 +83,8 @@ class PHPExcel_Calculation_Functions {
* @access private
* @var array
*/
protected static $_errorCodes = array( 'null' => '#NULL!',
protected static $errorCodes = array(
'null' => '#NULL!',
'divisionbyzero' => '#DIV/0!',
'value' => '#VALUE!',
'reference' => '#REF!',
@ -113,15 +107,16 @@ class PHPExcel_Calculation_Functions {
* PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
* @return boolean (Success or Failure)
*/
public static function setCompatibilityMode($compatibilityMode) {
public static function setCompatibilityMode($compatibilityMode)
{
if (($compatibilityMode == self::COMPATIBILITY_EXCEL) ||
($compatibilityMode == self::COMPATIBILITY_GNUMERIC) ||
($compatibilityMode == self::COMPATIBILITY_OPENOFFICE)) {
self::$compatibilityMode = $compatibilityMode;
return True;
return true;
}
return false;
}
return False;
} // function setCompatibilityMode()
/**
@ -135,9 +130,10 @@ class PHPExcel_Calculation_Functions {
* PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC 'Gnumeric'
* PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
*/
public static function getCompatibilityMode() {
public static function getCompatibilityMode()
{
return self::$compatibilityMode;
} // function getCompatibilityMode()
}
/**
@ -152,15 +148,16 @@ class PHPExcel_Calculation_Functions {
* PHPExcel_Calculation_Functions::RETURNDATE_EXCEL 'E'
* @return boolean Success or failure
*/
public static function setReturnDateType($returnDateType) {
public static function setReturnDateType($returnDateType)
{
if (($returnDateType == self::RETURNDATE_PHP_NUMERIC) ||
($returnDateType == self::RETURNDATE_PHP_OBJECT) ||
($returnDateType == self::RETURNDATE_EXCEL)) {
self::$ReturnDateType = $returnDateType;
return True;
self::$returnDateType = $returnDateType;
return true;
}
return false;
}
return False;
} // function setReturnDateType()
/**
@ -174,9 +171,10 @@ class PHPExcel_Calculation_Functions {
* PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT 'O'
* PHPExcel_Calculation_Functions::RETURNDATE_EXCEL 'E'
*/
public static function getReturnDateType() {
return self::$ReturnDateType;
} // function getReturnDateType()
public static function getReturnDateType()
{
return self::$returnDateType;
}
/**
@ -186,9 +184,10 @@ class PHPExcel_Calculation_Functions {
* @category Error Returns
* @return string #Not Yet Implemented
*/
public static function DUMMY() {
public static function DUMMY()
{
return '#Not Yet Implemented';
} // function DUMMY()
}
/**
@ -198,9 +197,10 @@ class PHPExcel_Calculation_Functions {
* @category Error Returns
* @return string #Not Yet Implemented
*/
public static function DIV0() {
return self::$_errorCodes['divisionbyzero'];
} // function DIV0()
public static function DIV0()
{
return self::$errorCodes['divisionbyzero'];
}
/**
@ -216,9 +216,10 @@ class PHPExcel_Calculation_Functions {
* @category Logical Functions
* @return string #N/A!
*/
public static function NA() {
return self::$_errorCodes['na'];
} // function NA()
public static function NA()
{
return self::$errorCodes['na'];
}
/**
@ -230,9 +231,10 @@ class PHPExcel_Calculation_Functions {
* @category Error Returns
* @return string #NUM!
*/
public static function NaN() {
return self::$_errorCodes['num'];
} // function NaN()
public static function NaN()
{
return self::$errorCodes['num'];
}
/**
@ -244,9 +246,10 @@ class PHPExcel_Calculation_Functions {
* @category Error Returns
* @return string #NAME?
*/
public static function NAME() {
return self::$_errorCodes['name'];
} // function NAME()
public static function NAME()
{
return self::$errorCodes['name'];
}
/**
@ -258,9 +261,10 @@ class PHPExcel_Calculation_Functions {
* @category Error Returns
* @return string #REF!
*/
public static function REF() {
return self::$_errorCodes['reference'];
} // function REF()
public static function REF()
{
return self::$errorCodes['reference'];
}
/**
@ -272,9 +276,10 @@ class PHPExcel_Calculation_Functions {
* @category Error Returns
* @return string #NULL!
*/
public static function NULL() {
return self::$_errorCodes['null'];
} // function NULL()
public static function NULL()
{
return self::$errorCodes['null'];
}
/**
@ -286,46 +291,53 @@ class PHPExcel_Calculation_Functions {
* @category Error Returns
* @return string #VALUE!
*/
public static function VALUE() {
return self::$_errorCodes['value'];
} // function VALUE()
public static function isMatrixValue($idx) {
return ((substr_count($idx,'.') <= 1) || (preg_match('/\.[A-Z]/',$idx) > 0));
public static function VALUE()
{
return self::$errorCodes['value'];
}
public static function isValue($idx) {
return (substr_count($idx,'.') == 0);
public static function isMatrixValue($idx)
{
return ((substr_count($idx, '.') <= 1) || (preg_match('/\.[A-Z]/', $idx) > 0));
}
public static function isCellValue($idx) {
return (substr_count($idx,'.') > 1);
public static function isValue($idx)
{
return (substr_count($idx, '.') == 0);
}
public static function _ifCondition($condition) {
public static function isCellValue($idx)
{
return (substr_count($idx, '.') > 1);
}
public static function ifCondition($condition)
{
$condition = PHPExcel_Calculation_Functions::flattenSingleValue($condition);
if (!isset($condition{0}))
if (!isset($condition{0})) {
$condition = '=""';
if (!in_array($condition{0},array('>', '<', '='))) {
if (!is_numeric($condition)) { $condition = PHPExcel_Calculation::_wrapResult(strtoupper($condition)); }
return '='.$condition;
}
if (!in_array($condition{0}, array('>', '<', '='))) {
if (!is_numeric($condition)) {
$condition = PHPExcel_Calculation::wrapResult(strtoupper($condition));
}
return '=' . $condition;
} else {
preg_match('/([<>=]+)(.*)/',$condition,$matches);
list(,$operator,$operand) = $matches;
preg_match('/([<>=]+)(.*)/', $condition, $matches);
list(, $operator, $operand) = $matches;
if (!is_numeric($operand)) {
$operand = str_replace('"', '""', $operand);
$operand = PHPExcel_Calculation::_wrapResult(strtoupper($operand));
$operand = PHPExcel_Calculation::wrapResult(strtoupper($operand));
}
return $operator.$operand;
}
} // function _ifCondition()
}
/**
* ERROR_TYPE
@ -333,18 +345,19 @@ class PHPExcel_Calculation_Functions {
* @param mixed $value Value to check
* @return boolean
*/
public static function ERROR_TYPE($value = '') {
public static function ERROR_TYPE($value = '')
{
$value = self::flattenSingleValue($value);
$i = 1;
foreach(self::$_errorCodes as $errorCode) {
foreach (self::$errorCodes as $errorCode) {
if ($value === $errorCode) {
return $i;
}
++$i;
}
return self::NA();
} // function ERROR_TYPE()
}
/**
@ -353,13 +366,14 @@ class PHPExcel_Calculation_Functions {
* @param mixed $value Value to check
* @return boolean
*/
public static function IS_BLANK($value = NULL) {
public static function IS_BLANK($value = null)
{
if (!is_null($value)) {
$value = self::flattenSingleValue($value);
}
return is_null($value);
} // function IS_BLANK()
}
/**
@ -368,11 +382,12 @@ class PHPExcel_Calculation_Functions {
* @param mixed $value Value to check
* @return boolean
*/
public static function IS_ERR($value = '') {
public static function IS_ERR($value = '')
{
$value = self::flattenSingleValue($value);
return self::IS_ERROR($value) && (!self::IS_NA($value));
} // function IS_ERR()
}
/**
@ -381,13 +396,15 @@ class PHPExcel_Calculation_Functions {
* @param mixed $value Value to check
* @return boolean
*/
public static function IS_ERROR($value = '') {
public static function IS_ERROR($value = '')
{
$value = self::flattenSingleValue($value);
if (!is_string($value))
if (!is_string($value)) {
return false;
return in_array($value, array_values(self::$_errorCodes));
} // function IS_ERROR()
}
return in_array($value, array_values(self::$errorCodes));
}
/**
@ -396,11 +413,12 @@ class PHPExcel_Calculation_Functions {
* @param mixed $value Value to check
* @return boolean
*/
public static function IS_NA($value = '') {
public static function IS_NA($value = '')
{
$value = self::flattenSingleValue($value);
return ($value === self::NA());
} // function IS_NA()
}
/**
@ -409,15 +427,18 @@ class PHPExcel_Calculation_Functions {
* @param mixed $value Value to check
* @return boolean
*/
public static function IS_EVEN($value = NULL) {
public static function IS_EVEN($value = null)
{
$value = self::flattenSingleValue($value);
if ($value === NULL)
if ($value === null) {
return self::NAME();
if ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value))))
} elseif ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value)))) {
return self::VALUE();
}
return ($value % 2 == 0);
} // function IS_EVEN()
}
/**
@ -426,15 +447,18 @@ class PHPExcel_Calculation_Functions {
* @param mixed $value Value to check
* @return boolean
*/
public static function IS_ODD($value = NULL) {
public static function IS_ODD($value = null)
{
$value = self::flattenSingleValue($value);
if ($value === NULL)
if ($value === null) {
return self::NAME();
if ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value))))
} elseif ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value)))) {
return self::VALUE();
}
return (abs($value) % 2 == 1);
} // function IS_ODD()
}
/**
@ -443,14 +467,15 @@ class PHPExcel_Calculation_Functions {
* @param mixed $value Value to check
* @return boolean
*/
public static function IS_NUMBER($value = NULL) {
public static function IS_NUMBER($value = null)
{
$value = self::flattenSingleValue($value);
if (is_string($value)) {
return False;
return false;
}
return is_numeric($value);
} // function IS_NUMBER()
}
/**
@ -459,11 +484,12 @@ class PHPExcel_Calculation_Functions {
* @param mixed $value Value to check
* @return boolean
*/
public static function IS_LOGICAL($value = NULL) {
public static function IS_LOGICAL($value = null)
{
$value = self::flattenSingleValue($value);
return is_bool($value);
} // function IS_LOGICAL()
}
/**
@ -472,11 +498,12 @@ class PHPExcel_Calculation_Functions {
* @param mixed $value Value to check
* @return boolean
*/
public static function IS_TEXT($value = NULL) {
public static function IS_TEXT($value = null)
{
$value = self::flattenSingleValue($value);
return (is_string($value) && !self::IS_ERROR($value));
} // function IS_TEXT()
}
/**
@ -485,9 +512,10 @@ class PHPExcel_Calculation_Functions {
* @param mixed $value Value to check
* @return boolean
*/
public static function IS_NONTEXT($value = NULL) {
public static function IS_NONTEXT($value = null)
{
return !self::IS_TEXT($value);
} // function IS_NONTEXT()
}
/**
@ -495,9 +523,10 @@ class PHPExcel_Calculation_Functions {
*
* @return string Version information
*/
public static function VERSION() {
public static function VERSION()
{
return 'PHPExcel ##VERSION##, ##DATE##';
} // function VERSION()
}
/**
@ -515,21 +544,20 @@ class PHPExcel_Calculation_Functions {
* An error value The error value
* Anything else 0
*/
public static function N($value = NULL) {
public static function N($value = null)
{
while (is_array($value)) {
$value = array_shift($value);
}
switch (gettype($value)) {
case 'double' :
case 'float' :
case 'integer' :
case 'double':
case 'float':
case 'integer':
return $value;
break;
case 'boolean' :
case 'boolean':
return (integer) $value;
break;
case 'string' :
case 'string':
// Errors
if ((strlen($value) > 0) && ($value{0} == '#')) {
return $value;
@ -537,7 +565,7 @@ class PHPExcel_Calculation_Functions {
break;
}
return 0;
} // function N()
}
/**
@ -554,11 +582,12 @@ class PHPExcel_Calculation_Functions {
* An error value 16
* Array or Matrix 64
*/
public static function TYPE($value = NULL) {
public static function TYPE($value = null)
{
$value = self::flattenArrayIndexed($value);
if (is_array($value) && (count($value) > 1)) {
$a = array_keys($value);
$a = array_pop($a);
end($value);
$a = key($value);
// Range of cells is an error
if (self::isCellValue($a)) {
return 16;
@ -566,19 +595,19 @@ class PHPExcel_Calculation_Functions {
} elseif (self::isMatrixValue($a)) {
return 64;
}
} elseif(empty($value)) {
} elseif (empty($value)) {
// Empty Cell
return 1;
}
$value = self::flattenSingleValue($value);
if (($value === NULL) || (is_float($value)) || (is_int($value))) {
if (($value === null) || (is_float($value)) || (is_int($value))) {
return 1;
} elseif(is_bool($value)) {
} elseif (is_bool($value)) {
return 4;
} elseif(is_array($value)) {
} elseif (is_array($value)) {
return 64;
} elseif(is_string($value)) {
} elseif (is_string($value)) {
// Errors
if ((strlen($value) > 0) && ($value{0} == '#')) {
return 16;
@ -586,7 +615,7 @@ class PHPExcel_Calculation_Functions {
return 2;
}
return 0;
} // function TYPE()
}
/**
@ -595,7 +624,8 @@ class PHPExcel_Calculation_Functions {
* @param array $array Array to be flattened
* @return array Flattened array
*/
public static function flattenArray($array) {
public static function flattenArray($array)
{
if (!is_array($array)) {
return (array) $array;
}
@ -618,7 +648,7 @@ class PHPExcel_Calculation_Functions {
}
return $arrayValues;
} // function flattenArray()
}
/**
@ -627,7 +657,8 @@ class PHPExcel_Calculation_Functions {
* @param array $array Array to be flattened
* @return array Flattened array
*/
public static function flattenArrayIndexed($array) {
public static function flattenArrayIndexed($array)
{
if (!is_array($array)) {
return (array) $array;
}
@ -650,7 +681,7 @@ class PHPExcel_Calculation_Functions {
}
return $arrayValues;
} // function flattenArrayIndexed()
}
/**
@ -659,15 +690,15 @@ class PHPExcel_Calculation_Functions {
* @param mixed $value Array or scalar value
* @return mixed
*/
public static function flattenSingleValue($value = '') {
public static function flattenSingleValue($value = '')
{
while (is_array($value)) {
$value = array_pop($value);
}
return $value;
} // function flattenSingleValue()
} // class PHPExcel_Calculation_Functions
}
}
//
@ -676,19 +707,22 @@ class PHPExcel_Calculation_Functions {
// So we test if they do exist for this version of PHP/operating platform; and if not we create them
//
if (!function_exists('acosh')) {
function acosh($x) {
function acosh($x)
{
return 2 * log(sqrt(($x + 1) / 2) + sqrt(($x - 1) / 2));
} // function acosh()
}
if (!function_exists('asinh')) {
function asinh($x) {
function asinh($x)
{
return log($x + sqrt(1 + $x * $x));
} // function asinh()
}
if (!function_exists('atanh')) {
function atanh($x) {
function atanh($x)
{
return (log(1 + $x) - log(1 - $x)) / 2;
} // function atanh()
}
@ -700,22 +734,23 @@ if (!function_exists('atanh')) {
//
if ((!function_exists('mb_str_replace')) &&
(function_exists('mb_substr')) && (function_exists('mb_strlen')) && (function_exists('mb_strpos'))) {
function mb_str_replace($search, $replace, $subject) {
if(is_array($subject)) {
function mb_str_replace($search, $replace, $subject)
{
if (is_array($subject)) {
$ret = array();
foreach($subject as $key => $val) {
foreach ($subject as $key => $val) {
$ret[$key] = mb_str_replace($search, $replace, $val);
}
return $ret;
}
foreach((array) $search as $key => $s) {
if($s == '' && $s !== 0) {
foreach ((array) $search as $key => $s) {
if ($s == '' && $s !== 0) {
continue;
}
$r = !is_array($replace) ? $replace : (array_key_exists($key, $replace) ? $replace[$key] : '');
$pos = mb_strpos($subject, $s, 0, 'UTF-8');
while($pos !== false) {
while ($pos !== false) {
$subject = mb_substr($subject, 0, $pos, 'UTF-8') . $r . mb_substr($subject, $pos + mb_strlen($s, 'UTF-8'), 65535, 'UTF-8');
$pos = mb_strpos($subject, $s, $pos + mb_strlen($r, 'UTF-8'), 'UTF-8');
}

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 - 2014 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,31 +30,12 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2014 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_Calculation_Logical
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Logical {
class PHPExcel_Calculation_Logical
{
/**
* TRUE
*
@ -57,9 +48,10 @@ class PHPExcel_Calculation_Logical {
* @category Logical Functions
* @return boolean True
*/
public static function TRUE() {
return TRUE;
} // function TRUE()
public static function TRUE()
{
return true;
}
/**
@ -74,9 +66,10 @@ class PHPExcel_Calculation_Logical {
* @category Logical Functions
* @return boolean False
*/
public static function FALSE() {
return FALSE;
} // function FALSE()
public static function FALSE()
{
return false;
}
/**
@ -100,9 +93,10 @@ class PHPExcel_Calculation_Logical {
* @param mixed $arg,... Data values
* @return boolean The logical AND of the arguments.
*/
public static function LOGICAL_AND() {
public static function LOGICAL_AND()
{
// Return value
$returnValue = TRUE;
$returnValue = true;
// Loop through the arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
@ -116,9 +110,9 @@ class PHPExcel_Calculation_Logical {
} elseif (is_string($arg)) {
$arg = strtoupper($arg);
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
$arg = TRUE;
$arg = true;
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
$arg = FALSE;
$arg = false;
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
@ -131,7 +125,7 @@ class PHPExcel_Calculation_Logical {
return PHPExcel_Calculation_Functions::VALUE();
}
return $returnValue;
} // function LOGICAL_AND()
}
/**
@ -155,9 +149,10 @@ class PHPExcel_Calculation_Logical {
* @param mixed $arg,... Data values
* @return boolean The logical OR of the arguments.
*/
public static function LOGICAL_OR() {
public static function LOGICAL_OR()
{
// Return value
$returnValue = FALSE;
$returnValue = false;
// Loop through the arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
@ -171,9 +166,9 @@ class PHPExcel_Calculation_Logical {
} elseif (is_string($arg)) {
$arg = strtoupper($arg);
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
$arg = TRUE;
$arg = true;
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
$arg = FALSE;
$arg = false;
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
@ -186,7 +181,7 @@ class PHPExcel_Calculation_Logical {
return PHPExcel_Calculation_Functions::VALUE();
}
return $returnValue;
} // function LOGICAL_OR()
}
/**
@ -209,21 +204,22 @@ class PHPExcel_Calculation_Logical {
* @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) {
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;
return false;
} elseif (($logical == 'FALSE') || ($logical == PHPExcel_Calculation::getFALSE())) {
return TRUE;
return true;
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
}
return !$logical;
} // function NOT()
}
/**
* STATEMENT_IF
@ -257,13 +253,14 @@ class PHPExcel_Calculation_Logical {
* @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);
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);
$returnIfFalse = (is_null($returnIfFalse)) ? false : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfFalse);
return ($condition) ? $returnIfTrue : $returnIfFalse;
} // function STATEMENT_IF()
}
/**
@ -278,11 +275,11 @@ class PHPExcel_Calculation_Logical {
* @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 = '') {
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
}
}

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_LookupRef
*
* Copyright (c) 2006 - 2014 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,32 +30,12 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2014 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_Calculation_LookupRef
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_LookupRef {
class PHPExcel_Calculation_LookupRef
{
/**
* CELL_ADDRESS
*
@ -67,7 +57,8 @@ class PHPExcel_Calculation_LookupRef {
* @param sheetText Optional Name of worksheet to use
* @return string
*/
public static function CELL_ADDRESS($row, $column, $relativity=1, $referenceStyle=True, $sheetText='') {
public static function CELL_ADDRESS($row, $column, $relativity = 1, $referenceStyle = true, $sheetText = '')
{
$row = PHPExcel_Calculation_Functions::flattenSingleValue($row);
$column = PHPExcel_Calculation_Functions::flattenSingleValue($column);
$relativity = PHPExcel_Calculation_Functions::flattenSingleValue($relativity);
@ -78,21 +69,31 @@ class PHPExcel_Calculation_LookupRef {
}
if ($sheetText > '') {
if (strpos($sheetText,' ') !== False) { $sheetText = "'".$sheetText."'"; }
if (strpos($sheetText, ' ') !== false) {
$sheetText = "'".$sheetText."'";
}
$sheetText .='!';
}
if ((!is_bool($referenceStyle)) || $referenceStyle) {
$rowRelative = $columnRelative = '$';
$column = PHPExcel_Cell::stringFromColumnIndex($column-1);
if (($relativity == 2) || ($relativity == 4)) { $columnRelative = ''; }
if (($relativity == 3) || ($relativity == 4)) { $rowRelative = ''; }
if (($relativity == 2) || ($relativity == 4)) {
$columnRelative = '';
}
if (($relativity == 3) || ($relativity == 4)) {
$rowRelative = '';
}
return $sheetText.$columnRelative.$column.$rowRelative.$row;
} else {
if (($relativity == 2) || ($relativity == 4)) { $column = '['.$column.']'; }
if (($relativity == 3) || ($relativity == 4)) { $row = '['.$row.']'; }
if (($relativity == 2) || ($relativity == 4)) {
$column = '['.$column.']';
}
if (($relativity == 3) || ($relativity == 4)) {
$row = '['.$row.']';
}
return $sheetText.'R'.$row.'C'.$column;
}
} // function CELL_ADDRESS()
}
/**
@ -109,33 +110,36 @@ class PHPExcel_Calculation_LookupRef {
* @param cellAddress A reference to a range of cells for which you want the column numbers
* @return integer or array of integer
*/
public static function COLUMN($cellAddress=Null) {
if (is_null($cellAddress) || trim($cellAddress) === '') { return 0; }
public static function COLUMN($cellAddress = null)
{
if (is_null($cellAddress) || trim($cellAddress) === '') {
return 0;
}
if (is_array($cellAddress)) {
foreach($cellAddress as $columnKey => $value) {
$columnKey = preg_replace('/[^a-z]/i','',$columnKey);
foreach ($cellAddress as $columnKey => $value) {
$columnKey = preg_replace('/[^a-z]/i', '', $columnKey);
return (integer) PHPExcel_Cell::columnIndexFromString($columnKey);
}
} else {
if (strpos($cellAddress,'!') !== false) {
list($sheet,$cellAddress) = explode('!',$cellAddress);
if (strpos($cellAddress, '!') !== false) {
list($sheet, $cellAddress) = explode('!', $cellAddress);
}
if (strpos($cellAddress,':') !== false) {
list($startAddress,$endAddress) = explode(':',$cellAddress);
$startAddress = preg_replace('/[^a-z]/i','',$startAddress);
$endAddress = preg_replace('/[^a-z]/i','',$endAddress);
if (strpos($cellAddress, ':') !== false) {
list($startAddress, $endAddress) = explode(':', $cellAddress);
$startAddress = preg_replace('/[^a-z]/i', '', $startAddress);
$endAddress = preg_replace('/[^a-z]/i', '', $endAddress);
$returnValue = array();
do {
$returnValue[] = (integer) PHPExcel_Cell::columnIndexFromString($startAddress);
} while ($startAddress++ != $endAddress);
return $returnValue;
} else {
$cellAddress = preg_replace('/[^a-z]/i','',$cellAddress);
$cellAddress = preg_replace('/[^a-z]/i', '', $cellAddress);
return (integer) PHPExcel_Cell::columnIndexFromString($cellAddress);
}
}
} // function COLUMN()
}
/**
@ -149,24 +153,24 @@ class PHPExcel_Calculation_LookupRef {
* @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of columns
* @return integer The number of columns in cellAddress
*/
public static function COLUMNS($cellAddress=Null) {
public static function COLUMNS($cellAddress = null)
{
if (is_null($cellAddress) || $cellAddress === '') {
return 1;
} elseif (!is_array($cellAddress)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$x = array_keys($cellAddress);
$x = array_shift($x);
$isMatrix = (is_numeric($x));
list($columns,$rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress);
reset($cellAddress);
$isMatrix = (is_numeric(key($cellAddress)));
list($columns, $rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress);
if ($isMatrix) {
return $rows;
} else {
return $columns;
}
} // function COLUMNS()
}
/**
@ -183,34 +187,37 @@ class PHPExcel_Calculation_LookupRef {
* @param cellAddress A reference to a range of cells for which you want the row numbers
* @return integer or array of integer
*/
public static function ROW($cellAddress=Null) {
if (is_null($cellAddress) || trim($cellAddress) === '') { return 0; }
public static function ROW($cellAddress = null)
{
if (is_null($cellAddress) || trim($cellAddress) === '') {
return 0;
}
if (is_array($cellAddress)) {
foreach($cellAddress as $columnKey => $rowValue) {
foreach($rowValue as $rowKey => $cellValue) {
return (integer) preg_replace('/[^0-9]/i','',$rowKey);
foreach ($cellAddress as $columnKey => $rowValue) {
foreach ($rowValue as $rowKey => $cellValue) {
return (integer) preg_replace('/[^0-9]/i', '', $rowKey);
}
}
} else {
if (strpos($cellAddress,'!') !== false) {
list($sheet,$cellAddress) = explode('!',$cellAddress);
if (strpos($cellAddress, '!') !== false) {
list($sheet, $cellAddress) = explode('!', $cellAddress);
}
if (strpos($cellAddress,':') !== false) {
list($startAddress,$endAddress) = explode(':',$cellAddress);
$startAddress = preg_replace('/[^0-9]/','',$startAddress);
$endAddress = preg_replace('/[^0-9]/','',$endAddress);
if (strpos($cellAddress, ':') !== false) {
list($startAddress, $endAddress) = explode(':', $cellAddress);
$startAddress = preg_replace('/[^0-9]/', '', $startAddress);
$endAddress = preg_replace('/[^0-9]/', '', $endAddress);
$returnValue = array();
do {
$returnValue[][] = (integer) $startAddress;
} while ($startAddress++ != $endAddress);
return $returnValue;
} else {
list($cellAddress) = explode(':',$cellAddress);
return (integer) preg_replace('/[^0-9]/','',$cellAddress);
list($cellAddress) = explode(':', $cellAddress);
return (integer) preg_replace('/[^0-9]/', '', $cellAddress);
}
}
}
} // function ROW()
/**
@ -224,23 +231,24 @@ class PHPExcel_Calculation_LookupRef {
* @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of rows
* @return integer The number of rows in cellAddress
*/
public static function ROWS($cellAddress=Null) {
public static function ROWS($cellAddress = null)
{
if (is_null($cellAddress) || $cellAddress === '') {
return 1;
} elseif (!is_array($cellAddress)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$i = array_keys($cellAddress);
$isMatrix = (is_numeric(array_shift($i)));
list($columns,$rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress);
reset($cellAddress);
$isMatrix = (is_numeric(key($cellAddress)));
list($columns, $rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress);
if ($isMatrix) {
return $columns;
} else {
return $rows;
}
} // function ROWS()
}
/**
@ -256,7 +264,8 @@ class PHPExcel_Calculation_LookupRef {
* @param PHPExcel_Cell $pCell The cell to set the hyperlink in
* @return mixed The value of $displayName (or $linkURL if $displayName was blank)
*/
public static function HYPERLINK($linkURL = '', $displayName = null, PHPExcel_Cell $pCell = null) {
public static function HYPERLINK($linkURL = '', $displayName = null, PHPExcel_Cell $pCell = null)
{
$args = func_get_args();
$pCell = array_pop($args);
@ -272,9 +281,10 @@ class PHPExcel_Calculation_LookupRef {
}
$pCell->getHyperlink()->setUrl($linkURL);
$pCell->getHyperlink()->setTooltip($displayName);
return $displayName;
} // function HYPERLINK()
}
/**
@ -295,16 +305,17 @@ class PHPExcel_Calculation_LookupRef {
* @todo Support for the optional a1 parameter introduced in Excel 2010
*
*/
public static function INDIRECT($cellAddress = NULL, PHPExcel_Cell $pCell = NULL) {
public static function INDIRECT($cellAddress = null, PHPExcel_Cell $pCell = null)
{
$cellAddress = PHPExcel_Calculation_Functions::flattenSingleValue($cellAddress);
if (is_null($cellAddress) || $cellAddress === '') {
return PHPExcel_Calculation_Functions::REF();
}
$cellAddress1 = $cellAddress;
$cellAddress2 = NULL;
if (strpos($cellAddress,':') !== false) {
list($cellAddress1,$cellAddress2) = explode(':',$cellAddress);
$cellAddress2 = null;
if (strpos($cellAddress, ':') !== false) {
list($cellAddress1, $cellAddress2) = explode(':', $cellAddress);
}
if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress1, $matches)) ||
@ -313,27 +324,27 @@ class PHPExcel_Calculation_LookupRef {
return PHPExcel_Calculation_Functions::REF();
}
if (strpos($cellAddress,'!') !== FALSE) {
list($sheetName, $cellAddress) = explode('!',$cellAddress);
if (strpos($cellAddress, '!') !== false) {
list($sheetName, $cellAddress) = explode('!', $cellAddress);
$sheetName = trim($sheetName, "'");
$pSheet = $pCell->getWorksheet()->getParent()->getSheetByName($sheetName);
} else {
$pSheet = $pCell->getWorksheet();
}
return PHPExcel_Calculation::getInstance()->extractNamedRange($cellAddress, $pSheet, FALSE);
return PHPExcel_Calculation::getInstance()->extractNamedRange($cellAddress, $pSheet, false);
}
if (strpos($cellAddress,'!') !== FALSE) {
list($sheetName,$cellAddress) = explode('!',$cellAddress);
if (strpos($cellAddress, '!') !== false) {
list($sheetName, $cellAddress) = explode('!', $cellAddress);
$sheetName = trim($sheetName, "'");
$pSheet = $pCell->getWorksheet()->getParent()->getSheetByName($sheetName);
} else {
$pSheet = $pCell->getWorksheet();
}
return PHPExcel_Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, FALSE);
} // function INDIRECT()
return PHPExcel_Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, false);
}
/**
@ -361,12 +372,13 @@ class PHPExcel_Calculation_LookupRef {
* @param width The width, in number of columns, that you want the returned reference to be. Width must be a positive number.
* @return string A reference to a cell or range of cells
*/
public static function OFFSET($cellAddress=Null,$rows=0,$columns=0,$height=null,$width=null) {
public static function OFFSET($cellAddress = null, $rows = 0, $columns = 0, $height = null, $width = null)
{
$rows = PHPExcel_Calculation_Functions::flattenSingleValue($rows);
$columns = PHPExcel_Calculation_Functions::flattenSingleValue($columns);
$height = PHPExcel_Calculation_Functions::flattenSingleValue($height);
$width = PHPExcel_Calculation_Functions::flattenSingleValue($width);
if ($cellAddress == Null) {
if ($cellAddress == null) {
return 0;
}
@ -376,18 +388,18 @@ class PHPExcel_Calculation_LookupRef {
return PHPExcel_Calculation_Functions::REF();
}
$sheetName = NULL;
if (strpos($cellAddress,"!")) {
list($sheetName,$cellAddress) = explode("!",$cellAddress);
$sheetName = null;
if (strpos($cellAddress, "!")) {
list($sheetName, $cellAddress) = explode("!", $cellAddress);
$sheetName = trim($sheetName, "'");
}
if (strpos($cellAddress,":")) {
list($startCell,$endCell) = explode(":",$cellAddress);
if (strpos($cellAddress, ":")) {
list($startCell, $endCell) = explode(":", $cellAddress);
} else {
$startCell = $endCell = $cellAddress;
}
list($startCellColumn,$startCellRow) = PHPExcel_Cell::coordinateFromString($startCell);
list($endCellColumn,$endCellRow) = PHPExcel_Cell::coordinateFromString($endCell);
list($startCellColumn, $startCellRow) = PHPExcel_Cell::coordinateFromString($startCell);
list($endCellColumn, $endCellRow) = PHPExcel_Cell::coordinateFromString($endCell);
$startCellRow += $rows;
$startCellColumn = PHPExcel_Cell::columnIndexFromString($startCellColumn) - 1;
@ -420,14 +432,14 @@ class PHPExcel_Calculation_LookupRef {
$cellAddress .= ':'.$endCellColumn.$endCellRow;
}
if ($sheetName !== NULL) {
if ($sheetName !== null) {
$pSheet = $pCell->getWorksheet()->getParent()->getSheetByName($sheetName);
} else {
$pSheet = $pCell->getWorksheet();
}
return PHPExcel_Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, False);
} // function OFFSET()
return PHPExcel_Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, false);
}
/**
@ -448,12 +460,13 @@ class PHPExcel_Calculation_LookupRef {
* text.
* @return mixed The selected value
*/
public static function CHOOSE() {
public static function CHOOSE()
{
$chooseArgs = func_get_args();
$chosenEntry = PHPExcel_Calculation_Functions::flattenArray(array_shift($chooseArgs));
$entryCount = count($chooseArgs) - 1;
if(is_array($chosenEntry)) {
if (is_array($chosenEntry)) {
$chosenEntry = array_shift($chosenEntry);
}
if ((is_numeric($chosenEntry)) && (!is_bool($chosenEntry))) {
@ -471,7 +484,7 @@ class PHPExcel_Calculation_LookupRef {
} else {
return $chooseArgs[$chosenEntry];
}
} // function CHOOSE()
}
/**
@ -487,7 +500,8 @@ class PHPExcel_Calculation_LookupRef {
* @param match_type The number -1, 0, or 1. -1 means above, 0 means exact match, 1 means below. If match_type is 1 or -1, the list has to be ordered.
* @return integer The relative position of the found item
*/
public static function MATCH($lookup_value, $lookup_array, $match_type=1) {
public static function MATCH($lookup_value, $lookup_array, $match_type = 1)
{
$lookup_array = PHPExcel_Calculation_Functions::flattenArray($lookup_array);
$lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value);
$match_type = (is_null($match_type)) ? 1 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($match_type);
@ -511,7 +525,7 @@ class PHPExcel_Calculation_LookupRef {
}
// lookup_array should contain only number, text, or logical values, or empty (null) cells
foreach($lookup_array as $i => $lookupArrayValue) {
foreach ($lookup_array as $i => $lookupArrayValue) {
// check the type of the value
if ((!is_numeric($lookupArrayValue)) && (!is_string($lookupArrayValue)) &&
(!is_bool($lookupArrayValue)) && (!is_null($lookupArrayValue))) {
@ -522,7 +536,7 @@ class PHPExcel_Calculation_LookupRef {
$lookup_array[$i] = strtolower($lookupArrayValue);
}
if ((is_null($lookupArrayValue)) && (($match_type == 1) || ($match_type == -1))) {
$lookup_array = array_slice($lookup_array,0,$i-1);
$lookup_array = array_slice($lookup_array, 0, $i-1);
}
}
@ -530,7 +544,7 @@ class PHPExcel_Calculation_LookupRef {
if ($match_type == 1) {
asort($lookup_array);
$keySet = array_keys($lookup_array);
} elseif($match_type == -1) {
} elseif ($match_type == -1) {
arsort($lookup_array);
$keySet = array_keys($lookup_array);
}
@ -538,42 +552,25 @@ class PHPExcel_Calculation_LookupRef {
// **
// find the match
// **
// loop on the cells
// var_dump($lookup_array);
// echo '<br />';
foreach($lookup_array as $i => $lookupArrayValue) {
foreach ($lookup_array as $i => $lookupArrayValue) {
if (($match_type == 0) && ($lookupArrayValue == $lookup_value)) {
// exact match
return ++$i;
} elseif (($match_type == -1) && ($lookupArrayValue <= $lookup_value)) {
// echo '$i = '.$i.' => ';
// var_dump($lookupArrayValue);
// echo '<br />';
// echo 'Keyset = ';
// var_dump($keySet);
// echo '<br />';
$i = array_search($i,$keySet);
// echo '$i='.$i.'<br />';
$i = array_search($i, $keySet);
// if match_type is -1 <=> find the smallest value that is greater than or equal to lookup_value
if ($i < 1){
// 1st cell was allready smaller than the lookup_value
if ($i < 1) {
// 1st cell was already smaller than the lookup_value
break;
} else {
// the previous cell was the match
return $keySet[$i-1]+1;
}
} elseif (($match_type == 1) && ($lookupArrayValue >= $lookup_value)) {
// echo '$i = '.$i.' => ';
// var_dump($lookupArrayValue);
// echo '<br />';
// echo 'Keyset = ';
// var_dump($keySet);
// echo '<br />';
$i = array_search($i,$keySet);
// echo '$i='.$i.'<br />';
$i = array_search($i, $keySet);
// if match_type is 1 <=> find the largest value that is less than or equal to lookup_value
if ($i < 1){
// 1st cell was allready bigger than the lookup_value
if ($i < 1) {
// 1st cell was already bigger than the lookup_value
break;
} else {
// the previous cell was the match
@ -584,7 +581,7 @@ class PHPExcel_Calculation_LookupRef {
// unsuccessful in finding a match, return #N/A error value
return PHPExcel_Calculation_Functions::NA();
} // function MATCH()
}
/**
@ -600,8 +597,8 @@ class PHPExcel_Calculation_LookupRef {
* @param column_num The column in array from which to return a value. If column_num is omitted, row_num is required.
* @return mixed the value of a specified cell or array of cells
*/
public static function INDEX($arrayValues,$rowNum = 0,$columnNum = 0) {
public static function INDEX($arrayValues, $rowNum = 0, $columnNum = 0)
{
if (($rowNum < 0) || ($columnNum < 0)) {
return PHPExcel_Calculation_Functions::VALUE();
}
@ -621,7 +618,7 @@ class PHPExcel_Calculation_LookupRef {
}
$rowNum = $rowKeys[--$rowNum];
$returnArray = array();
foreach($arrayValues as $arrayColumn) {
foreach ($arrayValues as $arrayColumn) {
if (is_array($arrayColumn)) {
if (isset($arrayColumn[$rowNum])) {
$returnArray[] = $arrayColumn[$rowNum];
@ -643,7 +640,7 @@ class PHPExcel_Calculation_LookupRef {
$rowNum = $rowKeys[--$rowNum];
return $arrayValues[$rowNum][$columnNum];
} // function INDEX()
}
/**
@ -654,31 +651,35 @@ class PHPExcel_Calculation_LookupRef {
*
* Unlike the Excel TRANSPOSE function, which will only work on a single row or column, this function will transpose a full matrix.
*/
public static function TRANSPOSE($matrixData) {
public static function TRANSPOSE($matrixData)
{
$returnMatrix = array();
if (!is_array($matrixData)) { $matrixData = array(array($matrixData)); }
if (!is_array($matrixData)) {
$matrixData = array(array($matrixData));
}
$column = 0;
foreach($matrixData as $matrixRow) {
foreach ($matrixData as $matrixRow) {
$row = 0;
foreach($matrixRow as $matrixCell) {
foreach ($matrixRow as $matrixCell) {
$returnMatrix[$row][$column] = $matrixCell;
++$row;
}
++$column;
}
return $returnMatrix;
} // function TRANSPOSE()
}
private static function _vlookupSort($a,$b) {
$f = array_keys($a);
$firstColumn = array_shift($f);
if (strtolower($a[$firstColumn]) == strtolower($b[$firstColumn])) {
private static function vlookupSort($a, $b)
{
reset($a);
$firstColumn = key($a);
if (($aLower = strtolower($a[$firstColumn])) == ($bLower = strtolower($b[$firstColumn]))) {
return 0;
}
return (strtolower($a[$firstColumn]) < strtolower($b[$firstColumn])) ? -1 : 1;
} // function _vlookupSort()
return ($aLower < $bLower) ? -1 : 1;
}
/**
@ -690,7 +691,8 @@ class PHPExcel_Calculation_LookupRef {
* @param not_exact_match Determines if you are looking for an exact match based on lookup_value.
* @return mixed The value of the found cell
*/
public static function VLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match=true) {
public static function VLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match = true)
{
$lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value);
$index_number = PHPExcel_Calculation_Functions::flattenSingleValue($index_number);
$not_exact_match = PHPExcel_Calculation_Functions::flattenSingleValue($not_exact_match);
@ -716,11 +718,11 @@ class PHPExcel_Calculation_LookupRef {
}
if (!$not_exact_match) {
uasort($lookup_array,array('self','_vlookupSort'));
uasort($lookup_array, array('self', 'vlookupSort'));
}
$rowNumber = $rowValue = False;
foreach($lookup_array as $rowKey => $rowData) {
$rowNumber = $rowValue = false;
foreach ($lookup_array as $rowKey => $rowData) {
if ((is_numeric($lookup_value) && is_numeric($rowData[$firstColumn]) && ($rowData[$firstColumn] > $lookup_value)) ||
(!is_numeric($lookup_value) && !is_numeric($rowData[$firstColumn]) && (strtolower($rowData[$firstColumn]) > strtolower($lookup_value)))) {
break;
@ -740,10 +742,10 @@ class PHPExcel_Calculation_LookupRef {
}
return PHPExcel_Calculation_Functions::NA();
} // function VLOOKUP()
}
/**
/**
* HLOOKUP
* The HLOOKUP function searches for value in the top-most row of lookup_array and returns the value in the same column based on the index_number.
* @param lookup_value The value that you want to match in lookup_array
@ -752,7 +754,8 @@ class PHPExcel_Calculation_LookupRef {
* @param not_exact_match Determines if you are looking for an exact match based on lookup_value.
* @return mixed The value of the found cell
*/
public static function HLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match=true) {
public static function HLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match = true)
{
$lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value);
$index_number = PHPExcel_Calculation_Functions::flattenSingleValue($index_number);
$not_exact_match = PHPExcel_Calculation_Functions::flattenSingleValue($not_exact_match);
@ -782,8 +785,8 @@ class PHPExcel_Calculation_LookupRef {
$firstRowH = asort($lookup_array[$firstColumn]);
}
$rowNumber = $rowValue = False;
foreach($lookup_array[$firstColumn] as $rowKey => $rowData) {
$rowNumber = $rowValue = false;
foreach ($lookup_array[$firstColumn] as $rowKey => $rowData) {
if ((is_numeric($lookup_value) && is_numeric($rowData) && ($rowData > $lookup_value)) ||
(!is_numeric($lookup_value) && !is_numeric($rowData) && (strtolower($rowData) > strtolower($lookup_value)))) {
break;
@ -803,7 +806,7 @@ class PHPExcel_Calculation_LookupRef {
}
return PHPExcel_Calculation_Functions::NA();
} // function HLOOKUP()
}
/**
@ -814,7 +817,8 @@ class PHPExcel_Calculation_LookupRef {
* @param result_vector The column from which the matching value must be returned
* @return mixed The value of the found cell
*/
public static function LOOKUP($lookup_value, $lookup_vector, $result_vector=null) {
public static function LOOKUP($lookup_value, $lookup_vector, $result_vector = null)
{
$lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value);
if (!is_array($lookup_vector)) {
@ -850,7 +854,7 @@ class PHPExcel_Calculation_LookupRef {
$lookup_vector = array_shift($lookup_vector);
}
if ($lookupColumns != 2) {
foreach($lookup_vector as &$value) {
foreach ($lookup_vector as &$value) {
if (is_array($value)) {
$k = array_keys($value);
$key1 = $key2 = array_shift($k);
@ -870,7 +874,6 @@ class PHPExcel_Calculation_LookupRef {
unset($value);
}
return self::VLOOKUP($lookup_value,$lookup_vector,2);
} // function LOOKUP()
} // class PHPExcel_Calculation_LookupRef
return self::VLOOKUP($lookup_value, $lookup_vector, 2);
}
}

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,18 @@
<?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel
* PHPExcel_Calculation_TextData
*
* Copyright (c) 2006 - 2014 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,50 +30,34 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2014 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##
*/
class PHPExcel_Calculation_TextData
{
private static $invalidChars;
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Calculation_TextData
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_TextData {
private static $_invalidChars = Null;
private static function _uniord($c) {
if (ord($c{0}) >=0 && ord($c{0}) <= 127)
private static function unicodeToOrd($c)
{
if (ord($c{0}) >=0 && ord($c{0}) <= 127) {
return ord($c{0});
if (ord($c{0}) >= 192 && ord($c{0}) <= 223)
} elseif (ord($c{0}) >= 192 && ord($c{0}) <= 223) {
return (ord($c{0})-192)*64 + (ord($c{1})-128);
if (ord($c{0}) >= 224 && ord($c{0}) <= 239)
} elseif (ord($c{0}) >= 224 && ord($c{0}) <= 239) {
return (ord($c{0})-224)*4096 + (ord($c{1})-128)*64 + (ord($c{2})-128);
if (ord($c{0}) >= 240 && ord($c{0}) <= 247)
} elseif (ord($c{0}) >= 240 && ord($c{0}) <= 247) {
return (ord($c{0})-240)*262144 + (ord($c{1})-128)*4096 + (ord($c{2})-128)*64 + (ord($c{3})-128);
if (ord($c{0}) >= 248 && ord($c{0}) <= 251)
} elseif (ord($c{0}) >= 248 && ord($c{0}) <= 251) {
return (ord($c{0})-248)*16777216 + (ord($c{1})-128)*262144 + (ord($c{2})-128)*4096 + (ord($c{3})-128)*64 + (ord($c{4})-128);
if (ord($c{0}) >= 252 && ord($c{0}) <= 253)
} elseif (ord($c{0}) >= 252 && ord($c{0}) <= 253) {
return (ord($c{0})-252)*1073741824 + (ord($c{1})-128)*16777216 + (ord($c{2})-128)*262144 + (ord($c{3})-128)*4096 + (ord($c{4})-128)*64 + (ord($c{5})-128);
if (ord($c{0}) >= 254 && ord($c{0}) <= 255) //error
} elseif (ord($c{0}) >= 254 && ord($c{0}) <= 255) {
// error
return PHPExcel_Calculation_Functions::VALUE();
}
return 0;
} // function _uniord()
}
/**
* CHARACTER
@ -71,7 +65,8 @@ class PHPExcel_Calculation_TextData {
* @param string $character Value
* @return int
*/
public static function CHARACTER($character) {
public static function CHARACTER($character)
{
$character = PHPExcel_Calculation_Functions::flattenSingleValue($character);
if ((!is_numeric($character)) || ($character < 0)) {
@ -92,22 +87,23 @@ class PHPExcel_Calculation_TextData {
* @param mixed $stringValue Value to check
* @return string
*/
public static function TRIMNONPRINTABLE($stringValue = '') {
public static function TRIMNONPRINTABLE($stringValue = '')
{
$stringValue = PHPExcel_Calculation_Functions::flattenSingleValue($stringValue);
if (is_bool($stringValue)) {
return ($stringValue) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
}
if (self::$_invalidChars == Null) {
self::$_invalidChars = range(chr(0),chr(31));
if (self::$invalidChars == null) {
self::$invalidChars = range(chr(0), chr(31));
}
if (is_string($stringValue) || is_numeric($stringValue)) {
return str_replace(self::$_invalidChars, '', trim($stringValue, "\x00..\x1F"));
return str_replace(self::$invalidChars, '', trim($stringValue, "\x00..\x1F"));
}
return null;
}
return NULL;
} // function TRIMNONPRINTABLE()
/**
@ -116,17 +112,18 @@ class PHPExcel_Calculation_TextData {
* @param mixed $stringValue Value to check
* @return string
*/
public static function TRIMSPACES($stringValue = '') {
public static function TRIMSPACES($stringValue = '')
{
$stringValue = PHPExcel_Calculation_Functions::flattenSingleValue($stringValue);
if (is_bool($stringValue)) {
return ($stringValue) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
}
if (is_string($stringValue) || is_numeric($stringValue)) {
return trim(preg_replace('/ +/',' ',trim($stringValue, ' ')), ' ');
return trim(preg_replace('/ +/', ' ', trim($stringValue, ' ')), ' ');
}
return null;
}
return NULL;
} // function TRIMSPACES()
/**
@ -135,9 +132,11 @@ class PHPExcel_Calculation_TextData {
* @param string $characters Value
* @return int
*/
public static function ASCIICODE($characters) {
if (($characters === NULL) || ($characters === ''))
public static function ASCIICODE($characters)
{
if (($characters === null) || ($characters === '')) {
return PHPExcel_Calculation_Functions::VALUE();
}
$characters = PHPExcel_Calculation_Functions::flattenSingleValue($characters);
if (is_bool($characters)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
@ -149,13 +148,17 @@ class PHPExcel_Calculation_TextData {
$character = $characters;
if ((function_exists('mb_strlen')) && (function_exists('mb_substr'))) {
if (mb_strlen($characters, 'UTF-8') > 1) { $character = mb_substr($characters, 0, 1, 'UTF-8'); }
return self::_uniord($character);
if (mb_strlen($characters, 'UTF-8') > 1) {
$character = mb_substr($characters, 0, 1, 'UTF-8');
}
return self::unicodeToOrd($character);
} else {
if (strlen($characters) > 0) { $character = substr($characters, 0, 1); }
if (strlen($characters) > 0) {
$character = substr($characters, 0, 1);
}
return ord($character);
}
} // function ASCIICODE()
}
/**
@ -163,8 +166,8 @@ class PHPExcel_Calculation_TextData {
*
* @return string
*/
public static function CONCATENATE() {
// Return value
public static function CONCATENATE()
{
$returnValue = '';
// Loop through arguments
@ -180,9 +183,8 @@ class PHPExcel_Calculation_TextData {
$returnValue .= $arg;
}
// Return
return $returnValue;
} // function CONCATENATE()
}
/**
@ -197,7 +199,8 @@ class PHPExcel_Calculation_TextData {
* If you omit decimals, it is assumed to be 2
* @return string
*/
public static function DOLLAR($value = 0, $decimals = 2) {
public static function DOLLAR($value = 0, $decimals = 2)
{
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$decimals = is_null($decimals) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($decimals);
@ -209,16 +212,18 @@ class PHPExcel_Calculation_TextData {
$mask = '$#,##0';
if ($decimals > 0) {
$mask .= '.' . str_repeat('0',$decimals);
$mask .= '.' . str_repeat('0', $decimals);
} else {
$round = pow(10,abs($decimals));
if ($value < 0) { $round = 0-$round; }
$round = pow(10, abs($decimals));
if ($value < 0) {
$round = 0-$round;
}
$value = PHPExcel_Calculation_MathTrig::MROUND($value, $round);
}
return PHPExcel_Style_NumberFormat::toFormattedString($value, $mask);
} // function DOLLAR()
}
/**
@ -229,7 +234,8 @@ class PHPExcel_Calculation_TextData {
* @param int $offset Offset within $haystack
* @return string
*/
public static function SEARCHSENSITIVE($needle,$haystack,$offset=1) {
public static function SEARCHSENSITIVE($needle, $haystack, $offset = 1)
{
$needle = PHPExcel_Calculation_Functions::flattenSingleValue($needle);
$haystack = PHPExcel_Calculation_Functions::flattenSingleValue($haystack);
$offset = PHPExcel_Calculation_Functions::flattenSingleValue($offset);
@ -254,7 +260,7 @@ class PHPExcel_Calculation_TextData {
}
}
return PHPExcel_Calculation_Functions::VALUE();
} // function SEARCHSENSITIVE()
}
/**
@ -265,7 +271,8 @@ class PHPExcel_Calculation_TextData {
* @param int $offset Offset within $haystack
* @return string
*/
public static function SEARCHINSENSITIVE($needle,$haystack,$offset=1) {
public static function SEARCHINSENSITIVE($needle, $haystack, $offset = 1)
{
$needle = PHPExcel_Calculation_Functions::flattenSingleValue($needle);
$haystack = PHPExcel_Calculation_Functions::flattenSingleValue($haystack);
$offset = PHPExcel_Calculation_Functions::flattenSingleValue($offset);
@ -280,7 +287,7 @@ class PHPExcel_Calculation_TextData {
return $offset;
}
if (function_exists('mb_stripos')) {
$pos = mb_stripos($haystack, $needle, --$offset,'UTF-8');
$pos = mb_stripos($haystack, $needle, --$offset, 'UTF-8');
} else {
$pos = stripos($haystack, $needle, --$offset);
}
@ -290,7 +297,7 @@ class PHPExcel_Calculation_TextData {
}
}
return PHPExcel_Calculation_Functions::VALUE();
} // function SEARCHINSENSITIVE()
}
/**
@ -301,7 +308,8 @@ class PHPExcel_Calculation_TextData {
* @param boolean $no_commas
* @return boolean
*/
public static function FIXEDFORMAT($value, $decimals = 2, $no_commas = FALSE) {
public static function FIXEDFORMAT($value, $decimals = 2, $no_commas = false)
{
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$decimals = PHPExcel_Calculation_Functions::flattenSingleValue($decimals);
$no_commas = PHPExcel_Calculation_Functions::flattenSingleValue($no_commas);
@ -312,14 +320,16 @@ class PHPExcel_Calculation_TextData {
}
$decimals = floor($decimals);
$valueResult = round($value,$decimals);
if ($decimals < 0) { $decimals = 0; }
$valueResult = round($value, $decimals);
if ($decimals < 0) {
$decimals = 0;
}
if (!$no_commas) {
$valueResult = number_format($valueResult,$decimals);
$valueResult = number_format($valueResult, $decimals);
}
return (string) $valueResult;
} // function FIXEDFORMAT()
}
/**
@ -329,7 +339,8 @@ class PHPExcel_Calculation_TextData {
* @param int $chars Number of characters
* @return string
*/
public static function LEFT($value = '', $chars = 1) {
public static function LEFT($value = '', $chars = 1)
{
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$chars = PHPExcel_Calculation_Functions::flattenSingleValue($chars);
@ -346,7 +357,7 @@ class PHPExcel_Calculation_TextData {
} else {
return substr($value, 0, $chars);
}
} // function LEFT()
}
/**
@ -357,7 +368,8 @@ class PHPExcel_Calculation_TextData {
* @param int $chars Number of characters
* @return string
*/
public static function MID($value = '', $start = 1, $chars = null) {
public static function MID($value = '', $start = 1, $chars = null)
{
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$start = PHPExcel_Calculation_Functions::flattenSingleValue($start);
$chars = PHPExcel_Calculation_Functions::flattenSingleValue($chars);
@ -375,7 +387,7 @@ class PHPExcel_Calculation_TextData {
} else {
return substr($value, --$start, $chars);
}
} // function MID()
}
/**
@ -385,7 +397,8 @@ class PHPExcel_Calculation_TextData {
* @param int $chars Number of characters
* @return string
*/
public static function RIGHT($value = '', $chars = 1) {
public static function RIGHT($value = '', $chars = 1)
{
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$chars = PHPExcel_Calculation_Functions::flattenSingleValue($chars);
@ -402,7 +415,7 @@ class PHPExcel_Calculation_TextData {
} else {
return substr($value, strlen($value) - $chars);
}
} // function RIGHT()
}
/**
@ -411,7 +424,8 @@ class PHPExcel_Calculation_TextData {
* @param string $value Value
* @return string
*/
public static function STRINGLENGTH($value = '') {
public static function STRINGLENGTH($value = '')
{
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
if (is_bool($value)) {
@ -423,7 +437,7 @@ class PHPExcel_Calculation_TextData {
} else {
return strlen($value);
}
} // function STRINGLENGTH()
}
/**
@ -434,7 +448,8 @@ class PHPExcel_Calculation_TextData {
* @param string $mixedCaseString
* @return string
*/
public static function LOWERCASE($mixedCaseString) {
public static function LOWERCASE($mixedCaseString)
{
$mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString);
if (is_bool($mixedCaseString)) {
@ -442,7 +457,7 @@ class PHPExcel_Calculation_TextData {
}
return PHPExcel_Shared_String::StrToLower($mixedCaseString);
} // function LOWERCASE()
}
/**
@ -453,7 +468,8 @@ class PHPExcel_Calculation_TextData {
* @param string $mixedCaseString
* @return string
*/
public static function UPPERCASE($mixedCaseString) {
public static function UPPERCASE($mixedCaseString)
{
$mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString);
if (is_bool($mixedCaseString)) {
@ -461,7 +477,7 @@ class PHPExcel_Calculation_TextData {
}
return PHPExcel_Shared_String::StrToUpper($mixedCaseString);
} // function UPPERCASE()
}
/**
@ -472,7 +488,8 @@ class PHPExcel_Calculation_TextData {
* @param string $mixedCaseString
* @return string
*/
public static function PROPERCASE($mixedCaseString) {
public static function PROPERCASE($mixedCaseString)
{
$mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString);
if (is_bool($mixedCaseString)) {
@ -480,7 +497,7 @@ class PHPExcel_Calculation_TextData {
}
return PHPExcel_Shared_String::StrToTitle($mixedCaseString);
} // function PROPERCASE()
}
/**
@ -492,17 +509,18 @@ class PHPExcel_Calculation_TextData {
* @param string $newText String to replace in defined position
* @return string
*/
public static function REPLACE($oldText = '', $start = 1, $chars = null, $newText) {
public static function REPLACE($oldText = '', $start = 1, $chars = null, $newText)
{
$oldText = PHPExcel_Calculation_Functions::flattenSingleValue($oldText);
$start = PHPExcel_Calculation_Functions::flattenSingleValue($start);
$chars = PHPExcel_Calculation_Functions::flattenSingleValue($chars);
$newText = PHPExcel_Calculation_Functions::flattenSingleValue($newText);
$left = self::LEFT($oldText,$start-1);
$right = self::RIGHT($oldText,self::STRINGLENGTH($oldText)-($start+$chars)+1);
$left = self::LEFT($oldText, $start-1);
$right = self::RIGHT($oldText, self::STRINGLENGTH($oldText)-($start+$chars)+1);
return $left.$newText.$right;
} // function REPLACE()
}
/**
@ -514,21 +532,22 @@ class PHPExcel_Calculation_TextData {
* @param integer $instance Instance Number
* @return string
*/
public static function SUBSTITUTE($text = '', $fromText = '', $toText = '', $instance = 0) {
public static function SUBSTITUTE($text = '', $fromText = '', $toText = '', $instance = 0)
{
$text = PHPExcel_Calculation_Functions::flattenSingleValue($text);
$fromText = PHPExcel_Calculation_Functions::flattenSingleValue($fromText);
$toText = PHPExcel_Calculation_Functions::flattenSingleValue($toText);
$instance = floor(PHPExcel_Calculation_Functions::flattenSingleValue($instance));
if ($instance == 0) {
if(function_exists('mb_str_replace')) {
return mb_str_replace($fromText,$toText,$text);
if (function_exists('mb_str_replace')) {
return mb_str_replace($fromText, $toText, $text);
} else {
return str_replace($fromText,$toText,$text);
return str_replace($fromText, $toText, $text);
}
} else {
$pos = -1;
while($instance > 0) {
while ($instance > 0) {
if (function_exists('mb_strpos')) {
$pos = mb_strpos($text, $fromText, $pos+1, 'UTF-8');
} else {
@ -541,15 +560,15 @@ class PHPExcel_Calculation_TextData {
}
if ($pos !== false) {
if (function_exists('mb_strlen')) {
return self::REPLACE($text,++$pos,mb_strlen($fromText, 'UTF-8'),$toText);
return self::REPLACE($text, ++$pos, mb_strlen($fromText, 'UTF-8'), $toText);
} else {
return self::REPLACE($text,++$pos,strlen($fromText),$toText);
return self::REPLACE($text, ++$pos, strlen($fromText), $toText);
}
}
}
return $text;
} // function SUBSTITUTE()
}
/**
@ -558,14 +577,15 @@ class PHPExcel_Calculation_TextData {
* @param mixed $testValue Value to check
* @return boolean
*/
public static function RETURNSTRING($testValue = '') {
public static function RETURNSTRING($testValue = '')
{
$testValue = PHPExcel_Calculation_Functions::flattenSingleValue($testValue);
if (is_string($testValue)) {
return $testValue;
}
return Null;
} // function RETURNSTRING()
return null;
}
/**
@ -575,7 +595,8 @@ class PHPExcel_Calculation_TextData {
* @param string $format Format mask to use
* @return boolean
*/
public static function TEXTFORMAT($value,$format) {
public static function TEXTFORMAT($value, $format)
{
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$format = PHPExcel_Calculation_Functions::flattenSingleValue($format);
@ -583,8 +604,8 @@ class PHPExcel_Calculation_TextData {
$value = PHPExcel_Calculation_DateTime::DATEVALUE($value);
}
return (string) PHPExcel_Style_NumberFormat::toFormattedString($value,$format);
} // function TEXTFORMAT()
return (string) PHPExcel_Style_NumberFormat::toFormattedString($value, $format);
}
/**
* VALUE
@ -592,7 +613,8 @@ class PHPExcel_Calculation_TextData {
* @param mixed $value Value to check
* @return boolean
*/
public static function VALUE($value = '') {
public static function VALUE($value = '')
{
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
if (!is_numeric($value)) {
@ -626,5 +648,4 @@ class PHPExcel_Calculation_TextData {
}
return (float) $value;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Calculation_Token_Stack
*
* Copyright (c) 2006 - 2014 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,44 +21,35 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2014 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_Calculation_Token_Stack
*
* @category PHPExcel_Calculation_Token_Stack
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Token_Stack {
class PHPExcel_Calculation_Token_Stack
{
/**
* The parser stack for formulae
*
* @var mixed[]
*/
private $_stack = array();
private $stack = array();
/**
* Count of entries in the parser stack
*
* @var integer
*/
private $_count = 0;
private $count = 0;
/**
* Return the number of entries on the stack
*
* @return integer
*/
public function count() {
return $this->_count;
} // function count()
public function count()
{
return $this->count;
}
/**
* Push a new entry onto the stack
@ -66,30 +58,33 @@ class PHPExcel_Calculation_Token_Stack {
* @param mixed $value
* @param mixed $reference
*/
public function push($type, $value, $reference = NULL) {
$this->_stack[$this->_count++] = array('type' => $type,
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);
$localeFunction = PHPExcel_Calculation::localeFunc($value);
if ($localeFunction != $value) {
$this->_stack[($this->_count - 1)]['localeValue'] = $localeFunction;
$this->stack[($this->count - 1)]['localeValue'] = $localeFunction;
}
}
}
} // function push()
/**
* Pop the last entry from the stack
*
* @return mixed
*/
public function pop() {
if ($this->_count > 0) {
return $this->_stack[--$this->_count];
public function pop()
{
if ($this->count > 0) {
return $this->stack[--$this->count];
}
return null;
}
return NULL;
} // function pop()
/**
* Return an entry from the stack without removing it
@ -97,19 +92,20 @@ class PHPExcel_Calculation_Token_Stack {
* @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;
public function last($n = 1)
{
if ($this->count - $n < 0) {
return null;
}
return $this->stack[$this->count - $n];
}
return $this->_stack[$this->_count - $n];
} // function last()
/**
* Clear the stack
*/
function clear() {
$this->_stack = array();
$this->_count = 0;
public function clear()
{
$this->stack = array();
$this->count = 0;
}
} // class PHPExcel_Calculation_Token_Stack
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Cell
*
* Copyright (c) 2006 - 2014 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,22 +21,12 @@
*
* @category PHPExcel
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2014 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
*
* @category PHPExcel
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Cell
{
/**
* Default range variable constant
*
@ -48,14 +39,14 @@ class PHPExcel_Cell
*
* @var PHPExcel_Cell_IValueBinder
*/
private static $_valueBinder = NULL;
private static $valueBinder;
/**
* Value of the cell
*
* @var mixed
*/
private $_value;
private $value;
/**
* Calculated value of the cell (used for caching)
@ -67,34 +58,34 @@ class PHPExcel_Cell
*
* @var mixed
*/
private $_calculatedValue = NULL;
private $calculatedValue;
/**
* Type of the cell data
*
* @var string
*/
private $_dataType;
private $dataType;
/**
* Parent worksheet
*
* @var PHPExcel_CachedObjectStorage_CacheBase
*/
private $_parent;
private $parent;
/**
* Index to cellXf
*
* @var int
*/
private $_xfIndex = 0;
private $xfIndex = 0;
/**
* Attributes of the formula
*
*/
private $_formulaAttributes;
private $formulaAttributes;
/**
@ -102,18 +93,21 @@ class PHPExcel_Cell
*
* @return void
**/
public function notifyCacheController() {
$this->_parent->updateCacheData($this);
public function notifyCacheController()
{
$this->parent->updateCacheData($this);
return $this;
}
public function detach() {
$this->_parent = NULL;
public function detach()
{
$this->parent = null;
}
public function attach(PHPExcel_CachedObjectStorage_CacheBase $parent) {
$this->_parent = $parent;
public function attach(PHPExcel_CachedObjectStorage_CacheBase $parent)
{
$this->parent = $parent;
}
@ -125,19 +119,20 @@ class PHPExcel_Cell
* @param PHPExcel_Worksheet $pSheet
* @throws PHPExcel_Exception
*/
public function __construct($pValue = NULL, $pDataType = NULL, PHPExcel_Worksheet $pSheet = NULL)
public function __construct($pValue = null, $pDataType = null, PHPExcel_Worksheet $pSheet = null)
{
// Initialise cell value
$this->_value = $pValue;
$this->value = $pValue;
// Set worksheet cache
$this->_parent = $pSheet->getCellCacheController();
$this->parent = $pSheet->getCellCacheController();
// Set datatype?
if ($pDataType !== NULL) {
if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2)
if ($pDataType !== null) {
if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2) {
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
$this->_dataType = $pDataType;
}
$this->dataType = $pDataType;
} elseif (!self::getValueBinder()->bindValue($this, $pValue)) {
throw new PHPExcel_Exception("Value could not be bound to cell.");
}
@ -150,7 +145,7 @@ class PHPExcel_Cell
*/
public function getColumn()
{
return $this->_parent->getCurrentColumn();
return $this->parent->getCurrentColumn();
}
/**
@ -160,7 +155,7 @@ class PHPExcel_Cell
*/
public function getRow()
{
return $this->_parent->getCurrentRow();
return $this->parent->getCurrentRow();
}
/**
@ -170,7 +165,7 @@ class PHPExcel_Cell
*/
public function getCoordinate()
{
return $this->_parent->getCurrentAddress();
return $this->parent->getCurrentAddress();
}
/**
@ -180,7 +175,7 @@ class PHPExcel_Cell
*/
public function getValue()
{
return $this->_value;
return $this->value;
}
/**
@ -206,7 +201,7 @@ class PHPExcel_Cell
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function setValue($pValue = NULL)
public function setValue($pValue = null)
{
if (!self::getValueBinder()->bindValue($this, $pValue)) {
throw new PHPExcel_Exception("Value could not be bound to cell.");
@ -222,30 +217,33 @@ class PHPExcel_Cell
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function setValueExplicit($pValue = NULL, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
public function setValueExplicit($pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
{
// set the value according to data type
switch ($pDataType) {
case PHPExcel_Cell_DataType::TYPE_NULL:
$this->_value = $pValue;
$this->value = $pValue;
break;
case PHPExcel_Cell_DataType::TYPE_STRING2:
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
// no break
case PHPExcel_Cell_DataType::TYPE_STRING:
// Synonym for string
case PHPExcel_Cell_DataType::TYPE_INLINE:
$this->_value = PHPExcel_Cell_DataType::checkString($pValue);
// Rich text
$this->value = PHPExcel_Cell_DataType::checkString($pValue);
break;
case PHPExcel_Cell_DataType::TYPE_NUMERIC:
$this->_value = (float)$pValue;
$this->value = (float) $pValue;
break;
case PHPExcel_Cell_DataType::TYPE_FORMULA:
$this->_value = (string)$pValue;
$this->value = (string) $pValue;
break;
case PHPExcel_Cell_DataType::TYPE_BOOL:
$this->_value = (bool)$pValue;
$this->value = (bool) $pValue;
break;
case PHPExcel_Cell_DataType::TYPE_ERROR:
$this->_value = PHPExcel_Cell_DataType::checkErrorCode($pValue);
$this->value = PHPExcel_Cell_DataType::checkErrorCode($pValue);
break;
default:
throw new PHPExcel_Exception('Invalid datatype: ' . $pDataType);
@ -253,7 +251,7 @@ class PHPExcel_Cell
}
// set the datatype
$this->_dataType = $pDataType;
$this->dataType = $pDataType;
return $this->notifyCacheController();
}
@ -267,15 +265,15 @@ class PHPExcel_Cell
* @return mixed
* @throws PHPExcel_Exception
*/
public function getCalculatedValue($resetLog = TRUE)
public function getCalculatedValue($resetLog = true)
{
//echo 'Cell '.$this->getCoordinate().' value is a '.$this->_dataType.' with a value of '.$this->getValue().PHP_EOL;
if ($this->_dataType == PHPExcel_Cell_DataType::TYPE_FORMULA) {
//echo 'Cell '.$this->getCoordinate().' value is a '.$this->dataType.' with a value of '.$this->getValue().PHP_EOL;
if ($this->dataType == PHPExcel_Cell_DataType::TYPE_FORMULA) {
try {
//echo 'Cell value for '.$this->getCoordinate().' is a formula: Calculating value'.PHP_EOL;
$result = PHPExcel_Calculation::getInstance(
$this->getWorksheet()->getParent()
)->calculateCellValue($this,$resetLog);
)->calculateCellValue($this, $resetLog);
//echo $this->getCoordinate().' calculation result is '.$result.PHP_EOL;
// We don't yet handle array returns
if (is_array($result)) {
@ -283,10 +281,10 @@ class PHPExcel_Cell
$result = array_pop($result);
}
}
} catch ( PHPExcel_Exception $ex ) {
if (($ex->getMessage() === 'Unable to access External Workbook') && ($this->_calculatedValue !== NULL)) {
//echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().PHP_EOL;
return $this->_calculatedValue; // Fallback for calculations referencing external files.
} catch (PHPExcel_Exception $ex) {
if (($ex->getMessage() === 'Unable to access External Workbook') && ($this->calculatedValue !== null)) {
//echo 'Returning fallback value of '.$this->calculatedValue.' for cell '.$this->getCoordinate().PHP_EOL;
return $this->calculatedValue; // Fallback for calculations referencing external files.
}
//echo 'Calculation Exception: '.$ex->getMessage().PHP_EOL;
$result = '#N/A';
@ -296,17 +294,17 @@ class PHPExcel_Cell
}
if ($result === '#Not Yet Implemented') {
//echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().PHP_EOL;
return $this->_calculatedValue; // Fallback if calculation engine does not support the formula.
//echo 'Returning fallback value of '.$this->calculatedValue.' for cell '.$this->getCoordinate().PHP_EOL;
return $this->calculatedValue; // Fallback if calculation engine does not support the formula.
}
//echo 'Returning calculated value of '.$result.' for cell '.$this->getCoordinate().PHP_EOL;
return $result;
} elseif($this->_value instanceof PHPExcel_RichText) {
// echo 'Cell value for '.$this->getCoordinate().' is rich text: Returning data value of '.$this->_value.'<br />';
return $this->_value->getPlainText();
} elseif ($this->value instanceof PHPExcel_RichText) {
// echo 'Cell value for '.$this->getCoordinate().' is rich text: Returning data value of '.$this->value.'<br />';
return $this->value->getPlainText();
}
// echo 'Cell value for '.$this->getCoordinate().' is not a formula: Returning data value of '.$this->_value.'<br />';
return $this->_value;
// echo 'Cell value for '.$this->getCoordinate().' is not a formula: Returning data value of '.$this->value.'<br />';
return $this->value;
}
/**
@ -315,10 +313,10 @@ class PHPExcel_Cell
* @param mixed $pValue Value
* @return PHPExcel_Cell
*/
public function setCalculatedValue($pValue = NULL)
public function setCalculatedValue($pValue = null)
{
if ($pValue !== NULL) {
$this->_calculatedValue = (is_numeric($pValue)) ? (float) $pValue : $pValue;
if ($pValue !== null) {
$this->calculatedValue = (is_numeric($pValue)) ? (float) $pValue : $pValue;
}
return $this->notifyCacheController();
@ -336,7 +334,7 @@ class PHPExcel_Cell
*/
public function getOldCalculatedValue()
{
return $this->_calculatedValue;
return $this->calculatedValue;
}
/**
@ -346,7 +344,7 @@ class PHPExcel_Cell
*/
public function getDataType()
{
return $this->_dataType;
return $this->dataType;
}
/**
@ -357,10 +355,10 @@ class PHPExcel_Cell
*/
public function setDataType($pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
{
if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2)
if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2) {
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
$this->_dataType = $pDataType;
}
$this->dataType = $pDataType;
return $this->notifyCacheController();
}
@ -372,7 +370,7 @@ class PHPExcel_Cell
*/
public function isFormula()
{
return $this->_dataType == PHPExcel_Cell_DataType::TYPE_FORMULA;
return $this->dataType == PHPExcel_Cell_DataType::TYPE_FORMULA;
}
/**
@ -383,7 +381,7 @@ class PHPExcel_Cell
*/
public function hasDataValidation()
{
if (!isset($this->_parent)) {
if (!isset($this->parent)) {
throw new PHPExcel_Exception('Cannot check for data validation when cell is not bound to a worksheet');
}
@ -398,7 +396,7 @@ class PHPExcel_Cell
*/
public function getDataValidation()
{
if (!isset($this->_parent)) {
if (!isset($this->parent)) {
throw new PHPExcel_Exception('Cannot get data validation for cell that is not bound to a worksheet');
}
@ -412,9 +410,9 @@ class PHPExcel_Cell
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function setDataValidation(PHPExcel_Cell_DataValidation $pDataValidation = NULL)
public function setDataValidation(PHPExcel_Cell_DataValidation $pDataValidation = null)
{
if (!isset($this->_parent)) {
if (!isset($this->parent)) {
throw new PHPExcel_Exception('Cannot set data validation for cell that is not bound to a worksheet');
}
@ -431,7 +429,7 @@ class PHPExcel_Cell
*/
public function hasHyperlink()
{
if (!isset($this->_parent)) {
if (!isset($this->parent)) {
throw new PHPExcel_Exception('Cannot check for hyperlink when cell is not bound to a worksheet');
}
@ -446,7 +444,7 @@ class PHPExcel_Cell
*/
public function getHyperlink()
{
if (!isset($this->_parent)) {
if (!isset($this->parent)) {
throw new PHPExcel_Exception('Cannot get hyperlink for cell that is not bound to a worksheet');
}
@ -460,9 +458,9 @@ class PHPExcel_Cell
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function setHyperlink(PHPExcel_Cell_Hyperlink $pHyperlink = NULL)
public function setHyperlink(PHPExcel_Cell_Hyperlink $pHyperlink = null)
{
if (!isset($this->_parent)) {
if (!isset($this->parent)) {
throw new PHPExcel_Exception('Cannot set hyperlink for cell that is not bound to a worksheet');
}
@ -476,8 +474,9 @@ class PHPExcel_Cell
*
* @return PHPExcel_CachedObjectStorage_CacheBase
*/
public function getParent() {
return $this->_parent;
public function getParent()
{
return $this->parent;
}
/**
@ -485,8 +484,9 @@ class PHPExcel_Cell
*
* @return PHPExcel_Worksheet
*/
public function getWorksheet() {
return $this->_parent->getParent();
public function getWorksheet()
{
return $this->parent->getParent();
}
/**
@ -494,7 +494,8 @@ class PHPExcel_Cell
*
* @return boolean
*/
public function isInMergeRange() {
public function isInMergeRange()
{
return (boolean) $this->getMergeRange();
}
@ -503,7 +504,8 @@ class PHPExcel_Cell
*
* @return boolean
*/
public function isMergeRangeValueCell() {
public function isMergeRangeValueCell()
{
if ($mergeRange = $this->getMergeRange()) {
$mergeRange = PHPExcel_Cell::splitRange($mergeRange);
list($startCell) = $mergeRange[0];
@ -519,8 +521,9 @@ class PHPExcel_Cell
*
* @return string
*/
public function getMergeRange() {
foreach($this->getWorksheet()->getMergeCells() as $mergeRange) {
public function getMergeRange()
{
foreach ($this->getWorksheet()->getMergeCells() as $mergeRange) {
if ($this->isInRange($mergeRange)) {
return $mergeRange;
}
@ -544,8 +547,9 @@ class PHPExcel_Cell
* @param PHPExcel_Worksheet $parent
* @return PHPExcel_Cell
*/
public function rebindParent(PHPExcel_Worksheet $parent) {
$this->_parent = $parent->getCellCacheController();
public function rebindParent(PHPExcel_Worksheet $parent)
{
$this->parent = $parent->getCellCacheController();
return $this->notifyCacheController();
}
@ -558,7 +562,7 @@ class PHPExcel_Cell
*/
public function isInRange($pRange = 'A1:A1')
{
list($rangeStart,$rangeEnd) = self::rangeBoundaries($pRange);
list($rangeStart, $rangeEnd) = self::rangeBoundaries($pRange);
// Translate properties
$myColumn = self::columnIndexFromString($this->getColumn());
@ -581,7 +585,7 @@ class PHPExcel_Cell
{
if (preg_match("/^([$]?[A-Z]{1,3})([$]?\d{1,7})$/", $pCoordinateString, $matches)) {
return array($matches[1],$matches[2]);
} elseif ((strpos($pCoordinateString,':') !== FALSE) || (strpos($pCoordinateString,',') !== FALSE)) {
} elseif ((strpos($pCoordinateString, ':') !== false) || (strpos($pCoordinateString, ',') !== false)) {
throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells');
} elseif ($pCoordinateString == '') {
throw new PHPExcel_Exception('Cell coordinate can not be zero-length string');
@ -600,14 +604,16 @@ class PHPExcel_Cell
*/
public static function absoluteReference($pCoordinateString = 'A1')
{
if (strpos($pCoordinateString,':') === FALSE && strpos($pCoordinateString,',') === FALSE) {
if (strpos($pCoordinateString, ':') === false && strpos($pCoordinateString, ',') === false) {
// Split out any worksheet name from the reference
$worksheet = '';
$cellAddress = explode('!',$pCoordinateString);
$cellAddress = explode('!', $pCoordinateString);
if (count($cellAddress) > 1) {
list($worksheet,$pCoordinateString) = $cellAddress;
list($worksheet, $pCoordinateString) = $cellAddress;
}
if ($worksheet > '') {
$worksheet .= '!';
}
if ($worksheet > '') $worksheet .= '!';
// Create absolute coordinate
if (ctype_digit($pCoordinateString)) {
@ -630,19 +636,21 @@ class PHPExcel_Cell
*/
public static function absoluteCoordinate($pCoordinateString = 'A1')
{
if (strpos($pCoordinateString,':') === FALSE && strpos($pCoordinateString,',') === FALSE) {
if (strpos($pCoordinateString, ':') === false && strpos($pCoordinateString, ',') === false) {
// Split out any worksheet name from the coordinate
$worksheet = '';
$cellAddress = explode('!',$pCoordinateString);
$cellAddress = explode('!', $pCoordinateString);
if (count($cellAddress) > 1) {
list($worksheet,$pCoordinateString) = $cellAddress;
list($worksheet, $pCoordinateString) = $cellAddress;
}
if ($worksheet > '') {
$worksheet .= '!';
}
if ($worksheet > '') $worksheet .= '!';
// Create absolute coordinate
list($column, $row) = self::coordinateFromString($pCoordinateString);
$column = ltrim($column,'$');
$row = ltrim($row,'$');
$column = ltrim($column, '$');
$row = ltrim($row, '$');
return $worksheet . '$' . $column . '$' . $row;
}
@ -660,7 +668,7 @@ class PHPExcel_Cell
public static function splitRange($pRange = 'A1:A1')
{
// Ensure $pRange is a valid range
if(empty($pRange)) {
if (empty($pRange)) {
$pRange = self::DEFAULT_RANGE;
}
@ -707,7 +715,7 @@ class PHPExcel_Cell
public static function rangeBoundaries($pRange = 'A1:A1')
{
// Ensure $pRange is a valid range
if(empty($pRange)) {
if (empty($pRange)) {
$pRange = self::DEFAULT_RANGE;
}
@ -715,7 +723,7 @@ class PHPExcel_Cell
$pRange = strtoupper($pRange);
// Extract range
if (strpos($pRange, ':') === FALSE) {
if (strpos($pRange, ':') === false) {
$rangeA = $rangeB = $pRange;
} else {
list($rangeA, $rangeB) = explode(':', $pRange);
@ -741,7 +749,7 @@ class PHPExcel_Cell
public static function rangeDimension($pRange = 'A1:A1')
{
// Calculate range outer borders
list($rangeStart,$rangeEnd) = self::rangeBoundaries($pRange);
list($rangeStart, $rangeEnd) = self::rangeBoundaries($pRange);
return array( ($rangeEnd[0] - $rangeStart[0] + 1), ($rangeEnd[1] - $rangeStart[1] + 1) );
}
@ -756,7 +764,7 @@ class PHPExcel_Cell
public static function getRangeBoundaries($pRange = 'A1:A1')
{
// Ensure $pRange is a valid range
if(empty($pRange)) {
if (empty($pRange)) {
$pRange = self::DEFAULT_RANGE;
}
@ -764,7 +772,7 @@ class PHPExcel_Cell
$pRange = strtoupper($pRange);
// Extract range
if (strpos($pRange, ':') === FALSE) {
if (strpos($pRange, ':') === false) {
$rangeA = $rangeB = $pRange;
} else {
list($rangeA, $rangeB) = explode(':', $pRange);
@ -786,9 +794,9 @@ class PHPExcel_Cell
// though it's additional memory overhead
static $_indexCache = array();
if (isset($_indexCache[$pString]))
if (isset($_indexCache[$pString])) {
return $_indexCache[$pString];
}
// It's surprising how costly the strtoupper() and ord() calls actually are, so we use a lookup array rather than use ord()
// and make it case insensitive to get rid of the strtoupper() as well. Because it's a static, there's no significant
// memory overhead either
@ -805,10 +813,10 @@ class PHPExcel_Cell
if (!isset($pString{1})) {
$_indexCache[$pString] = $_columnLookup[$pString];
return $_indexCache[$pString];
} elseif(!isset($pString{2})) {
} elseif (!isset($pString{2})) {
$_indexCache[$pString] = $_columnLookup[$pString{0}] * 26 + $_columnLookup[$pString{1}];
return $_indexCache[$pString];
} elseif(!isset($pString{3})) {
} elseif (!isset($pString{3})) {
$_indexCache[$pString] = $_columnLookup[$pString{0}] * 676 + $_columnLookup[$pString{1}] * 26 + $_columnLookup[$pString{2}];
return $_indexCache[$pString];
}
@ -851,7 +859,8 @@ class PHPExcel_Cell
* @param string $pRange Range (e.g. A1 or A1:C10 or A1:E10 A20:E25)
* @return array Array containing single cell references
*/
public static function extractAllCellReferencesInRange($pRange = 'A1') {
public static function extractAllCellReferencesInRange($pRange = 'A1')
{
// Returnvalue
$returnValue = array();
@ -859,14 +868,14 @@ class PHPExcel_Cell
$cellBlocks = explode(' ', str_replace('$', '', strtoupper($pRange)));
foreach ($cellBlocks as $cellBlock) {
// Single cell?
if (strpos($cellBlock,':') === FALSE && strpos($cellBlock,',') === FALSE) {
if (strpos($cellBlock, ':') === false && strpos($cellBlock, ',') === false) {
$returnValue[] = $cellBlock;
continue;
}
// Range...
$ranges = self::splitRange($cellBlock);
foreach($ranges as $range) {
foreach ($ranges as $range) {
// Single cell?
if (!isset($range[1])) {
$returnValue[] = $range[0];
@ -875,9 +884,9 @@ class PHPExcel_Cell
// Range...
list($rangeStart, $rangeEnd) = $range;
sscanf($rangeStart,'%[A-Z]%d', $startCol, $startRow);
sscanf($rangeEnd,'%[A-Z]%d', $endCol, $endRow);
$endCol++;
sscanf($rangeStart, '%[A-Z]%d', $startCol, $startRow);
sscanf($rangeEnd, '%[A-Z]%d', $endCol, $endRow);
++$endCol;
// Current data
$currentCol = $startCol;
@ -898,8 +907,8 @@ class PHPExcel_Cell
// Sort the result by column and row
$sortKeys = array();
foreach (array_unique($returnValue) as $coord) {
sscanf($coord,'%[A-Z]%d', $column, $row);
$sortKeys[sprintf('%3s%09d',$column,$row)] = $coord;
sscanf($coord, '%[A-Z]%d', $column, $row);
$sortKeys[sprintf('%3s%09d', $column, $row)] = $coord;
}
ksort($sortKeys);
@ -932,12 +941,13 @@ class PHPExcel_Cell
*
* @return PHPExcel_Cell_IValueBinder
*/
public static function getValueBinder() {
if (self::$_valueBinder === NULL) {
self::$_valueBinder = new PHPExcel_Cell_DefaultValueBinder();
public static function getValueBinder()
{
if (self::$valueBinder === null) {
self::$valueBinder = new PHPExcel_Cell_DefaultValueBinder();
}
return self::$_valueBinder;
return self::$valueBinder;
}
/**
@ -946,21 +956,23 @@ class PHPExcel_Cell
* @param PHPExcel_Cell_IValueBinder $binder
* @throws PHPExcel_Exception
*/
public static function setValueBinder(PHPExcel_Cell_IValueBinder $binder = NULL) {
if ($binder === NULL) {
public static function setValueBinder(PHPExcel_Cell_IValueBinder $binder = null)
{
if ($binder === null) {
throw new PHPExcel_Exception("A PHPExcel_Cell_IValueBinder is required for PHPExcel to function correctly.");
}
self::$_valueBinder = $binder;
self::$valueBinder = $binder;
}
/**
* 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)) && ($key != '_parent')) {
if ((is_object($value)) && ($key != 'parent')) {
$this->$key = clone $value;
} else {
$this->$key = $value;
@ -975,7 +987,7 @@ class PHPExcel_Cell
*/
public function getXfIndex()
{
return $this->_xfIndex;
return $this->xfIndex;
}
/**
@ -986,7 +998,7 @@ class PHPExcel_Cell
*/
public function setXfIndex($pValue = 0)
{
$this->_xfIndex = $pValue;
$this->xfIndex = $pValue;
return $this->notifyCacheController();
}
@ -996,7 +1008,7 @@ class PHPExcel_Cell
*/
public function setFormulaAttributes($pAttributes)
{
$this->_formulaAttributes = $pAttributes;
$this->formulaAttributes = $pAttributes;
return $this;
}
@ -1005,7 +1017,7 @@ class PHPExcel_Cell
*/
public function getFormulaAttributes()
{
return $this->_formulaAttributes;
return $this->formulaAttributes;
}
/**
@ -1017,6 +1029,4 @@ class PHPExcel_Cell
{
return (string) $this->getValue();
}
}

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 - 2014 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 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
{
/**
@ -66,16 +57,16 @@ 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;
}
@ -83,20 +74,24 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
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 - 2014 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 - 2014 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 - 2014 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 - 2014 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 - 2014 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 - 2014 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 - 2014 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 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
{
/**
@ -67,7 +58,7 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
}
// Set value explicit
$cell->setValueExplicit( $value, self::dataTypeForValue($value) );
$cell->setValueExplicit($value, self::dataTypeForValue($value));
// Done!
return true;
@ -79,7 +70,8 @@ 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 ($pValue === null) {
return PHPExcel_Cell_DataType::TYPE_NULL;
@ -95,9 +87,9 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
} 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} !== '.' ) {
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)) {
} elseif ((strpos($pValue, '.') === false) && ($pValue > PHP_INT_MAX)) {
return PHPExcel_Cell_DataType::TYPE_STRING;
}
return PHPExcel_Cell_DataType::TYPE_NUMERIC;

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Cell_Hyperlink
*
* Copyright (c) 2006 - 2014 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 - 2014 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 - 2014 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 - 2014 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 - 2014 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 - 2014 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);
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Chart
*
* Copyright (c) 2006 - 2014 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_Chart
* @copyright Copyright (c) 2006 - 2014 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_Chart
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Chart
{
/**
@ -40,98 +32,98 @@ class PHPExcel_Chart
*
* @var string
*/
private $_name = '';
private $name = '';
/**
* Worksheet
*
* @var PHPExcel_Worksheet
*/
private $_worksheet = null;
private $worksheet;
/**
* Chart Title
*
* @var PHPExcel_Chart_Title
*/
private $_title = null;
private $title;
/**
* Chart Legend
*
* @var PHPExcel_Chart_Legend
*/
private $_legend = null;
private $legend;
/**
* X-Axis Label
*
* @var PHPExcel_Chart_Title
*/
private $_xAxisLabel = null;
private $xAxisLabel;
/**
* Y-Axis Label
*
* @var PHPExcel_Chart_Title
*/
private $_yAxisLabel = null;
private $yAxisLabel;
/**
* Chart Plot Area
*
* @var PHPExcel_Chart_PlotArea
*/
private $_plotArea = null;
private $plotArea;
/**
* Plot Visible Only
*
* @var boolean
*/
private $_plotVisibleOnly = true;
private $plotVisibleOnly = true;
/**
* Display Blanks as
*
* @var string
*/
private $_displayBlanksAs = '0';
private $displayBlanksAs = '0';
/**
* Chart Asix Y as
*
* @var PHPExcel_Chart_Axis
*/
private $_yAxis = null;
private $yAxis;
/**
* Chart Asix X as
*
* @var PHPExcel_Chart_Axis
*/
private $_xAxis = null;
private $xAxis;
/**
* Chart Major Gridlines as
*
* @var PHPExcel_Chart_GridLines
*/
private $_majorGridlines = null;
private $majorGridlines;
/**
* Chart Minor Gridlines as
*
* @var PHPExcel_Chart_GridLines
*/
private $_minorGridlines = null;
private $minorGridlines;
/**
* Top-Left Cell Position
*
* @var string
*/
private $_topLeftCellRef = 'A1';
private $topLeftCellRef = 'A1';
/**
@ -139,7 +131,7 @@ class PHPExcel_Chart
*
* @var integer
*/
private $_topLeftXOffset = 0;
private $topLeftXOffset = 0;
/**
@ -147,7 +139,7 @@ class PHPExcel_Chart
*
* @var integer
*/
private $_topLeftYOffset = 0;
private $topLeftYOffset = 0;
/**
@ -155,7 +147,7 @@ class PHPExcel_Chart
*
* @var string
*/
private $_bottomRightCellRef = 'A1';
private $bottomRightCellRef = 'A1';
/**
@ -163,7 +155,7 @@ class PHPExcel_Chart
*
* @var integer
*/
private $_bottomRightXOffset = 10;
private $bottomRightXOffset = 10;
/**
@ -171,7 +163,7 @@ class PHPExcel_Chart
*
* @var integer
*/
private $_bottomRightYOffset = 10;
private $bottomRightYOffset = 10;
/**
@ -179,18 +171,18 @@ class PHPExcel_Chart
*/
public function __construct($name, PHPExcel_Chart_Title $title = null, PHPExcel_Chart_Legend $legend = null, PHPExcel_Chart_PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = '0', PHPExcel_Chart_Title $xAxisLabel = null, PHPExcel_Chart_Title $yAxisLabel = null, PHPExcel_Chart_Axis $xAxis = null, PHPExcel_Chart_Axis $yAxis = null, PHPExcel_Chart_GridLines $majorGridlines = null, PHPExcel_Chart_GridLines $minorGridlines = null)
{
$this->_name = $name;
$this->_title = $title;
$this->_legend = $legend;
$this->_xAxisLabel = $xAxisLabel;
$this->_yAxisLabel = $yAxisLabel;
$this->_plotArea = $plotArea;
$this->_plotVisibleOnly = $plotVisibleOnly;
$this->_displayBlanksAs = $displayBlanksAs;
$this->_xAxis = $xAxis;
$this->_yAxis = $yAxis;
$this->_majorGridlines = $majorGridlines;
$this->_minorGridlines = $minorGridlines;
$this->name = $name;
$this->title = $title;
$this->legend = $legend;
$this->xAxisLabel = $xAxisLabel;
$this->yAxisLabel = $yAxisLabel;
$this->plotArea = $plotArea;
$this->plotVisibleOnly = $plotVisibleOnly;
$this->displayBlanksAs = $displayBlanksAs;
$this->xAxis = $xAxis;
$this->yAxis = $yAxis;
$this->majorGridlines = $majorGridlines;
$this->minorGridlines = $minorGridlines;
}
/**
@ -198,8 +190,9 @@ class PHPExcel_Chart
*
* @return string
*/
public function getName() {
return $this->_name;
public function getName()
{
return $this->name;
}
/**
@ -207,8 +200,9 @@ class PHPExcel_Chart
*
* @return PHPExcel_Worksheet
*/
public function getWorksheet() {
return $this->_worksheet;
public function getWorksheet()
{
return $this->worksheet;
}
/**
@ -218,8 +212,9 @@ class PHPExcel_Chart
* @throws PHPExcel_Chart_Exception
* @return PHPExcel_Chart
*/
public function setWorksheet(PHPExcel_Worksheet $pValue = null) {
$this->_worksheet = $pValue;
public function setWorksheet(PHPExcel_Worksheet $pValue = null)
{
$this->worksheet = $pValue;
return $this;
}
@ -229,8 +224,9 @@ class PHPExcel_Chart
*
* @return PHPExcel_Chart_Title
*/
public function getTitle() {
return $this->_title;
public function getTitle()
{
return $this->title;
}
/**
@ -239,8 +235,9 @@ class PHPExcel_Chart
* @param PHPExcel_Chart_Title $title
* @return PHPExcel_Chart
*/
public function setTitle(PHPExcel_Chart_Title $title) {
$this->_title = $title;
public function setTitle(PHPExcel_Chart_Title $title)
{
$this->title = $title;
return $this;
}
@ -250,8 +247,9 @@ class PHPExcel_Chart
*
* @return PHPExcel_Chart_Legend
*/
public function getLegend() {
return $this->_legend;
public function getLegend()
{
return $this->legend;
}
/**
@ -260,8 +258,9 @@ class PHPExcel_Chart
* @param PHPExcel_Chart_Legend $legend
* @return PHPExcel_Chart
*/
public function setLegend(PHPExcel_Chart_Legend $legend) {
$this->_legend = $legend;
public function setLegend(PHPExcel_Chart_Legend $legend)
{
$this->legend = $legend;
return $this;
}
@ -271,8 +270,9 @@ class PHPExcel_Chart
*
* @return PHPExcel_Chart_Title
*/
public function getXAxisLabel() {
return $this->_xAxisLabel;
public function getXAxisLabel()
{
return $this->xAxisLabel;
}
/**
@ -281,8 +281,9 @@ class PHPExcel_Chart
* @param PHPExcel_Chart_Title $label
* @return PHPExcel_Chart
*/
public function setXAxisLabel(PHPExcel_Chart_Title $label) {
$this->_xAxisLabel = $label;
public function setXAxisLabel(PHPExcel_Chart_Title $label)
{
$this->xAxisLabel = $label;
return $this;
}
@ -292,8 +293,9 @@ class PHPExcel_Chart
*
* @return PHPExcel_Chart_Title
*/
public function getYAxisLabel() {
return $this->_yAxisLabel;
public function getYAxisLabel()
{
return $this->yAxisLabel;
}
/**
@ -302,8 +304,9 @@ class PHPExcel_Chart
* @param PHPExcel_Chart_Title $label
* @return PHPExcel_Chart
*/
public function setYAxisLabel(PHPExcel_Chart_Title $label) {
$this->_yAxisLabel = $label;
public function setYAxisLabel(PHPExcel_Chart_Title $label)
{
$this->yAxisLabel = $label;
return $this;
}
@ -313,8 +316,9 @@ class PHPExcel_Chart
*
* @return PHPExcel_Chart_PlotArea
*/
public function getPlotArea() {
return $this->_plotArea;
public function getPlotArea()
{
return $this->plotArea;
}
/**
@ -322,8 +326,9 @@ class PHPExcel_Chart
*
* @return boolean
*/
public function getPlotVisibleOnly() {
return $this->_plotVisibleOnly;
public function getPlotVisibleOnly()
{
return $this->plotVisibleOnly;
}
/**
@ -332,8 +337,9 @@ class PHPExcel_Chart
* @param boolean $plotVisibleOnly
* @return PHPExcel_Chart
*/
public function setPlotVisibleOnly($plotVisibleOnly = true) {
$this->_plotVisibleOnly = $plotVisibleOnly;
public function setPlotVisibleOnly($plotVisibleOnly = true)
{
$this->plotVisibleOnly = $plotVisibleOnly;
return $this;
}
@ -343,8 +349,9 @@ class PHPExcel_Chart
*
* @return string
*/
public function getDisplayBlanksAs() {
return $this->_displayBlanksAs;
public function getDisplayBlanksAs()
{
return $this->displayBlanksAs;
}
/**
@ -353,8 +360,9 @@ class PHPExcel_Chart
* @param string $displayBlanksAs
* @return PHPExcel_Chart
*/
public function setDisplayBlanksAs($displayBlanksAs = '0') {
$this->_displayBlanksAs = $displayBlanksAs;
public function setDisplayBlanksAs($displayBlanksAs = '0')
{
$this->displayBlanksAs = $displayBlanksAs;
}
@ -363,9 +371,10 @@ class PHPExcel_Chart
*
* @return PHPExcel_Chart_Axis
*/
public function getChartAxisY() {
if($this->_yAxis !== NULL){
return $this->_yAxis;
public function getChartAxisY()
{
if ($this->yAxis !== null) {
return $this->yAxis;
}
return new PHPExcel_Chart_Axis();
@ -376,9 +385,10 @@ class PHPExcel_Chart
*
* @return PHPExcel_Chart_Axis
*/
public function getChartAxisX() {
if($this->_xAxis !== NULL){
return $this->_xAxis;
public function getChartAxisX()
{
if ($this->xAxis !== null) {
return $this->xAxis;
}
return new PHPExcel_Chart_Axis();
@ -389,9 +399,10 @@ class PHPExcel_Chart
*
* @return PHPExcel_Chart_GridLines
*/
public function getMajorGridlines() {
if($this->_majorGridlines !== NULL){
return $this->_majorGridlines;
public function getMajorGridlines()
{
if ($this->majorGridlines !== null) {
return $this->majorGridlines;
}
return new PHPExcel_Chart_GridLines();
@ -402,9 +413,10 @@ class PHPExcel_Chart
*
* @return PHPExcel_Chart_GridLines
*/
public function getMinorGridlines() {
if($this->_minorGridlines !== NULL){
return $this->_minorGridlines;
public function getMinorGridlines()
{
if ($this->minorGridlines !== null) {
return $this->minorGridlines;
}
return new PHPExcel_Chart_GridLines();
@ -419,12 +431,15 @@ class PHPExcel_Chart
* @param integer $yOffset
* @return PHPExcel_Chart
*/
public function setTopLeftPosition($cell, $xOffset=null, $yOffset=null) {
$this->_topLeftCellRef = $cell;
if (!is_null($xOffset))
public function setTopLeftPosition($cell, $xOffset = null, $yOffset = null)
{
$this->topLeftCellRef = $cell;
if (!is_null($xOffset)) {
$this->setTopLeftXOffset($xOffset);
if (!is_null($yOffset))
}
if (!is_null($yOffset)) {
$this->setTopLeftYOffset($yOffset);
}
return $this;
}
@ -434,10 +449,12 @@ class PHPExcel_Chart
*
* @return array an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell
*/
public function getTopLeftPosition() {
return array( 'cell' => $this->_topLeftCellRef,
'xOffset' => $this->_topLeftXOffset,
'yOffset' => $this->_topLeftYOffset
public function getTopLeftPosition()
{
return array(
'cell' => $this->topLeftCellRef,
'xOffset' => $this->topLeftXOffset,
'yOffset' => $this->topLeftYOffset
);
}
@ -446,8 +463,9 @@ class PHPExcel_Chart
*
* @return string
*/
public function getTopLeftCell() {
return $this->_topLeftCellRef;
public function getTopLeftCell()
{
return $this->topLeftCellRef;
}
/**
@ -456,8 +474,9 @@ class PHPExcel_Chart
* @param string $cell
* @return PHPExcel_Chart
*/
public function setTopLeftCell($cell) {
$this->_topLeftCellRef = $cell;
public function setTopLeftCell($cell)
{
$this->topLeftCellRef = $cell;
return $this;
}
@ -469,11 +488,14 @@ class PHPExcel_Chart
* @param integer $yOffset
* @return PHPExcel_Chart
*/
public function setTopLeftOffset($xOffset=null,$yOffset=null) {
if (!is_null($xOffset))
public function setTopLeftOffset($xOffset = null, $yOffset = null)
{
if (!is_null($xOffset)) {
$this->setTopLeftXOffset($xOffset);
if (!is_null($yOffset))
}
if (!is_null($yOffset)) {
$this->setTopLeftYOffset($yOffset);
}
return $this;
}
@ -483,30 +505,36 @@ class PHPExcel_Chart
*
* @return integer[]
*/
public function getTopLeftOffset() {
return array( 'X' => $this->_topLeftXOffset,
'Y' => $this->_topLeftYOffset
public function getTopLeftOffset()
{
return array(
'X' => $this->topLeftXOffset,
'Y' => $this->topLeftYOffset
);
}
public function setTopLeftXOffset($xOffset) {
$this->_topLeftXOffset = $xOffset;
public function setTopLeftXOffset($xOffset)
{
$this->topLeftXOffset = $xOffset;
return $this;
}
public function getTopLeftXOffset() {
return $this->_topLeftXOffset;
public function getTopLeftXOffset()
{
return $this->topLeftXOffset;
}
public function setTopLeftYOffset($yOffset) {
$this->_topLeftYOffset = $yOffset;
public function setTopLeftYOffset($yOffset)
{
$this->topLeftYOffset = $yOffset;
return $this;
}
public function getTopLeftYOffset() {
return $this->_topLeftYOffset;
public function getTopLeftYOffset()
{
return $this->topLeftYOffset;
}
/**
@ -517,12 +545,15 @@ class PHPExcel_Chart
* @param integer $yOffset
* @return PHPExcel_Chart
*/
public function setBottomRightPosition($cell, $xOffset=null, $yOffset=null) {
$this->_bottomRightCellRef = $cell;
if (!is_null($xOffset))
public function setBottomRightPosition($cell, $xOffset = null, $yOffset = null)
{
$this->bottomRightCellRef = $cell;
if (!is_null($xOffset)) {
$this->setBottomRightXOffset($xOffset);
if (!is_null($yOffset))
}
if (!is_null($yOffset)) {
$this->setBottomRightYOffset($yOffset);
}
return $this;
}
@ -532,15 +563,18 @@ class PHPExcel_Chart
*
* @return array an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell
*/
public function getBottomRightPosition() {
return array( 'cell' => $this->_bottomRightCellRef,
'xOffset' => $this->_bottomRightXOffset,
'yOffset' => $this->_bottomRightYOffset
public function getBottomRightPosition()
{
return array(
'cell' => $this->bottomRightCellRef,
'xOffset' => $this->bottomRightXOffset,
'yOffset' => $this->bottomRightYOffset
);
}
public function setBottomRightCell($cell) {
$this->_bottomRightCellRef = $cell;
public function setBottomRightCell($cell)
{
$this->bottomRightCellRef = $cell;
return $this;
}
@ -550,8 +584,9 @@ class PHPExcel_Chart
*
* @return string
*/
public function getBottomRightCell() {
return $this->_bottomRightCellRef;
public function getBottomRightCell()
{
return $this->bottomRightCellRef;
}
/**
@ -561,11 +596,14 @@ class PHPExcel_Chart
* @param integer $yOffset
* @return PHPExcel_Chart
*/
public function setBottomRightOffset($xOffset=null,$yOffset=null) {
if (!is_null($xOffset))
public function setBottomRightOffset($xOffset = null, $yOffset = null)
{
if (!is_null($xOffset)) {
$this->setBottomRightXOffset($xOffset);
if (!is_null($yOffset))
}
if (!is_null($yOffset)) {
$this->setBottomRightYOffset($yOffset);
}
return $this;
}
@ -575,40 +613,48 @@ class PHPExcel_Chart
*
* @return integer[]
*/
public function getBottomRightOffset() {
return array( 'X' => $this->_bottomRightXOffset,
'Y' => $this->_bottomRightYOffset
public function getBottomRightOffset()
{
return array(
'X' => $this->bottomRightXOffset,
'Y' => $this->bottomRightYOffset
);
}
public function setBottomRightXOffset($xOffset) {
$this->_bottomRightXOffset = $xOffset;
public function setBottomRightXOffset($xOffset)
{
$this->bottomRightXOffset = $xOffset;
return $this;
}
public function getBottomRightXOffset() {
return $this->_bottomRightXOffset;
public function getBottomRightXOffset()
{
return $this->bottomRightXOffset;
}
public function setBottomRightYOffset($yOffset) {
$this->_bottomRightYOffset = $yOffset;
public function setBottomRightYOffset($yOffset)
{
$this->bottomRightYOffset = $yOffset;
return $this;
}
public function getBottomRightYOffset() {
return $this->_bottomRightYOffset;
public function getBottomRightYOffset()
{
return $this->bottomRightYOffset;
}
public function refresh() {
if ($this->_worksheet !== NULL) {
$this->_plotArea->refresh($this->_worksheet);
public function refresh()
{
if ($this->worksheet !== null) {
$this->plotArea->refresh($this->worksheet);
}
}
public function render($outputDestination = null) {
public function render($outputDestination = null)
{
$libraryName = PHPExcel_Settings::getChartRendererName();
if (is_null($libraryName)) {
return false;
@ -617,9 +663,9 @@ class PHPExcel_Chart
$this->refresh();
$libraryPath = PHPExcel_Settings::getChartRendererPath();
$includePath = str_replace('\\','/',get_include_path());
$rendererPath = str_replace('\\','/',$libraryPath);
if (strpos($rendererPath,$includePath) === false) {
$includePath = str_replace('\\', '/', get_include_path());
$rendererPath = str_replace('\\', '/', $libraryPath);
if (strpos($rendererPath, $includePath) === false) {
set_include_path(get_include_path() . PATH_SEPARATOR . $libraryPath);
}
@ -631,5 +677,4 @@ class PHPExcel_Chart
}
return $renderer->render($outputDestination);
}
}

View file

@ -1,5 +1,4 @@
<?php
require_once 'Properties.php';
/**
* Created by PhpStorm.
@ -8,17 +7,14 @@ require_once 'Properties.php';
* Time: 12:11 PM
*/
class PHPExcel_Chart_Axis extends
PHPExcel_Properties {
class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties
{
/**
* Axis Number
*
* @var array of mixed
*/
private
$_axis_number = array(
private $axisNumber = array(
'format' => self::FORMAT_CODE_GENERAL,
'source_linked' => 1
);
@ -28,18 +24,17 @@ class PHPExcel_Chart_Axis extends
*
* @var array of mixed
*/
private $_axis_options = array(
'minimum' => NULL,
'maximum' => NULL,
'major_unit' => NULL,
'minor_unit' => NULL,
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
'horizontal_crosses_value' => null
);
/**
@ -47,10 +42,9 @@ class PHPExcel_Chart_Axis extends
*
* @var array of mixed
*/
private $_fill_properties = array(
private $fillProperties = array(
'type' => self::EXCEL_COLOR_TYPE_ARGB,
'value' => NULL,
'value' => null,
'alpha' => 0
);
@ -59,10 +53,9 @@ class PHPExcel_Chart_Axis extends
*
* @var array of mixed
*/
private $_line_properties = array(
private $lineProperties = array(
'type' => self::EXCEL_COLOR_TYPE_ARGB,
'value' => NULL,
'value' => null,
'alpha' => 0
);
@ -71,8 +64,7 @@ class PHPExcel_Chart_Axis extends
*
* @var array of mixed
*/
private $_line_style_properties = array(
private $lineStyleProperties = array(
'width' => '9525',
'compound' => self::LINE_STYLE_COMPOUND_SIMPLE,
'dash' => self::LINE_STYLE_DASH_SOLID,
@ -95,25 +87,24 @@ class PHPExcel_Chart_Axis extends
*
* @var array of mixed
*/
private $_shadow_properties = array(
private $shadowProperties = array(
'presets' => self::SHADOW_PRESETS_NOSHADOW,
'effect' => NULL,
'effect' => null,
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => 'black',
'alpha' => 40,
),
'size' => array(
'sx' => NULL,
'sy' => NULL,
'kx' => NULL
'sx' => null,
'sy' => null,
'kx' => null
),
'blur' => NULL,
'direction' => NULL,
'distance' => NULL,
'algn' => NULL,
'rotWithShape' => NULL
'blur' => null,
'direction' => null,
'distance' => null,
'algn' => null,
'rotWithShape' => null
);
/**
@ -121,9 +112,8 @@ class PHPExcel_Chart_Axis extends
*
* @var array of mixed
*/
private $_glow_properties = array(
'size' => NULL,
private $glowProperties = array(
'size' => null,
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => 'black',
@ -136,9 +126,8 @@ class PHPExcel_Chart_Axis extends
*
* @var array of mixed
*/
private $_soft_edges = array(
'size' => NULL
private $softEdges = array(
'size' => null
);
/**
@ -146,10 +135,10 @@ class PHPExcel_Chart_Axis extends
*
* @return string
*/
public function setAxisNumberProperties($format_code) {
$this->_axis_number['format'] = (string) $format_code;
$this->_axis_number['source_linked'] = 0;
public function setAxisNumberProperties($format_code)
{
$this->axisNumber['format'] = (string) $format_code;
$this->axisNumber['source_linked'] = 0;
}
/**
@ -157,9 +146,9 @@ class PHPExcel_Chart_Axis extends
*
* @return string
*/
public function getAxisNumberFormat() {
return $this->_axis_number['format'];
public function getAxisNumberFormat()
{
return $this->axisNumber['format'];
}
/**
@ -167,9 +156,9 @@ class PHPExcel_Chart_Axis extends
*
* @return string
*/
public function getAxisNumberSourceLinked() {
return (string) $this->_axis_number['source_linked'];
public function getAxisNumberSourceLinked()
{
return (string) $this->axisNumber['source_linked'];
}
/**
@ -187,23 +176,19 @@ class PHPExcel_Chart_Axis extends
* @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->_axis_options['axis_labels'] = (string) $axis_labels;
($horizontal_crosses_value !== NULL)
? $this->_axis_options['horizontal_crosses_value'] = (string) $horizontal_crosses_value : NULL;
($horizontal_crosses !== NULL) ? $this->_axis_options['horizontal_crosses'] = (string) $horizontal_crosses : NULL;
($axis_orientation !== NULL) ? $this->_axis_options['orientation'] = (string) $axis_orientation : NULL;
($major_tmt !== NULL) ? $this->_axis_options['major_tick_mark'] = (string) $major_tmt : NULL;
($minor_tmt !== NULL) ? $this->_axis_options['minor_tick_mark'] = (string) $minor_tmt : NULL;
($minor_tmt !== NULL) ? $this->_axis_options['minor_tick_mark'] = (string) $minor_tmt : NULL;
($minimum !== NULL) ? $this->_axis_options['minimum'] = (string) $minimum : NULL;
($maximum !== NULL) ? $this->_axis_options['maximum'] = (string) $maximum : NULL;
($major_unit !== NULL) ? $this->_axis_options['major_unit'] = (string) $major_unit : NULL;
($minor_unit !== NULL) ? $this->_axis_options['minor_unit'] = (string) $minor_unit : NULL;
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;
}
/**
@ -213,9 +198,9 @@ class PHPExcel_Chart_Axis extends
*
* @return string
*/
public function getAxisOptionsProperty($property) {
return $this->_axis_options[$property];
public function getAxisOptionsProperty($property)
{
return $this->axisOptions[$property];
}
/**
@ -224,8 +209,8 @@ class PHPExcel_Chart_Axis extends
* @param string $orientation
*
*/
public function setAxisOrientation($orientation) {
public function setAxisOrientation($orientation)
{
$this->orientation = (string) $orientation;
}
@ -237,9 +222,9 @@ class PHPExcel_Chart_Axis extends
* @param string $type
*
*/
public function setFillParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB) {
$this->_fill_properties = $this->setColorProperties($color, $alpha, $type);
public function setFillParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB)
{
$this->fillProperties = $this->setColorProperties($color, $alpha, $type);
}
/**
@ -250,9 +235,9 @@ class PHPExcel_Chart_Axis extends
* @param string $type
*
*/
public function setLineParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB) {
$this->_line_properties = $this->setColorProperties($color, $alpha, $type);
public function setLineParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB)
{
$this->lineProperties = $this->setColorProperties($color, $alpha, $type);
}
/**
@ -262,9 +247,9 @@ class PHPExcel_Chart_Axis extends
*
* @return string
*/
public function getFillProperty($property) {
return $this->_fill_properties[$property];
public function getFillProperty($property)
{
return $this->fillProperties[$property];
}
/**
@ -274,9 +259,9 @@ class PHPExcel_Chart_Axis extends
*
* @return string
*/
public function getLineProperty($property) {
return $this->_line_properties[$property];
public function getLineProperty($property)
{
return $this->lineProperties[$property];
}
/**
@ -293,25 +278,17 @@ class PHPExcel_Chart_Axis extends
* @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->_line_style_properties['width'] = $this->getExcelPointsWidth((float) $line_width)
: NULL;
(!is_null($compound_type)) ? $this->_line_style_properties['compound'] = (string) $compound_type : NULL;
(!is_null($dash_type)) ? $this->_line_style_properties['dash'] = (string) $dash_type : NULL;
(!is_null($cap_type)) ? $this->_line_style_properties['cap'] = (string) $cap_type : NULL;
(!is_null($join_type)) ? $this->_line_style_properties['join'] = (string) $join_type : NULL;
(!is_null($head_arrow_type)) ? $this->_line_style_properties['arrow']['head']['type'] = (string) $head_arrow_type
: NULL;
(!is_null($head_arrow_size)) ? $this->_line_style_properties['arrow']['head']['size'] = (string) $head_arrow_size
: NULL;
(!is_null($end_arrow_type)) ? $this->_line_style_properties['arrow']['end']['type'] = (string) $end_arrow_type
: NULL;
(!is_null($end_arrow_size)) ? $this->_line_style_properties['arrow']['end']['size'] = (string) $end_arrow_size
: NULL;
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;
}
/**
@ -321,9 +298,9 @@ class PHPExcel_Chart_Axis extends
*
* @return string
*/
public function getLineStyleProperty($elements) {
return $this->getArrayElementsValue($this->_line_style_properties, $elements);
public function getLineStyleProperty($elements)
{
return $this->getArrayElementsValue($this->lineStyleProperties, $elements);
}
/**
@ -333,9 +310,9 @@ class PHPExcel_Chart_Axis extends
*
* @return string
*/
public function getLineStyleArrowWidth($arrow) {
return $this->getLineStyleArrowSize($this->_line_style_properties['arrow'][$arrow]['size'], 'w');
public function getLineStyleArrowWidth($arrow)
{
return $this->getLineStyleArrowSize($this->lineStyleProperties['arrow'][$arrow]['size'], 'w');
}
/**
@ -345,9 +322,9 @@ class PHPExcel_Chart_Axis extends
*
* @return string
*/
public function getLineStyleArrowLength($arrow) {
return $this->getLineStyleArrowSize($this->_line_style_properties['arrow'][$arrow]['size'], 'len');
public function getLineStyleArrowLength($arrow)
{
return $this->getLineStyleArrowSize($this->lineStyleProperties['arrow'][$arrow]['size'], 'len');
}
/**
@ -362,17 +339,17 @@ class PHPExcel_Chart_Axis extends
* @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->_shadow_properties['color']['value'] : $sh_color_value
, is_null($sh_color_alpha) ? (int) $this->_shadow_properties['color']['alpha'] : $sh_color_alpha
, is_null($sh_color_type) ? $this->_shadow_properties['color']['type'] : $sh_color_type)
->_setShadowBlur($sh_blur)
->_setShadowAngle($sh_angle)
->_setShadowDistance($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);
}
/**
@ -382,10 +359,10 @@ class PHPExcel_Chart_Axis extends
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowPresetsProperties($shadow_presets) {
$this->_shadow_properties['presets'] = $shadow_presets;
$this->_setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets));
private function setShadowPresetsProperties($shadow_presets)
{
$this->shadowProperties['presets'] = $shadow_presets;
$this->setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets));
return $this;
}
@ -398,20 +375,20 @@ class PHPExcel_Chart_Axis extends
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowProperiesMapValues(array $properties_map, &$reference = NULL) {
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->_shadow_properties[$property_key];
if ($reference === null) {
$reference = & $this->shadowProperties[$property_key];
} else {
$reference = & $reference[$property_key];
}
$this->_setShadowProperiesMapValues($property_val, $reference);
$this->setShadowProperiesMapValues($property_val, $reference);
} else {
if ($base_reference === NULL) {
$this->_shadow_properties[$property_key] = $property_val;
if ($base_reference === null) {
$this->shadowProperties[$property_key] = $property_val;
} else {
$reference[$property_key] = $property_val;
}
@ -430,9 +407,9 @@ class PHPExcel_Chart_Axis extends
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowColor($color, $alpha, $type) {
$this->_shadow_properties['color'] = $this->setColorProperties($color, $alpha, $type);
private function setShadowColor($color, $alpha, $type)
{
$this->shadowProperties['color'] = $this->setColorProperties($color, $alpha, $type);
return $this;
}
@ -444,10 +421,10 @@ class PHPExcel_Chart_Axis extends
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowBlur($blur) {
if ($blur !== NULL) {
$this->_shadow_properties['blur'] = (string) $this->getExcelPointsWidth($blur);
private function setShadowBlur($blur)
{
if ($blur !== null) {
$this->shadowProperties['blur'] = (string) $this->getExcelPointsWidth($blur);
}
return $this;
@ -460,10 +437,10 @@ class PHPExcel_Chart_Axis extends
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowAngle($angle) {
if ($angle !== NULL) {
$this->_shadow_properties['direction'] = (string) $this->getExcelPointsAngle($angle);
private function setShadowAngle($angle)
{
if ($angle !== null) {
$this->shadowProperties['direction'] = (string) $this->getExcelPointsAngle($angle);
}
return $this;
@ -476,10 +453,10 @@ class PHPExcel_Chart_Axis extends
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowDistance($distance) {
if ($distance !== NULL) {
$this->_shadow_properties['distance'] = (string) $this->getExcelPointsWidth($distance);
private function setShadowDistance($distance)
{
if ($distance !== null) {
$this->shadowProperties['distance'] = (string) $this->getExcelPointsWidth($distance);
}
return $this;
@ -493,9 +470,9 @@ class PHPExcel_Chart_Axis extends
* @param int $color_alpha
* @param string $color_type
*/
public function getShadowProperty($elements) {
return $this->getArrayElementsValue($this->_shadow_properties, $elements);
public function getShadowProperty($elements)
{
return $this->getArrayElementsValue($this->shadowProperties, $elements);
}
/**
@ -506,14 +483,14 @@ class PHPExcel_Chart_Axis extends
* @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->_glow_properties['color']['value'] : $color_value
, is_null($color_alpha) ? (int) $this->_glow_properties['color']['alpha'] : $color_alpha
, is_null($color_type) ? $this->_glow_properties['color']['type'] : $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
);
}
/**
@ -523,9 +500,9 @@ class PHPExcel_Chart_Axis extends
*
* @return string
*/
public function getGlowProperty($property) {
return $this->getArrayElementsValue($this->_glow_properties, $property);
public function getGlowProperty($property)
{
return $this->getArrayElementsValue($this->glowProperties, $property);
}
/**
@ -535,10 +512,10 @@ class PHPExcel_Chart_Axis extends
*
* @return PHPExcel_Chart_Axis
*/
private function _setGlowSize($size) {
private function setGlowSize($size)
{
if (!is_null($size)) {
$this->_glow_properties['size'] = $this->getExcelPointsWidth($size);
$this->glowProperties['size'] = $this->getExcelPointsWidth($size);
}
return $this;
@ -553,9 +530,9 @@ class PHPExcel_Chart_Axis extends
*
* @return PHPExcel_Chart_Axis
*/
private function _setGlowColor($color, $alpha, $type) {
$this->_glow_properties['color'] = $this->setColorProperties($color, $alpha, $type);
private function setGlowColor($color, $alpha, $type)
{
$this->glowProperties['color'] = $this->setColorProperties($color, $alpha, $type);
return $this;
}
@ -565,10 +542,10 @@ class PHPExcel_Chart_Axis extends
*
* @param float $size
*/
public function setSoftEdges($size) {
public function setSoftEdges($size)
{
if (!is_null($size)) {
$_soft_edges['size'] = (string) $this->getExcelPointsWidth($size);
$softEdges['size'] = (string) $this->getExcelPointsWidth($size);
}
}
@ -577,8 +554,8 @@ class PHPExcel_Chart_Axis extends
*
* @return string
*/
public function getSoftEdgesSize() {
return $this->_soft_edges['size'];
public function getSoftEdgesSize()
{
return $this->softEdges['size'];
}
}

View file

@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 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_Chart
* @copyright Copyright (c) 2006 - 2014 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,11 +31,10 @@
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @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';
@ -76,90 +75,90 @@ class PHPExcel_Chart_DataSeries
*
* @var string
*/
private $_plotType = null;
private $plotType;
/**
* Plot Grouping Type
*
* @var boolean
*/
private $_plotGrouping = null;
private $plotGrouping;
/**
* Plot Direction
*
* @var boolean
*/
private $_plotDirection = null;
private $plotDirection;
/**
* Plot Style
*
* @var string
*/
private $_plotStyle = null;
private $plotStyle;
/**
* Order of plots in Series
*
* @var array of integer
*/
private $_plotOrder = array();
private $plotOrder = array();
/**
* Plot Label
*
* @var array of PHPExcel_Chart_DataSeriesValues
*/
private $_plotLabel = array();
private $plotLabel = array();
/**
* Plot Category
*
* @var array of PHPExcel_Chart_DataSeriesValues
*/
private $_plotCategory = array();
private $plotCategory = array();
/**
* Smooth Line
*
* @var string
*/
private $_smoothLine = null;
private $smoothLine;
/**
* Plot Values
*
* @var array of PHPExcel_Chart_DataSeriesValues
*/
private $_plotValues = array();
private $plotValues = array();
/**
* 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;
$this->plotType = $plotType;
$this->plotGrouping = $plotGrouping;
$this->plotOrder = $plotOrder;
$keys = array_keys($plotValues);
$this->_plotValues = $plotValues;
$this->plotValues = $plotValues;
if ((count($plotLabel) == 0) || (is_null($plotLabel[$keys[0]]))) {
$plotLabel[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
}
$this->_plotLabel = $plotLabel;
$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->plotCategory = $plotCategory;
$this->smoothLine = $smoothLine;
$this->plotStyle = $plotStyle;
if (is_null($plotDirection)) {
$plotDirection = self::DIRECTION_COL;
}
$this->_plotDirection = $plotDirection;
$this->plotDirection = $plotDirection;
}
/**
@ -167,8 +166,9 @@ class PHPExcel_Chart_DataSeries
*
* @return string
*/
public function getPlotType() {
return $this->_plotType;
public function getPlotType()
{
return $this->plotType;
}
/**
@ -177,8 +177,9 @@ class PHPExcel_Chart_DataSeries
* @param string $plotType
* @return PHPExcel_Chart_DataSeries
*/
public function setPlotType($plotType = '') {
$this->_plotType = $plotType;
public function setPlotType($plotType = '')
{
$this->plotType = $plotType;
return $this;
}
@ -187,8 +188,9 @@ class PHPExcel_Chart_DataSeries
*
* @return string
*/
public function getPlotGrouping() {
return $this->_plotGrouping;
public function getPlotGrouping()
{
return $this->plotGrouping;
}
/**
@ -197,8 +199,9 @@ class PHPExcel_Chart_DataSeries
* @param string $groupingType
* @return PHPExcel_Chart_DataSeries
*/
public function setPlotGrouping($groupingType = null) {
$this->_plotGrouping = $groupingType;
public function setPlotGrouping($groupingType = null)
{
$this->plotGrouping = $groupingType;
return $this;
}
@ -207,8 +210,9 @@ class PHPExcel_Chart_DataSeries
*
* @return string
*/
public function getPlotDirection() {
return $this->_plotDirection;
public function getPlotDirection()
{
return $this->plotDirection;
}
/**
@ -217,8 +221,9 @@ class PHPExcel_Chart_DataSeries
* @param string $plotDirection
* @return PHPExcel_Chart_DataSeries
*/
public function setPlotDirection($plotDirection = null) {
$this->_plotDirection = $plotDirection;
public function setPlotDirection($plotDirection = null)
{
$this->plotDirection = $plotDirection;
return $this;
}
@ -227,8 +232,9 @@ class PHPExcel_Chart_DataSeries
*
* @return string
*/
public function getPlotOrder() {
return $this->_plotOrder;
public function getPlotOrder()
{
return $this->plotOrder;
}
/**
@ -236,8 +242,9 @@ class PHPExcel_Chart_DataSeries
*
* @return array of PHPExcel_Chart_DataSeriesValues
*/
public function getPlotLabels() {
return $this->_plotLabel;
public function getPlotLabels()
{
return $this->plotLabel;
}
/**
@ -245,12 +252,13 @@ class PHPExcel_Chart_DataSeries
*
* @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]];
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;
}
@ -260,8 +268,9 @@ class PHPExcel_Chart_DataSeries
*
* @return array of PHPExcel_Chart_DataSeriesValues
*/
public function getPlotCategories() {
return $this->_plotCategory;
public function getPlotCategories()
{
return $this->plotCategory;
}
/**
@ -269,12 +278,13 @@ class PHPExcel_Chart_DataSeries
*
* @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]];
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;
}
@ -284,8 +294,9 @@ class PHPExcel_Chart_DataSeries
*
* @return string
*/
public function getPlotStyle() {
return $this->_plotStyle;
public function getPlotStyle()
{
return $this->plotStyle;
}
/**
@ -294,8 +305,9 @@ class PHPExcel_Chart_DataSeries
* @param string $plotStyle
* @return PHPExcel_Chart_DataSeries
*/
public function setPlotStyle($plotStyle = null) {
$this->_plotStyle = $plotStyle;
public function setPlotStyle($plotStyle = null)
{
$this->plotStyle = $plotStyle;
return $this;
}
@ -304,8 +316,9 @@ class PHPExcel_Chart_DataSeries
*
* @return array of PHPExcel_Chart_DataSeriesValues
*/
public function getPlotValues() {
return $this->_plotValues;
public function getPlotValues()
{
return $this->plotValues;
}
/**
@ -313,12 +326,13 @@ class PHPExcel_Chart_DataSeries
*
* @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]];
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;
}
@ -328,8 +342,9 @@ class PHPExcel_Chart_DataSeries
*
* @return integer
*/
public function getPlotSeriesCount() {
return count($this->_plotValues);
public function getPlotSeriesCount()
{
return count($this->plotValues);
}
/**
@ -337,8 +352,9 @@ class PHPExcel_Chart_DataSeries
*
* @return boolean
*/
public function getSmoothLine() {
return $this->_smoothLine;
public function getSmoothLine()
{
return $this->smoothLine;
}
/**
@ -347,24 +363,28 @@ class PHPExcel_Chart_DataSeries
* @param boolean $smoothLine
* @return PHPExcel_Chart_DataSeries
*/
public function setSmoothLine($smoothLine = TRUE) {
$this->_smoothLine = $smoothLine;
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);
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 - 2014 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,26 +21,17 @@
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2014 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_Chart_DataSeriesValues
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Chart_DataSeriesValues
{
const DATASERIES_TYPE_STRING = 'String';
const DATASERIES_TYPE_NUMBER = 'Number';
private static $_dataTypeValues = array(
private static $dataTypeValues = array(
self::DATASERIES_TYPE_STRING,
self::DATASERIES_TYPE_NUMBER,
);
@ -49,42 +41,42 @@ class PHPExcel_Chart_DataSeriesValues
*
* @var string
*/
private $_dataType = null;
private $dataType;
/**
* Series Data Source
*
* @var string
*/
private $_dataSource = null;
private $dataSource;
/**
* Format Code
*
* @var string
*/
private $_formatCode = null;
private $formatCode;
/**
* Series Point Marker
*
* @var string
*/
private $_marker = null;
private $pointMarker;
/**
* Point Count (The number of datapoints in the dataseries)
*
* @var integer
*/
private $_pointCount = 0;
private $pointCount = 0;
/**
* Data Values
*
* @var array of mixed
*/
private $_dataValues = array();
private $dataValues = array();
/**
* Create a new PHPExcel_Chart_DataSeriesValues object
@ -92,11 +84,11 @@ class PHPExcel_Chart_DataSeriesValues
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;
$this->dataSource = $dataSource;
$this->formatCode = $formatCode;
$this->pointCount = $pointCount;
$this->dataValues = $dataValues;
$this->pointMarker = $marker;
}
/**
@ -104,8 +96,9 @@ class PHPExcel_Chart_DataSeriesValues
*
* @return string
*/
public function getDataType() {
return $this->_dataType;
public function getDataType()
{
return $this->dataType;
}
/**
@ -119,11 +112,12 @@ class PHPExcel_Chart_DataSeriesValues
* Normally used for chart data values
* @return PHPExcel_Chart_DataSeriesValues
*/
public function setDataType($dataType = self::DATASERIES_TYPE_NUMBER) {
if (!in_array($dataType, self::$_dataTypeValues)) {
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;
$this->dataType = $dataType;
return $this;
}
@ -133,8 +127,9 @@ class PHPExcel_Chart_DataSeriesValues
*
* @return string
*/
public function getDataSource() {
return $this->_dataSource;
public function getDataSource()
{
return $this->dataSource;
}
/**
@ -143,8 +138,9 @@ class PHPExcel_Chart_DataSeriesValues
* @param string $dataSource
* @return PHPExcel_Chart_DataSeriesValues
*/
public function setDataSource($dataSource = null, $refreshDataValues = true) {
$this->_dataSource = $dataSource;
public function setDataSource($dataSource = null, $refreshDataValues = true)
{
$this->dataSource = $dataSource;
if ($refreshDataValues) {
// TO DO
@ -158,8 +154,9 @@ class PHPExcel_Chart_DataSeriesValues
*
* @return string
*/
public function getPointMarker() {
return $this->_marker;
public function getPointMarker()
{
return $this->pointMarker;
}
/**
@ -168,8 +165,9 @@ class PHPExcel_Chart_DataSeriesValues
* @param string $marker
* @return PHPExcel_Chart_DataSeriesValues
*/
public function setPointMarker($marker = null) {
$this->_marker = $marker;
public function setPointMarker($marker = null)
{
$this->pointMarker = $marker;
return $this;
}
@ -179,8 +177,9 @@ class PHPExcel_Chart_DataSeriesValues
*
* @return string
*/
public function getFormatCode() {
return $this->_formatCode;
public function getFormatCode()
{
return $this->formatCode;
}
/**
@ -189,8 +188,9 @@ class PHPExcel_Chart_DataSeriesValues
* @param string $formatCode
* @return PHPExcel_Chart_DataSeriesValues
*/
public function setFormatCode($formatCode = null) {
$this->_formatCode = $formatCode;
public function setFormatCode($formatCode = null)
{
$this->formatCode = $formatCode;
return $this;
}
@ -200,8 +200,9 @@ class PHPExcel_Chart_DataSeriesValues
*
* @return integer
*/
public function getPointCount() {
return $this->_pointCount;
public function getPointCount()
{
return $this->pointCount;
}
/**
@ -209,9 +210,10 @@ class PHPExcel_Chart_DataSeriesValues
*
* @return boolean
*/
public function isMultiLevelSeries() {
if (count($this->_dataValues) > 0) {
return is_array($this->_dataValues[0]);
public function isMultiLevelSeries()
{
if (count($this->dataValues) > 0) {
return is_array($this->dataValues[0]);
}
return null;
}
@ -221,10 +223,11 @@ class PHPExcel_Chart_DataSeriesValues
*
* @return boolean
*/
public function multiLevelCount() {
public function multiLevelCount()
{
$levelCount = 0;
foreach($this->_dataValues as $dataValueSet) {
$levelCount = max($levelCount,count($dataValueSet));
foreach ($this->dataValues as $dataValueSet) {
$levelCount = max($levelCount, count($dataValueSet));
}
return $levelCount;
}
@ -234,8 +237,9 @@ class PHPExcel_Chart_DataSeriesValues
*
* @return array of mixed
*/
public function getDataValues() {
return $this->_dataValues;
public function getDataValues()
{
return $this->dataValues;
}
/**
@ -243,14 +247,15 @@ class PHPExcel_Chart_DataSeriesValues
*
* @return mixed
*/
public function getDataValue() {
$count = count($this->_dataValues);
public function getDataValue()
{
$count = count($this->dataValues);
if ($count == 0) {
return null;
} elseif ($count == 1) {
return $this->_dataValues[0];
return $this->dataValues[0];
}
return $this->_dataValues;
return $this->dataValues;
}
/**
@ -258,13 +263,14 @@ class PHPExcel_Chart_DataSeriesValues
*
* @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
* 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);
public function setDataValues($dataValues = array(), $refreshDataSource = true)
{
$this->dataValues = PHPExcel_Calculation_Functions::flattenArray($dataValues);
$this->pointCount = count($dataValues);
if ($refreshDataSource) {
// TO DO
@ -273,55 +279,55 @@ class PHPExcel_Chart_DataSeriesValues
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) {
public function refresh(PHPExcel_Worksheet $worksheet, $flatten = true)
{
if ($this->dataSource !== null) {
$calcEngine = PHPExcel_Calculation::getInstance($worksheet->getParent());
$newDataValues = PHPExcel_Calculation::_unwrapResult(
$newDataValues = PHPExcel_Calculation::unwrapResult(
$calcEngine->_calculateFormulaValue(
'='.$this->_dataSource,
NULL,
'='.$this->dataSource,
null,
$worksheet->getCell('A1')
)
);
if ($flatten) {
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
foreach($this->_dataValues as &$dataValue) {
$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);
$cellRange = explode('!', $this->dataSource);
if (count($cellRange) > 1) {
list(,$cellRange) = $cellRange;
list(, $cellRange) = $cellRange;
}
$dimensions = PHPExcel_Cell::rangeDimension(str_replace('$','',$cellRange));
$dimensions = PHPExcel_Cell::rangeDimension(str_replace('$', '', $cellRange));
if (($dimensions[0] == 1) || ($dimensions[1] == 1)) {
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
$this->dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
} else {
$newArray = array_values(array_shift($newDataValues));
foreach($newArray as $i => $newDataSet) {
foreach ($newArray as $i => $newDataSet) {
$newArray[$i] = array($newDataSet);
}
foreach($newDataValues as $newDataSet) {
foreach ($newDataValues as $newDataSet) {
$i = 0;
foreach($newDataSet as $newDataVal) {
array_unshift($newArray[$i++],$newDataVal);
foreach ($newDataSet as $newDataVal) {
array_unshift($newArray[$i++], $newDataVal);
}
}
$this->_dataValues = $newArray;
$this->dataValues = $newArray;
}
}
$this->_pointCount = count($this->_dataValues);
$this->pointCount = count($this->dataValues);
}
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Chart_Exception
*
* Copyright (c) 2006 - 2014 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,20 +21,12 @@
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2014 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_Chart_Exception
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Chart_Exception extends PHPExcel_Exception {
class PHPExcel_Chart_Exception extends PHPExcel_Exception
{
/**
* Error handler callback
*
@ -43,7 +36,8 @@ class PHPExcel_Chart_Exception extends PHPExcel_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,5 +1,5 @@
<?php
require_once 'Properties.php';
/**
* Created by PhpStorm.
* User: Wiktor Trzonkowski
@ -7,8 +7,8 @@ require_once 'Properties.php';
* Time: 2:36 PM
*/
class PHPExcel_Chart_GridLines extends
PHPExcel_Properties {
class PHPExcel_Chart_GridLines extends PHPExcel_Chart_Properties
{
/**
* Properties of Class:
@ -20,12 +20,12 @@ class PHPExcel_Chart_GridLines extends
*
*/
private
$_object_state = FALSE,
$_line_properties = array(
private $objectState = false;
private $lineProperties = array(
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => NULL,
'value' => null,
'alpha' => 0
),
'style' => array(
@ -45,36 +45,39 @@ class PHPExcel_Chart_GridLines extends
),
)
)
),
$_shadow_properties = array(
);
private $shadowProperties = array(
'presets' => self::SHADOW_PRESETS_NOSHADOW,
'effect' => NULL,
'effect' => null,
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => 'black',
'alpha' => 85,
),
'size' => array(
'sx' => NULL,
'sy' => NULL,
'kx' => NULL
'sx' => null,
'sy' => null,
'kx' => null
),
'blur' => NULL,
'direction' => NULL,
'distance' => NULL,
'algn' => NULL,
'rotWithShape' => NULL
),
$_glow_properties = array(
'size' => 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
)
),
$_soft_edges = array(
'size' => NULL
);
private $softEdges = array(
'size' => null
);
/**
@ -83,8 +86,9 @@ class PHPExcel_Chart_GridLines extends
* @return bool
*/
public function getObjectState() {
return $this->_object_state;
public function getObjectState()
{
return $this->objectState;
}
/**
@ -93,8 +97,9 @@ class PHPExcel_Chart_GridLines extends
* @return PHPExcel_Chart_GridLines
*/
private function _activateObject() {
$this->_object_state = TRUE;
private function activateObject()
{
$this->objectState = true;
return $this;
}
@ -107,13 +112,14 @@ class PHPExcel_Chart_GridLines extends
* @param string $type
*/
public function setLineColorProperties($value, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_STANDARD) {
$this
->_activateObject()
->_line_properties['color'] = $this->setColorProperties(
public function setLineColorProperties($value, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_STANDARD)
{
$this->activateObject()
->lineProperties['color'] = $this->setColorProperties(
$value,
$alpha,
$type);
$type
);
}
/**
@ -130,35 +136,36 @@ class PHPExcel_Chart_GridLines extends
* @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();
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->_line_properties['style']['width'] = $this->getExcelPointsWidth((float) $line_width)
: NULL;
? $this->lineProperties['style']['width'] = $this->getExcelPointsWidth((float) $line_width)
: null;
(!is_null($compound_type))
? $this->_line_properties['style']['compound'] = (string) $compound_type
: NULL;
? $this->lineProperties['style']['compound'] = (string) $compound_type
: null;
(!is_null($dash_type))
? $this->_line_properties['style']['dash'] = (string) $dash_type
: NULL;
? $this->lineProperties['style']['dash'] = (string) $dash_type
: null;
(!is_null($cap_type))
? $this->_line_properties['style']['cap'] = (string) $cap_type
: NULL;
? $this->lineProperties['style']['cap'] = (string) $cap_type
: null;
(!is_null($join_type))
? $this->_line_properties['style']['join'] = (string) $join_type
: NULL;
? $this->lineProperties['style']['join'] = (string) $join_type
: null;
(!is_null($head_arrow_type))
? $this->_line_properties['style']['arrow']['head']['type'] = (string) $head_arrow_type
: NULL;
? $this->lineProperties['style']['arrow']['head']['type'] = (string) $head_arrow_type
: null;
(!is_null($head_arrow_size))
? $this->_line_properties['style']['arrow']['head']['size'] = (string) $head_arrow_size
: NULL;
? $this->lineProperties['style']['arrow']['head']['size'] = (string) $head_arrow_size
: null;
(!is_null($end_arrow_type))
? $this->_line_properties['style']['arrow']['end']['type'] = (string) $end_arrow_type
: NULL;
? $this->lineProperties['style']['arrow']['end']['type'] = (string) $end_arrow_type
: null;
(!is_null($end_arrow_size))
? $this->_line_properties['style']['arrow']['end']['size'] = (string) $end_arrow_size
: NULL;
? $this->lineProperties['style']['arrow']['end']['size'] = (string) $end_arrow_size
: null;
}
/**
@ -169,8 +176,9 @@ class PHPExcel_Chart_GridLines extends
* @return string
*/
public function getLineColorProperty($parameter) {
return $this->_line_properties['color'][$parameter];
public function getLineColorProperty($parameter)
{
return $this->lineProperties['color'][$parameter];
}
/**
@ -181,8 +189,9 @@ class PHPExcel_Chart_GridLines extends
* @return string
*/
public function getLineStyleProperty($elements) {
return $this->getArrayElementsValue($this->_line_properties['style'], $elements);
public function getLineStyleProperty($elements)
{
return $this->getArrayElementsValue($this->lineProperties['style'], $elements);
}
/**
@ -195,11 +204,12 @@ class PHPExcel_Chart_GridLines extends
*
*/
public function setGlowProperties($size, $color_value = NULL, $color_alpha = NULL, $color_type = NULL) {
public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null)
{
$this
->_activateObject()
->_setGlowSize($size)
->_setGlowColor($color_value, $color_alpha, $color_type);
->activateObject()
->setGlowSize($size)
->setGlowColor($color_value, $color_alpha, $color_type);
}
/**
@ -210,8 +220,9 @@ class PHPExcel_Chart_GridLines extends
* @return string
*/
public function getGlowColor($property) {
return $this->_glow_properties['color'][$property];
public function getGlowColor($property)
{
return $this->glowProperties['color'][$property];
}
/**
@ -220,8 +231,9 @@ class PHPExcel_Chart_GridLines extends
* @return string
*/
public function getGlowSize() {
return $this->_glow_properties['size'];
public function getGlowSize()
{
return $this->glowProperties['size'];
}
/**
@ -232,8 +244,9 @@ class PHPExcel_Chart_GridLines extends
* @return PHPExcel_Chart_GridLines
*/
private function _setGlowSize($size) {
$this->_glow_properties['size'] = $this->getExcelPointsWidth((float) $size);
private function setGlowSize($size)
{
$this->glowProperties['size'] = $this->getExcelPointsWidth((float) $size);
return $this;
}
@ -248,15 +261,16 @@ class PHPExcel_Chart_GridLines extends
* @return PHPExcel_Chart_GridLines
*/
private function _setGlowColor($color, $alpha, $type) {
private function setGlowColor($color, $alpha, $type)
{
if (!is_null($color)) {
$this->_glow_properties['color']['value'] = (string) $color;
$this->glowProperties['color']['value'] = (string) $color;
}
if (!is_null($alpha)) {
$this->_glow_properties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
$this->glowProperties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
}
if (!is_null($type)) {
$this->_glow_properties['color']['type'] = (string) $type;
$this->glowProperties['color']['type'] = (string) $type;
}
return $this;
@ -271,8 +285,9 @@ class PHPExcel_Chart_GridLines extends
* @return string
*/
public function getLineStyleArrowParameters($arrow_selector, $property_selector) {
return $this->getLineStyleArrowSize($this->_line_properties['style']['arrow'][$arrow_selector]['size'], $property_selector);
public function getLineStyleArrowParameters($arrow_selector, $property_selector)
{
return $this->getLineStyleArrowSize($this->lineProperties['style']['arrow'][$arrow_selector]['size'], $property_selector);
}
/**
@ -288,18 +303,18 @@ class PHPExcel_Chart_GridLines extends
*
*/
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->_shadow_properties['color']['value'] : $sh_color_value
, is_null($sh_color_alpha) ? (int) $this->_shadow_properties['color']['alpha']
: $this->getTrueAlpha($sh_color_alpha)
, is_null($sh_color_type) ? $this->_shadow_properties['color']['type'] : $sh_color_type)
->_setShadowBlur($sh_blur)
->_setShadowAngle($sh_angle)
->_setShadowDistance($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);
}
/**
@ -310,9 +325,10 @@ class PHPExcel_Chart_GridLines extends
* @return PHPExcel_Chart_GridLines
*/
private function _setShadowPresetsProperties($shadow_presets) {
$this->_shadow_properties['presets'] = $shadow_presets;
$this->_setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets));
private function setShadowPresetsProperties($shadow_presets)
{
$this->shadowProperties['presets'] = $shadow_presets;
$this->setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets));
return $this;
}
@ -326,19 +342,20 @@ class PHPExcel_Chart_GridLines extends
* @return PHPExcel_Chart_GridLines
*/
private function _setShadowProperiesMapValues(array $properties_map, &$reference = NULL) {
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->_shadow_properties[$property_key];
if ($reference === null) {
$reference = & $this->shadowProperties[$property_key];
} else {
$reference = & $reference[$property_key];
}
$this->_setShadowProperiesMapValues($property_val, $reference);
$this->setShadowProperiesMapValues($property_val, $reference);
} else {
if ($base_reference === NULL) {
$this->_shadow_properties[$property_key] = $property_val;
if ($base_reference === null) {
$this->shadowProperties[$property_key] = $property_val;
} else {
$reference[$property_key] = $property_val;
}
@ -354,19 +371,18 @@ class PHPExcel_Chart_GridLines extends
* @param string $color
* @param int $alpha
* @param string $type
*
* @return PHPExcel_Chart_GridLines
*/
private function _setShadowColor($color, $alpha, $type) {
private function setShadowColor($color, $alpha, $type)
{
if (!is_null($color)) {
$this->_shadow_properties['color']['value'] = (string) $color;
$this->shadowProperties['color']['value'] = (string) $color;
}
if (!is_null($alpha)) {
$this->_shadow_properties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
$this->shadowProperties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
}
if (!is_null($type)) {
$this->_shadow_properties['color']['type'] = (string) $type;
$this->shadowProperties['color']['type'] = (string) $type;
}
return $this;
@ -379,10 +395,10 @@ class PHPExcel_Chart_GridLines extends
*
* @return PHPExcel_Chart_GridLines
*/
private function _setShadowBlur($blur) {
if ($blur !== NULL) {
$this->_shadow_properties['blur'] = (string) $this->getExcelPointsWidth($blur);
private function setShadowBlur($blur)
{
if ($blur !== null) {
$this->shadowProperties['blur'] = (string) $this->getExcelPointsWidth($blur);
}
return $this;
@ -392,13 +408,13 @@ class PHPExcel_Chart_GridLines extends
* Set Shadow Angle
*
* @param int $angle
*
* @return PHPExcel_Chart_GridLines
*/
private function _setShadowAngle($angle) {
if ($angle !== NULL) {
$this->_shadow_properties['direction'] = (string) $this->getExcelPointsAngle($angle);
private function setShadowAngle($angle)
{
if ($angle !== null) {
$this->shadowProperties['direction'] = (string) $this->getExcelPointsAngle($angle);
}
return $this;
@ -408,13 +424,12 @@ class PHPExcel_Chart_GridLines extends
* Set Shadow Distance
*
* @param float $distance
*
* @return PHPExcel_Chart_GridLines
*/
private function _setShadowDistance($distance) {
if ($distance !== NULL) {
$this->_shadow_properties['distance'] = (string) $this->getExcelPointsWidth($distance);
private function setShadowDistance($distance)
{
if ($distance !== null) {
$this->shadowProperties['distance'] = (string) $this->getExcelPointsWidth($distance);
}
return $this;
@ -425,12 +440,11 @@ class PHPExcel_Chart_GridLines extends
*
* @param string $elements
* @param array $elements
*
* @return string
*/
public function getShadowProperty($elements) {
return $this->getArrayElementsValue($this->_shadow_properties, $elements);
public function getShadowProperty($elements)
{
return $this->getArrayElementsValue($this->shadowProperties, $elements);
}
/**
@ -438,11 +452,11 @@ class PHPExcel_Chart_GridLines extends
*
* @param float $size
*/
public function setSoftEdgesSize($size) {
public function setSoftEdgesSize($size)
{
if (!is_null($size)) {
$this->_activateObject();
$_soft_edges['size'] = (string) $this->getExcelPointsWidth($size);
$this->activateObject();
$softEdges['size'] = (string) $this->getExcelPointsWidth($size);
}
}
@ -451,8 +465,8 @@ class PHPExcel_Chart_GridLines extends
*
* @return string
*/
public function getSoftEdgesSize() {
return $this->_soft_edges['size'];
public function getSoftEdgesSize()
{
return $this->softEdges['size'];
}
}

View file

@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 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_Chart
* @copyright Copyright (c) 2006 - 2014 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 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Chart_Layout
{
@ -40,49 +40,49 @@ class PHPExcel_Chart_Layout
*
* @var string
*/
private $_layoutTarget = NULL;
private $layoutTarget;
/**
* X Mode
*
* @var string
*/
private $_xMode = NULL;
private $xMode;
/**
* Y Mode
*
* @var string
*/
private $_yMode = NULL;
private $yMode;
/**
* X-Position
*
* @var float
*/
private $_xPos = NULL;
private $xPos;
/**
* Y-Position
*
* @var float
*/
private $_yPos = NULL;
private $yPos;
/**
* width
*
* @var float
*/
private $_width = NULL;
private $width;
/**
* height
*
* @var float
*/
private $_height = NULL;
private $height;
/**
* show legend key
@ -90,7 +90,7 @@ class PHPExcel_Chart_Layout
*
* @var boolean
*/
private $_showLegendKey = NULL;
private $showLegendKey;
/**
* show value
@ -98,7 +98,7 @@ class PHPExcel_Chart_Layout
*
* @var boolean
*/
private $_showVal = NULL;
private $showVal;
/**
* show category name
@ -106,7 +106,7 @@ class PHPExcel_Chart_Layout
*
* @var boolean
*/
private $_showCatName = NULL;
private $showCatName;
/**
* show data series name
@ -114,7 +114,7 @@ class PHPExcel_Chart_Layout
*
* @var boolean
*/
private $_showSerName = NULL;
private $showSerName;
/**
* show percentage
@ -122,14 +122,14 @@ class PHPExcel_Chart_Layout
*
* @var boolean
*/
private $_showPercent = NULL;
private $showPercent;
/**
* show bubble size
*
* @var boolean
*/
private $_showBubbleSize = NULL;
private $showBubbleSize;
/**
* show leader lines
@ -137,21 +137,35 @@ class PHPExcel_Chart_Layout
*
* @var boolean
*/
private $_showLeaderLines = NULL;
private $showLeaderLines;
/**
* Create a new PHPExcel_Chart_Layout
*/
public function __construct($layout=array())
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']; }
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'];
}
}
/**
@ -159,8 +173,9 @@ class PHPExcel_Chart_Layout
*
* @return string
*/
public function getLayoutTarget() {
return $this->_layoutTarget;
public function getLayoutTarget()
{
return $this->layoutTarget;
}
/**
@ -169,8 +184,9 @@ class PHPExcel_Chart_Layout
* @param Layout Target $value
* @return PHPExcel_Chart_Layout
*/
public function setLayoutTarget($value) {
$this->_layoutTarget = $value;
public function setLayoutTarget($value)
{
$this->layoutTarget = $value;
return $this;
}
@ -179,8 +195,9 @@ class PHPExcel_Chart_Layout
*
* @return string
*/
public function getXMode() {
return $this->_xMode;
public function getXMode()
{
return $this->xMode;
}
/**
@ -189,8 +206,9 @@ class PHPExcel_Chart_Layout
* @param X-Mode $value
* @return PHPExcel_Chart_Layout
*/
public function setXMode($value) {
$this->_xMode = $value;
public function setXMode($value)
{
$this->xMode = $value;
return $this;
}
@ -199,8 +217,9 @@ class PHPExcel_Chart_Layout
*
* @return string
*/
public function getYMode() {
return $this->_yMode;
public function getYMode()
{
return $this->yMode;
}
/**
@ -209,8 +228,9 @@ class PHPExcel_Chart_Layout
* @param Y-Mode $value
* @return PHPExcel_Chart_Layout
*/
public function setYMode($value) {
$this->_yMode = $value;
public function setYMode($value)
{
$this->yMode = $value;
return $this;
}
@ -219,8 +239,9 @@ class PHPExcel_Chart_Layout
*
* @return number
*/
public function getXPosition() {
return $this->_xPos;
public function getXPosition()
{
return $this->xPos;
}
/**
@ -229,8 +250,9 @@ class PHPExcel_Chart_Layout
* @param X-Position $value
* @return PHPExcel_Chart_Layout
*/
public function setXPosition($value) {
$this->_xPos = $value;
public function setXPosition($value)
{
$this->xPos = $value;
return $this;
}
@ -239,8 +261,9 @@ class PHPExcel_Chart_Layout
*
* @return number
*/
public function getYPosition() {
return $this->_yPos;
public function getYPosition()
{
return $this->yPos;
}
/**
@ -249,8 +272,9 @@ class PHPExcel_Chart_Layout
* @param Y-Position $value
* @return PHPExcel_Chart_Layout
*/
public function setYPosition($value) {
$this->_yPos = $value;
public function setYPosition($value)
{
$this->yPos = $value;
return $this;
}
@ -259,8 +283,9 @@ class PHPExcel_Chart_Layout
*
* @return number
*/
public function getWidth() {
return $this->_width;
public function getWidth()
{
return $this->width;
}
/**
@ -269,8 +294,9 @@ class PHPExcel_Chart_Layout
* @param Width $value
* @return PHPExcel_Chart_Layout
*/
public function setWidth($value) {
$this->_width = $value;
public function setWidth($value)
{
$this->width = $value;
return $this;
}
@ -279,8 +305,9 @@ class PHPExcel_Chart_Layout
*
* @return number
*/
public function getHeight() {
return $this->_height;
public function getHeight()
{
return $this->height;
}
/**
@ -289,8 +316,9 @@ class PHPExcel_Chart_Layout
* @param Height $value
* @return PHPExcel_Chart_Layout
*/
public function setHeight($value) {
$this->_height = $value;
public function setHeight($value)
{
$this->height = $value;
return $this;
}
@ -300,8 +328,9 @@ class PHPExcel_Chart_Layout
*
* @return boolean
*/
public function getShowLegendKey() {
return $this->_showLegendKey;
public function getShowLegendKey()
{
return $this->showLegendKey;
}
/**
@ -311,8 +340,9 @@ class PHPExcel_Chart_Layout
* @param boolean $value Show legend key
* @return PHPExcel_Chart_Layout
*/
public function setShowLegendKey($value) {
$this->_showLegendKey = $value;
public function setShowLegendKey($value)
{
$this->showLegendKey = $value;
return $this;
}
@ -321,8 +351,9 @@ class PHPExcel_Chart_Layout
*
* @return boolean
*/
public function getShowVal() {
return $this->_showVal;
public function getShowVal()
{
return $this->showVal;
}
/**
@ -332,8 +363,9 @@ class PHPExcel_Chart_Layout
* @param boolean $value Show val
* @return PHPExcel_Chart_Layout
*/
public function setShowVal($value) {
$this->_showVal = $value;
public function setShowVal($value)
{
$this->showVal = $value;
return $this;
}
@ -342,8 +374,9 @@ class PHPExcel_Chart_Layout
*
* @return boolean
*/
public function getShowCatName() {
return $this->_showCatName;
public function getShowCatName()
{
return $this->showCatName;
}
/**
@ -353,8 +386,9 @@ class PHPExcel_Chart_Layout
* @param boolean $value Show cat name
* @return PHPExcel_Chart_Layout
*/
public function setShowCatName($value) {
$this->_showCatName = $value;
public function setShowCatName($value)
{
$this->showCatName = $value;
return $this;
}
@ -363,8 +397,9 @@ class PHPExcel_Chart_Layout
*
* @return boolean
*/
public function getShowSerName() {
return $this->_showSerName;
public function getShowSerName()
{
return $this->showSerName;
}
/**
@ -374,8 +409,9 @@ class PHPExcel_Chart_Layout
* @param boolean $value Show series name
* @return PHPExcel_Chart_Layout
*/
public function setShowSerName($value) {
$this->_showSerName = $value;
public function setShowSerName($value)
{
$this->showSerName = $value;
return $this;
}
@ -384,8 +420,9 @@ class PHPExcel_Chart_Layout
*
* @return boolean
*/
public function getShowPercent() {
return $this->_showPercent;
public function getShowPercent()
{
return $this->showPercent;
}
/**
@ -395,8 +432,9 @@ class PHPExcel_Chart_Layout
* @param boolean $value Show percentage
* @return PHPExcel_Chart_Layout
*/
public function setShowPercent($value) {
$this->_showPercent = $value;
public function setShowPercent($value)
{
$this->showPercent = $value;
return $this;
}
@ -405,8 +443,9 @@ class PHPExcel_Chart_Layout
*
* @return boolean
*/
public function getShowBubbleSize() {
return $this->_showBubbleSize;
public function getShowBubbleSize()
{
return $this->showBubbleSize;
}
/**
@ -416,8 +455,9 @@ class PHPExcel_Chart_Layout
* @param boolean $value Show bubble size
* @return PHPExcel_Chart_Layout
*/
public function setShowBubbleSize($value) {
$this->_showBubbleSize = $value;
public function setShowBubbleSize($value)
{
$this->showBubbleSize = $value;
return $this;
}
@ -426,8 +466,9 @@ class PHPExcel_Chart_Layout
*
* @return boolean
*/
public function getShowLeaderLines() {
return $this->_showLeaderLines;
public function getShowLeaderLines()
{
return $this->showLeaderLines;
}
/**
@ -437,9 +478,9 @@ class PHPExcel_Chart_Layout
* @param boolean $value Show leader lines
* @return PHPExcel_Chart_Layout
*/
public function setShowLeaderLines($value) {
$this->_showLeaderLines = $value;
public function setShowLeaderLines($value)
{
$this->showLeaderLines = $value;
return $this;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Chart_Legend
*
* Copyright (c) 2006 - 2014 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_Chart
* @copyright Copyright (c) 2006 - 2014 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_Chart_Legend
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Chart_Legend
{
/** Legend positions */
@ -49,7 +41,8 @@ class PHPExcel_Chart_Legend
const POSITION_TOP = 't';
const POSITION_TOPRIGHT = 'tr';
private static $_positionXLref = array( self::xlLegendPositionBottom => self::POSITION_BOTTOM,
private static $positionXLref = array(
self::xlLegendPositionBottom => self::POSITION_BOTTOM,
self::xlLegendPositionCorner => self::POSITION_TOPRIGHT,
self::xlLegendPositionCustom => '??',
self::xlLegendPositionLeft => self::POSITION_LEFT,
@ -62,30 +55,30 @@ class PHPExcel_Chart_Legend
*
* @var string
*/
private $_position = self::POSITION_RIGHT;
private $position = self::POSITION_RIGHT;
/**
* Allow overlay of other elements?
*
* @var boolean
*/
private $_overlay = TRUE;
private $overlay = true;
/**
* Legend Layout
*
* @var PHPExcel_Chart_Layout
*/
private $_layout = NULL;
private $layout = null;
/**
* Create a new PHPExcel_Chart_Legend
*/
public function __construct($position = self::POSITION_RIGHT, PHPExcel_Chart_Layout $layout = NULL, $overlay = FALSE)
public function __construct($position = self::POSITION_RIGHT, PHPExcel_Chart_Layout $layout = null, $overlay = false)
{
$this->setPosition($position);
$this->_layout = $layout;
$this->layout = $layout;
$this->setOverlay($overlay);
}
@ -94,8 +87,9 @@ class PHPExcel_Chart_Legend
*
* @return string
*/
public function getPosition() {
return $this->_position;
public function getPosition()
{
return $this->position;
}
/**
@ -103,12 +97,13 @@ class PHPExcel_Chart_Legend
*
* @param string $position
*/
public function setPosition($position = self::POSITION_RIGHT) {
if (!in_array($position,self::$_positionXLref)) {
public function setPosition($position = self::POSITION_RIGHT)
{
if (!in_array($position, self::$positionXLref)) {
return false;
}
$this->_position = $position;
$this->position = $position;
return true;
}
@ -117,8 +112,9 @@ class PHPExcel_Chart_Legend
*
* @return number
*/
public function getPositionXL() {
return array_search($this->_position,self::$_positionXLref);
public function getPositionXL()
{
return array_search($this->position, self::$positionXLref);
}
/**
@ -126,12 +122,13 @@ class PHPExcel_Chart_Legend
*
* @param number $positionXL
*/
public function setPositionXL($positionXL = self::xlLegendPositionRight) {
if (!array_key_exists($positionXL,self::$_positionXLref)) {
public function setPositionXL($positionXL = self::xlLegendPositionRight)
{
if (!array_key_exists($positionXL, self::$positionXLref)) {
return false;
}
$this->_position = self::$_positionXLref[$positionXL];
$this->position = self::$positionXLref[$positionXL];
return true;
}
@ -140,8 +137,9 @@ class PHPExcel_Chart_Legend
*
* @return boolean
*/
public function getOverlay() {
return $this->_overlay;
public function getOverlay()
{
return $this->overlay;
}
/**
@ -150,12 +148,13 @@ class PHPExcel_Chart_Legend
* @param boolean $overlay
* @return boolean
*/
public function setOverlay($overlay = FALSE) {
public function setOverlay($overlay = false)
{
if (!is_bool($overlay)) {
return false;
}
$this->_overlay = $overlay;
$this->overlay = $overlay;
return true;
}
@ -164,8 +163,8 @@ class PHPExcel_Chart_Legend
*
* @return PHPExcel_Chart_Layout
*/
public function getLayout() {
return $this->_layout;
public function getLayout()
{
return $this->layout;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Chart_PlotArea
*
* Copyright (c) 2006 - 2014 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_Chart
* @copyright Copyright (c) 2006 - 2014 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_Chart_PlotArea
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Chart_PlotArea
{
/**
@ -40,22 +32,22 @@ class PHPExcel_Chart_PlotArea
*
* @var PHPExcel_Chart_Layout
*/
private $_layout = null;
private $layout = null;
/**
* Plot Series
*
* @var array of PHPExcel_Chart_DataSeries
*/
private $_plotSeries = array();
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;
$this->layout = $layout;
$this->plotSeries = $plotSeries;
}
/**
@ -63,8 +55,9 @@ class PHPExcel_Chart_PlotArea
*
* @return PHPExcel_Chart_Layout
*/
public function getLayout() {
return $this->_layout;
public function getLayout()
{
return $this->layout;
}
/**
@ -72,8 +65,9 @@ class PHPExcel_Chart_PlotArea
*
* @return array of PHPExcel_Chart_DataSeries
*/
public function getPlotGroupCount() {
return count($this->_plotSeries);
public function getPlotGroupCount()
{
return count($this->plotSeries);
}
/**
@ -81,9 +75,10 @@ class PHPExcel_Chart_PlotArea
*
* @return integer
*/
public function getPlotSeriesCount() {
public function getPlotSeriesCount()
{
$seriesCount = 0;
foreach($this->_plotSeries as $plot) {
foreach ($this->plotSeries as $plot) {
$seriesCount += $plot->getPlotSeriesCount();
}
return $seriesCount;
@ -94,8 +89,9 @@ class PHPExcel_Chart_PlotArea
*
* @return array of PHPExcel_Chart_DataSeries
*/
public function getPlotGroup() {
return $this->_plotSeries;
public function getPlotGroup()
{
return $this->plotSeries;
}
/**
@ -103,8 +99,9 @@ class PHPExcel_Chart_PlotArea
*
* @return PHPExcel_Chart_DataSeries
*/
public function getPlotGroupByIndex($index) {
return $this->_plotSeries[$index];
public function getPlotGroupByIndex($index)
{
return $this->plotSeries[$index];
}
/**
@ -113,16 +110,17 @@ class PHPExcel_Chart_PlotArea
* @param [PHPExcel_Chart_DataSeries]
* @return PHPExcel_Chart_PlotArea
*/
public function setPlotSeries($plotSeries = array()) {
$this->_plotSeries = $plotSeries;
public function setPlotSeries($plotSeries = array())
{
$this->plotSeries = $plotSeries;
return $this;
}
public function refresh(PHPExcel_Worksheet $worksheet) {
foreach($this->_plotSeries as $plotSeries) {
public function refresh(PHPExcel_Worksheet $worksheet)
{
foreach ($this->plotSeries as $plotSeries) {
$plotSeries->refresh($worksheet);
}
}
}

View file

@ -6,8 +6,8 @@
* Time: 5:45 PM
*/
abstract class PHPExcel_Properties {
abstract class PHPExcel_Chart_Properties
{
const
EXCEL_COLOR_TYPE_STANDARD = 'prstClr',
EXCEL_COLOR_TYPE_SCHEME = 'schemeClr',
@ -70,7 +70,7 @@ abstract class PHPExcel_Properties {
LINE_STYLE_JOIN_MITER = 'miter',
LINE_STYLE_JOIN_BEVEL = 'bevel',
LINE_STYLE_ARROW_TYPE_NOARROW = NULL,
LINE_STYLE_ARROW_TYPE_NOARROW = null,
LINE_STYLE_ARROW_TYPE_ARROW = 'triangle',
LINE_STYLE_ARROW_TYPE_OPEN = 'arrow',
LINE_STYLE_ARROW_TYPE_STEALTH = 'stealth',
@ -88,7 +88,7 @@ abstract class PHPExcel_Properties {
LINE_STYLE_ARROW_SIZE_9 = 9;
const
SHADOW_PRESETS_NOSHADOW = NULL,
SHADOW_PRESETS_NOSHADOW = null,
SHADOW_PRESETS_OUTER_BOTTTOM_RIGHT = 1,
SHADOW_PRESETS_OUTER_BOTTOM = 2,
SHADOW_PRESETS_OUTER_BOTTOM_LEFT = 3,
@ -113,19 +113,23 @@ abstract class PHPExcel_Properties {
SHADOW_PRESETS_PERSPECTIVE_LOWER_RIGHT = 22,
SHADOW_PRESETS_PERSPECTIVE_LOWER_LEFT = 23;
protected function getExcelPointsWidth($width) {
protected function getExcelPointsWidth($width)
{
return $width * 12700;
}
protected function getExcelPointsAngle($angle) {
protected function getExcelPointsAngle($angle)
{
return $angle * 60000;
}
protected function getTrueAlpha($alpha) {
protected function getTrueAlpha($alpha)
{
return (string) 100 - $alpha . '000';
}
protected function setColorProperties($color, $alpha, $type) {
protected function setColorProperties($color, $alpha, $type)
{
return array(
'type' => (string) $type,
'value' => (string) $color,
@ -133,7 +137,8 @@ abstract class PHPExcel_Properties {
);
}
protected function getLineStyleArrowSize($array_selector, $array_kay_selector) {
protected function getLineStyleArrowSize($array_selector, $array_kay_selector)
{
$sizes = array(
1 => array('w' => 'sm', 'len' => 'sm'),
2 => array('w' => 'sm', 'len' => 'med'),
@ -149,7 +154,8 @@ abstract class PHPExcel_Properties {
return $sizes[$array_selector][$array_kay_selector];
}
protected function getShadowPresetsMap($shadow_presets_option) {
protected function getShadowPresetsMap($shadow_presets_option)
{
$presets_options = array(
//OUTER
1 => array(
@ -341,7 +347,8 @@ abstract class PHPExcel_Properties {
return $presets_options[$shadow_presets_option];
}
protected function getArrayElementsValue($properties, $elements) {
protected function getArrayElementsValue($properties, $elements)
{
$reference = & $properties;
if (!is_array($elements)) {
return $reference[$elements];
@ -349,11 +356,8 @@ abstract class PHPExcel_Properties {
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 - 2014 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_Chart
* @copyright Copyright (c) 2006 - 2014 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_Chart_Title
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Chart_Title
{
@ -41,22 +33,22 @@ class PHPExcel_Chart_Title
*
* @var string
*/
private $_caption = null;
private $caption = null;
/**
* Title Layout
*
* @var PHPExcel_Chart_Layout
*/
private $_layout = null;
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;
$this->caption = $caption;
$this->layout = $layout;
}
/**
@ -64,8 +56,9 @@ class PHPExcel_Chart_Title
*
* @return string
*/
public function getCaption() {
return $this->_caption;
public function getCaption()
{
return $this->caption;
}
/**
@ -74,8 +67,9 @@ class PHPExcel_Chart_Title
* @param string $caption
* @return PHPExcel_Chart_Title
*/
public function setCaption($caption = null) {
$this->_caption = $caption;
public function setCaption($caption = null)
{
$this->caption = $caption;
return $this;
}
@ -85,8 +79,8 @@ class PHPExcel_Chart_Title
*
* @return PHPExcel_Chart_Layout
*/
public function getLayout() {
return $this->_layout;
public function getLayout()
{
return $this->layout;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Comment
*
* Copyright (c) 2006 - 2014 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 - 2014 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 - 2014 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)) {
@ -320,8 +331,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable
*
* @return string
*/
public function __toString() {
return $this->_text->getPlainText();
public function __toString()
{
return $this->text->getPlainText();
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_DocumentProperties
*
* Copyright (c) 2006 - 2014 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 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_DocumentProperties
{
/** constants */
@ -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'];
}
}
@ -437,17 +455,18 @@ class PHPExcel_DocumentProperties
* 'b' : Boolean
* @return PHPExcel_DocumentProperties
*/
public function setCustomProperty($propertyName,$propertyValue='',$propertyType=NULL) {
if (($propertyType === NULL) || (!in_array($propertyType,array(self::PROPERTY_TYPE_INTEGER,
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) {
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 - 2014 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 - 2014 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_DocumentSecurity
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_DocumentSecurity
{
/**
@ -40,35 +32,35 @@ class PHPExcel_DocumentSecurity
*
* @var boolean
*/
private $_lockRevision;
private $lockRevision;
/**
* LockStructure
*
* @var boolean
*/
private $_lockStructure;
private $lockStructure;
/**
* LockWindows
*
* @var boolean
*/
private $_lockWindows;
private $lockWindows;
/**
* RevisionsPassword
*
* @var string
*/
private $_revisionsPassword;
private $revisionsPassword;
/**
* WorkbookPassword
*
* @var string
*/
private $_workbookPassword;
private $workbookPassword;
/**
* Create a new PHPExcel_DocumentSecurity
@ -76,22 +68,23 @@ class PHPExcel_DocumentSecurity
public function __construct()
{
// Initialise values
$this->_lockRevision = false;
$this->_lockStructure = false;
$this->_lockWindows = false;
$this->_revisionsPassword = '';
$this->_workbookPassword = '';
$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,8 +103,9 @@ class PHPExcel_DocumentSecurity
* @param boolean $pValue
* @return PHPExcel_DocumentSecurity
*/
function setLockRevision($pValue = false) {
$this->_lockRevision = $pValue;
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,8 +125,9 @@ class PHPExcel_DocumentSecurity
* @param boolean $pValue
* @return PHPExcel_DocumentSecurity
*/
function setLockStructure($pValue = false) {
$this->_lockStructure = $pValue;
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,8 +147,9 @@ class PHPExcel_DocumentSecurity
* @param boolean $pValue
* @return PHPExcel_DocumentSecurity
*/
function setLockWindows($pValue = false) {
$this->_lockWindows = $pValue;
public function setLockWindows($pValue = false)
{
$this->lockWindows = $pValue;
return $this;
}
@ -159,8 +158,9 @@ class PHPExcel_DocumentSecurity
*
* @return string
*/
function getRevisionsPassword() {
return $this->_revisionsPassword;
public function getRevisionsPassword()
{
return $this->revisionsPassword;
}
/**
@ -170,11 +170,12 @@ class PHPExcel_DocumentSecurity
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
* @return PHPExcel_DocumentSecurity
*/
function setRevisionsPassword($pValue = '', $pAlreadyHashed = false) {
public function setRevisionsPassword($pValue = '', $pAlreadyHashed = false)
{
if (!$pAlreadyHashed) {
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
}
$this->_revisionsPassword = $pValue;
$this->revisionsPassword = $pValue;
return $this;
}
@ -183,8 +184,9 @@ class PHPExcel_DocumentSecurity
*
* @return string
*/
function getWorkbookPassword() {
return $this->_workbookPassword;
public function getWorkbookPassword()
{
return $this->workbookPassword;
}
/**
@ -194,18 +196,20 @@ class PHPExcel_DocumentSecurity
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
* @return PHPExcel_DocumentSecurity
*/
function setWorkbookPassword($pValue = '', $pAlreadyHashed = false) {
public function setWorkbookPassword($pValue = '', $pAlreadyHashed = false)
{
if (!$pAlreadyHashed) {
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
}
$this->_workbookPassword = $pValue;
$this->workbookPassword = $pValue;
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)) {

View file

@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 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 - 2014 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 - 2014 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 - 2014 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 - 2014 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_HashTable
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_HashTable
{
/**
@ -40,14 +32,14 @@ class PHPExcel_HashTable
*
* @var array
*/
public $_items = array();
protected $items = array();
/**
* HashTable key map
*
* @var array
*/
public $_keyMap = array();
protected $keyMap = array();
/**
* Create a new PHPExcel_HashTable
@ -57,7 +49,7 @@ class PHPExcel_HashTable
*/
public function __construct($pSource = null)
{
if ($pSource !== NULL) {
if ($pSource !== null) {
// Create HashTable
$this->addFromSource($pSource);
}
@ -69,11 +61,12 @@ class PHPExcel_HashTable
* @param PHPExcel_IComparable[] $pSource Source array to create HashTable from
* @throws PHPExcel_Exception
*/
public function addFromSource($pSource = null) {
public function addFromSource($pSource = null)
{
// Check if an array was passed
if ($pSource == null) {
return;
} else if (!is_array($pSource)) {
} elseif (!is_array($pSource)) {
throw new PHPExcel_Exception('Invalid array parameter passed.');
}
@ -88,11 +81,12 @@ class PHPExcel_HashTable
* @param PHPExcel_IComparable $pSource Item to add
* @throws PHPExcel_Exception
*/
public function add(PHPExcel_IComparable $pSource = null) {
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;
if (!isset($this->items[$hash])) {
$this->items[$hash] = $pSource;
$this->keyMap[count($this->items) - 1] = $hash;
}
}
@ -102,22 +96,23 @@ class PHPExcel_HashTable
* @param PHPExcel_IComparable $pSource Item to remove
* @throws PHPExcel_Exception
*/
public function remove(PHPExcel_IComparable $pSource = null) {
public function remove(PHPExcel_IComparable $pSource = null)
{
$hash = $pSource->getHashCode();
if (isset($this->_items[$hash])) {
unset($this->_items[$hash]);
if (isset($this->items[$hash])) {
unset($this->items[$hash]);
$deleteKey = -1;
foreach ($this->_keyMap as $key => $value) {
foreach ($this->keyMap as $key => $value) {
if ($deleteKey >= 0) {
$this->_keyMap[$key - 1] = $value;
$this->keyMap[$key - 1] = $value;
}
if ($value == $hash) {
$deleteKey = $key;
}
}
unset($this->_keyMap[count($this->_keyMap) - 1]);
unset($this->keyMap[count($this->keyMap) - 1]);
}
}
@ -125,9 +120,10 @@ class PHPExcel_HashTable
* Clear HashTable
*
*/
public function clear() {
$this->_items = array();
$this->_keyMap = array();
public function clear()
{
$this->items = array();
$this->keyMap = array();
}
/**
@ -135,8 +131,9 @@ class PHPExcel_HashTable
*
* @return int
*/
public function count() {
return count($this->_items);
public function count()
{
return count($this->items);
}
/**
@ -145,8 +142,9 @@ class PHPExcel_HashTable
* @param string $pHashCode
* @return int Index
*/
public function getIndexForHashCode($pHashCode = '') {
return array_search($pHashCode, $this->_keyMap);
public function getIndexForHashCode($pHashCode = '')
{
return array_search($pHashCode, $this->keyMap);
}
/**
@ -156,9 +154,10 @@ class PHPExcel_HashTable
* @return PHPExcel_IComparable
*
*/
public function getByIndex($pIndex = 0) {
if (isset($this->_keyMap[$pIndex])) {
return $this->getByHashCode( $this->_keyMap[$pIndex] );
public function getByIndex($pIndex = 0)
{
if (isset($this->keyMap[$pIndex])) {
return $this->getByHashCode($this->keyMap[$pIndex]);
}
return null;
@ -171,9 +170,10 @@ class PHPExcel_HashTable
* @return PHPExcel_IComparable
*
*/
public function getByHashCode($pHashCode = '') {
if (isset($this->_items[$pHashCode])) {
return $this->_items[$pHashCode];
public function getByHashCode($pHashCode = '')
{
if (isset($this->items[$pHashCode])) {
return $this->items[$pHashCode];
}
return null;
@ -184,14 +184,16 @@ class PHPExcel_HashTable
*
* @return PHPExcel_IComparable[]
*/
public function toArray() {
return $this->_items;
public function toArray()
{
return $this->items;
}
/**
* 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

@ -573,7 +573,8 @@ class PHPExcel_Helper_HTML
protected $richTextObject;
protected function initialise() {
protected function initialise()
{
$this->face = $this->size = $this->color = null;
$this->bold = $this->italic = $this->underline = $this->superscript = $this->subscript = $this->strikethrough = false;
@ -582,11 +583,12 @@ class PHPExcel_Helper_HTML
$this->stringData = '';
}
public function toRichTextObject($html) {
public function toRichTextObject($html)
{
$this->initialise();
// Create a new DOM object
$dom = new domDocument;
$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);
@ -596,13 +598,33 @@ class PHPExcel_Helper_HTML
$this->richTextObject = new PHPExcel_RichText();;
$this->parseElements($dom);
// Clean any further spurious whitespace
$this->cleanWhitespace();
return $this->richTextObject;
}
protected function buildTextRun() {
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) === '')
if (trim($text) === '') {
return;
}
$richtextRun = $this->richTextObject->createTextRun($this->stringData);
if ($this->face) {
@ -612,7 +634,7 @@ class PHPExcel_Helper_HTML
$richtextRun->getFont()->setSize($this->size);
}
if ($this->color) {
$richtextRun->getFont()->setColor( new PHPExcel_Style_Color( 'ff' . $this->color ) );
$richtextRun->getFont()->setColor(new PHPExcel_Style_Color('ff' . $this->color));
}
if ($this->bold) {
$richtextRun->getFont()->setBold(true);
@ -635,19 +657,22 @@ class PHPExcel_Helper_HTML
$this->stringData = '';
}
protected function rgbToColour($rgb) {
protected function rgbToColour($rgb)
{
preg_match_all('/\d+/', $rgb, $values);
foreach($values[0] as &$value) {
foreach ($values[0] as &$value) {
$value = str_pad(dechex($value), 2, '0', STR_PAD_LEFT);
}
return implode($values[0]);
}
protected function colourNameLookup($rgb) {
protected function colourNameLookup($rgb)
{
return self::$colourMap[$rgb];
}
protected function startFontTag($tag) {
protected function startFontTag($tag)
{
foreach ($tag->attributes as $attribute) {
$attributeName = strtolower($attribute->name);
$attributeValue = $attribute->value;
@ -655,7 +680,7 @@ class PHPExcel_Helper_HTML
if ($attributeName == 'color') {
if (preg_match('/rgb\s*\(/', $attributeValue)) {
$this->$attributeName = $this->rgbToColour($attributeValue);
} elseif(strpos(trim($attributeValue), '#') === 0) {
} elseif (strpos(trim($attributeValue), '#') === 0) {
$this->$attributeName = ltrim($attributeValue, '#');
} else {
$this->$attributeName = $this->colourNameLookup($attributeValue);
@ -666,69 +691,89 @@ class PHPExcel_Helper_HTML
}
}
protected function endFontTag() {
protected function endFontTag()
{
$this->face = $this->size = $this->color = null;
}
protected function startBoldTag() {
protected function startBoldTag()
{
$this->bold = true;
}
protected function endBoldTag() {
protected function endBoldTag()
{
$this->bold = false;
}
protected function startItalicTag() {
protected function startItalicTag()
{
$this->italic = true;
}
protected function endItalicTag() {
protected function endItalicTag()
{
$this->italic = false;
}
protected function startUnderlineTag() {
protected function startUnderlineTag()
{
$this->underline = true;
}
protected function endUnderlineTag() {
protected function endUnderlineTag()
{
$this->underline = false;
}
protected function startSubscriptTag() {
protected function startSubscriptTag()
{
$this->subscript = true;
}
protected function endSubscriptTag() {
protected function endSubscriptTag()
{
$this->subscript = false;
}
protected function startSuperscriptTag() {
protected function startSuperscriptTag()
{
$this->superscript = true;
}
protected function endSuperscriptTag() {
protected function endSuperscriptTag()
{
$this->superscript = false;
}
protected function startStrikethruTag() {
protected function startStrikethruTag()
{
$this->strikethrough = true;
}
protected function endStrikethruTag() {
protected function endStrikethruTag()
{
$this->strikethrough = false;
}
protected function breakTag() {
$this->stringData .= PHP_EOL;
protected function breakTag()
{
$this->stringData .= "\n";
}
protected function parseTextNode(DOMText $textNode) {
$domText = preg_replace('/\s+/u', ' ', ltrim($textNode->nodeValue));
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) {
protected function handleCallback($element, $callbackTag, $callbacks)
{
if (isset($callbacks[$callbackTag])) {
$elementHandler = $callbacks[$callbackTag];
if (method_exists($this, $elementHandler)) {
@ -737,20 +782,21 @@ class PHPExcel_Helper_HTML
}
}
protected function parseElementNode(DOMElement $element) {
protected function parseElementNode(DOMElement $element)
{
$callbackTag = strtolower($element->nodeName);
$this->stack[] = $callbackTag;
$this->handleCallback($element, $callbackTag, $this->startTagCallbacks);
$this->parseElements($element);
$this->stringData .= ' ';
array_pop($this->stack);
$this->handleCallback($element, $callbackTag, $this->endTagCallbacks);
}
protected function parseElements(DOMNode $element) {
protected function parseElements(DOMNode $element)
{
foreach ($element->childNodes as $child) {
if ($child instanceof DOMText) {
$this->parseTextNode($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,19 +19,10 @@
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2014 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_IComparable
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
interface PHPExcel_IComparable
{
/**
@ -39,5 +31,4 @@ interface PHPExcel_IComparable
* @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 - 2014 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 +30,10 @@
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2014 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_IOFactory
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_IOFactory
{
/**
@ -51,7 +43,7 @@ class PHPExcel_IOFactory
* @access private
* @static
*/
private static $_searchLocations = array(
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}' )
);
@ -63,7 +55,7 @@ class PHPExcel_IOFactory
* @access private
* @static
*/
private static $_autoResolveClasses = array(
private static $autoResolveClasses = array(
'Excel2007',
'Excel5',
'Excel2003XML',
@ -77,7 +69,9 @@ class PHPExcel_IOFactory
/**
* Private constructor for PHPExcel_IOFactory
*/
private function __construct() { }
private function __construct()
{
}
/**
* Get search locations
@ -86,9 +80,10 @@ class PHPExcel_IOFactory
* @access public
* @return array
*/
public static function getSearchLocations() {
return self::$_searchLocations;
} // function getSearchLocations()
public static function getSearchLocations()
{
return self::$searchLocations;
}
/**
* Set search locations
@ -98,13 +93,14 @@ class PHPExcel_IOFactory
* @param array $value
* @throws PHPExcel_Reader_Exception
*/
public static function setSearchLocations($value) {
public static function setSearchLocations($value)
{
if (is_array($value)) {
self::$_searchLocations = $value;
self::$searchLocations = $value;
} else {
throw new PHPExcel_Reader_Exception('Invalid parameter passed.');
}
} // function setSearchLocations()
}
/**
* Add search location
@ -115,9 +111,10 @@ class PHPExcel_IOFactory
* @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()
public static function addSearchLocation($type = '', $location = '', $classname = '')
{
self::$searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname );
}
/**
* Create PHPExcel_Writer_IWriter
@ -129,17 +126,18 @@ class PHPExcel_IOFactory
* @return PHPExcel_Writer_IWriter
* @throws PHPExcel_Reader_Exception
*/
public static function createWriter(PHPExcel $phpExcel, $writerType = '') {
public static function createWriter(PHPExcel $phpExcel, $writerType = '')
{
// Search type
$searchType = 'IWriter';
// Include class
foreach (self::$_searchLocations as $searchLocation) {
foreach (self::$searchLocations as $searchLocation) {
if ($searchLocation['type'] == $searchType) {
$className = str_replace('{0}', $writerType, $searchLocation['class']);
$instance = new $className($phpExcel);
if ($instance !== NULL) {
if ($instance !== null) {
return $instance;
}
}
@ -147,7 +145,7 @@ class PHPExcel_IOFactory
// Nothing found...
throw new PHPExcel_Reader_Exception("No $searchType found for type $writerType");
} // function createWriter()
}
/**
* Create PHPExcel_Reader_IReader
@ -158,17 +156,18 @@ class PHPExcel_IOFactory
* @return PHPExcel_Reader_IReader
* @throws PHPExcel_Reader_Exception
*/
public static function createReader($readerType = '') {
public static function createReader($readerType = '')
{
// Search type
$searchType = 'IReader';
// Include class
foreach (self::$_searchLocations as $searchLocation) {
foreach (self::$searchLocations as $searchLocation) {
if ($searchLocation['type'] == $searchType) {
$className = str_replace('{0}', $readerType, $searchLocation['class']);
$instance = new $className();
if ($instance !== NULL) {
if ($instance !== null) {
return $instance;
}
}
@ -176,7 +175,7 @@ class PHPExcel_IOFactory
// Nothing found...
throw new PHPExcel_Reader_Exception("No $searchType found for type $readerType");
} // function createReader()
}
/**
* Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution
@ -187,10 +186,11 @@ class PHPExcel_IOFactory
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
*/
public static function load($pFilename) {
public static function load($pFilename)
{
$reader = self::createReaderForFile($pFilename);
return $reader->load($pFilename);
} // function load()
}
/**
* Identify file type using automatic PHPExcel_Reader_IReader resolution
@ -201,13 +201,14 @@ class PHPExcel_IOFactory
* @return string
* @throws PHPExcel_Reader_Exception
*/
public static function identify($pFilename) {
public static function identify($pFilename)
{
$reader = self::createReaderForFile($pFilename);
$className = get_class($reader);
$classType = explode('_',$className);
$classType = explode('_', $className);
unset($reader);
return array_pop($classType);
} // function identify()
}
/**
* Create PHPExcel_Reader_IReader for file using automatic PHPExcel_Reader_IReader resolution
@ -218,12 +219,12 @@ class PHPExcel_IOFactory
* @return PHPExcel_Reader_IReader
* @throws PHPExcel_Reader_Exception
*/
public static function createReaderForFile($pFilename) {
public static function createReaderForFile($pFilename)
{
// First, lucky guess by inspecting file extension
$pathinfo = pathinfo($pFilename);
$extensionType = NULL;
$extensionType = null;
if (isset($pathinfo['extension'])) {
switch (strtolower($pathinfo['extension'])) {
case 'xlsx': // Excel (OfficeOpenXML) Spreadsheet
@ -262,7 +263,7 @@ class PHPExcel_IOFactory
break;
}
if ($extensionType !== NULL) {
if ($extensionType !== null) {
$reader = self::createReader($extensionType);
// Let's see if we are lucky
if (isset($reader) && $reader->canRead($pFilename)) {
@ -272,8 +273,8 @@ class PHPExcel_IOFactory
}
// 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) {
// 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);
@ -284,5 +285,5 @@ class PHPExcel_IOFactory
}
throw new PHPExcel_Reader_Exception('Unable to identify a reader for this file');
} // function createReaderForFile()
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_NamedRange
*
* Copyright (c) 2006 - 2014 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 - 2014 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_NamedRange
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_NamedRange
{
/**
@ -40,35 +32,35 @@ class PHPExcel_NamedRange
*
* @var string
*/
private $_name;
private $name;
/**
* Worksheet on which the named range can be resolved
*
* @var PHPExcel_Worksheet
*/
private $_worksheet;
private $worksheet;
/**
* Range of the referenced cells
*
* @var string
*/
private $_range;
private $range;
/**
* Is the named range local? (i.e. can only be used on $this->_worksheet)
* Is the named range local? (i.e. can only be used on $this->worksheet)
*
* @var bool
*/
private $_localOnly;
private $localOnly;
/**
* Scope
*
* @var PHPExcel_Worksheet
*/
private $_scope;
private $scope;
/**
* Create a new NamedRange
@ -83,17 +75,16 @@ class PHPExcel_NamedRange
public function __construct($pName = null, PHPExcel_Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null)
{
// Validate data
if (($pName === NULL) || ($pWorksheet === NULL) || ($pRange === NULL)) {
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;
$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,24 +103,25 @@ class PHPExcel_NamedRange
* @param string $value
* @return PHPExcel_NamedRange
*/
public function setName($value = null) {
if ($value !== NULL) {
public function setName($value = null)
{
if ($value !== null) {
// Old title
$oldTitle = $this->_name;
$oldTitle = $this->name;
// Re-attach
if ($this->_worksheet !== NULL) {
$this->_worksheet->getParent()->removeNamedRange($this->_name,$this->_worksheet);
if ($this->worksheet !== null) {
$this->worksheet->getParent()->removeNamedRange($this->name, $this->worksheet);
}
$this->_name = $value;
$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);
$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,9 +142,10 @@ class PHPExcel_NamedRange
* @param PHPExcel_Worksheet $value
* @return PHPExcel_NamedRange
*/
public function setWorksheet(PHPExcel_Worksheet $value = null) {
if ($value !== NULL) {
$this->_worksheet = $value;
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,9 +166,10 @@ class PHPExcel_NamedRange
* @param string $value
* @return PHPExcel_NamedRange
*/
public function setRange($value = null) {
if ($value !== NULL) {
$this->_range = $value;
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,9 +190,10 @@ class PHPExcel_NamedRange
* @param bool $value
* @return PHPExcel_NamedRange
*/
public function setLocalOnly($value = false) {
$this->_localOnly = $value;
$this->_scope = $value ? $this->_worksheet : null;
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,9 +213,10 @@ 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;
public function setScope(PHPExcel_Worksheet $value = null)
{
$this->scope = $value;
$this->localOnly = ($value == null) ? false : true;
return $this;
}
@ -226,14 +227,16 @@ 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) {
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() {
public function __clone()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Reader_Abstract
*
* Copyright (c) 2006 - 2014 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_Reader
* @copyright Copyright (c) 2006 - 2014 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_Reader_Abstract
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
{
/**
@ -42,7 +34,16 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*
* @var boolean
*/
protected $_readDataOnly = FALSE;
protected $readDataOnly = 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;
/**
* Read charts that are defined in the workbook?
@ -50,7 +51,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*
* @var boolean
*/
protected $_includeCharts = FALSE;
protected $includeCharts = false;
/**
* Restrict which sheets should be loaded?
@ -58,16 +59,16 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*
* @var array of string
*/
protected $_loadSheetsOnly = NULL;
protected $loadSheetsOnly;
/**
* PHPExcel_Reader_IReadFilter instance
*
* @var PHPExcel_Reader_IReadFilter
*/
protected $_readFilter = NULL;
protected $readFilter;
protected $_fileHandle = NULL;
protected $fileHandle = null;
/**
@ -77,8 +78,9 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*
* @return boolean
*/
public function getReadDataOnly() {
return $this->_readDataOnly;
public function getReadDataOnly()
{
return $this->readDataOnly;
}
/**
@ -90,8 +92,36 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*
* @return PHPExcel_Reader_IReader
*/
public function setReadDataOnly($pValue = FALSE) {
$this->_readDataOnly = $pValue;
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;
}
@ -103,8 +133,9 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*
* @return boolean
*/
public function getIncludeCharts() {
return $this->_includeCharts;
public function getIncludeCharts()
{
return $this->includeCharts;
}
/**
@ -117,8 +148,9 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*
* @return PHPExcel_Reader_IReader
*/
public function setIncludeCharts($pValue = FALSE) {
$this->_includeCharts = (boolean) $pValue;
public function setIncludeCharts($pValue = false)
{
$this->includeCharts = (boolean) $pValue;
return $this;
}
@ -131,7 +163,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*/
public function getLoadSheetsOnly()
{
return $this->_loadSheetsOnly;
return $this->loadSheetsOnly;
}
/**
@ -143,13 +175,13 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*
* @return PHPExcel_Reader_IReader
*/
public function setLoadSheetsOnly($value = NULL)
public function setLoadSheetsOnly($value = null)
{
if ($value === NULL)
if ($value === null) {
return $this->setLoadAllSheets();
}
$this->_loadSheetsOnly = is_array($value) ?
$value : array($value);
$this->loadSheetsOnly = is_array($value) ? $value : array($value);
return $this;
}
@ -161,7 +193,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*/
public function setLoadAllSheets()
{
$this->_loadSheetsOnly = NULL;
$this->loadSheetsOnly = null;
return $this;
}
@ -170,8 +202,9 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*
* @return PHPExcel_Reader_IReadFilter
*/
public function getReadFilter() {
return $this->_readFilter;
public function getReadFilter()
{
return $this->readFilter;
}
/**
@ -180,8 +213,9 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* @param PHPExcel_Reader_IReadFilter $pValue
* @return PHPExcel_Reader_IReader
*/
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
$this->_readFilter = $pValue;
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue)
{
$this->readFilter = $pValue;
return $this;
}
@ -192,7 +226,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* @throws PHPExcel_Reader_Exception
* @return resource
*/
protected function _openFile($pFilename)
protected function openFile($pFilename)
{
// Check if file exists
if (!file_exists($pFilename) || !is_readable($pFilename)) {
@ -200,8 +234,8 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
}
// Open file
$this->_fileHandle = fopen($pFilename, 'r');
if ($this->_fileHandle === FALSE) {
$this->fileHandle = fopen($pFilename, 'r');
if ($this->fileHandle === false) {
throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading.");
}
}
@ -217,13 +251,13 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
{
// Check if file exists
try {
$this->_openFile($pFilename);
$this->openFile($pFilename);
} catch (Exception $e) {
return FALSE;
return false;
}
$readable = $this->_isValidFormat();
fclose ($this->_fileHandle);
$readable = $this->isValidFormat();
fclose($this->fileHandle);
return $readable;
}

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 - 2014 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 +30,10 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2014 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_Reader_CSV
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
{
/**
@ -50,7 +42,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* @access private
* @var string
*/
private $_inputEncoding = 'UTF-8';
private $inputEncoding = 'UTF-8';
/**
* Delimiter
@ -58,7 +50,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* @access private
* @var string
*/
private $_delimiter = ',';
private $delimiter = ',';
/**
* Enclosure
@ -66,7 +58,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* @access private
* @var string
*/
private $_enclosure = '"';
private $enclosure = '"';
/**
* Sheet index to read
@ -74,7 +66,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* @access private
* @var int
*/
private $_sheetIndex = 0;
private $sheetIndex = 0;
/**
* Load rows contiguously
@ -82,21 +74,22 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* @access private
* @var int
*/
private $_contiguous = false;
private $contiguous = false;
/**
* Row counter for loading rows contiguously
*
* @var int
*/
private $_contiguousRow = -1;
private $contiguousRow = -1;
/**
* Create a new PHPExcel_Reader_CSV
*/
public function __construct() {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
public function __construct()
{
$this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
}
/**
@ -104,9 +97,9 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
*
* @return boolean
*/
protected function _isValidFormat()
protected function isValidFormat()
{
return TRUE;
return true;
}
/**
@ -116,7 +109,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
*/
public function setInputEncoding($pValue = 'UTF-8')
{
$this->_inputEncoding = $pValue;
$this->inputEncoding = $pValue;
return $this;
}
@ -127,43 +120,61 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
*/
public function getInputEncoding()
{
return $this->_inputEncoding;
return $this->inputEncoding;
}
/**
* Move filepointer past any BOM marker
*
*/
protected function _skipBOM()
protected function skipBOM()
{
rewind($this->_fileHandle);
rewind($this->fileHandle);
switch ($this->_inputEncoding) {
switch ($this->inputEncoding) {
case 'UTF-8':
fgets($this->_fileHandle, 4) == "\xEF\xBB\xBF" ?
fseek($this->_fileHandle, 3) : fseek($this->_fileHandle, 0);
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);
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);
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);
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);
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)
*
@ -173,17 +184,18 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
public function listWorksheetInfo($pFilename)
{
// Open file
$this->_openFile($pFilename);
if (!$this->_isValidFormat()) {
fclose ($this->_fileHandle);
$this->openFile($pFilename);
if (!$this->isValidFormat()) {
fclose($this->fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
}
$fileHandle = $this->_fileHandle;
$fileHandle = $this->fileHandle;
// Skip BOM, if any
$this->_skipBOM();
$this->skipBOM();
$this->checkSeparator();
$escapeEnclosures = array( "\\" . $this->_enclosure, $this->_enclosure . $this->_enclosure );
$escapeEnclosures = array( "\\" . $this->enclosure, $this->enclosure . $this->enclosure );
$worksheetInfo = array();
$worksheetInfo[0]['worksheetName'] = 'Worksheet';
@ -193,7 +205,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
$worksheetInfo[0]['totalColumns'] = 0;
// Loop through each line of the file in turn
while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
while (($rowData = fgetcsv($fileHandle, 0, $this->delimiter, $this->enclosure)) !== false) {
$worksheetInfo[0]['totalRows']++;
$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], count($rowData) - 1);
}
@ -237,43 +249,44 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
ini_set('auto_detect_line_endings', true);
// Open file
$this->_openFile($pFilename);
if (!$this->_isValidFormat()) {
fclose ($this->_fileHandle);
$this->openFile($pFilename);
if (!$this->isValidFormat()) {
fclose($this->fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
}
$fileHandle = $this->_fileHandle;
$fileHandle = $this->fileHandle;
// Skip BOM, if any
$this->_skipBOM();
$this->skipBOM();
$this->checkSeparator();
// Create new PHPExcel object
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
while ($objPHPExcel->getSheetCount() <= $this->sheetIndex) {
$objPHPExcel->createSheet();
}
$sheet = $objPHPExcel->setActiveSheetIndex($this->_sheetIndex);
$sheet = $objPHPExcel->setActiveSheetIndex($this->sheetIndex);
$escapeEnclosures = array( "\\" . $this->_enclosure,
$this->_enclosure . $this->_enclosure
$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;
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) {
while (($rowData = fgetcsv($fileHandle, 0, $this->delimiter, $this->enclosure)) !== false) {
$columnLetter = 'A';
foreach($rowData as $rowDatum) {
if ($rowDatum != '' && $this->_readFilter->readCell($columnLetter, $currentRow)) {
foreach ($rowData as $rowDatum) {
if ($rowDatum != '' && $this->readFilter->readCell($columnLetter, $currentRow)) {
// Unescape enclosures
$rowDatum = str_replace($escapeEnclosures, $this->_enclosure, $rowDatum);
$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);
if ($this->inputEncoding !== 'UTF-8') {
$rowDatum = PHPExcel_Shared_String::ConvertEncoding($rowDatum, 'UTF-8', $this->inputEncoding);
}
// Set cell value
@ -287,8 +300,8 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
// Close file
fclose($fileHandle);
if ($this->_contiguous) {
$this->_contiguousRow = $currentRow;
if ($this->contiguous) {
$this->contiguousRow = $currentRow;
}
ini_set('auto_detect_line_endings', $lineEnding);
@ -302,8 +315,9 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
*
* @return string
*/
public function getDelimiter() {
return $this->_delimiter;
public function getDelimiter()
{
return $this->delimiter;
}
/**
@ -312,8 +326,9 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* @param string $pValue Delimiter, defaults to ,
* @return PHPExcel_Reader_CSV
*/
public function setDelimiter($pValue = ',') {
$this->_delimiter = $pValue;
public function setDelimiter($pValue = ',')
{
$this->delimiter = $pValue;
return $this;
}
@ -322,8 +337,9 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
*
* @return string
*/
public function getEnclosure() {
return $this->_enclosure;
public function getEnclosure()
{
return $this->enclosure;
}
/**
@ -332,11 +348,12 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* @param string $pValue Enclosure, defaults to "
* @return PHPExcel_Reader_CSV
*/
public function setEnclosure($pValue = '"') {
public function setEnclosure($pValue = '"')
{
if ($pValue == '') {
$pValue = '"';
}
$this->_enclosure = $pValue;
$this->enclosure = $pValue;
return $this;
}
@ -345,8 +362,9 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
*
* @return integer
*/
public function getSheetIndex() {
return $this->_sheetIndex;
public function getSheetIndex()
{
return $this->sheetIndex;
}
/**
@ -355,8 +373,9 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* @param integer $pValue Sheet index
* @return PHPExcel_Reader_CSV
*/
public function setSheetIndex($pValue = 0) {
$this->_sheetIndex = $pValue;
public function setSheetIndex($pValue = 0)
{
$this->sheetIndex = $pValue;
return $this;
}
@ -365,11 +384,11 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
*
* @param boolean $contiguous
*/
public function setContiguous($contiguous = FALSE)
public function setContiguous($contiguous = false)
{
$this->_contiguous = (bool) $contiguous;
$this->contiguous = (bool) $contiguous;
if (!$contiguous) {
$this->_contiguousRow = -1;
$this->contiguousRow = -1;
}
return $this;
@ -380,8 +399,8 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
*
* @return boolean
*/
public function getContiguous() {
return $this->_contiguous;
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 - 2014 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 - 2014 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_Reader_DefaultReadFilter
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2014 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 $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 = '') {
public function readCell($column, $row, $worksheetName = '')
{
return true;
}
}

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_Excel2003XML
*
* Copyright (c) 2006 - 2014 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 +30,10 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2014 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_Reader_Excel2003XML
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
{
/**
@ -49,21 +41,21 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
*
* @var array
*/
protected $_styles = array();
protected $styles = array();
/**
* Character set used in the file
*
* @var string
*/
protected $_charSet = 'UTF-8';
protected $charSet = 'UTF-8';
/**
* Create a new PHPExcel_Reader_Excel2003XML
*/
public function __construct() {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
public function __construct()
{
$this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
}
@ -93,15 +85,15 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
);
// Open file
$this->_openFile($pFilename);
$fileHandle = $this->_fileHandle;
$this->openFile($pFilename);
$fileHandle = $this->fileHandle;
// Read sample data (first 2 KB will do)
$data = fread($fileHandle, 2048);
fclose($fileHandle);
$valid = true;
foreach($signature as $match) {
foreach ($signature as $match) {
// every part of the signature must be present
if (strpos($data, $match) === false) {
$valid = false;
@ -110,10 +102,10 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
}
// Retrieve charset encoding
if(preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/um',$data,$matches)) {
$this->_charSet = strtoupper($matches[1]);
if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/um', $data, $matches)) {
$this->charSet = strtoupper($matches[1]);
}
// echo 'Character Set is ',$this->_charSet,'<br />';
// echo 'Character Set is ', $this->charSet,'<br />';
return $valid;
}
@ -141,9 +133,9 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$namespaces = $xml->getNamespaces(true);
$xml_ss = $xml->children($namespaces['ss']);
foreach($xml_ss->Worksheet as $worksheet) {
foreach ($xml_ss->Worksheet as $worksheet) {
$worksheet_ss = $worksheet->attributes($namespaces['ss']);
$worksheetNames[] = self::_convertStringEncoding((string) $worksheet_ss['Name'],$this->_charSet);
$worksheetNames[] = self::convertStringEncoding((string) $worksheet_ss['Name'], $this->charSet);
}
return $worksheetNames;
@ -170,7 +162,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$worksheetID = 1;
$xml_ss = $xml->children($namespaces['ss']);
foreach($xml_ss->Worksheet as $worksheet) {
foreach ($xml_ss->Worksheet as $worksheet) {
$worksheet_ss = $worksheet->attributes($namespaces['ss']);
$tmpInfo = array();
@ -189,11 +181,11 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
if (isset($worksheet->Table->Row)) {
$rowIndex = 0;
foreach($worksheet->Table->Row as $rowData) {
foreach ($worksheet->Table->Row as $rowData) {
$columnIndex = 0;
$rowHasData = false;
foreach($rowData->Cell as $cell) {
foreach ($rowData->Cell as $cell) {
if (isset($cell->Data)) {
$tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex);
$rowHasData = true;
@ -238,10 +230,10 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
return $this->loadIntoExisting($pFilename, $objPHPExcel);
}
protected static function identifyFixedStyleValue($styleList,&$styleAttributeValue) {
protected static function identifyFixedStyleValue($styleList, &$styleAttributeValue)
{
$styleAttributeValue = strtolower($styleAttributeValue);
foreach($styleList as $style) {
foreach ($styleList as $style) {
if ($styleAttributeValue == strtolower($style)) {
$styleAttributeValue = $style;
return true;
@ -250,13 +242,13 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
return false;
}
/**
* pixel units to excel width units(units of 1/256th of a character width)
* @param pxs
* @return
*/
protected static function _pixel2WidthUnits($pxs) {
protected static function pixel2WidthUnits($pxs)
{
$UNIT_OFFSET_MAP = array(0, 36, 73, 109, 146, 182, 219);
$widthUnits = 256 * ($pxs / 7);
@ -264,25 +256,24 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
return $widthUnits;
}
/**
* excel width units(units of 1/256th of a character width) to pixel units
* @param widthUnits
* @return
*/
protected static function _widthUnits2Pixel($widthUnits) {
protected static function widthUnits2Pixel($widthUnits)
{
$pixels = ($widthUnits / 256) * 7;
$offsetWidthUnits = $widthUnits % 256;
$pixels += round($offsetWidthUnits / (256 / 7));
return $pixels;
}
protected static function _hex2str($hex) {
protected static function hex2str($hex)
{
return chr(hexdec($hex[1]));
}
/**
* Loads PHPExcel from file into PHPExcel instance
*
@ -321,7 +312,6 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$timezoneObj = new DateTimeZone('Europe/London');
$GMT = new DateTimeZone('UTC');
// Check if file exists
if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
@ -336,201 +326,197 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$docProps = $objPHPExcel->getProperties();
if (isset($xml->DocumentProperties[0])) {
foreach($xml->DocumentProperties[0] as $propertyName => $propertyValue) {
foreach ($xml->DocumentProperties[0] as $propertyName => $propertyValue) {
switch ($propertyName) {
case 'Title' :
$docProps->setTitle(self::_convertStringEncoding($propertyValue,$this->_charSet));
case 'Title':
$docProps->setTitle(self::convertStringEncoding($propertyValue, $this->charSet));
break;
case 'Subject' :
$docProps->setSubject(self::_convertStringEncoding($propertyValue,$this->_charSet));
case 'Subject':
$docProps->setSubject(self::convertStringEncoding($propertyValue, $this->charSet));
break;
case 'Author' :
$docProps->setCreator(self::_convertStringEncoding($propertyValue,$this->_charSet));
case 'Author':
$docProps->setCreator(self::convertStringEncoding($propertyValue, $this->charSet));
break;
case 'Created' :
case 'Created':
$creationDate = strtotime($propertyValue);
$docProps->setCreated($creationDate);
break;
case 'LastAuthor' :
$docProps->setLastModifiedBy(self::_convertStringEncoding($propertyValue,$this->_charSet));
case 'LastAuthor':
$docProps->setLastModifiedBy(self::convertStringEncoding($propertyValue, $this->charSet));
break;
case 'LastSaved' :
case 'LastSaved':
$lastSaveDate = strtotime($propertyValue);
$docProps->setModified($lastSaveDate);
break;
case 'Company' :
$docProps->setCompany(self::_convertStringEncoding($propertyValue,$this->_charSet));
case 'Company':
$docProps->setCompany(self::convertStringEncoding($propertyValue, $this->charSet));
break;
case 'Category' :
$docProps->setCategory(self::_convertStringEncoding($propertyValue,$this->_charSet));
case 'Category':
$docProps->setCategory(self::convertStringEncoding($propertyValue, $this->charSet));
break;
case 'Manager' :
$docProps->setManager(self::_convertStringEncoding($propertyValue,$this->_charSet));
case 'Manager':
$docProps->setManager(self::convertStringEncoding($propertyValue, $this->charSet));
break;
case 'Keywords' :
$docProps->setKeywords(self::_convertStringEncoding($propertyValue,$this->_charSet));
case 'Keywords':
$docProps->setKeywords(self::convertStringEncoding($propertyValue, $this->charSet));
break;
case 'Description' :
$docProps->setDescription(self::_convertStringEncoding($propertyValue,$this->_charSet));
case 'Description':
$docProps->setDescription(self::convertStringEncoding($propertyValue, $this->charSet));
break;
}
}
}
if (isset($xml->CustomDocumentProperties)) {
foreach($xml->CustomDocumentProperties[0] as $propertyName => $propertyValue) {
foreach ($xml->CustomDocumentProperties[0] as $propertyName => $propertyValue) {
$propertyAttributes = $propertyValue->attributes($namespaces['dt']);
$propertyName = preg_replace_callback('/_x([0-9a-z]{4})_/','PHPExcel_Reader_Excel2003XML::_hex2str',$propertyName);
$propertyName = preg_replace_callback('/_x([0-9a-z]{4})_/', 'PHPExcel_Reader_Excel2003XML::hex2str', $propertyName);
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_UNKNOWN;
switch((string) $propertyAttributes) {
case 'string' :
switch ((string) $propertyAttributes) {
case 'string':
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING;
$propertyValue = trim($propertyValue);
break;
case 'boolean' :
case 'boolean':
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN;
$propertyValue = (bool) $propertyValue;
break;
case 'integer' :
case 'integer':
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_INTEGER;
$propertyValue = intval($propertyValue);
break;
case 'float' :
case 'float':
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT;
$propertyValue = floatval($propertyValue);
break;
case 'dateTime.tz' :
case 'dateTime.tz':
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE;
$propertyValue = strtotime(trim($propertyValue));
break;
}
$docProps->setCustomProperty($propertyName,$propertyValue,$propertyType);
$docProps->setCustomProperty($propertyName, $propertyValue, $propertyType);
}
}
foreach($xml->Styles[0] as $style) {
foreach ($xml->Styles[0] as $style) {
$style_ss = $style->attributes($namespaces['ss']);
$styleID = (string) $style_ss['ID'];
// echo 'Style ID = '.$styleID.'<br />';
if ($styleID == 'Default') {
$this->_styles['Default'] = array();
} else {
$this->_styles[$styleID] = $this->_styles['Default'];
}
$this->styles[$styleID] = (isset($this->styles['Default'])) ? $this->styles['Default'] : array();
foreach ($style as $styleType => $styleData) {
$styleAttributes = $styleData->attributes($namespaces['ss']);
// echo $styleType.'<br />';
switch ($styleType) {
case 'Alignment' :
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
case 'Alignment':
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
$styleAttributeValue = (string) $styleAttributeValue;
switch ($styleAttributeKey) {
case 'Vertical' :
if (self::identifyFixedStyleValue($verticalAlignmentStyles,$styleAttributeValue)) {
$this->_styles[$styleID]['alignment']['vertical'] = $styleAttributeValue;
case 'Vertical':
if (self::identifyFixedStyleValue($verticalAlignmentStyles, $styleAttributeValue)) {
$this->styles[$styleID]['alignment']['vertical'] = $styleAttributeValue;
}
break;
case 'Horizontal' :
if (self::identifyFixedStyleValue($horizontalAlignmentStyles,$styleAttributeValue)) {
$this->_styles[$styleID]['alignment']['horizontal'] = $styleAttributeValue;
case 'Horizontal':
if (self::identifyFixedStyleValue($horizontalAlignmentStyles, $styleAttributeValue)) {
$this->styles[$styleID]['alignment']['horizontal'] = $styleAttributeValue;
}
break;
case 'WrapText' :
$this->_styles[$styleID]['alignment']['wrap'] = true;
case 'WrapText':
$this->styles[$styleID]['alignment']['wrap'] = true;
break;
}
}
break;
case 'Borders' :
foreach($styleData->Border as $borderStyle) {
case 'Borders':
foreach ($styleData->Border as $borderStyle) {
$borderAttributes = $borderStyle->attributes($namespaces['ss']);
$thisBorder = array();
foreach($borderAttributes as $borderStyleKey => $borderStyleValue) {
foreach ($borderAttributes as $borderStyleKey => $borderStyleValue) {
// echo $borderStyleKey.' = '.$borderStyleValue.'<br />';
switch ($borderStyleKey) {
case 'LineStyle' :
case 'LineStyle':
$thisBorder['style'] = PHPExcel_Style_Border::BORDER_MEDIUM;
// $thisBorder['style'] = $borderStyleValue;
break;
case 'Weight' :
case 'Weight':
// $thisBorder['style'] = $borderStyleValue;
break;
case 'Position' :
case 'Position':
$borderPosition = strtolower($borderStyleValue);
break;
case 'Color' :
$borderColour = substr($borderStyleValue,1);
case 'Color':
$borderColour = substr($borderStyleValue, 1);
$thisBorder['color']['rgb'] = $borderColour;
break;
}
}
if (!empty($thisBorder)) {
if (($borderPosition == 'left') || ($borderPosition == 'right') || ($borderPosition == 'top') || ($borderPosition == 'bottom')) {
$this->_styles[$styleID]['borders'][$borderPosition] = $thisBorder;
$this->styles[$styleID]['borders'][$borderPosition] = $thisBorder;
}
}
}
break;
case 'Font' :
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
case 'Font':
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
$styleAttributeValue = (string) $styleAttributeValue;
switch ($styleAttributeKey) {
case 'FontName' :
$this->_styles[$styleID]['font']['name'] = $styleAttributeValue;
case 'FontName':
$this->styles[$styleID]['font']['name'] = $styleAttributeValue;
break;
case 'Size' :
$this->_styles[$styleID]['font']['size'] = $styleAttributeValue;
case 'Size':
$this->styles[$styleID]['font']['size'] = $styleAttributeValue;
break;
case 'Color' :
$this->_styles[$styleID]['font']['color']['rgb'] = substr($styleAttributeValue,1);
case 'Color':
$this->styles[$styleID]['font']['color']['rgb'] = substr($styleAttributeValue, 1);
break;
case 'Bold' :
$this->_styles[$styleID]['font']['bold'] = true;
case 'Bold':
$this->styles[$styleID]['font']['bold'] = true;
break;
case 'Italic' :
$this->_styles[$styleID]['font']['italic'] = true;
case 'Italic':
$this->styles[$styleID]['font']['italic'] = true;
break;
case 'Underline' :
if (self::identifyFixedStyleValue($underlineStyles,$styleAttributeValue)) {
$this->_styles[$styleID]['font']['underline'] = $styleAttributeValue;
case 'Underline':
if (self::identifyFixedStyleValue($underlineStyles, $styleAttributeValue)) {
$this->styles[$styleID]['font']['underline'] = $styleAttributeValue;
}
break;
}
}
break;
case 'Interior' :
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
case 'Interior':
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
switch ($styleAttributeKey) {
case 'Color' :
$this->_styles[$styleID]['fill']['color']['rgb'] = substr($styleAttributeValue,1);
case 'Color':
$this->styles[$styleID]['fill']['color']['rgb'] = substr($styleAttributeValue, 1);
break;
}
}
break;
case 'NumberFormat' :
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
case 'NumberFormat':
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
$styleAttributeValue = str_replace($fromFormats,$toFormats,$styleAttributeValue);
$styleAttributeValue = str_replace($fromFormats, $toFormats, $styleAttributeValue);
switch ($styleAttributeValue) {
case 'Short Date' :
case 'Short Date':
$styleAttributeValue = 'dd/mm/yyyy';
break;
}
if ($styleAttributeValue > '') {
$this->_styles[$styleID]['numberformat']['code'] = $styleAttributeValue;
$this->styles[$styleID]['numberformat']['code'] = $styleAttributeValue;
}
}
break;
case 'Protection' :
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
case 'Protection':
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
}
break;
}
}
// print_r($this->_styles[$styleID]);
// print_r($this->styles[$styleID]);
// echo '<hr />';
}
// echo '<hr />';
@ -538,30 +524,30 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$worksheetID = 0;
$xml_ss = $xml->children($namespaces['ss']);
foreach($xml_ss->Worksheet as $worksheet) {
foreach ($xml_ss->Worksheet as $worksheet) {
$worksheet_ss = $worksheet->attributes($namespaces['ss']);
if ((isset($this->_loadSheetsOnly)) && (isset($worksheet_ss['Name'])) &&
(!in_array($worksheet_ss['Name'], $this->_loadSheetsOnly))) {
if ((isset($this->loadSheetsOnly)) && (isset($worksheet_ss['Name'])) &&
(!in_array($worksheet_ss['Name'], $this->loadSheetsOnly))) {
continue;
}
// echo '<h3>Worksheet: ',$worksheet_ss['Name'],'<h3>';
// echo '<h3>Worksheet: ', $worksheet_ss['Name'],'<h3>';
//
// Create new Worksheet
$objPHPExcel->createSheet();
$objPHPExcel->setActiveSheetIndex($worksheetID);
if (isset($worksheet_ss['Name'])) {
$worksheetName = self::_convertStringEncoding((string) $worksheet_ss['Name'],$this->_charSet);
$worksheetName = self::convertStringEncoding((string) $worksheet_ss['Name'], $this->charSet);
// Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in
// formula cells... during the load, all formulae should be correct, and we're simply bringing
// the worksheet name in line with the formula, not the reverse
$objPHPExcel->getActiveSheet()->setTitle($worksheetName,false);
$objPHPExcel->getActiveSheet()->setTitle($worksheetName, false);
}
$columnID = 'A';
if (isset($worksheet->Table->Column)) {
foreach($worksheet->Table->Column as $columnData) {
foreach ($worksheet->Table->Column as $columnData) {
$columnData_ss = $columnData->attributes($namespaces['ss']);
if (isset($columnData_ss['Index'])) {
$columnID = PHPExcel_Cell::stringFromColumnIndex($columnData_ss['Index']-1);
@ -578,7 +564,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$rowID = 1;
if (isset($worksheet->Table->Row)) {
$additionalMergedCells = 0;
foreach($worksheet->Table->Row as $rowData) {
foreach ($worksheet->Table->Row as $rowData) {
$rowHasData = false;
$row_ss = $rowData->attributes($namespaces['ss']);
if (isset($row_ss['Index'])) {
@ -587,15 +573,14 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
// echo '<b>Row '.$rowID.'</b><br />';
$columnID = 'A';
foreach($rowData->Cell as $cell) {
foreach ($rowData->Cell as $cell) {
$cell_ss = $cell->attributes($namespaces['ss']);
if (isset($cell_ss['Index'])) {
$columnID = PHPExcel_Cell::stringFromColumnIndex($cell_ss['Index']-1);
}
$cellRange = $columnID.$rowID;
if ($this->getReadFilter() !== NULL) {
if ($this->getReadFilter() !== null) {
if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
continue;
}
@ -642,26 +627,26 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
const TYPE_INLINE = 'inlineStr';
const TYPE_ERROR = 'e';
*/
case 'String' :
$cellValue = self::_convertStringEncoding($cellValue,$this->_charSet);
case 'String':
$cellValue = self::convertStringEncoding($cellValue, $this->charSet);
$type = PHPExcel_Cell_DataType::TYPE_STRING;
break;
case 'Number' :
case 'Number':
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$cellValue = (float) $cellValue;
if (floor($cellValue) == $cellValue) {
$cellValue = (integer) $cellValue;
}
break;
case 'Boolean' :
case 'Boolean':
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
$cellValue = ($cellValue != 0);
break;
case 'DateTime' :
case 'DateTime':
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$cellValue = PHPExcel_Shared_Date::PHPToExcel(strtotime($cellValue));
break;
case 'Error' :
case 'Error':
$type = PHPExcel_Cell_DataType::TYPE_ERROR;
break;
}
@ -671,58 +656,66 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
// echo 'FORMULA<br />';
$type = PHPExcel_Cell_DataType::TYPE_FORMULA;
$columnNumber = PHPExcel_Cell::columnIndexFromString($columnID);
if (substr($cellDataFormula,0,3) == 'of:') {
$cellDataFormula = substr($cellDataFormula,3);
// echo 'Before: ',$cellDataFormula,'<br />';
$temp = explode('"',$cellDataFormula);
if (substr($cellDataFormula, 0, 3) == 'of:') {
$cellDataFormula = substr($cellDataFormula, 3);
// echo 'Before: ', $cellDataFormula,'<br />';
$temp = explode('"', $cellDataFormula);
$key = false;
foreach($temp as &$value) {
foreach ($temp as &$value) {
// Only replace in alternate array entries (i.e. non-quoted blocks)
if ($key = !$key) {
$value = str_replace(array('[.','.',']'),'',$value);
$value = str_replace(array('[.', '.', ']'), '', $value);
}
}
} else {
// Convert R1C1 style references to A1 style references (but only when not quoted)
// echo 'Before: ',$cellDataFormula,'<br />';
$temp = explode('"',$cellDataFormula);
// echo 'Before: ', $cellDataFormula,'<br />';
$temp = explode('"', $cellDataFormula);
$key = false;
foreach($temp as &$value) {
foreach ($temp as &$value) {
// Only replace in alternate array entries (i.e. non-quoted blocks)
if ($key = !$key) {
preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/',$value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE);
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) {
foreach ($cellReferences as $cellReference) {
$rowReference = $cellReference[2][0];
// Empty R reference is the current row
if ($rowReference == '') $rowReference = $rowID;
if ($rowReference == '') {
$rowReference = $rowID;
}
// Bracketed R references are relative to the current row
if ($rowReference{0} == '[') $rowReference = $rowID + trim($rowReference,'[]');
if ($rowReference{0} == '[') {
$rowReference = $rowID + trim($rowReference, '[]');
}
$columnReference = $cellReference[4][0];
// Empty C reference is the current column
if ($columnReference == '') $columnReference = $columnNumber;
if ($columnReference == '') {
$columnReference = $columnNumber;
}
// Bracketed C references are relative to the current column
if ($columnReference{0} == '[') $columnReference = $columnNumber + trim($columnReference,'[]');
if ($columnReference{0} == '[') {
$columnReference = $columnNumber + trim($columnReference, '[]');
}
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference;
$value = substr_replace($value,$A1CellReference,$cellReference[0][1],strlen($cellReference[0][0]));
$value = substr_replace($value, $A1CellReference, $cellReference[0][1], strlen($cellReference[0][0]));
}
}
}
}
unset($value);
// Then rebuild the formula string
$cellDataFormula = implode('"',$temp);
// echo 'After: ',$cellDataFormula,'<br />';
$cellDataFormula = implode('"', $temp);
// echo 'After: ', $cellDataFormula,'<br />';
}
// echo 'Cell '.$columnID.$rowID.' is a '.$type.' with a value of '.(($hasCalculatedValue) ? $cellDataFormula : $cellValue).'<br />';
//
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $cellValue),$type);
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $cellValue), $type);
if ($hasCalculatedValue) {
// echo 'Formula result is '.$cellValue.'<br />';
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setCalculatedValue($cellValue);
@ -736,29 +729,27 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$author = 'unknown';
if (isset($commentAttributes->Author)) {
$author = (string)$commentAttributes->Author;
// echo 'Author: ',$author,'<br />';
// echo 'Author: ', $author,'<br />';
}
$node = $cell->Comment->Data->asXML();
// $annotation = str_replace('html:','',substr($node,49,-10));
// echo $annotation,'<br />';
$annotation = strip_tags($node);
// echo 'Annotation: ',$annotation,'<br />';
$objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID )
->setAuthor(self::_convertStringEncoding($author ,$this->_charSet))
->setText($this->_parseRichText($annotation) );
// echo 'Annotation: ', $annotation,'<br />';
$objPHPExcel->getActiveSheet()->getComment($columnID.$rowID)->setAuthor(self::convertStringEncoding($author, $this->charSet))->setText($this->parseRichText($annotation));
}
if (($cellIsSet) && (isset($cell_ss['StyleID']))) {
$style = (string) $cell_ss['StyleID'];
// echo 'Cell style for '.$columnID.$rowID.' is '.$style.'<br />';
if ((isset($this->_styles[$style])) && (!empty($this->_styles[$style]))) {
if ((isset($this->styles[$style])) && (!empty($this->styles[$style]))) {
// echo 'Cell '.$columnID.$rowID.'<br />';
// print_r($this->_styles[$style]);
// print_r($this->styles[$style]);
// echo '<br />';
if (!$objPHPExcel->getActiveSheet()->cellExists($columnID.$rowID)) {
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValue(NULL);
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValue(null);
}
$objPHPExcel->getActiveSheet()->getStyle($cellRange)->applyFromArray($this->_styles[$style]);
$objPHPExcel->getActiveSheet()->getStyle($cellRange)->applyFromArray($this->styles[$style]);
}
}
++$columnID;
@ -790,20 +781,21 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
}
protected static function _convertStringEncoding($string,$charset) {
protected static function convertStringEncoding($string, $charset)
{
if ($charset != 'UTF-8') {
return PHPExcel_Shared_String::ConvertEncoding($string,'UTF-8',$charset);
return PHPExcel_Shared_String::ConvertEncoding($string, 'UTF-8', $charset);
}
return $string;
}
protected function _parseRichText($is = '') {
protected function parseRichText($is = '')
{
$value = new PHPExcel_RichText();
$value->createText(self::_convertStringEncoding($is,$this->_charSet));
$value->createText(self::convertStringEncoding($is, $this->charSet));
return $value;
}
}

File diff suppressed because it is too large Load diff

View file

@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 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_Reader_Excel2007
* @copyright Copyright (c) 2006 - 2014 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##
*/
@ -30,11 +30,12 @@
*
* @category PHPExcel
* @package PHPExcel_Reader_Excel2007
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_Excel2007_Chart
{
private static function _getAttribute($component, $name, $format) {
private static function getAttribute($component, $name, $format)
{
$attributes = $component->attributes();
if (isset($attributes[$name])) {
if ($format == 'string') {
@ -48,145 +49,146 @@ class PHPExcel_Reader_Excel2007_Chart
}
}
return null;
} // function _getAttribute()
}
private static function _readColor($color,$background=false) {
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();
} elseif (isset($color["indexed"])) {
return PHPExcel_Style_Color::indexedColor($color["indexed"]-7, $background)->getARGB();
}
}
public static function readChart($chartElements,$chartName) {
public static function readChart($chartElements, $chartName)
{
$namespacesChartMeta = $chartElements->getNamespaces(true);
$chartElementsC = $chartElements->children($namespacesChartMeta['c']);
$XaxisLabel = $YaxisLabel = $legend = $title = NULL;
$dispBlanksAs = $plotVisOnly = NULL;
$XaxisLabel = $YaxisLabel = $legend = $title = null;
$dispBlanksAs = $plotVisOnly = null;
foreach($chartElementsC as $chartElementKey => $chartElement) {
foreach ($chartElementsC as $chartElementKey => $chartElement) {
switch ($chartElementKey) {
case "chart":
foreach($chartElement as $chartDetailsKey => $chartDetails) {
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) {
foreach ($chartDetails as $chartDetailKey => $chartDetail) {
switch ($chartDetailKey) {
case "layout":
$plotAreaLayout = self::_chartLayoutDetails($chartDetail,$namespacesChartMeta,'plotArea');
$plotAreaLayout = self::chartLayoutDetails($chartDetail, $namespacesChartMeta, 'plotArea');
break;
case "catAx":
if (isset($chartDetail->title)) {
$XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']),$namespacesChartMeta,'cat');
$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');
$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');
$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);
$barDirection = self::getAttribute($chartDetail->barDir, 'val', 'string');
$plotSer = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotDirection($barDirection);
$plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail);
$plotAttributes = self::readChartAttributes($chartDetail);
break;
case "lineChart":
case "line3DChart":
$plotSeries[] = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
$plotAttributes = self::_readChartAttributes($chartDetail);
$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);
$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 = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($explosion);
$plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail);
$plotAttributes = self::readChartAttributes($chartDetail);
break;
case "scatterChart":
$scatterStyle = self::_getAttribute($chartDetail->scatterStyle, 'val', 'string');
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
$scatterStyle = self::getAttribute($chartDetail->scatterStyle, 'val', 'string');
$plotSer = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($scatterStyle);
$plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail);
$plotAttributes = self::readChartAttributes($chartDetail);
break;
case "bubbleChart":
$bubbleScale = self::_getAttribute($chartDetail->bubbleScale, 'val', 'integer');
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
$bubbleScale = self::getAttribute($chartDetail->bubbleScale, 'val', 'integer');
$plotSer = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($bubbleScale);
$plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail);
$plotAttributes = self::readChartAttributes($chartDetail);
break;
case "radarChart":
$radarStyle = self::_getAttribute($chartDetail->radarStyle, 'val', 'string');
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
$radarStyle = self::getAttribute($chartDetail->radarStyle, 'val', 'string');
$plotSer = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($radarStyle);
$plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail);
$plotAttributes = self::readChartAttributes($chartDetail);
break;
case "surfaceChart":
case "surface3DChart":
$wireFrame = self::_getAttribute($chartDetail->wireframe, 'val', 'boolean');
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
$wireFrame = self::getAttribute($chartDetail->wireframe, 'val', 'boolean');
$plotSer = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($wireFrame);
$plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail);
$plotAttributes = self::readChartAttributes($chartDetail);
break;
case "stockChart":
$plotSeries[] = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
$plotAttributes = self::_readChartAttributes($plotAreaLayout);
$plotSeries[] = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotAttributes = self::readChartAttributes($plotAreaLayout);
break;
}
}
if ($plotAreaLayout == NULL) {
if ($plotAreaLayout == null) {
$plotAreaLayout = new PHPExcel_Chart_Layout();
}
$plotArea = new PHPExcel_Chart_PlotArea($plotAreaLayout,$plotSeries);
self::_setChartAttributes($plotAreaLayout,$plotAttributes);
$plotArea = new PHPExcel_Chart_PlotArea($plotAreaLayout, $plotSeries);
self::setChartAttributes($plotAreaLayout, $plotAttributes);
break;
case "plotVisOnly":
$plotVisOnly = self::_getAttribute($chartDetails, 'val', 'string');
$plotVisOnly = self::getAttribute($chartDetails, 'val', 'string');
break;
case "dispBlanksAs":
$dispBlanksAs = self::_getAttribute($chartDetails, 'val', 'string');
$dispBlanksAs = self::getAttribute($chartDetails, 'val', 'string');
break;
case "title":
$title = self::_chartTitle($chartDetails,$namespacesChartMeta,'title');
$title = self::chartTitle($chartDetails, $namespacesChartMeta, 'title');
break;
case "legend":
$legendPos = 'r';
$legendLayout = null;
$legendOverlay = false;
foreach($chartDetails as $chartDetailKey => $chartDetail) {
foreach ($chartDetails as $chartDetailKey => $chartDetail) {
switch ($chartDetailKey) {
case "legendPos":
$legendPos = self::_getAttribute($chartDetail, 'val', 'string');
$legendPos = self::getAttribute($chartDetail, 'val', 'string');
break;
case "overlay":
$legendOverlay = self::_getAttribute($chartDetail, 'val', 'boolean');
$legendOverlay = self::getAttribute($chartDetail, 'val', 'boolean');
break;
case "layout":
$legendLayout = self::_chartLayoutDetails($chartDetail,$namespacesChartMeta,'legend');
$legendLayout = self::chartLayoutDetails($chartDetail, $namespacesChartMeta, 'legend');
break;
}
}
@ -196,38 +198,38 @@ class PHPExcel_Reader_Excel2007_Chart
}
}
}
$chart = new PHPExcel_Chart($chartName,$title,$legend,$plotArea,$plotVisOnly,$dispBlanksAs,$XaxisLabel,$YaxisLabel);
$chart = new PHPExcel_Chart($chartName, $title, $legend, $plotArea, $plotVisOnly, $dispBlanksAs, $XaxisLabel, $YaxisLabel);
return $chart;
} // function readChart()
}
private static function _chartTitle($titleDetails,$namespacesChartMeta,$type) {
private static function chartTitle($titleDetails, $namespacesChartMeta, $type)
{
$caption = array();
$titleLayout = null;
foreach($titleDetails as $titleDetailKey => $chartDetail) {
foreach ($titleDetails as $titleDetailKey => $chartDetail) {
switch ($titleDetailKey) {
case "tx":
$titleDetails = $chartDetail->rich->children($namespacesChartMeta['a']);
foreach($titleDetails as $titleKey => $titleDetail) {
foreach ($titleDetails as $titleKey => $titleDetail) {
switch ($titleKey) {
case "p":
$titleDetailPart = $titleDetail->children($namespacesChartMeta['a']);
$caption[] = self::_parseRichText($titleDetailPart);
$caption[] = self::parseRichText($titleDetailPart);
}
}
break;
case "layout":
$titleLayout = self::_chartLayoutDetails($chartDetail,$namespacesChartMeta);
$titleLayout = self::chartLayoutDetails($chartDetail, $namespacesChartMeta);
break;
}
}
return new PHPExcel_Chart_Title($caption, $titleLayout);
} // function _chartTitle()
}
private static function _chartLayoutDetails($chartDetail,$namespacesChartMeta) {
private static function chartLayoutDetails($chartDetail, $namespacesChartMeta)
{
if (!isset($chartDetail->manualLayout)) {
return null;
}
@ -236,108 +238,110 @@ class PHPExcel_Reader_Excel2007_Chart
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');
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 _chartDataSeries($chartDetail,$namespacesChartMeta,$plotType) {
$multiSeriesType = NULL;
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) {
foreach ($seriesDetailSet as $seriesDetailKey => $seriesDetails) {
switch ($seriesDetailKey) {
case "grouping":
$multiSeriesType = self::_getAttribute($chartDetail->grouping, 'val', 'string');
$multiSeriesType = self::getAttribute($chartDetail->grouping, 'val', 'string');
break;
case "ser":
$marker = NULL;
foreach($seriesDetails as $seriesKey => $seriesDetail) {
$marker = null;
foreach ($seriesDetails as $seriesKey => $seriesDetail) {
switch ($seriesKey) {
case "idx":
$seriesIndex = self::_getAttribute($seriesDetail, 'val', 'integer');
$seriesIndex = self::getAttribute($seriesDetail, 'val', 'integer');
break;
case "order":
$seriesOrder = self::_getAttribute($seriesDetail, 'val', 'integer');
$seriesOrder = self::getAttribute($seriesDetail, 'val', 'integer');
$plotOrder[$seriesIndex] = $seriesOrder;
break;
case "tx":
$seriesLabel[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta);
$seriesLabel[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta);
break;
case "marker":
$marker = self::_getAttribute($seriesDetail->symbol, 'val', 'string');
$marker = self::getAttribute($seriesDetail->symbol, 'val', 'string');
break;
case "smooth":
$smoothLine = self::_getAttribute($seriesDetail, 'val', 'boolean');
$smoothLine = self::getAttribute($seriesDetail, 'val', 'boolean');
break;
case "cat":
$seriesCategory[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta);
$seriesCategory[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta);
break;
case "val":
$seriesValues[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta,$marker);
$seriesValues[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
break;
case "xVal":
$seriesCategory[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta,$marker);
$seriesCategory[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
break;
case "yVal":
$seriesValues[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta,$marker);
$seriesValues[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
break;
}
}
}
}
return new PHPExcel_Chart_DataSeries($plotType,$multiSeriesType,$plotOrder,$seriesLabel,$seriesCategory,$seriesValues,$smoothLine);
} // function _chartDataSeries()
return new PHPExcel_Chart_DataSeries($plotType, $multiSeriesType, $plotOrder, $seriesLabel, $seriesCategory, $seriesValues, $smoothLine);
}
private static function _chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker = null, $smoothLine = false) {
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');
$seriesData = self::chartDataSeriesValues($seriesDetail->strRef->strCache->children($namespacesChartMeta['c']), 's');
return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
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']));
$seriesData = self::chartDataSeriesValues($seriesDetail->numRef->numCache->children($namespacesChartMeta['c']));
return new PHPExcel_Chart_DataSeriesValues('Number',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
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 = self::chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlStrRef->multiLvlStrCache->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 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 = 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 new PHPExcel_Chart_DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine);
}
return null;
} // function _chartDataSeriesValueSet()
}
private static function _chartDataSeriesValues($seriesValueSet,$dataType='n') {
private static function chartDataSeriesValues($seriesValueSet, $dataType = 'n')
{
$seriesVal = array();
$formatCode = '';
$pointCount = 0;
foreach($seriesValueSet as $seriesValueIdx => $seriesValue) {
foreach ($seriesValueSet as $seriesValueIdx => $seriesValue) {
switch ($seriesValueIdx) {
case 'ptCount':
$pointCount = self::_getAttribute($seriesValue, 'val', 'integer');
$pointCount = self::getAttribute($seriesValue, 'val', 'integer');
break;
case 'formatCode':
$formatCode = (string) $seriesValue;
break;
case 'pt':
$pointVal = self::_getAttribute($seriesValue, 'idx', 'integer');
$pointVal = self::getAttribute($seriesValue, 'idx', 'integer');
if ($dataType == 's') {
$seriesVal[$pointVal] = (string) $seriesValue->v;
} else {
@ -347,33 +351,30 @@ class PHPExcel_Reader_Excel2007_Chart
}
}
if (empty($seriesVal)) {
$seriesVal = NULL;
}
return array( 'formatCode' => $formatCode,
return array(
'formatCode' => $formatCode,
'pointCount' => $pointCount,
'dataValues' => $seriesVal
);
} // function _chartDataSeriesValues()
}
private static function _chartDataSeriesValuesMultiLevel($seriesValueSet,$dataType='n') {
private static function chartDataSeriesValuesMultiLevel($seriesValueSet, $dataType = 'n')
{
$seriesVal = array();
$formatCode = '';
$pointCount = 0;
foreach($seriesValueSet->lvl as $seriesLevelIdx => $seriesLevel) {
foreach($seriesLevel as $seriesValueIdx => $seriesValue) {
foreach ($seriesValueSet->lvl as $seriesLevelIdx => $seriesLevel) {
foreach ($seriesLevel as $seriesValueIdx => $seriesValue) {
switch ($seriesValueIdx) {
case 'ptCount':
$pointCount = self::_getAttribute($seriesValue, 'val', 'integer');
$pointCount = self::getAttribute($seriesValue, 'val', 'integer');
break;
case 'formatCode':
$formatCode = (string) $seriesValue;
break;
case 'pt':
$pointVal = self::_getAttribute($seriesValue, 'idx', 'integer');
$pointVal = self::getAttribute($seriesValue, 'idx', 'integer');
if ($dataType == 's') {
$seriesVal[$pointVal][] = (string) $seriesValue->v;
} else {
@ -384,65 +385,67 @@ class PHPExcel_Reader_Excel2007_Chart
}
}
return array( 'formatCode' => $formatCode,
return array(
'formatCode' => $formatCode,
'pointCount' => $pointCount,
'dataValues' => $seriesVal
);
} // function _chartDataSeriesValuesMultiLevel()
}
private static function _parseRichText($titleDetailPart = null) {
private static function parseRichText($titleDetailPart = null)
{
$value = new PHPExcel_RichText();
foreach($titleDetailPart as $titleDetailElementKey => $titleDetailElement) {
foreach ($titleDetailPart as $titleDetailElementKey => $titleDetailElement) {
if (isset($titleDetailElement->t)) {
$objText = $value->createTextRun( (string) $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'));
$fontSize = (self::getAttribute($titleDetailElement->rPr, 'sz', 'integer'));
if (!is_null($fontSize)) {
$objText->getFont()->setSize(floor($fontSize / 100));
}
$fontColor = (self::_getAttribute($titleDetailElement->rPr, 'color', 'string'));
$fontColor = (self::getAttribute($titleDetailElement->rPr, 'color', 'string'));
if (!is_null($fontColor)) {
$objText->getFont()->setColor( new PHPExcel_Style_Color( self::_readColor($fontColor) ) );
$objText->getFont()->setColor(new PHPExcel_Style_Color(self::readColor($fontColor)));
}
$bold = self::_getAttribute($titleDetailElement->rPr, 'b', 'boolean');
$bold = self::getAttribute($titleDetailElement->rPr, 'b', 'boolean');
if (!is_null($bold)) {
$objText->getFont()->setBold($bold);
}
$italic = self::_getAttribute($titleDetailElement->rPr, 'i', 'boolean');
$italic = self::getAttribute($titleDetailElement->rPr, 'i', 'boolean');
if (!is_null($italic)) {
$objText->getFont()->setItalic($italic);
}
$baseline = self::_getAttribute($titleDetailElement->rPr, 'baseline', 'integer');
$baseline = self::getAttribute($titleDetailElement->rPr, 'baseline', 'integer');
if (!is_null($baseline)) {
if ($baseline > 0) {
$objText->getFont()->setSuperScript(true);
} elseif($baseline < 0) {
} elseif ($baseline < 0) {
$objText->getFont()->setSubScript(true);
}
}
$underscore = (self::_getAttribute($titleDetailElement->rPr, 'u', 'string'));
$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') {
} 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'));
$strikethrough = (self::getAttribute($titleDetailElement->rPr, 's', 'string'));
if (!is_null($strikethrough)) {
if ($strikethrough == 'noStrike') {
$objText->getFont()->setStrikethrough(false);
@ -456,62 +459,62 @@ class PHPExcel_Reader_Excel2007_Chart
return $value;
}
private static function _readChartAttributes($chartDetail) {
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');
$plotAttributes['showLegendKey'] = self::getAttribute($chartDetail->dLbls->showLegendKey, 'val', 'string');
}
if (isset($chartDetail->dLbls->showVal)) {
$plotAttributes['showVal'] = self::_getAttribute($chartDetail->dLbls->showVal, 'val', 'string');
$plotAttributes['showVal'] = self::getAttribute($chartDetail->dLbls->showVal, 'val', 'string');
}
if (isset($chartDetail->dLbls->showCatName)) {
$plotAttributes['showCatName'] = self::_getAttribute($chartDetail->dLbls->showCatName, 'val', 'string');
$plotAttributes['showCatName'] = self::getAttribute($chartDetail->dLbls->showCatName, 'val', 'string');
}
if (isset($chartDetail->dLbls->showSerName)) {
$plotAttributes['showSerName'] = self::_getAttribute($chartDetail->dLbls->showSerName, 'val', 'string');
$plotAttributes['showSerName'] = self::getAttribute($chartDetail->dLbls->showSerName, 'val', 'string');
}
if (isset($chartDetail->dLbls->showPercent)) {
$plotAttributes['showPercent'] = self::_getAttribute($chartDetail->dLbls->showPercent, 'val', 'string');
$plotAttributes['showPercent'] = self::getAttribute($chartDetail->dLbls->showPercent, 'val', 'string');
}
if (isset($chartDetail->dLbls->showBubbleSize)) {
$plotAttributes['showBubbleSize'] = self::_getAttribute($chartDetail->dLbls->showBubbleSize, 'val', 'string');
$plotAttributes['showBubbleSize'] = self::getAttribute($chartDetail->dLbls->showBubbleSize, 'val', 'string');
}
if (isset($chartDetail->dLbls->showLeaderLines)) {
$plotAttributes['showLeaderLines'] = self::_getAttribute($chartDetail->dLbls->showLeaderLines, 'val', 'string');
$plotAttributes['showLeaderLines'] = self::getAttribute($chartDetail->dLbls->showLeaderLines, 'val', 'string');
}
}
return $plotAttributes;
}
private static function _setChartAttributes($plotArea,$plotAttributes)
private static function setChartAttributes($plotArea, $plotAttributes)
{
foreach($plotAttributes as $plotAttributeKey => $plotAttributeValue) {
switch($plotAttributeKey) {
case 'showLegendKey' :
foreach ($plotAttributes as $plotAttributeKey => $plotAttributeValue) {
switch ($plotAttributeKey) {
case 'showLegendKey':
$plotArea->setShowLegendKey($plotAttributeValue);
break;
case 'showVal' :
case 'showVal':
$plotArea->setShowVal($plotAttributeValue);
break;
case 'showCatName' :
case 'showCatName':
$plotArea->setShowCatName($plotAttributeValue);
break;
case 'showSerName' :
case 'showSerName':
$plotArea->setShowSerName($plotAttributeValue);
break;
case 'showPercent' :
case 'showPercent':
$plotArea->setShowPercent($plotAttributeValue);
break;
case 'showBubbleSize' :
case 'showBubbleSize':
$plotArea->setShowBubbleSize($plotAttributeValue);
break;
case 'showLeaderLines' :
case 'showLeaderLines':
$plotArea->setShowLeaderLines($plotAttributeValue);
break;
}
}
}
}

View file

@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 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_Reader_Excel2007
* @copyright Copyright (c) 2006 - 2014 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 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel_Reader_Excel2007
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_Excel2007_Theme
{
@ -40,21 +40,21 @@ class PHPExcel_Reader_Excel2007_Theme
*
* @var string
*/
private $_themeName;
private $themeName;
/**
* Colour Scheme Name
*
* @var string
*/
private $_colourSchemeName;
private $colourSchemeName;
/**
* Colour Map indexed by position
*
* @var array of string
*/
private $_colourMapValues;
private $colourMapValues;
/**
@ -62,19 +62,19 @@ class PHPExcel_Reader_Excel2007_Theme
*
* @var array of string
*/
private $_colourMap;
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;
$this->themeName = $themeName;
$this->colourSchemeName = $colourSchemeName;
$this->colourMap = $colourMap;
}
/**
@ -84,7 +84,7 @@ class PHPExcel_Reader_Excel2007_Theme
*/
public function getThemeName()
{
return $this->_themeName;
return $this->themeName;
}
/**
@ -92,8 +92,9 @@ class PHPExcel_Reader_Excel2007_Theme
*
* @return string
*/
public function getColourSchemeName() {
return $this->_colourSchemeName;
public function getColourSchemeName()
{
return $this->colourSchemeName;
}
/**
@ -101,9 +102,10 @@ class PHPExcel_Reader_Excel2007_Theme
*
* @return string
*/
public function getColourByIndex($index=0) {
if (isset($this->_colourMap[$index])) {
return $this->_colourMap[$index];
public function getColourByIndex($index = 0)
{
if (isset($this->colourMap[$index])) {
return $this->colourMap[$index];
}
return null;
}
@ -111,7 +113,8 @@ class PHPExcel_Reader_Excel2007_Theme
/**
* 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)) && ($key != '_parent')) {

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;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Reader_Excel5_Escher
*
* Copyright (c) 2006 - 2014 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,18 +21,10 @@
*
* @category PHPExcel
* @package PHPExcel_Reader_Excel5
* @copyright Copyright (c) 2006 - 2014 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_Reader_Excel5_Escher
*
* @category PHPExcel
* @package PHPExcel_Reader_Excel5
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_Excel5_Escher
{
const DGGCONTAINER = 0xF000;
@ -58,28 +51,28 @@ class PHPExcel_Reader_Excel5_Escher
*
* @var string
*/
private $_data;
private $data;
/**
* Size in bytes of the Escher stream data
*
* @var int
*/
private $_dataSize;
private $dataSize;
/**
* Current position of stream pointer in Escher stream data
*
* @var int
*/
private $_pos;
private $pos;
/**
* The object to be returned by the reader. Modified during load.
*
* @var mixed
*/
private $_object;
private $object;
/**
* Create a new PHPExcel_Reader_Excel5_Escher instance
@ -88,7 +81,7 @@ class PHPExcel_Reader_Excel5_Escher
*/
public function __construct($object)
{
$this->_object = $object;
$this->object = $object;
}
/**
@ -98,80 +91,117 @@ class PHPExcel_Reader_Excel5_Escher
*/
public function load($data)
{
$this->_data = $data;
$this->data = $data;
// total byte size of Excel data (workbook global substream + sheet substreams)
$this->_dataSize = strlen($this->_data);
$this->dataSize = strlen($this->data);
$this->_pos = 0;
$this->pos = 0;
// Parse Escher stream
while ($this->_pos < $this->_dataSize) {
while ($this->pos < $this->dataSize) {
// offset: 2; size: 2: Record Type
$fbt = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos + 2);
$fbt = PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos + 2);
switch ($fbt) {
case self::DGGCONTAINER: $this->_readDggContainer(); break;
case self::DGG: $this->_readDgg(); break;
case self::BSTORECONTAINER: $this->_readBstoreContainer(); break;
case self::BSE: $this->_readBSE(); break;
case self::BLIPJPEG: $this->_readBlipJPEG(); break;
case self::BLIPPNG: $this->_readBlipPNG(); break;
case self::OPT: $this->_readOPT(); break;
case self::TERTIARYOPT: $this->_readTertiaryOPT(); break;
case self::SPLITMENUCOLORS: $this->_readSplitMenuColors(); break;
case self::DGCONTAINER: $this->_readDgContainer(); break;
case self::DG: $this->_readDg(); break;
case self::SPGRCONTAINER: $this->_readSpgrContainer(); break;
case self::SPCONTAINER: $this->_readSpContainer(); break;
case self::SPGR: $this->_readSpgr(); break;
case self::SP: $this->_readSp(); break;
case self::CLIENTTEXTBOX: $this->_readClientTextbox(); break;
case self::CLIENTANCHOR: $this->_readClientAnchor(); break;
case self::CLIENTDATA: $this->_readClientData(); break;
default: $this->_readDefault(); break;
case self::DGGCONTAINER:
$this->readDggContainer();
break;
case self::DGG:
$this->readDgg();
break;
case self::BSTORECONTAINER:
$this->readBstoreContainer();
break;
case self::BSE:
$this->readBSE();
break;
case self::BLIPJPEG:
$this->readBlipJPEG();
break;
case self::BLIPPNG:
$this->readBlipPNG();
break;
case self::OPT:
$this->readOPT();
break;
case self::TERTIARYOPT:
$this->readTertiaryOPT();
break;
case self::SPLITMENUCOLORS:
$this->readSplitMenuColors();
break;
case self::DGCONTAINER:
$this->readDgContainer();
break;
case self::DG:
$this->readDg();
break;
case self::SPGRCONTAINER:
$this->readSpgrContainer();
break;
case self::SPCONTAINER:
$this->readSpContainer();
break;
case self::SPGR:
$this->readSpgr();
break;
case self::SP:
$this->readSp();
break;
case self::CLIENTTEXTBOX:
$this->readClientTextbox();
break;
case self::CLIENTANCHOR:
$this->readClientAnchor();
break;
case self::CLIENTDATA:
$this->readClientData();
break;
default:
$this->readDefault();
break;
}
}
return $this->_object;
return $this->object;
}
/**
* Read a generic record
*/
private function _readDefault()
private function readDefault()
{
// offset 0; size: 2; recVer and recInstance
$verInstance = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos);
$verInstance = PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos);
// offset: 2; size: 2: Record Type
$fbt = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos + 2);
$fbt = PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos + 2);
// bit: 0-3; mask: 0x000F; recVer
$recVer = (0x000F & $verInstance) >> 0;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$this->pos += 8 + $length;
}
/**
* Read DggContainer record (Drawing Group Container)
*/
private function _readDggContainer()
private function readDggContainer()
{
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$this->pos += 8 + $length;
// record is a container, read contents
$dggContainer = new PHPExcel_Shared_Escher_DggContainer();
$this->_object->setDggContainer($dggContainer);
$this->object->setDggContainer($dggContainer);
$reader = new PHPExcel_Reader_Excel5_Escher($dggContainer);
$reader->load($recordData);
}
@ -179,29 +209,29 @@ class PHPExcel_Reader_Excel5_Escher
/**
* Read Dgg record (Drawing Group)
*/
private function _readDgg()
private function readDgg()
{
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$this->pos += 8 + $length;
}
/**
* Read BstoreContainer record (Blip Store Container)
*/
private function _readBstoreContainer()
private function readBstoreContainer()
{
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$this->pos += 8 + $length;
// record is a container, read contents
$bstoreContainer = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer();
$this->_object->setBstoreContainer($bstoreContainer);
$this->object->setBstoreContainer($bstoreContainer);
$reader = new PHPExcel_Reader_Excel5_Escher($bstoreContainer);
$reader->load($recordData);
}
@ -209,22 +239,22 @@ class PHPExcel_Reader_Excel5_Escher
/**
* Read BSE record
*/
private function _readBSE()
private function readBSE()
{
// offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$this->pos += 8 + $length;
// add BSE to BstoreContainer
$BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE();
$this->_object->addBSE($BSE);
$this->object->addBSE($BSE);
$BSE->setBLIPType($recInstance);
@ -238,16 +268,16 @@ class PHPExcel_Reader_Excel5_Escher
$rgbUid = substr($recordData, 2, 16);
// offset: 18; size: 2; tag
$tag = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 18);
$tag = PHPExcel_Reader_Excel5::getInt2d($recordData, 18);
// offset: 20; size: 4; size of BLIP in bytes
$size = PHPExcel_Reader_Excel5::_GetInt4d($recordData, 20);
$size = PHPExcel_Reader_Excel5::getInt4d($recordData, 20);
// offset: 24; size: 4; number of references to this BLIP
$cRef = PHPExcel_Reader_Excel5::_GetInt4d($recordData, 24);
$cRef = PHPExcel_Reader_Excel5::getInt4d($recordData, 24);
// offset: 28; size: 4; MSOFO file offset
$foDelay = PHPExcel_Reader_Excel5::_GetInt4d($recordData, 28);
$foDelay = PHPExcel_Reader_Excel5::getInt4d($recordData, 28);
// offset: 32; size: 1; unused1
$unused1 = ord($recordData{32});
@ -275,18 +305,18 @@ class PHPExcel_Reader_Excel5_Escher
/**
* Read BlipJPEG record. Holds raw JPEG image data
*/
private function _readBlipJPEG()
private function readBlipJPEG()
{
// offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$this->pos += 8 + $length;
$pos = 0;
@ -310,24 +340,24 @@ class PHPExcel_Reader_Excel5_Escher
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
$blip->setData($data);
$this->_object->setBlip($blip);
$this->object->setBlip($blip);
}
/**
* Read BlipPNG record. Holds raw PNG image data
*/
private function _readBlipPNG()
private function readBlipPNG()
{
// offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$this->pos += 8 + $length;
$pos = 0;
@ -351,71 +381,71 @@ class PHPExcel_Reader_Excel5_Escher
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
$blip->setData($data);
$this->_object->setBlip($blip);
$this->object->setBlip($blip);
}
/**
* Read OPT record. This record may occur within DggContainer record or SpContainer
*/
private function _readOPT()
private function readOPT()
{
// offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$this->pos += 8 + $length;
$this->_readOfficeArtRGFOPTE($recordData, $recInstance);
$this->readOfficeArtRGFOPTE($recordData, $recInstance);
}
/**
* Read TertiaryOPT record
*/
private function _readTertiaryOPT()
private function readTertiaryOPT()
{
// offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$this->pos += 8 + $length;
}
/**
* Read SplitMenuColors record
*/
private function _readSplitMenuColors()
private function readSplitMenuColors()
{
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$this->pos += 8 + $length;
}
/**
* Read DgContainer record (Drawing Container)
*/
private function _readDgContainer()
private function readDgContainer()
{
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$this->pos += 8 + $length;
// record is a container, read contents
$dgContainer = new PHPExcel_Shared_Escher_DgContainer();
$this->_object->setDgContainer($dgContainer);
$this->object->setDgContainer($dgContainer);
$reader = new PHPExcel_Reader_Excel5_Escher($dgContainer);
$escher = $reader->load($recordData);
}
@ -423,37 +453,37 @@ class PHPExcel_Reader_Excel5_Escher
/**
* Read Dg record (Drawing)
*/
private function _readDg()
private function readDg()
{
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$this->pos += 8 + $length;
}
/**
* Read SpgrContainer record (Shape Group Container)
*/
private function _readSpgrContainer()
private function readSpgrContainer()
{
// context is either context DgContainer or SpgrContainer
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$this->pos += 8 + $length;
// record is a container, read contents
$spgrContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer();
if ($this->_object instanceof PHPExcel_Shared_Escher_DgContainer) {
if ($this->object instanceof PHPExcel_Shared_Escher_DgContainer) {
// DgContainer
$this->_object->setSpgrContainer($spgrContainer);
$this->object->setSpgrContainer($spgrContainer);
} else {
// SpgrContainer
$this->_object->addChild($spgrContainer);
$this->object->addChild($spgrContainer);
}
$reader = new PHPExcel_Reader_Excel5_Escher($spgrContainer);
@ -463,17 +493,17 @@ class PHPExcel_Reader_Excel5_Escher
/**
* Read SpContainer record (Shape Container)
*/
private function _readSpContainer()
private function readSpContainer()
{
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length);
// add spContainer to spgrContainer
$spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer();
$this->_object->addChild($spContainer);
$this->object->addChild($spContainer);
// move stream pointer to next record
$this->_pos += 8 + $length;
$this->pos += 8 + $length;
// record is a container, read contents
$reader = new PHPExcel_Reader_Excel5_Escher($spContainer);
@ -483,113 +513,113 @@ class PHPExcel_Reader_Excel5_Escher
/**
* Read Spgr record (Shape Group)
*/
private function _readSpgr()
private function readSpgr()
{
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$this->pos += 8 + $length;
}
/**
* Read Sp record (Shape)
*/
private function _readSp()
private function readSp()
{
// offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$this->pos += 8 + $length;
}
/**
* Read ClientTextbox record
*/
private function _readClientTextbox()
private function readClientTextbox()
{
// offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$this->pos += 8 + $length;
}
/**
* Read ClientAnchor record. This record holds information about where the shape is anchored in worksheet
*/
private function _readClientAnchor()
private function readClientAnchor()
{
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$this->pos += 8 + $length;
// offset: 2; size: 2; upper-left corner column index (0-based)
$c1 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 2);
$c1 = PHPExcel_Reader_Excel5::getInt2d($recordData, 2);
// offset: 4; size: 2; upper-left corner horizontal offset in 1/1024 of column width
$startOffsetX = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 4);
$startOffsetX = PHPExcel_Reader_Excel5::getInt2d($recordData, 4);
// offset: 6; size: 2; upper-left corner row index (0-based)
$r1 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 6);
$r1 = PHPExcel_Reader_Excel5::getInt2d($recordData, 6);
// offset: 8; size: 2; upper-left corner vertical offset in 1/256 of row height
$startOffsetY = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 8);
$startOffsetY = PHPExcel_Reader_Excel5::getInt2d($recordData, 8);
// offset: 10; size: 2; bottom-right corner column index (0-based)
$c2 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 10);
$c2 = PHPExcel_Reader_Excel5::getInt2d($recordData, 10);
// offset: 12; size: 2; bottom-right corner horizontal offset in 1/1024 of column width
$endOffsetX = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 12);
$endOffsetX = PHPExcel_Reader_Excel5::getInt2d($recordData, 12);
// offset: 14; size: 2; bottom-right corner row index (0-based)
$r2 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 14);
$r2 = PHPExcel_Reader_Excel5::getInt2d($recordData, 14);
// offset: 16; size: 2; bottom-right corner vertical offset in 1/256 of row height
$endOffsetY = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 16);
$endOffsetY = PHPExcel_Reader_Excel5::getInt2d($recordData, 16);
// set the start coordinates
$this->_object->setStartCoordinates(PHPExcel_Cell::stringFromColumnIndex($c1) . ($r1 + 1));
$this->object->setStartCoordinates(PHPExcel_Cell::stringFromColumnIndex($c1) . ($r1 + 1));
// set the start offsetX
$this->_object->setStartOffsetX($startOffsetX);
$this->object->setStartOffsetX($startOffsetX);
// set the start offsetY
$this->_object->setStartOffsetY($startOffsetY);
$this->object->setStartOffsetY($startOffsetY);
// set the end coordinates
$this->_object->setEndCoordinates(PHPExcel_Cell::stringFromColumnIndex($c2) . ($r2 + 1));
$this->object->setEndCoordinates(PHPExcel_Cell::stringFromColumnIndex($c2) . ($r2 + 1));
// set the end offsetX
$this->_object->setEndOffsetX($endOffsetX);
$this->object->setEndOffsetX($endOffsetX);
// set the end offsetY
$this->_object->setEndOffsetY($endOffsetY);
$this->object->setEndOffsetY($endOffsetY);
}
/**
* Read ClientData record
*/
private function _readClientData()
private function readClientData()
{
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$this->pos += 8 + $length;
}
/**
@ -598,8 +628,8 @@ class PHPExcel_Reader_Excel5_Escher
* @param string $data Binary data
* @param int $n Number of properties
*/
private function _readOfficeArtRGFOPTE($data, $n) {
private function readOfficeArtRGFOPTE($data, $n)
{
$splicedComplexData = substr($data, 6 * $n);
// loop through property-value pairs
@ -608,7 +638,7 @@ class PHPExcel_Reader_Excel5_Escher
$fopte = substr($data, 6 * $i, 6);
// offset: 0; size: 2; opid
$opid = PHPExcel_Reader_Excel5::_GetInt2d($fopte, 0);
$opid = PHPExcel_Reader_Excel5::getInt2d($fopte, 0);
// bit: 0-13; mask: 0x3FFF; opid.opid
$opidOpid = (0x3FFF & $opid) >> 0;
@ -620,7 +650,7 @@ class PHPExcel_Reader_Excel5_Escher
$opidFComplex = (0x8000 & $opid) >> 15;
// offset: 2; size: 4; the value for this property
$op = PHPExcel_Reader_Excel5::_GetInt4d($fopte, 2);
$op = PHPExcel_Reader_Excel5::getInt4d($fopte, 2);
if ($opidFComplex) {
$complexData = substr($splicedComplexData, 0, $op);
@ -633,8 +663,7 @@ class PHPExcel_Reader_Excel5_Escher
$value = $op;
}
$this->_object->setOPT($opidOpid, $value);
$this->object->setOPT($opidOpid, $value);
}
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Reader_Excel5_MD5
*
* Copyright (c) 2006 - 2014 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_Reader_Excel5
* @copyright Copyright (c) 2006 - 2014 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_Reader_Excel5_MD5
*
* @category PHPExcel
* @package PHPExcel_Reader_Excel5
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_Excel5_MD5
{
// Context
@ -41,7 +33,6 @@ class PHPExcel_Reader_Excel5_MD5
private $c;
private $d;
/**
* MD5 stream constructor
*/
@ -50,7 +41,6 @@ class PHPExcel_Reader_Excel5_MD5
$this->reset();
}
/**
* Reset the MD5 stream context
*/
@ -62,7 +52,6 @@ class PHPExcel_Reader_Excel5_MD5
$this->d = 0x10325476;
}
/**
* Get MD5 stream context
*
@ -82,7 +71,6 @@ class PHPExcel_Reader_Excel5_MD5
return $s;
}
/**
* Add data to context
*
@ -97,10 +85,10 @@ class PHPExcel_Reader_Excel5_MD5
$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');
$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);
@ -180,31 +168,26 @@ class PHPExcel_Reader_Excel5_MD5
$this->d = ($this->d + $D) & 0xffffffff;
}
private static function F($X, $Y, $Z)
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)
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)
private static function h($X, $Y, $Z)
{
return ($X ^ $Y ^ $Z); // X XOR Y XOR Z
}
private static function I($X, $Y, $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;
@ -212,7 +195,6 @@ class PHPExcel_Reader_Excel5_MD5
$A = ($B + $A) & 0xffffffff;
}
private static function rotate($decimal, $bits)
{
$binary = str_pad(decbin($decimal), 32, "0", STR_PAD_LEFT);

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Reader_Excel5_RC4
*
* Copyright (c) 2006 - 2014 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,24 +21,16 @@
*
* @category PHPExcel
* @package PHPExcel_Reader_Excel5
* @copyright Copyright (c) 2006 - 2014 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_Reader_Excel5_RC4
*
* @category PHPExcel
* @package PHPExcel_Reader_Excel5
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_Excel5_RC4
{
// Context
var $s = array();
var $i = 0;
var $j = 0;
protected $s = array();
protected $i = 0;
protected $j = 0;
/**
* RC4 stream decryption/encryption constrcutor

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 - 2014 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,20 +21,12 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2014 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_Reader_Exception
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_Exception extends PHPExcel_Exception {
class PHPExcel_Reader_Exception extends PHPExcel_Exception
{
/**
* Error handler callback
*
@ -43,7 +36,8 @@ class PHPExcel_Reader_Exception extends PHPExcel_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,18 @@
<?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel
* PHPExcel_Reader_Gnumeric
*
* Copyright (c) 2006 - 2014 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 +30,10 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2014 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_Reader_Gnumeric
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
{
/**
@ -49,27 +41,26 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
*
* @var array
*/
private $_styles = array();
private $styles = array();
/**
* Shared Expressions
*
* @var array
*/
private $_expressions = array();
private $_referenceHelper = null;
private $expressions = array();
private $referenceHelper = null;
/**
* Create a new PHPExcel_Reader_Gnumeric
*/
public function __construct() {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
$this->_referenceHelper = PHPExcel_ReferenceHelper::getInstance();
public function __construct()
{
$this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
$this->referenceHelper = PHPExcel_ReferenceHelper::getInstance();
}
/**
* Can the current PHPExcel_Reader_IReader read the file?
*
@ -101,7 +92,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
return true;
}
/**
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
*
@ -116,10 +106,8 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
}
$xml = new XMLReader();
$xml->xml(
$this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions()
);
$xml->setParserProperty(2,true);
$xml->xml($this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions());
$xml->setParserProperty(2, true);
$worksheetNames = array();
while ($xml->read()) {
@ -135,7 +123,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
return $worksheetNames;
}
/**
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
*
@ -150,10 +137,8 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
}
$xml = new XMLReader();
$xml->xml(
$this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions()
);
$xml->setParserProperty(2,true);
$xml->xml($this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions());
$xml->setParserProperty(2, true);
$worksheetInfo = array();
while ($xml->read()) {
@ -188,8 +173,8 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
return $worksheetInfo;
}
private function _gzfileGetContents($filename) {
private function gzfileGetContents($filename)
{
$file = @gzopen($filename, 'rb');
if ($file !== false) {
$data = '';
@ -201,7 +186,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
return $data;
}
/**
* Loads PHPExcel from file
*
@ -218,7 +202,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
return $this->loadIntoExisting($pFilename, $objPHPExcel);
}
/**
* Loads PHPExcel from file into PHPExcel instance
*
@ -237,7 +220,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$timezoneObj = new DateTimeZone('Europe/London');
$GMT = new DateTimeZone('UTC');
$gFileData = $this->_gzfileGetContents($pFilename);
$gFileData = $this->gzfileGetContents($pFilename);
// echo '<pre>';
// echo htmlentities($gFileData,ENT_QUOTES,'UTF-8');
@ -257,31 +240,30 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$officeDocXML = $officeXML->{'document-meta'};
$officeDocMetaXML = $officeDocXML->meta;
foreach($officeDocMetaXML as $officePropertyData) {
foreach ($officeDocMetaXML as $officePropertyData) {
$officePropertyDC = array();
if (isset($namespacesMeta['dc'])) {
$officePropertyDC = $officePropertyData->children($namespacesMeta['dc']);
}
foreach($officePropertyDC as $propertyName => $propertyValue) {
foreach ($officePropertyDC as $propertyName => $propertyValue) {
$propertyValue = (string) $propertyValue;
switch ($propertyName) {
case 'title' :
case 'title':
$docProps->setTitle(trim($propertyValue));
break;
case 'subject' :
case 'subject':
$docProps->setSubject(trim($propertyValue));
break;
case 'creator' :
case 'creator':
$docProps->setCreator(trim($propertyValue));
$docProps->setLastModifiedBy(trim($propertyValue));
break;
case 'date' :
case 'date':
$creationDate = strtotime(trim($propertyValue));
$docProps->setCreated($creationDate);
$docProps->setModified($creationDate);
break;
case 'description' :
case 'description':
$docProps->setDescription(trim($propertyValue));
break;
}
@ -290,32 +272,32 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
if (isset($namespacesMeta['meta'])) {
$officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']);
}
foreach($officePropertyMeta as $propertyName => $propertyValue) {
foreach ($officePropertyMeta as $propertyName => $propertyValue) {
$attributes = $propertyValue->attributes($namespacesMeta['meta']);
$propertyValue = (string) $propertyValue;
switch ($propertyName) {
case 'keyword' :
case 'keyword':
$docProps->setKeywords(trim($propertyValue));
break;
case 'initial-creator' :
case 'initial-creator':
$docProps->setCreator(trim($propertyValue));
$docProps->setLastModifiedBy(trim($propertyValue));
break;
case 'creation-date' :
case 'creation-date':
$creationDate = strtotime(trim($propertyValue));
$docProps->setCreated($creationDate);
$docProps->setModified($creationDate);
break;
case 'user-defined' :
list(,$attrName) = explode(':',$attributes['name']);
case 'user-defined':
list(, $attrName) = explode(':', $attributes['name']);
switch ($attrName) {
case 'publisher' :
case 'publisher':
$docProps->setCompany(trim($propertyValue));
break;
case 'category' :
case 'category':
$docProps->setCategory(trim($propertyValue));
break;
case 'manager' :
case 'manager':
$docProps->setManager(trim($propertyValue));
break;
}
@ -324,30 +306,30 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
}
}
} elseif (isset($gnmXML->Summary)) {
foreach($gnmXML->Summary->Item as $summaryItem) {
foreach ($gnmXML->Summary->Item as $summaryItem) {
$propertyName = $summaryItem->name;
$propertyValue = $summaryItem->{'val-string'};
switch ($propertyName) {
case 'title' :
case 'title':
$docProps->setTitle(trim($propertyValue));
break;
case 'comments' :
case 'comments':
$docProps->setDescription(trim($propertyValue));
break;
case 'keywords' :
case 'keywords':
$docProps->setKeywords(trim($propertyValue));
break;
case 'category' :
case 'category':
$docProps->setCategory(trim($propertyValue));
break;
case 'manager' :
case 'manager':
$docProps->setManager(trim($propertyValue));
break;
case 'author' :
case 'author':
$docProps->setCreator(trim($propertyValue));
$docProps->setLastModifiedBy(trim($propertyValue));
break;
case 'company' :
case 'company':
$docProps->setCompany(trim($propertyValue));
break;
}
@ -355,10 +337,10 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
}
$worksheetID = 0;
foreach($gnmXML->Sheets->Sheet as $sheet) {
foreach ($gnmXML->Sheets->Sheet as $sheet) {
$worksheetName = (string) $sheet->Name;
// echo '<b>Worksheet: ',$worksheetName,'</b><br />';
if ((isset($this->_loadSheetsOnly)) && (!in_array($worksheetName, $this->_loadSheetsOnly))) {
// echo '<b>Worksheet: ', $worksheetName,'</b><br />';
if ((isset($this->loadSheetsOnly)) && (!in_array($worksheetName, $this->loadSheetsOnly))) {
continue;
}
@ -370,35 +352,35 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
// Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in formula
// cells... during the load, all formulae should be correct, and we're simply bringing the worksheet
// name in line with the formula, not the reverse
$objPHPExcel->getActiveSheet()->setTitle($worksheetName,false);
$objPHPExcel->getActiveSheet()->setTitle($worksheetName, false);
if ((!$this->_readDataOnly) && (isset($sheet->PrintInformation))) {
if ((!$this->readDataOnly) && (isset($sheet->PrintInformation))) {
if (isset($sheet->PrintInformation->Margins)) {
foreach($sheet->PrintInformation->Margins->children('gnm',TRUE) as $key => $margin) {
foreach ($sheet->PrintInformation->Margins->children('gnm', true) as $key => $margin) {
$marginAttributes = $margin->attributes();
$marginSize = 72 / 100; // Default
switch($marginAttributes['PrefUnit']) {
case 'mm' :
switch ($marginAttributes['PrefUnit']) {
case 'mm':
$marginSize = intval($marginAttributes['Points']) / 100;
break;
}
switch($key) {
case 'top' :
switch ($key) {
case 'top':
$objPHPExcel->getActiveSheet()->getPageMargins()->setTop($marginSize);
break;
case 'bottom' :
case 'bottom':
$objPHPExcel->getActiveSheet()->getPageMargins()->setBottom($marginSize);
break;
case 'left' :
case 'left':
$objPHPExcel->getActiveSheet()->getPageMargins()->setLeft($marginSize);
break;
case 'right' :
case 'right':
$objPHPExcel->getActiveSheet()->getPageMargins()->setRight($marginSize);
break;
case 'header' :
case 'header':
$objPHPExcel->getActiveSheet()->getPageMargins()->setHeader($marginSize);
break;
case 'footer' :
case 'footer':
$objPHPExcel->getActiveSheet()->getPageMargins()->setFooter($marginSize);
break;
}
@ -406,18 +388,22 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
}
}
foreach($sheet->Cells->Cell as $cell) {
foreach ($sheet->Cells->Cell as $cell) {
$cellAttributes = $cell->attributes();
$row = (int) $cellAttributes->Row + 1;
$column = (int) $cellAttributes->Col;
if ($row > $maxRow) $maxRow = $row;
if ($column > $maxCol) $maxCol = $column;
if ($row > $maxRow) {
$maxRow = $row;
}
if ($column > $maxCol) {
$maxCol = $column;
}
$column = PHPExcel_Cell::stringFromColumnIndex($column);
// Read cell?
if ($this->getReadFilter() !== NULL) {
if ($this->getReadFilter() !== null) {
if (!$this->getReadFilter()->readCell($column, $row, $worksheetName)) {
continue;
}
@ -425,76 +411,75 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$ValueType = $cellAttributes->ValueType;
$ExprID = (string) $cellAttributes->ExprID;
// echo 'Cell ',$column,$row,'<br />';
// echo 'Type is ',$ValueType,'<br />';
// echo 'Value is ',$cell,'<br />';
// echo 'Cell ', $column, $row,'<br />';
// echo 'Type is ', $ValueType,'<br />';
// echo 'Value is ', $cell,'<br />';
$type = PHPExcel_Cell_DataType::TYPE_FORMULA;
if ($ExprID > '') {
if (((string) $cell) > '') {
$this->_expressions[$ExprID] = array( 'column' => $cellAttributes->Col,
$this->expressions[$ExprID] = array(
'column' => $cellAttributes->Col,
'row' => $cellAttributes->Row,
'formula' => (string) $cell
);
// echo 'NEW EXPRESSION ',$ExprID,'<br />';
// echo 'NEW EXPRESSION ', $ExprID,'<br />';
} else {
$expression = $this->_expressions[$ExprID];
$expression = $this->expressions[$ExprID];
$cell = $this->_referenceHelper->updateFormulaReferences( $expression['formula'],
$cell = $this->referenceHelper->updateFormulaReferences(
$expression['formula'],
'A1',
$cellAttributes->Col - $expression['column'],
$cellAttributes->Row - $expression['row'],
$worksheetName
);
// echo 'SHARED EXPRESSION ',$ExprID,'<br />';
// echo 'New Value is ',$cell,'<br />';
// echo 'SHARED EXPRESSION ', $ExprID,'<br />';
// echo 'New Value is ', $cell,'<br />';
}
$type = PHPExcel_Cell_DataType::TYPE_FORMULA;
} else {
switch($ValueType) {
case '10' : // NULL
switch ($ValueType) {
case '10': // NULL
$type = PHPExcel_Cell_DataType::TYPE_NULL;
break;
case '20' : // Boolean
case '20': // Boolean
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
$cell = ($cell == 'TRUE') ? True : False;
$cell = ($cell == 'TRUE') ? true: false;
break;
case '30' : // Integer
case '30': // Integer
$cell = intval($cell);
case '40' : // Float
// Excel 2007+ doesn't differentiate between integer and float, so set the value and dropthru to the next (numeric) case
case '40': // Float
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
break;
case '50' : // Error
case '50': // Error
$type = PHPExcel_Cell_DataType::TYPE_ERROR;
break;
case '60' : // String
case '60': // String
$type = PHPExcel_Cell_DataType::TYPE_STRING;
break;
case '70' : // Cell Range
case '80' : // Array
case '70': // Cell Range
case '80': // Array
}
}
$objPHPExcel->getActiveSheet()->getCell($column.$row)->setValueExplicit($cell,$type);
$objPHPExcel->getActiveSheet()->getCell($column.$row)->setValueExplicit($cell, $type);
}
if ((!$this->_readDataOnly) && (isset($sheet->Objects))) {
foreach($sheet->Objects->children('gnm',TRUE) as $key => $comment) {
if ((!$this->readDataOnly) && (isset($sheet->Objects))) {
foreach ($sheet->Objects->children('gnm', true) as $key => $comment) {
$commentAttributes = $comment->attributes();
// Only comment objects are handled at the moment
if ($commentAttributes->Text) {
$objPHPExcel->getActiveSheet()->getComment( (string)$commentAttributes->ObjectBound )
->setAuthor( (string)$commentAttributes->Author )
->setText($this->_parseRichText((string)$commentAttributes->Text) );
$objPHPExcel->getActiveSheet()->getComment((string)$commentAttributes->ObjectBound)->setAuthor((string)$commentAttributes->Author)->setText($this->parseRichText((string)$commentAttributes->Text));
}
}
}
// echo '$maxCol=',$maxCol,'; $maxRow=',$maxRow,'<br />';
// echo '$maxCol=', $maxCol,'; $maxRow=', $maxRow,'<br />';
//
foreach($sheet->Styles->StyleRegion as $styleRegion) {
foreach ($sheet->Styles->StyleRegion as $styleRegion) {
$styleAttributes = $styleRegion->attributes();
if (($styleAttributes['startRow'] <= $maxRow) &&
($styleAttributes['startCol'] <= $maxCol)) {
$startColumn = PHPExcel_Cell::stringFromColumnIndex((int) $styleAttributes['startCol']);
$startRow = $styleAttributes['startRow'] + 1;
@ -509,121 +494,121 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
// var_dump($styleAttributes);
// echo '<br />';
// We still set the number format mask for date/time values, even if _readDataOnly is true
if ((!$this->_readDataOnly) ||
// We still set the number format mask for date/time values, even if readDataOnly is true
if ((!$this->readDataOnly) ||
(PHPExcel_Shared_Date::isDateTimeFormatCode((string) $styleAttributes['Format']))) {
$styleArray = array();
$styleArray['numberformat']['code'] = (string) $styleAttributes['Format'];
// If _readDataOnly is false, we set all formatting information
if (!$this->_readDataOnly) {
switch($styleAttributes['HAlign']) {
case '1' :
// If readDataOnly is false, we set all formatting information
if (!$this->readDataOnly) {
switch ($styleAttributes['HAlign']) {
case '1':
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
break;
case '2' :
case '2':
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_LEFT;
break;
case '4' :
case '4':
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_RIGHT;
break;
case '8' :
case '8':
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_CENTER;
break;
case '16' :
case '64' :
case '16':
case '64':
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS;
break;
case '32' :
case '32':
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY;
break;
}
switch($styleAttributes['VAlign']) {
case '1' :
switch ($styleAttributes['VAlign']) {
case '1':
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_TOP;
break;
case '2' :
case '2':
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
break;
case '4' :
case '4':
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_CENTER;
break;
case '8' :
case '8':
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_JUSTIFY;
break;
}
$styleArray['alignment']['wrap'] = ($styleAttributes['WrapText'] == '1') ? True : False;
$styleArray['alignment']['shrinkToFit'] = ($styleAttributes['ShrinkToFit'] == '1') ? True : False;
$styleArray['alignment']['wrap'] = ($styleAttributes['WrapText'] == '1') ? true : false;
$styleArray['alignment']['shrinkToFit'] = ($styleAttributes['ShrinkToFit'] == '1') ? true : false;
$styleArray['alignment']['indent'] = (intval($styleAttributes["Indent"]) > 0) ? $styleAttributes["indent"] : 0;
$RGB = self::_parseGnumericColour($styleAttributes["Fore"]);
$RGB = self::parseGnumericColour($styleAttributes["Fore"]);
$styleArray['font']['color']['rgb'] = $RGB;
$RGB = self::_parseGnumericColour($styleAttributes["Back"]);
$RGB = self::parseGnumericColour($styleAttributes["Back"]);
$shade = $styleAttributes["Shade"];
if (($RGB != '000000') || ($shade != '0')) {
$styleArray['fill']['color']['rgb'] = $styleArray['fill']['startcolor']['rgb'] = $RGB;
$RGB2 = self::_parseGnumericColour($styleAttributes["PatternColor"]);
$RGB2 = self::parseGnumericColour($styleAttributes["PatternColor"]);
$styleArray['fill']['endcolor']['rgb'] = $RGB2;
switch($shade) {
case '1' :
switch ($shade) {
case '1':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_SOLID;
break;
case '2' :
case '2':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR;
break;
case '3' :
case '3':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_GRADIENT_PATH;
break;
case '4' :
case '4':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN;
break;
case '5' :
case '5':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY;
break;
case '6' :
case '6':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID;
break;
case '7' :
case '7':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL;
break;
case '8' :
case '8':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS;
break;
case '9' :
case '9':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKUP;
break;
case '10' :
case '10':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL;
break;
case '11' :
case '11':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625;
break;
case '12' :
case '12':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_GRAY125;
break;
case '13' :
case '13':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN;
break;
case '14' :
case '14':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY;
break;
case '15' :
case '15':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID;
break;
case '16' :
case '16':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL;
break;
case '17' :
case '17':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS;
break;
case '18' :
case '18':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP;
break;
case '19' :
case '19':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL;
break;
case '20' :
case '20':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY;
break;
}
@ -634,56 +619,56 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
// echo '<br />';
$styleArray['font']['name'] = (string) $styleRegion->Style->Font;
$styleArray['font']['size'] = intval($fontAttributes['Unit']);
$styleArray['font']['bold'] = ($fontAttributes['Bold'] == '1') ? True : False;
$styleArray['font']['italic'] = ($fontAttributes['Italic'] == '1') ? True : False;
$styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? True : False;
switch($fontAttributes['Underline']) {
case '1' :
$styleArray['font']['bold'] = ($fontAttributes['Bold'] == '1') ? true : false;
$styleArray['font']['italic'] = ($fontAttributes['Italic'] == '1') ? true : false;
$styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? true : false;
switch ($fontAttributes['Underline']) {
case '1':
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLE;
break;
case '2' :
case '2':
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_DOUBLE;
break;
case '3' :
case '3':
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING;
break;
case '4' :
case '4':
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING;
break;
default :
default:
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_NONE;
break;
}
switch($fontAttributes['Script']) {
case '1' :
$styleArray['font']['superScript'] = True;
switch ($fontAttributes['Script']) {
case '1':
$styleArray['font']['superScript'] = true;
break;
case '-1' :
$styleArray['font']['subScript'] = True;
case '-1':
$styleArray['font']['subScript'] = true;
break;
}
if (isset($styleRegion->Style->StyleBorder)) {
if (isset($styleRegion->Style->StyleBorder->Top)) {
$styleArray['borders']['top'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->Top->attributes());
$styleArray['borders']['top'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Top->attributes());
}
if (isset($styleRegion->Style->StyleBorder->Bottom)) {
$styleArray['borders']['bottom'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->Bottom->attributes());
$styleArray['borders']['bottom'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Bottom->attributes());
}
if (isset($styleRegion->Style->StyleBorder->Left)) {
$styleArray['borders']['left'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->Left->attributes());
$styleArray['borders']['left'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Left->attributes());
}
if (isset($styleRegion->Style->StyleBorder->Right)) {
$styleArray['borders']['right'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->Right->attributes());
$styleArray['borders']['right'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Right->attributes());
}
if ((isset($styleRegion->Style->StyleBorder->Diagonal)) && (isset($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}))) {
$styleArray['borders']['diagonal'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes());
$styleArray['borders']['diagonal'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes());
$styleArray['borders']['diagonaldirection'] = PHPExcel_Style_Borders::DIAGONAL_BOTH;
} elseif (isset($styleRegion->Style->StyleBorder->Diagonal)) {
$styleArray['borders']['diagonal'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes());
$styleArray['borders']['diagonal'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes());
$styleArray['borders']['diagonaldirection'] = PHPExcel_Style_Borders::DIAGONAL_UP;
} elseif (isset($styleRegion->Style->StyleBorder->{'Rev-Diagonal'})) {
$styleArray['borders']['diagonal'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}->attributes());
$styleArray['borders']['diagonal'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}->attributes());
$styleArray['borders']['diagonaldirection'] = PHPExcel_Style_Borders::DIAGONAL_DOWN;
}
}
@ -699,12 +684,12 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
}
}
if ((!$this->_readDataOnly) && (isset($sheet->Cols))) {
if ((!$this->readDataOnly) && (isset($sheet->Cols))) {
// Column Widths
$columnAttributes = $sheet->Cols->attributes();
$defaultWidth = $columnAttributes['DefaultSizePts'] / 5.4;
$c = 0;
foreach($sheet->Cols->ColInfo as $columnOverride) {
foreach ($sheet->Cols->ColInfo as $columnOverride) {
$columnAttributes = $columnOverride->attributes();
$column = $columnAttributes['No'];
$columnWidth = $columnAttributes['Unit'] / 5.4;
@ -728,13 +713,13 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
}
}
if ((!$this->_readDataOnly) && (isset($sheet->Rows))) {
if ((!$this->readDataOnly) && (isset($sheet->Rows))) {
// Row Heights
$rowAttributes = $sheet->Rows->attributes();
$defaultHeight = $rowAttributes['DefaultSizePts'];
$r = 0;
foreach($sheet->Rows->RowInfo as $rowOverride) {
foreach ($sheet->Rows->RowInfo as $rowOverride) {
$rowAttributes = $rowOverride->attributes();
$row = $rowAttributes['No'];
$rowHeight = $rowAttributes['Unit'];
@ -760,8 +745,8 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
// Handle Merged Cells in this worksheet
if (isset($sheet->MergedRegions)) {
foreach($sheet->MergedRegions->Merge as $mergeCells) {
if (strpos($mergeCells,':') !== FALSE) {
foreach ($sheet->MergedRegions->Merge as $mergeCells) {
if (strpos($mergeCells, ':') !== false) {
$objPHPExcel->getActiveSheet()->mergeCells($mergeCells);
}
}
@ -772,102 +757,94 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
// Loop through definedNames (global named ranges)
if (isset($gnmXML->Names)) {
foreach($gnmXML->Names->Name as $namedRange) {
foreach ($gnmXML->Names->Name as $namedRange) {
$name = (string) $namedRange->name;
$range = (string) $namedRange->value;
if (stripos($range, '#REF!') !== false) {
continue;
}
$range = explode('!',$range);
$range[0] = trim($range[0],"'");;
$range = explode('!', $range);
$range[0] = trim($range[0], "'");
if ($worksheet = $objPHPExcel->getSheetByName($range[0])) {
$extractedRange = str_replace('$', '', $range[1]);
$objPHPExcel->addNamedRange( new PHPExcel_NamedRange($name, $worksheet, $extractedRange) );
$objPHPExcel->addNamedRange(new PHPExcel_NamedRange($name, $worksheet, $extractedRange));
}
}
}
// Return
return $objPHPExcel;
}
private static function _parseBorderAttributes($borderAttributes)
private static function parseBorderAttributes($borderAttributes)
{
$styleArray = array();
if (isset($borderAttributes["Color"])) {
$RGB = self::_parseGnumericColour($borderAttributes["Color"]);
$styleArray['color']['rgb'] = $RGB;
$styleArray['color']['rgb'] = self::parseGnumericColour($borderAttributes["Color"]);
}
switch ($borderAttributes["Style"]) {
case '0' :
case '0':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_NONE;
break;
case '1' :
case '1':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case '2' :
case '2':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUM;
break;
case '4' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHED;
break;
case '5' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_THICK;
break;
case '6' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DOUBLE;
break;
case '7' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DOTTED;
break;
case '9' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHDOT;
break;
case '10' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT;
break;
case '11' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHDOTDOT;
break;
case '12' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT;
break;
case '13' :
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT;
break;
case '3' :
case '3':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_SLANTDASHDOT;
break;
case '8' :
case '4':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHED;
break;
case '5':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_THICK;
break;
case '6':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DOUBLE;
break;
case '7':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DOTTED;
break;
case '8':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHED;
break;
case '9':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHDOT;
break;
case '10':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT;
break;
case '11':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHDOTDOT;
break;
case '12':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT;
break;
case '13':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT;
break;
}
return $styleArray;
}
private function _parseRichText($is = '') {
private function parseRichText($is = '')
{
$value = new PHPExcel_RichText();
$value->createText($is);
return $value;
}
private static function _parseGnumericColour($gnmColour) {
list($gnmR,$gnmG,$gnmB) = explode(':',$gnmColour);
$gnmR = substr(str_pad($gnmR,4,'0',STR_PAD_RIGHT),0,2);
$gnmG = substr(str_pad($gnmG,4,'0',STR_PAD_RIGHT),0,2);
$gnmB = substr(str_pad($gnmB,4,'0',STR_PAD_RIGHT),0,2);
$RGB = $gnmR.$gnmG.$gnmB;
// echo 'Excel Colour: ',$RGB,'<br />';
return $RGB;
private static function parseGnumericColour($gnmColour)
{
list($gnmR, $gnmG, $gnmB) = explode(':', $gnmColour);
$gnmR = substr(str_pad($gnmR, 4, '0', STR_PAD_RIGHT), 0, 2);
$gnmG = substr(str_pad($gnmG, 4, '0', STR_PAD_RIGHT), 0, 2);
$gnmB = substr(str_pad($gnmB, 4, '0', STR_PAD_RIGHT), 0, 2);
return $gnmR . $gnmG . $gnmB;
}
}

View file

@ -1,9 +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 - 2014 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,26 +29,11 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2014 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_Reader_HTML
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
{
@ -49,52 +42,71 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
*
* @var string
*/
protected $_inputEncoding = 'ANSI';
protected $inputEncoding = 'ANSI';
/**
* Sheet index to read
*
* @var int
*/
protected $_sheetIndex = 0;
protected $sheetIndex = 0;
/**
* Formats
*
* @var array
*/
protected $_formats = array(
'h1' => array('font' => array('bold' => true,
protected $formats = array(
'h1' => array(
'font' => array(
'bold' => true,
'size' => 24,
),
), // Bold, 24pt
'h2' => array('font' => array('bold' => true,
'h2' => array(
'font' => array(
'bold' => true,
'size' => 18,
),
), // Bold, 18pt
'h3' => array('font' => array('bold' => true,
'h3' => array(
'font' => array(
'bold' => true,
'size' => 13.5,
),
), // Bold, 13.5pt
'h4' => array('font' => array('bold' => true,
'h4' => array(
'font' => array(
'bold' => true,
'size' => 12,
),
), // Bold, 12pt
'h5' => array('font' => array('bold' => true,
'h5' => array(
'font' => array(
'bold' => true,
'size' => 10,
),
), // Bold, 10pt
'h6' => array('font' => array('bold' => true,
'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,
'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,
'hr' => array(
'borders' => array(
'bottom' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array(
PHPExcel_Style_Color::COLOR_BLACK,
),
),
),
@ -108,7 +120,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
*/
public function __construct()
{
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
$this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
}
/**
@ -116,16 +128,16 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
*
* @return boolean
*/
protected function _isValidFormat()
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) &&
$data = fread($this->fileHandle, 2048);
if ((strpos($data, '<') !== false) &&
(strlen($data) !== strlen(strip_tags($data)))) {
return TRUE;
return true;
}
return FALSE;
return false;
}
/**
@ -151,7 +163,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
*/
public function setInputEncoding($pValue = 'ANSI')
{
$this->_inputEncoding = $pValue;
$this->inputEncoding = $pValue;
return $this;
}
@ -163,37 +175,38 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
*/
public function getInputEncoding()
{
return $this->_inputEncoding;
return $this->inputEncoding;
}
// 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');
protected $dataArray = array();
protected $tableLevel = 0;
protected $nestedColumn = array('A');
protected function _setTableStartColumn($column)
protected function setTableStartColumn($column)
{
if ($this->_tableLevel == 0)
if ($this->tableLevel == 0) {
$column = 'A';
++$this->_tableLevel;
$this->_nestedColumn[$this->_tableLevel] = $column;
}
++$this->tableLevel;
$this->nestedColumn[$this->tableLevel] = $column;
return $this->_nestedColumn[$this->_tableLevel];
return $this->nestedColumn[$this->tableLevel];
}
protected function _getTableStartColumn()
protected function getTableStartColumn()
{
return $this->_nestedColumn[$this->_tableLevel];
return $this->nestedColumn[$this->tableLevel];
}
protected function _releaseTableStartColumn()
protected function releaseTableStartColumn()
{
--$this->_tableLevel;
--$this->tableLevel;
return array_pop($this->_nestedColumn);
return array_pop($this->nestedColumn);
}
protected function _flushCell($sheet, $column, $row, &$cellContent)
protected function flushCell($sheet, $column, $row, &$cellContent)
{
if (is_string($cellContent)) {
// Simple String content
@ -203,17 +216,17 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
// 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;
$this->dataArray[$row][$column] = $cellContent;
}
} else {
// We have a Rich Text run
// TODO
$this->_dataArray[$row][$column] = 'RICH TEXT: ' . $cellContent;
$this->dataArray[$row][$column] = 'RICH TEXT: ' . $cellContent;
}
$cellContent = (string) '';
}
protected function _processDomElement(DOMNode $element, $sheet, &$row, &$column, &$cellContent, $format = null)
protected function processDomElement(DOMNode $element, $sheet, &$row, &$column, &$cellContent, $format = null)
{
foreach ($element->childNodes as $child) {
if ($child instanceof DOMText) {
@ -235,7 +248,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
}
switch ($child->nodeName) {
case 'meta' :
case 'meta':
foreach ($attributeArray as $attributeName => $attributeValue) {
switch ($attributeName) {
case 'content':
@ -244,156 +257,160 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
break;
}
}
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
break;
case 'title' :
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
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 'span':
case 'div':
case 'font':
case 'i':
case 'em':
case 'strong':
case 'b' :
case 'b':
// echo 'STYLING, SPAN OR DIV<br />';
if ($cellContent > '')
if ($cellContent > '') {
$cellContent .= ' ';
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
if ($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);
case 'hr':
$this->flushCell($sheet, $column, $row, $cellContent);
++$row;
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]);
} else {
$cellContent = '----------';
$this->_flushCell($sheet, $column, $row, $cellContent);
$this->flushCell($sheet, $column, $row, $cellContent);
}
++$row;
case 'br' :
if ($this->_tableLevel > 0) {
// 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);
$this->flushCell($sheet, $column, $row, $cellContent);
++$row;
}
// echo 'HARD LINE BREAK: ' , '<br />';
break;
case 'a' :
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]);
if (isset($this->formats[$child->nodeName])) {
$sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]);
}
break;
}
}
$cellContent .= ' ';
$this->_processDomElement($child, $sheet, $row, $column, $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) {
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);
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF LIST ENTRY:' , '<br />';
} else {
if ($cellContent > '') {
$this->_flushCell($sheet, $column, $row, $cellContent);
$this->flushCell($sheet, $column, $row, $cellContent);
$row++;
}
// echo 'START OF PARAGRAPH: ' , '<br />';
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF PARAGRAPH:' , '<br />';
$this->_flushCell($sheet, $column, $row, $cellContent);
$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++;
$column = 'A';
}
break;
case 'li' :
if ($this->_tableLevel > 0) {
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);
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF LIST ENTRY:' , '<br />';
} else {
if ($cellContent > '') {
$this->_flushCell($sheet, $column, $row, $cellContent);
$this->flushCell($sheet, $column, $row, $cellContent);
}
++$row;
// echo 'LIST ENTRY: ' , '<br />';
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF LIST ENTRY:' , '<br />';
$this->_flushCell($sheet, $column, $row, $cellContent);
$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)
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) {
}
$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);
case 'thead':
case 'tbody':
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
break;
case 'tr' :
$column = $this->_getTableStartColumn();
case 'tr':
$column = $this->getTableStartColumn();
$cellContent = '';
// echo 'START OF TABLE ' , $this->_tableLevel , ' ROW<br />';
$this->_processDomElement($child, $sheet, $row, $column, $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 />';
// 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 />';
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 />';
while (isset($this->rowspan[$column . $row])) {
++$column;
}
$this->_flushCell($sheet, $column, $row, $cellContent);
$this->flushCell($sheet, $column, $row, $cellContent);
// if (isset($attributeArray['style']) && !empty($attributeArray['style'])) {
// $styleAry = $this->getPhpExcelStyleArray($attributeArray['style']);
@ -433,15 +450,15 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
}
++$column;
break;
case 'body' :
case 'body':
$row = 1;
$column = 'A';
$content = '';
$this->_tableLevel = 0;
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
$this->tableLevel = 0;
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
break;
default:
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
}
}
}
@ -458,26 +475,26 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
// Open file to validate
$this->_openFile($pFilename);
if (!$this->_isValidFormat()) {
fclose($this->_fileHandle);
$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);
fclose($this->fileHandle);
// Create new PHPExcel
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
while ($objPHPExcel->getSheetCount() <= $this->sheetIndex) {
$objPHPExcel->createSheet();
}
$objPHPExcel->setActiveSheetIndex($this->_sheetIndex);
$objPHPExcel->setActiveSheetIndex($this->sheetIndex);
// Create a new DOM object
$dom = new domDocument;
// Reload the HTML file into the DOM object
$loaded = $dom->loadHTML($this->securityScanFile($pFilename));
if ($loaded === FALSE) {
throw new PHPExcel_Reader_Exception('Failed to load ', $pFilename, ' as a DOM Document');
$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');
}
// Discard white space
@ -486,7 +503,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
$row = 0;
$column = 'A';
$content = '';
$this->_processDomElement($dom, $objPHPExcel->getActiveSheet(), $row, $column, $content);
$this->processDomElement($dom, $objPHPExcel->getActiveSheet(), $row, $column, $content);
// Return
return $objPHPExcel;
@ -499,7 +516,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
*/
public function getSheetIndex()
{
return $this->_sheetIndex;
return $this->sheetIndex;
}
/**
@ -510,7 +527,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
*/
public function setSheetIndex($pValue = 0)
{
$this->_sheetIndex = $pValue;
$this->sheetIndex = $pValue;
return $this;
}
@ -529,6 +546,4 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
}
return $xml;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Reader_IReadFilter
*
* Copyright (c) 2006 - 2014 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,26 +21,17 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2014 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_Reader_IReadFilter
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2014 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 $column Column address (as a string value like "A", or "IV")
* @param $row Row number
* @param $worksheetName Optional worksheet name
* @return boolean
*/

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Reader_IReader
*
* Copyright (c) 2006 - 2014 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_Reader
* @copyright Copyright (c) 2006 - 2014 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_Reader_IReader
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
interface PHPExcel_Reader_IReader
{
/**

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_OOCalc
*
* Copyright (c) 2006 - 2014 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 +30,10 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2014 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_Reader_OOCalc
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
{
/**
@ -49,17 +41,16 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
*
* @var array
*/
private $_styles = array();
private $styles = array();
/**
* Create a new PHPExcel_Reader_OOCalc
*/
public function __construct() {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
public function __construct()
{
$this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
}
/**
* Can the current PHPExcel_Reader_IReader read the file?
*
@ -77,7 +68,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$zipClass = PHPExcel_Settings::getZipClass();
// Check if zip class exists
// if (!class_exists($zipClass, FALSE)) {
// if (!class_exists($zipClass, false)) {
// throw new PHPExcel_Reader_Exception($zipClass . " library is not enabled");
// }
@ -89,12 +80,12 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$stat = $zip->statName('mimetype');
if ($stat && ($stat['size'] <= 255)) {
$mimeType = $zip->getFromName($stat['name']);
} elseif($stat = $zip->statName('META-INF/manifest.xml')) {
} elseif ($stat = $zip->statName('META-INF/manifest.xml')) {
$xml = simplexml_load_string($this->securityScan($zip->getFromName('META-INF/manifest.xml')), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$namespacesContent = $xml->getNamespaces(true);
if (isset($namespacesContent['manifest'])) {
$manifest = $xml->children($namespacesContent['manifest']);
foreach($manifest as $manifestDataSet) {
foreach ($manifest as $manifestDataSet) {
$manifestAttributes = $manifestDataSet->attributes($namespacesContent['manifest']);
if ($manifestAttributes->{'full-path'} == '/') {
$mimeType = (string) $manifestAttributes->{'media-type'};
@ -109,7 +100,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
return ($mimeType === 'application/vnd.oasis.opendocument.spreadsheet');
}
return FALSE;
return false;
}
@ -137,18 +128,19 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$xml = new XMLReader();
$res = $xml->xml($this->securityScanFile('zip://'.realpath($pFilename).'#content.xml'), null, PHPExcel_Settings::getLibXmlLoaderOptions());
$xml->setParserProperty(2,true);
$xml->setParserProperty(2, true);
// Step into the first level of content of the XML
$xml->read();
while ($xml->read()) {
// Quickly jump through to the office:body node
while ($xml->name !== 'office:body') {
if ($xml->isEmptyElement)
if ($xml->isEmptyElement) {
$xml->read();
else
} else {
$xml->next();
}
}
// Now read each node until we find our first table:table node
while ($xml->read()) {
if ($xml->name == 'table:table' && $xml->nodeType == XMLReader::ELEMENT) {
@ -164,7 +156,6 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
return $worksheetNames;
}
/**
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
*
@ -189,18 +180,19 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$xml = new XMLReader();
$res = $xml->xml($this->securityScanFile('zip://'.realpath($pFilename).'#content.xml'), null, PHPExcel_Settings::getLibXmlLoaderOptions());
$xml->setParserProperty(2,true);
$xml->setParserProperty(2, true);
// Step into the first level of content of the XML
$xml->read();
while ($xml->read()) {
// Quickly jump through to the office:body node
while ($xml->name !== 'office:body') {
if ($xml->isEmptyElement)
if ($xml->isEmptyElement) {
$xml->read();
else
} else {
$xml->next();
}
}
// Now read each node until we find our first table:table node
while ($xml->read()) {
if ($xml->name == 'table:table' && $xml->nodeType == XMLReader::ELEMENT) {
@ -222,7 +214,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$rowspan = $xml->getAttribute('table:number-rows-repeated');
$rowspan = empty($rowspan) ? 1 : $rowspan;
$tmpInfo['totalRows'] += $rowspan;
$tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells);
$tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'], $currCells);
$currCells = 0;
// Step into the row
$xml->read();
@ -243,14 +235,14 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
}
} while ($xml->name != 'table:table');
$tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells);
$tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'], $currCells);
$tmpInfo['lastColumnIndex'] = $tmpInfo['totalColumns'] - 1;
$tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
$worksheetInfo[] = $tmpInfo;
}
}
// foreach($workbookData->table as $worksheetDataSet) {
// foreach ($workbookData->table as $worksheetDataSet) {
// $worksheetData = $worksheetDataSet->children($namespacesContent['table']);
// $worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']);
//
@ -289,7 +281,6 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
return $worksheetInfo;
}
/**
* Loads PHPExcel from file
*
@ -306,10 +297,10 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
return $this->loadIntoExisting($pFilename, $objPHPExcel);
}
private static function identifyFixedStyleValue($styleList,&$styleAttributeValue) {
private static function identifyFixedStyleValue($styleList, &$styleAttributeValue)
{
$styleAttributeValue = strtolower($styleAttributeValue);
foreach($styleList as $style) {
foreach ($styleList as $style) {
if ($styleAttributeValue == strtolower($style)) {
$styleAttributeValue = $style;
return true;
@ -318,7 +309,6 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
return false;
}
/**
* Loads PHPExcel from file into PHPExcel instance
*
@ -353,30 +343,30 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$docProps = $objPHPExcel->getProperties();
$officeProperty = $xml->children($namespacesMeta['office']);
foreach($officeProperty as $officePropertyData) {
foreach ($officeProperty as $officePropertyData) {
$officePropertyDC = array();
if (isset($namespacesMeta['dc'])) {
$officePropertyDC = $officePropertyData->children($namespacesMeta['dc']);
}
foreach($officePropertyDC as $propertyName => $propertyValue) {
foreach ($officePropertyDC as $propertyName => $propertyValue) {
$propertyValue = (string) $propertyValue;
switch ($propertyName) {
case 'title' :
case 'title':
$docProps->setTitle($propertyValue);
break;
case 'subject' :
case 'subject':
$docProps->setSubject($propertyValue);
break;
case 'creator' :
case 'creator':
$docProps->setCreator($propertyValue);
$docProps->setLastModifiedBy($propertyValue);
break;
case 'date' :
case 'date':
$creationDate = strtotime($propertyValue);
$docProps->setCreated($creationDate);
$docProps->setModified($creationDate);
break;
case 'description' :
case 'description':
$docProps->setDescription($propertyValue);
break;
}
@ -385,45 +375,45 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
if (isset($namespacesMeta['dc'])) {
$officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']);
}
foreach($officePropertyMeta as $propertyName => $propertyValue) {
foreach ($officePropertyMeta as $propertyName => $propertyValue) {
$propertyValueAttributes = $propertyValue->attributes($namespacesMeta['meta']);
$propertyValue = (string) $propertyValue;
switch ($propertyName) {
case 'initial-creator' :
case 'initial-creator':
$docProps->setCreator($propertyValue);
break;
case 'keyword' :
case 'keyword':
$docProps->setKeywords($propertyValue);
break;
case 'creation-date' :
case 'creation-date':
$creationDate = strtotime($propertyValue);
$docProps->setCreated($creationDate);
break;
case 'user-defined' :
case 'user-defined':
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING;
foreach ($propertyValueAttributes as $key => $value) {
if ($key == 'name') {
$propertyValueName = (string) $value;
} elseif($key == 'value-type') {
} elseif ($key == 'value-type') {
switch ($value) {
case 'date' :
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'date');
case 'date':
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue, 'date');
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE;
break;
case 'boolean' :
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'bool');
case 'boolean':
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue, 'bool');
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN;
break;
case 'float' :
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'r4');
case 'float':
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue, 'r4');
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT;
break;
default :
default:
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING;
}
}
}
$docProps->setCustomProperty($propertyValueName,$propertyValue,$propertyValueType);
$docProps->setCustomProperty($propertyValueName, $propertyValue, $propertyValueType);
break;
}
}
@ -438,18 +428,18 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
// echo '</pre><hr />';
$workbook = $xml->children($namespacesContent['office']);
foreach($workbook->body->spreadsheet as $workbookData) {
foreach ($workbook->body->spreadsheet as $workbookData) {
$workbookData = $workbookData->children($namespacesContent['table']);
$worksheetID = 0;
foreach($workbookData->table as $worksheetDataSet) {
foreach ($workbookData->table as $worksheetDataSet) {
$worksheetData = $worksheetDataSet->children($namespacesContent['table']);
// print_r($worksheetData);
// echo '<br />';
$worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']);
// print_r($worksheetDataAttributes);
// echo '<br />';
if ((isset($this->_loadSheetsOnly)) && (isset($worksheetDataAttributes['name'])) &&
(!in_array($worksheetDataAttributes['name'], $this->_loadSheetsOnly))) {
if ((isset($this->loadSheetsOnly)) && (isset($worksheetDataAttributes['name'])) &&
(!in_array($worksheetDataAttributes['name'], $this->loadSheetsOnly))) {
continue;
}
@ -462,34 +452,31 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
// Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in
// formula cells... during the load, all formulae should be correct, and we're simply
// bringing the worksheet name in line with the formula, not the reverse
$objPHPExcel->getActiveSheet()->setTitle($worksheetName,false);
$objPHPExcel->getActiveSheet()->setTitle($worksheetName, false);
}
$rowID = 1;
foreach($worksheetData as $key => $rowData) {
foreach ($worksheetData as $key => $rowData) {
// echo '<b>'.$key.'</b><br />';
switch ($key) {
case 'table-header-rows':
foreach ($rowData as $key=>$cellData) {
foreach ($rowData as $key => $cellData) {
$rowData = $cellData;
break;
}
case 'table-row' :
case 'table-row':
$rowDataTableAttributes = $rowData->attributes($namespacesContent['table']);
$rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ?
$rowDataTableAttributes['number-rows-repeated'] : 1;
$rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ? $rowDataTableAttributes['number-rows-repeated'] : 1;
$columnID = 'A';
foreach($rowData as $key => $cellData) {
if ($this->getReadFilter() !== NULL) {
foreach ($rowData as $key => $cellData) {
if ($this->getReadFilter() !== null) {
if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
continue;
}
}
// echo '<b>'.$columnID.$rowID.'</b><br />';
$cellDataText = (isset($namespacesContent['text'])) ?
$cellData->children($namespacesContent['text']) :
'';
$cellDataText = (isset($namespacesContent['text'])) ? $cellData->children($namespacesContent['text']) : '';
$cellDataOffice = $cellData->children($namespacesContent['office']);
$cellDataOfficeAttributes = $cellData->attributes($namespacesContent['office']);
$cellDataTableAttributes = $cellData->attributes($namespacesContent['table']);
@ -514,20 +501,19 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
// echo 'Cell has comment<br />';
$annotationText = $cellDataOffice->annotation->children($namespacesContent['text']);
$textArray = array();
foreach($annotationText as $t) {
foreach ($annotationText as $t) {
if (isset($t->span)) {
foreach($t->span as $text) {
foreach ($t->span as $text) {
$textArray[] = (string)$text;
}
} else {
$textArray[] = (string) $t;
}
}
$text = implode("\n",$textArray);
// echo $text,'<br />';
$objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID )
$text = implode("\n", $textArray);
// echo $text, '<br />';
$objPHPExcel->getActiveSheet()->getComment($columnID.$rowID)->setText($this->parseRichText($text));
// ->setAuthor( $author )
->setText($this->_parseRichText($text) );
}
if (isset($cellDataText->p)) {
@ -553,7 +539,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
// echo 'Value Type is '.$cellDataOfficeAttributes['value-type'].'<br />';
switch ($cellDataOfficeAttributes['value-type']) {
case 'string' :
case 'string':
$type = PHPExcel_Cell_DataType::TYPE_STRING;
$dataValue = $allCellDataText;
if (isset($dataValue->a)) {
@ -562,11 +548,11 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$hyperlink = $cellXLinkAttributes['href'];
}
break;
case 'boolean' :
case 'boolean':
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
$dataValue = ($allCellDataText == 'TRUE') ? True : False;
$dataValue = ($allCellDataText == 'TRUE') ? true : false;
break;
case 'percentage' :
case 'percentage':
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$dataValue = (float) $cellDataOfficeAttributes['value'];
if (floor($dataValue) == $dataValue) {
@ -574,7 +560,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
}
$formatting = PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00;
break;
case 'currency' :
case 'currency':
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$dataValue = (float) $cellDataOfficeAttributes['value'];
if (floor($dataValue) == $dataValue) {
@ -582,68 +568,68 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
}
$formatting = PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE;
break;
case 'float' :
case 'float':
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$dataValue = (float) $cellDataOfficeAttributes['value'];
if (floor($dataValue) == $dataValue) {
if ($dataValue == (integer) $dataValue)
if ($dataValue == (integer) $dataValue) {
$dataValue = (integer) $dataValue;
else
} else {
$dataValue = (float) $dataValue;
}
}
break;
case 'date' :
case 'date':
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$dateObj = new DateTime($cellDataOfficeAttributes['date-value'], $GMT);
$dateObj->setTimeZone($timezoneObj);
list($year,$month,$day,$hour,$minute,$second) = explode(' ',$dateObj->format('Y m d H i s'));
$dataValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year,$month,$day,$hour,$minute,$second);
list($year, $month, $day, $hour, $minute, $second) = explode(' ', $dateObj->format('Y m d H i s'));
$dataValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year, $month, $day, $hour, $minute, $second);
if ($dataValue != floor($dataValue)) {
$formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15.' '.PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4;
} else {
$formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15;
}
break;
case 'time' :
case 'time':
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$dataValue = PHPExcel_Shared_Date::PHPToExcel(strtotime('01-01-1970 '.implode(':',sscanf($cellDataOfficeAttributes['time-value'],'PT%dH%dM%dS'))));
$dataValue = PHPExcel_Shared_Date::PHPToExcel(strtotime('01-01-1970 '.implode(':', sscanf($cellDataOfficeAttributes['time-value'], 'PT%dH%dM%dS'))));
$formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4;
break;
}
// echo 'Data value is '.$dataValue.'<br />';
// if ($hyperlink !== NULL) {
// if ($hyperlink !== null) {
// echo 'Hyperlink is '.$hyperlink.'<br />';
// }
} else {
$type = PHPExcel_Cell_DataType::TYPE_NULL;
$dataValue = NULL;
$dataValue = null;
}
if ($hasCalculatedValue) {
$type = PHPExcel_Cell_DataType::TYPE_FORMULA;
// echo 'Formula: ', $cellDataFormula, PHP_EOL;
$cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula,':=')+1);
$temp = explode('"',$cellDataFormula);
$cellDataFormula = substr($cellDataFormula, strpos($cellDataFormula, ':=')+1);
$temp = explode('"', $cellDataFormula);
$tKey = false;
foreach($temp as &$value) {
foreach ($temp as &$value) {
// Only replace in alternate array entries (i.e. non-quoted blocks)
if ($tKey = !$tKey) {
$value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/Ui','$1!$2:$3',$value); // Cell range reference in another sheet
$value = preg_replace('/\[([^\.]+)\.([^\.]+)\]/Ui','$1!$2',$value); // Cell reference in another sheet
$value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/Ui','$1:$2',$value); // Cell range reference
$value = preg_replace('/\[\.([^\.]+)\]/Ui','$1',$value); // Simple cell reference
$value = PHPExcel_Calculation::_translateSeparator(';',',',$value,$inBraces);
$value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/Ui', '$1!$2:$3', $value); // Cell range reference in another sheet
$value = preg_replace('/\[([^\.]+)\.([^\.]+)\]/Ui', '$1!$2', $value); // Cell reference in another sheet
$value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/Ui', '$1:$2', $value); // Cell range reference
$value = preg_replace('/\[\.([^\.]+)\]/Ui', '$1', $value); // Simple cell reference
$value = PHPExcel_Calculation::translateSeparator(';', ',', $value, $inBraces);
}
}
unset($value);
// Then rebuild the formula string
$cellDataFormula = implode('"',$temp);
$cellDataFormula = implode('"', $temp);
// echo 'Adjusted Formula: ', $cellDataFormula, PHP_EOL;
}
$colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ?
$cellDataTableAttributes['number-columns-repeated'] : 1;
if ($type !== NULL) {
$colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ? $cellDataTableAttributes['number-columns-repeated'] : 1;
if ($type !== null) {
for ($i = 0; $i < $colRepeats; ++$i) {
if ($i > 0) {
++$columnID;
@ -651,17 +637,17 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
if ($type !== PHPExcel_Cell_DataType::TYPE_NULL) {
for ($rowAdjust = 0; $rowAdjust < $rowRepeats; ++$rowAdjust) {
$rID = $rowID + $rowAdjust;
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue),$type);
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue), $type);
if ($hasCalculatedValue) {
// echo 'Forumla result is '.$dataValue.'<br />';
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setCalculatedValue($dataValue);
}
if ($formatting !== NULL) {
if ($formatting !== null) {
$objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode($formatting);
} else {
$objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_GENERAL);
}
if ($hyperlink !== NULL) {
if ($hyperlink !== null) {
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->getHyperlink()->setUrl($hyperlink);
}
}
@ -671,7 +657,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
// Merged cells
if ((isset($cellDataTableAttributes['number-columns-spanned'])) || (isset($cellDataTableAttributes['number-rows-spanned']))) {
if (($type !== PHPExcel_Cell_DataType::TYPE_NULL) || (!$this->_readDataOnly)) {
if (($type !== PHPExcel_Cell_DataType::TYPE_NULL) || (!$this->readDataOnly)) {
$columnTo = $columnID;
if (isset($cellDataTableAttributes['number-columns-spanned'])) {
$columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-spanned'] -2);
@ -699,13 +685,12 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
return $objPHPExcel;
}
private function _parseRichText($is = '') {
private function parseRichText($is = '')
{
$value = new PHPExcel_RichText();
$value->createText($is);
return $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_Reader_SYLK
*
* Copyright (c) 2006 - 2014 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 +30,10 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2014 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_Reader_SYLK
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
{
/**
@ -49,34 +41,35 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
*
* @var string
*/
private $_inputEncoding = 'ANSI';
private $inputEncoding = 'ANSI';
/**
* Sheet index to read
*
* @var int
*/
private $_sheetIndex = 0;
private $sheetIndex = 0;
/**
* Formats
*
* @var array
*/
private $_formats = array();
private $formats = array();
/**
* Format Count
*
* @var int
*/
private $_format = 0;
private $format = 0;
/**
* Create a new PHPExcel_Reader_SYLK
*/
public function __construct() {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
public function __construct()
{
$this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
}
/**
@ -84,24 +77,24 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
*
* @return boolean
*/
protected function _isValidFormat()
protected function isValidFormat()
{
// Read sample data (first 2 KB will do)
$data = fread($this->_fileHandle, 2048);
$data = fread($this->fileHandle, 2048);
// Count delimiters in file
$delimiterCount = substr_count($data, ';');
if ($delimiterCount < 1) {
return FALSE;
return false;
}
// Analyze first line looking for ID; signature
$lines = explode("\n", $data);
if (substr($lines[0],0,4) != 'ID;P') {
return FALSE;
if (substr($lines[0], 0, 4) != 'ID;P') {
return false;
}
return TRUE;
return true;
}
/**
@ -111,7 +104,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
*/
public function setInputEncoding($pValue = 'ANSI')
{
$this->_inputEncoding = $pValue;
$this->inputEncoding = $pValue;
return $this;
}
@ -122,7 +115,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
*/
public function getInputEncoding()
{
return $this->_inputEncoding;
return $this->inputEncoding;
}
/**
@ -134,12 +127,12 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
public function listWorksheetInfo($pFilename)
{
// Open file
$this->_openFile($pFilename);
if (!$this->_isValidFormat()) {
fclose ($this->_fileHandle);
$this->openFile($pFilename);
if (!$this->isValidFormat()) {
fclose($this->fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
}
$fileHandle = $this->_fileHandle;
$fileHandle = $this->fileHandle;
rewind($fileHandle);
$worksheetInfo = array();
@ -154,7 +147,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
// loop through one row (line) at a time in the file
$rowIndex = 0;
while (($rowData = fgets($fileHandle)) !== FALSE) {
while (($rowData = fgets($fileHandle)) !== false) {
$columnIndex = 0;
// convert SYLK encoded $rowData to UTF-8
@ -162,20 +155,20 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements 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)))));
$rowData = explode("\t", str_replace('¤', ';', str_replace(';', "\t", str_replace(';;', '¤', rtrim($rowData)))));
$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;
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);
case 'R':
case 'Y':
$rowIndex = substr($rowDatum, 1);
break;
}
@ -221,19 +214,19 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
// Open file
$this->_openFile($pFilename);
if (!$this->_isValidFormat()) {
fclose ($this->_fileHandle);
$this->openFile($pFilename);
if (!$this->isValidFormat()) {
fclose($this->fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
}
$fileHandle = $this->_fileHandle;
$fileHandle = $this->fileHandle;
rewind($fileHandle);
// Create new PHPExcel
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
while ($objPHPExcel->getSheetCount() <= $this->sheetIndex) {
$objPHPExcel->createSheet();
}
$objPHPExcel->setActiveSheetIndex( $this->_sheetIndex );
$objPHPExcel->setActiveSheetIndex($this->sheetIndex);
$fromFormats = array('\-', '\ ');
$toFormats = array('-', ' ');
@ -243,140 +236,172 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
$column = $row = '';
// loop through one row (line) at a time in the file
while (($rowData = fgets($fileHandle)) !== FALSE) {
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)))));
$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));
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);
case 'E':
case 'F':
$formatArray['font']['name'] = substr($rowDatum, 1);
break;
case 'L' : $formatArray['font']['size'] = substr($rowDatum,1);
case 'L':
$formatArray['font']['size'] = substr($rowDatum, 1);
break;
case 'S' : $styleSettings = substr($rowDatum,1);
for ($i=0;$i<strlen($styleSettings);++$i) {
case 'S':
$styleSettings = substr($rowDatum, 1);
for ($i=0; $i<strlen($styleSettings); ++$i) {
switch ($styleSettings{$i}) {
case 'I' : $formatArray['font']['italic'] = true;
case 'I':
$formatArray['font']['italic'] = true;
break;
case 'D' : $formatArray['font']['bold'] = true;
case 'D':
$formatArray['font']['bold'] = true;
break;
case 'T' : $formatArray['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
case 'T':
$formatArray['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'B' : $formatArray['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
case 'B':
$formatArray['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'L' : $formatArray['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
case 'L':
$formatArray['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'R' : $formatArray['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
case 'R':
$formatArray['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
}
}
break;
}
}
$this->_formats['P'.$this->_format++] = $formatArray;
$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);
foreach ($rowData as $rowDatum) {
switch ($rowDatum{0}) {
case 'C':
case 'X':
$column = substr($rowDatum, 1);
break;
case 'R' :
case 'Y' : $row = substr($rowDatum,1);
case 'R':
case 'Y':
$row = substr($rowDatum, 1);
break;
case 'K' : $cellData = substr($rowDatum,1);
case 'K':
$cellData = substr($rowDatum, 1);
break;
case 'E' : $cellDataFormula = '='.substr($rowDatum,1);
case 'E':
$cellDataFormula = '='.substr($rowDatum, 1);
// Convert R1C1 style references to A1 style references (but only when not quoted)
$temp = explode('"',$cellDataFormula);
$temp = explode('"', $cellDataFormula);
$key = false;
foreach($temp as &$value) {
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);
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) {
foreach ($cellReferences as $cellReference) {
$rowReference = $cellReference[2][0];
// Empty R reference is the current row
if ($rowReference == '') $rowReference = $row;
if ($rowReference == '') {
$rowReference = $row;
}
// Bracketed R references are relative to the current row
if ($rowReference{0} == '[') $rowReference = $row + trim($rowReference,'[]');
if ($rowReference{0} == '[') {
$rowReference = $row + trim($rowReference, '[]');
}
$columnReference = $cellReference[4][0];
// Empty C reference is the current column
if ($columnReference == '') $columnReference = $column;
if ($columnReference == '') {
$columnReference = $column;
}
// Bracketed C references are relative to the current column
if ($columnReference{0} == '[') $columnReference = $column + trim($columnReference,'[]');
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]));
$value = substr_replace($value, $A1CellReference, $cellReference[0][1], strlen($cellReference[0][0]));
}
}
}
unset($value);
// Then rebuild the formula string
$cellDataFormula = implode('"',$temp);
$cellDataFormula = implode('"', $temp);
$hasCalculatedValue = true;
break;
}
}
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
$cellData = PHPExcel_Calculation::_unwrapResult($cellData);
$cellData = PHPExcel_Calculation::unwrapResult($cellData);
// Set cell value
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setValue(($hasCalculatedValue) ? $cellDataFormula : $cellData);
if ($hasCalculatedValue) {
$cellData = PHPExcel_Calculation::_unwrapResult($cellData);
$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);
foreach ($rowData as $rowDatum) {
switch ($rowDatum{0}) {
case 'C':
case 'X':
$column = substr($rowDatum, 1);
break;
case 'R' :
case 'Y' : $row = substr($rowDatum,1);
case 'R':
case 'Y':
$row = substr($rowDatum, 1);
break;
case 'P' : $formatStyle = $rowDatum;
case 'P':
$formatStyle = $rowDatum;
break;
case 'W' : list($startCol,$endCol,$columnWidth) = explode(' ',substr($rowDatum,1));
case 'W':
list($startCol, $endCol, $columnWidth) = explode(' ', substr($rowDatum, 1));
break;
case 'S' : $styleSettings = substr($rowDatum,1);
for ($i=0;$i<strlen($styleSettings);++$i) {
case 'S':
$styleSettings = substr($rowDatum, 1);
for ($i=0; $i<strlen($styleSettings); ++$i) {
switch ($styleSettings{$i}) {
case 'I' : $styleData['font']['italic'] = true;
case 'I':
$styleData['font']['italic'] = true;
break;
case 'D' : $styleData['font']['bold'] = true;
case 'D':
$styleData['font']['bold'] = true;
break;
case 'T' : $styleData['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
case 'T':
$styleData['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'B' : $styleData['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
case 'B':
$styleData['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'L' : $styleData['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
case 'L':
$styleData['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'R' : $styleData['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
case 'R':
$styleData['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
}
}
@ -385,8 +410,8 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
}
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 (isset($this->formats[$formatStyle])) {
$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($this->formats[$formatStyle]);
}
}
if ((!empty($styleData)) && ($column > '') && ($row > '')) {
@ -407,13 +432,15 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
}
}
} else {
foreach($rowData as $rowDatum) {
switch($rowDatum{0}) {
case 'C' :
case 'X' : $column = substr($rowDatum,1);
foreach ($rowData as $rowDatum) {
switch ($rowDatum{0}) {
case 'C':
case 'X':
$column = substr($rowDatum, 1);
break;
case 'R' :
case 'Y' : $row = substr($rowDatum,1);
case 'R':
case 'Y':
$row = substr($rowDatum, 1);
break;
}
}
@ -432,8 +459,9 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
*
* @return int
*/
public function getSheetIndex() {
return $this->_sheetIndex;
public function getSheetIndex()
{
return $this->sheetIndex;
}
/**
@ -442,9 +470,9 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
* @param int $pValue Sheet index
* @return PHPExcel_Reader_SYLK
*/
public function setSheetIndex($pValue = 0) {
$this->_sheetIndex = $pValue;
public function setSheetIndex($pValue = 0)
{
$this->sheetIndex = $pValue;
return $this;
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_ReferenceHelper (Singleton)
*
* Copyright (c) 2006 - 2014 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 - 2014 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_ReferenceHelper (Singleton)
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_ReferenceHelper
{
/** Constants */
@ -47,25 +39,27 @@ class PHPExcel_ReferenceHelper
*
* @var PHPExcel_ReferenceHelper
*/
private static $_instance;
private static $instance;
/**
* Get an instance of this class
*
* @return PHPExcel_ReferenceHelper
*/
public static function getInstance() {
if (!isset(self::$_instance) || (self::$_instance === NULL)) {
self::$_instance = new PHPExcel_ReferenceHelper();
public static function getInstance()
{
if (!isset(self::$instance) || (self::$instance === null)) {
self::$instance = new PHPExcel_ReferenceHelper();
}
return self::$_instance;
return self::$instance;
}
/**
* Create a new PHPExcel_ReferenceHelper
*/
protected function __construct() {
protected function __construct()
{
}
/**
@ -76,7 +70,8 @@ class PHPExcel_ReferenceHelper
* @param string $b Second column to test (e.g. 'Z')
* @return integer
*/
public static function columnSort($a, $b) {
public static function columnSort($a, $b)
{
return strcasecmp(strlen($a) . $a, strlen($b) . $b);
}
@ -88,7 +83,8 @@ class PHPExcel_ReferenceHelper
* @param string $b Second column to test (e.g. 'Z')
* @return integer
*/
public static function columnReverseSort($a, $b) {
public static function columnReverseSort($a, $b)
{
return 1 - strcasecmp(strlen($a) . $a, strlen($b) . $b);
}
@ -100,9 +96,10 @@ class PHPExcel_ReferenceHelper
* @param string $b Second cell to test (e.g. 'Z1')
* @return integer
*/
public static function cellSort($a, $b) {
sscanf($a,'%[A-Z]%d', $ac, $ar);
sscanf($b,'%[A-Z]%d', $bc, $br);
public static function cellSort($a, $b)
{
sscanf($a, '%[A-Z]%d', $ac, $ar);
sscanf($b, '%[A-Z]%d', $bc, $br);
if ($ar == $br) {
return strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc);
@ -118,9 +115,10 @@ class PHPExcel_ReferenceHelper
* @param string $b Second cell to test (e.g. 'Z1')
* @return integer
*/
public static function cellReverseSort($a, $b) {
sscanf($a,'%[A-Z]%d', $ac, $ar);
sscanf($b,'%[A-Z]%d', $bc, $br);
public static function cellReverseSort($a, $b)
{
sscanf($a, '%[A-Z]%d', $ac, $ar);
sscanf($b, '%[A-Z]%d', $bc, $br);
if ($ar == $br) {
return 1 - strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc);
@ -138,20 +136,21 @@ class PHPExcel_ReferenceHelper
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
* @return boolean
*/
private static function cellAddressInDeleteRange($cellAddress, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols) {
private static function cellAddressInDeleteRange($cellAddress, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols)
{
list($cellColumn, $cellRow) = PHPExcel_Cell::coordinateFromString($cellAddress);
$cellColumnIndex = PHPExcel_Cell::columnIndexFromString($cellColumn);
// Is cell within the range of rows/columns if we're deleting
if ($pNumRows < 0 &&
($cellRow >= ($beforeRow + $pNumRows)) &&
($cellRow < $beforeRow)) {
return TRUE;
return true;
} elseif ($pNumCols < 0 &&
($cellColumnIndex >= ($beforeColumnIndex + $pNumCols)) &&
($cellColumnIndex < $beforeColumnIndex)) {
return TRUE;
return true;
}
return FALSE;
return false;
}
/**
@ -164,7 +163,7 @@ class PHPExcel_ReferenceHelper
* @param integer $beforeRow Number of the row we're inserting/deleting before
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
*/
protected function _adjustPageBreaks(PHPExcel_Worksheet $pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
protected function adjustPageBreaks(PHPExcel_Worksheet $pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
{
$aBreaks = $pSheet->getBreaks();
($pNumCols > 0 || $pNumRows > 0) ?
@ -198,7 +197,7 @@ class PHPExcel_ReferenceHelper
* @param integer $beforeRow Number of the row we're inserting/deleting before
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
*/
protected function _adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
protected function adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
{
$aComments = $pSheet->getComments();
$aNewComments = array(); // the new array of all comments
@ -225,18 +224,16 @@ class PHPExcel_ReferenceHelper
* @param integer $beforeRow Number of the row we're inserting/deleting before
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
*/
protected function _adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
protected function adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
{
$aHyperlinkCollection = $pSheet->getHyperlinkCollection();
($pNumCols > 0 || $pNumRows > 0) ?
uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) :
uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellSort'));
($pNumCols > 0 || $pNumRows > 0) ? uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) : uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellSort'));
foreach ($aHyperlinkCollection as $key => $value) {
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
if ($key != $newReference) {
$pSheet->setHyperlink( $newReference, $value );
$pSheet->setHyperlink( $key, null );
$pSheet->setHyperlink($newReference, $value);
$pSheet->setHyperlink($key, null);
}
}
}
@ -251,17 +248,16 @@ class PHPExcel_ReferenceHelper
* @param integer $beforeRow Number of the row we're inserting/deleting before
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
*/
protected function _adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
protected function adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
{
$aDataValidationCollection = $pSheet->getDataValidationCollection();
($pNumCols > 0 || $pNumRows > 0) ?
uksort($aDataValidationCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) :
uksort($aDataValidationCollection, array('PHPExcel_ReferenceHelper','cellSort'));
($pNumCols > 0 || $pNumRows > 0) ? uksort($aDataValidationCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) : uksort($aDataValidationCollection, array('PHPExcel_ReferenceHelper','cellSort'));
foreach ($aDataValidationCollection as $key => $value) {
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
if ($key != $newReference) {
$pSheet->setDataValidation( $newReference, $value );
$pSheet->setDataValidation( $key, null );
$pSheet->setDataValidation($newReference, $value);
$pSheet->setDataValidation($key, null);
}
}
}
@ -276,7 +272,7 @@ class PHPExcel_ReferenceHelper
* @param integer $beforeRow Number of the row we're inserting/deleting before
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
*/
protected function _adjustMergeCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
protected function adjustMergeCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
{
$aMergeCells = $pSheet->getMergeCells();
$aNewMergeCells = array(); // the new array of all merge cells
@ -297,7 +293,7 @@ class PHPExcel_ReferenceHelper
* @param integer $beforeRow Number of the row we're inserting/deleting before
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
*/
protected function _adjustProtectedCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
protected function adjustProtectedCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
{
$aProtectedCells = $pSheet->getProtectedCells();
($pNumCols > 0 || $pNumRows > 0) ?
@ -306,8 +302,8 @@ class PHPExcel_ReferenceHelper
foreach ($aProtectedCells as $key => $value) {
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
if ($key != $newReference) {
$pSheet->protectCells( $newReference, $value, true );
$pSheet->unprotectCells( $key );
$pSheet->protectCells($newReference, $value, true);
$pSheet->unprotectCells($key);
}
}
}
@ -322,7 +318,7 @@ class PHPExcel_ReferenceHelper
* @param integer $beforeRow Number of the row we're inserting/deleting before
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
*/
protected function _adjustColumnDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
protected function adjustColumnDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
{
$aColumnDimensions = array_reverse($pSheet->getColumnDimensions(), true);
if (!empty($aColumnDimensions)) {
@ -347,7 +343,7 @@ class PHPExcel_ReferenceHelper
* @param integer $beforeRow Number of the row we're inserting/deleting before
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
*/
protected function _adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
protected function adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
{
$aRowDimensions = array_reverse($pSheet->getRowDimensions(), true);
if (!empty($aRowDimensions)) {
@ -380,7 +376,7 @@ class PHPExcel_ReferenceHelper
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing
* @throws PHPExcel_Exception
*/
public function insertNewBefore($pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, PHPExcel_Worksheet $pSheet = NULL)
public function insertNewBefore($pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, PHPExcel_Worksheet $pSheet = null)
{
$remove = ($pNumCols < 0 || $pNumRows < 0);
$aCellCollection = $pSheet->getCellCollection();
@ -424,7 +420,7 @@ class PHPExcel_ReferenceHelper
}
// Loop through cells, bottom-up, and change cell coordinates
if($remove) {
if ($remove) {
// It's faster to reverse and pop than to use unshift, especially with large cell collections
$aCellCollection = array_reverse($aCellCollection);
}
@ -440,9 +436,7 @@ class PHPExcel_ReferenceHelper
$newCoordinates = PHPExcel_Cell::stringFromColumnIndex($cellIndex-1 + $pNumCols) . ($cell->getRow() + $pNumRows);
// Should the cell be updated? Move value and cellXf index from one cell to another.
if (($cellIndex >= $beforeColumnIndex) &&
($cell->getRow() >= $beforeRow)) {
if (($cellIndex >= $beforeColumnIndex) && ($cell->getRow() >= $beforeRow)) {
// Update cell styles
$pSheet->getCell($newCoordinates)->setXfIndex($cell->getXfIndex());
@ -450,8 +444,7 @@ class PHPExcel_ReferenceHelper
if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
// Formula should be adjusted
$pSheet->getCell($newCoordinates)
->setValue($this->updateFormulaReferences($cell->getValue(),
$pBefore, $pNumCols, $pNumRows, $pSheet->getTitle()));
->setValue($this->updateFormulaReferences($cell->getValue(), $pBefore, $pNumCols, $pNumRows, $pSheet->getTitle()));
} else {
// Formula should not be adjusted
$pSheet->getCell($newCoordinates)->setValue($cell->getValue());
@ -459,14 +452,12 @@ class PHPExcel_ReferenceHelper
// Clear the original cell
$pSheet->getCellCacheController()->deleteCacheData($cellID);
} else {
/* We don't need to update styles for rows/columns before our insertion position,
but we do still need to adjust any formulae in those cells */
if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
// Formula should be adjusted
$cell->setValue($this->updateFormulaReferences($cell->getValue(),
$pBefore, $pNumCols, $pNumRows, $pSheet->getTitle()));
$cell->setValue($this->updateFormulaReferences($cell->getValue(), $pBefore, $pNumCols, $pNumRows, $pSheet->getTitle()));
}
}
@ -478,9 +469,8 @@ class PHPExcel_ReferenceHelper
if ($pNumCols > 0 && $beforeColumnIndex - 2 > 0) {
for ($i = $beforeRow; $i <= $highestRow - 1; ++$i) {
// Style
$coordinate = PHPExcel_Cell::stringFromColumnIndex( $beforeColumnIndex - 2 ) . $i;
$coordinate = PHPExcel_Cell::stringFromColumnIndex($beforeColumnIndex - 2) . $i;
if ($pSheet->cellExists($coordinate)) {
$xfIndex = $pSheet->getCell($coordinate)->getXfIndex();
$conditionalStyles = $pSheet->conditionalStylesExists($coordinate) ?
@ -502,7 +492,6 @@ class PHPExcel_ReferenceHelper
if ($pNumRows > 0 && $beforeRow - 1 > 0) {
for ($i = $beforeColumnIndex - 1; $i <= PHPExcel_Cell::columnIndexFromString($highestColumn) - 1; ++$i) {
// Style
$coordinate = PHPExcel_Cell::stringFromColumnIndex($i) . ($beforeRow - 1);
if ($pSheet->cellExists($coordinate)) {
@ -524,28 +513,28 @@ class PHPExcel_ReferenceHelper
}
// Update worksheet: column dimensions
$this->_adjustColumnDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
$this->adjustColumnDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
// Update worksheet: row dimensions
$this->_adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
$this->adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
// Update worksheet: page breaks
$this->_adjustPageBreaks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
$this->adjustPageBreaks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
// Update worksheet: comments
$this->_adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
$this->adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
// Update worksheet: hyperlinks
$this->_adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
$this->adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
// Update worksheet: data validations
$this->_adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
$this->adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
// Update worksheet: merge cells
$this->_adjustMergeCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
$this->adjustMergeCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
// Update worksheet: protected cells
$this->_adjustProtectedCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
$this->adjustProtectedCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
// Update worksheet: autofilter
$autoFilter = $pSheet->getAutoFilter();
@ -554,9 +543,9 @@ class PHPExcel_ReferenceHelper
if ($pNumCols != 0) {
$autoFilterColumns = array_keys($autoFilter->getColumns());
if (count($autoFilterColumns) > 0) {
sscanf($pBefore,'%[A-Z]%d', $column, $row);
sscanf($pBefore, '%[A-Z]%d', $column, $row);
$columnIndex = PHPExcel_Cell::columnIndexFromString($column);
list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($autoFilterRange);
list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($autoFilterRange);
if ($columnIndex <= $rangeEnd[0]) {
if ($pNumCols < 0) {
// If we're actually deleting any columns that fall within the autofilter range,
@ -564,7 +553,7 @@ class PHPExcel_ReferenceHelper
$deleteColumn = $columnIndex + $pNumCols - 1;
$deleteCount = abs($pNumCols);
for ($i = 1; $i <= $deleteCount; ++$i) {
if (in_array(PHPExcel_Cell::stringFromColumnIndex($deleteColumn),$autoFilterColumns)) {
if (in_array(PHPExcel_Cell::stringFromColumnIndex($deleteColumn), $autoFilterColumns)) {
$autoFilter->clearColumn(PHPExcel_Cell::stringFromColumnIndex($deleteColumn));
}
++$deleteColumn;
@ -584,7 +573,7 @@ class PHPExcel_ReferenceHelper
$toColRef = $rangeEnd[0]+$pNumCols;
do {
$autoFilter->shiftColumn(PHPExcel_Cell::stringFromColumnIndex($endColRef-1),PHPExcel_Cell::stringFromColumnIndex($toColRef-1));
$autoFilter->shiftColumn(PHPExcel_Cell::stringFromColumnIndex($endColRef-1), PHPExcel_Cell::stringFromColumnIndex($toColRef-1));
--$endColRef;
--$toColRef;
} while ($startColRef <= $endColRef);
@ -594,7 +583,7 @@ class PHPExcel_ReferenceHelper
$toColID = PHPExcel_Cell::stringFromColumnIndex($startCol+$pNumCols-1);
$endColID = PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0]);
do {
$autoFilter->shiftColumn($startColID,$toColID);
$autoFilter->shiftColumn($startColID, $toColID);
++$startColID;
++$toColID;
} while ($startColID != $endColID);
@ -602,17 +591,17 @@ class PHPExcel_ReferenceHelper
}
}
}
$pSheet->setAutoFilter( $this->updateCellReference($autoFilterRange, $pBefore, $pNumCols, $pNumRows) );
$pSheet->setAutoFilter($this->updateCellReference($autoFilterRange, $pBefore, $pNumCols, $pNumRows));
}
// Update worksheet: freeze pane
if ($pSheet->getFreezePane() != '') {
$pSheet->freezePane( $this->updateCellReference($pSheet->getFreezePane(), $pBefore, $pNumCols, $pNumRows) );
$pSheet->freezePane($this->updateCellReference($pSheet->getFreezePane(), $pBefore, $pNumCols, $pNumRows));
}
// Page setup
if ($pSheet->getPageSetup()->isPrintAreaSet()) {
$pSheet->getPageSetup()->setPrintArea( $this->updateCellReference($pSheet->getPageSetup()->getPrintArea(), $pBefore, $pNumCols, $pNumRows) );
$pSheet->getPageSetup()->setPrintArea($this->updateCellReference($pSheet->getPageSetup()->getPrintArea(), $pBefore, $pNumCols, $pNumRows));
}
// Update worksheet: drawings
@ -628,9 +617,7 @@ class PHPExcel_ReferenceHelper
if (count($pSheet->getParent()->getNamedRanges()) > 0) {
foreach ($pSheet->getParent()->getNamedRanges() as $namedRange) {
if ($namedRange->getWorksheet()->getHashCode() == $pSheet->getHashCode()) {
$namedRange->setRange(
$this->updateCellReference($namedRange->getRange(), $pBefore, $pNumCols, $pNumRows)
);
$namedRange->setRange($this->updateCellReference($namedRange->getRange(), $pBefore, $pNumCols, $pNumRows));
}
}
}
@ -650,11 +637,12 @@ class PHPExcel_ReferenceHelper
* @return string Updated formula
* @throws PHPExcel_Exception
*/
public function updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, $sheetName = '') {
public function updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, $sheetName = '')
{
// Update cell references in the formula
$formulaBlocks = explode('"',$pFormula);
$formulaBlocks = explode('"', $pFormula);
$i = false;
foreach($formulaBlocks as &$formulaBlock) {
foreach ($formulaBlocks as &$formulaBlock) {
// Ignore blocks that were enclosed in quotes (alternating entries in the $formulaBlocks array after the explode)
if ($i = !$i) {
$adjustCount = 0;
@ -662,19 +650,19 @@ class PHPExcel_ReferenceHelper
// Search for row ranges (e.g. 'Sheet1'!3:5 or 3:5) with or without $ absolutes (e.g. $3:5)
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_ROWRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
if ($matchCount > 0) {
foreach($matches as $match) {
foreach ($matches as $match) {
$fromString = ($match[2] > '') ? $match[2].'!' : '';
$fromString .= $match[3].':'.$match[4];
$modified3 = substr($this->updateCellReference('$A'.$match[3],$pBefore,$pNumCols,$pNumRows),2);
$modified4 = substr($this->updateCellReference('$A'.$match[4],$pBefore,$pNumCols,$pNumRows),2);
$modified3 = substr($this->updateCellReference('$A'.$match[3], $pBefore, $pNumCols, $pNumRows), 2);
$modified4 = substr($this->updateCellReference('$A'.$match[4], $pBefore, $pNumCols, $pNumRows), 2);
if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
if (($match[2] == '') || (trim($match[2], "'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3.':'.$modified4;
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = 100000;
$row = 10000000+trim($match[3],'$');
$row = 10000000 + trim($match[3], '$');
$cellIndex = $column.$row;
$newCellTokens[$cellIndex] = preg_quote($toString);
@ -687,18 +675,18 @@ class PHPExcel_ReferenceHelper
// Search for column ranges (e.g. 'Sheet1'!C:E or C:E) with or without $ absolutes (e.g. $C:E)
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_COLRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
if ($matchCount > 0) {
foreach($matches as $match) {
foreach ($matches as $match) {
$fromString = ($match[2] > '') ? $match[2].'!' : '';
$fromString .= $match[3].':'.$match[4];
$modified3 = substr($this->updateCellReference($match[3].'$1',$pBefore,$pNumCols,$pNumRows),0,-2);
$modified4 = substr($this->updateCellReference($match[4].'$1',$pBefore,$pNumCols,$pNumRows),0,-2);
$modified3 = substr($this->updateCellReference($match[3].'$1', $pBefore, $pNumCols, $pNumRows), 0, -2);
$modified4 = substr($this->updateCellReference($match[4].'$1', $pBefore, $pNumCols, $pNumRows), 0, -2);
if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
if (($match[2] == '') || (trim($match[2], "'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3.':'.$modified4;
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = PHPExcel_Cell::columnIndexFromString(trim($match[3],'$')) + 100000;
$column = PHPExcel_Cell::columnIndexFromString(trim($match[3], '$')) + 100000;
$row = 10000000;
$cellIndex = $column.$row;
@ -712,20 +700,20 @@ class PHPExcel_ReferenceHelper
// Search for cell ranges (e.g. 'Sheet1'!A3:C5 or A3:C5) with or without $ absolutes (e.g. $A1:C$5)
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_CELLRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
if ($matchCount > 0) {
foreach($matches as $match) {
foreach ($matches as $match) {
$fromString = ($match[2] > '') ? $match[2].'!' : '';
$fromString .= $match[3].':'.$match[4];
$modified3 = $this->updateCellReference($match[3],$pBefore,$pNumCols,$pNumRows);
$modified4 = $this->updateCellReference($match[4],$pBefore,$pNumCols,$pNumRows);
$modified3 = $this->updateCellReference($match[3], $pBefore, $pNumCols, $pNumRows);
$modified4 = $this->updateCellReference($match[4], $pBefore, $pNumCols, $pNumRows);
if ($match[3].$match[4] !== $modified3.$modified4) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
if (($match[2] == '') || (trim($match[2], "'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3.':'.$modified4;
list($column,$row) = PHPExcel_Cell::coordinateFromString($match[3]);
list($column, $row) = PHPExcel_Cell::coordinateFromString($match[3]);
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000;
$row = trim($row,'$') + 10000000;
$column = PHPExcel_Cell::columnIndexFromString(trim($column, '$')) + 100000;
$row = trim($row, '$') + 10000000;
$cellIndex = $column.$row;
$newCellTokens[$cellIndex] = preg_quote($toString);
@ -739,19 +727,19 @@ class PHPExcel_ReferenceHelper
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_CELLREF.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
if ($matchCount > 0) {
foreach($matches as $match) {
foreach ($matches as $match) {
$fromString = ($match[2] > '') ? $match[2].'!' : '';
$fromString .= $match[3];
$modified3 = $this->updateCellReference($match[3],$pBefore,$pNumCols,$pNumRows);
$modified3 = $this->updateCellReference($match[3], $pBefore, $pNumCols, $pNumRows);
if ($match[3] !== $modified3) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
if (($match[2] == '') || (trim($match[2], "'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3;
list($column,$row) = PHPExcel_Cell::coordinateFromString($match[3]);
list($column, $row) = PHPExcel_Cell::coordinateFromString($match[3]);
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000;
$row = trim($row,'$') + 10000000;
$column = PHPExcel_Cell::columnIndexFromString(trim($column, '$')) + 100000;
$row = trim($row, '$') + 10000000;
$cellIndex = $row . $column;
$newCellTokens[$cellIndex] = preg_quote($toString);
@ -769,14 +757,14 @@ class PHPExcel_ReferenceHelper
ksort($cellTokens);
ksort($newCellTokens);
} // Update cell references in the formula
$formulaBlock = str_replace('\\','',preg_replace($cellTokens,$newCellTokens,$formulaBlock));
$formulaBlock = str_replace('\\', '', preg_replace($cellTokens, $newCellTokens, $formulaBlock));
}
}
}
unset($formulaBlock);
// Then rebuild the formula string
return implode('"',$formulaBlocks);
return implode('"', $formulaBlocks);
}
/**
@ -789,17 +777,18 @@ class PHPExcel_ReferenceHelper
* @return string Updated cell range
* @throws PHPExcel_Exception
*/
public function updateCellReference($pCellRange = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
public function updateCellReference($pCellRange = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0)
{
// Is it in another worksheet? Will not have to update anything.
if (strpos($pCellRange, "!") !== false) {
return $pCellRange;
// Is it a range or a single cell?
} elseif (strpos($pCellRange, ':') === false && strpos($pCellRange, ',') === false) {
// Single cell
return $this->_updateSingleCellReference($pCellRange, $pBefore, $pNumCols, $pNumRows);
return $this->updateSingleCellReference($pCellRange, $pBefore, $pNumCols, $pNumRows);
} elseif (strpos($pCellRange, ':') !== false || strpos($pCellRange, ',') !== false) {
// Range
return $this->_updateCellRange($pCellRange, $pBefore, $pNumCols, $pNumRows);
return $this->updateCellRange($pCellRange, $pBefore, $pNumCols, $pNumRows);
} else {
// Return original
return $pCellRange;
@ -813,7 +802,8 @@ class PHPExcel_ReferenceHelper
* @param string $oldName Old name (name to replace)
* @param string $newName New name
*/
public function updateNamedFormulas(PHPExcel $pPhpExcel, $oldName = '', $newName = '') {
public function updateNamedFormulas(PHPExcel $pPhpExcel, $oldName = '', $newName = '')
{
if ($oldName == '') {
return;
}
@ -821,7 +811,7 @@ class PHPExcel_ReferenceHelper
foreach ($pPhpExcel->getWorksheetIterator() as $sheet) {
foreach ($sheet->getCellCollection(false) as $cellID) {
$cell = $sheet->getCell($cellID);
if (($cell !== NULL) && ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA)) {
if (($cell !== null) && ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA)) {
$formula = $cell->getValue();
if (strpos($formula, $oldName) !== false) {
$formula = str_replace("'" . $oldName . "'!", "'" . $newName . "'!", $formula);
@ -843,8 +833,9 @@ class PHPExcel_ReferenceHelper
* @return string Updated cell range
* @throws PHPExcel_Exception
*/
private function _updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
if (strpos($pCellRange,':') !== false || strpos($pCellRange, ',') !== false) {
private function updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0)
{
if (strpos($pCellRange, ':') !== false || strpos($pCellRange, ',') !== false) {
// Update range
$range = PHPExcel_Cell::splitRange($pCellRange);
$ic = count($range);
@ -852,13 +843,13 @@ class PHPExcel_ReferenceHelper
$jc = count($range[$i]);
for ($j = 0; $j < $jc; ++$j) {
if (ctype_alpha($range[$i][$j])) {
$r = PHPExcel_Cell::coordinateFromString($this->_updateSingleCellReference($range[$i][$j].'1', $pBefore, $pNumCols, $pNumRows));
$r = PHPExcel_Cell::coordinateFromString($this->updateSingleCellReference($range[$i][$j].'1', $pBefore, $pNumCols, $pNumRows));
$range[$i][$j] = $r[0];
} elseif(ctype_digit($range[$i][$j])) {
$r = PHPExcel_Cell::coordinateFromString($this->_updateSingleCellReference('A'.$range[$i][$j], $pBefore, $pNumCols, $pNumRows));
} elseif (ctype_digit($range[$i][$j])) {
$r = PHPExcel_Cell::coordinateFromString($this->updateSingleCellReference('A'.$range[$i][$j], $pBefore, $pNumCols, $pNumRows));
$range[$i][$j] = $r[1];
} else {
$range[$i][$j] = $this->_updateSingleCellReference($range[$i][$j], $pBefore, $pNumCols, $pNumRows);
$range[$i][$j] = $this->updateSingleCellReference($range[$i][$j], $pBefore, $pNumCols, $pNumRows);
}
}
}
@ -880,23 +871,22 @@ class PHPExcel_ReferenceHelper
* @return string Updated cell reference
* @throws PHPExcel_Exception
*/
private function _updateSingleCellReference($pCellReference = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
private function updateSingleCellReference($pCellReference = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0)
{
if (strpos($pCellReference, ':') === false && strpos($pCellReference, ',') === false) {
// Get coordinates of $pBefore
list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString( $pBefore );
list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString($pBefore);
// Get coordinates of $pCellReference
list($newColumn, $newRow) = PHPExcel_Cell::coordinateFromString( $pCellReference );
list($newColumn, $newRow) = PHPExcel_Cell::coordinateFromString($pCellReference);
// Verify which parts should be updated
$updateColumn = (($newColumn{0} != '$') && ($beforeColumn{0} != '$') &&
PHPExcel_Cell::columnIndexFromString($newColumn) >= PHPExcel_Cell::columnIndexFromString($beforeColumn));
$updateRow = (($newRow{0} != '$') && ($beforeRow{0} != '$') &&
$newRow >= $beforeRow);
$updateColumn = (($newColumn{0} != '$') && ($beforeColumn{0} != '$') && (PHPExcel_Cell::columnIndexFromString($newColumn) >= PHPExcel_Cell::columnIndexFromString($beforeColumn)));
$updateRow = (($newRow{0} != '$') && ($beforeRow{0} != '$') && $newRow >= $beforeRow);
// Create new column reference
if ($updateColumn) {
$newColumn = PHPExcel_Cell::stringFromColumnIndex( PHPExcel_Cell::columnIndexFromString($newColumn) - 1 + $pNumCols );
$newColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($newColumn) - 1 + $pNumCols);
}
// Create new row reference
@ -916,7 +906,8 @@ class PHPExcel_ReferenceHelper
*
* @throws PHPExcel_Exception
*/
public final function __clone() {
final public function __clone()
{
throw new PHPExcel_Exception("Cloning a Singleton is not allowed!");
}
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_RichText
*
* Copyright (c) 2006 - 2014 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 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_RichText implements PHPExcel_IComparable
{
/**
@ -40,7 +32,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
*
* @var PHPExcel_RichText_ITextElement[]
*/
private $_richTextElements;
private $richTextElements;
/**
* Create a new PHPExcel_RichText instance
@ -51,10 +43,10 @@ class PHPExcel_RichText implements PHPExcel_IComparable
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,19 +19,10 @@
*
* @category PHPExcel
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2014 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_ITextElement
*
* @category PHPExcel
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
interface PHPExcel_RichText_ITextElement
{
/**

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,19 +19,10 @@
*
* @category PHPExcel
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2014 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_Run
*
* @category PHPExcel
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
{
/**
@ -38,7 +30,7 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
*
* @var PHPExcel_Style_Font
*/
private $_font;
private $font;
/**
* Create a new PHPExcel_RichText_Run instance
@ -49,7 +41,7 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
{
// Initialise variables
$this->setText($pText);
$this->_font = new PHPExcel_Style_Font();
$this->font = new PHPExcel_Style_Font();
}
/**
@ -57,8 +49,9 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
*
* @return PHPExcel_Style_Font
*/
public function getFont() {
return $this->_font;
public function getFont()
{
return $this->font;
}
/**
@ -68,8 +61,9 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
* @throws PHPExcel_Exception
* @return PHPExcel_RichText_ITextElement
*/
public function setFont(PHPExcel_Style_Font $pFont = null) {
$this->_font = $pFont;
public function setFont(PHPExcel_Style_Font $pFont = null)
{
$this->font = $pFont;
return $this;
}
@ -78,18 +72,20 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
*
* @return string Hash code
*/
public function getHashCode() {
public function getHashCode()
{
return md5(
$this->getText()
. $this->_font->getHashCode()
. __CLASS__
$this->getText() .
$this->font->getHashCode() .
__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,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,19 +19,10 @@
*
* @category PHPExcel
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2014 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_TextElement
*
* @category PHPExcel
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
{
/**
@ -38,7 +30,7 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
*
* @var string
*/
private $_text;
private $text;
/**
* Create a new PHPExcel_RichText_TextElement instance
@ -48,7 +40,7 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
public function __construct($pText = '')
{
// Initialise variables
$this->_text = $pText;
$this->text = $pText;
}
/**
@ -56,8 +48,9 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
*
* @return string Text
*/
public function getText() {
return $this->_text;
public function getText()
{
return $this->text;
}
/**
@ -66,8 +59,9 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
* @param $pText string Text
* @return PHPExcel_RichText_ITextElement
*/
public function setText($pText = '') {
$this->_text = $pText;
public function setText($pText = '')
{
$this->text = $pText;
return $this;
}
@ -76,7 +70,8 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
*
* @return PHPExcel_Style_Font
*/
public function getFont() {
public function getFont()
{
return null;
}
@ -85,17 +80,19 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
*
* @return string Hash code
*/
public function getHashCode() {
public function getHashCode()
{
return md5(
$this->_text
. __CLASS__
$this->text .
__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_Settings
*
* Copyright (c) 2006 - 2014 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,21 +30,10 @@
*
* @category PHPExcel
* @package PHPExcel_Settings
* @copyright Copyright (c) 2006 - 2014 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 */
@ -51,11 +50,11 @@ class PHPExcel_Settings
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,
@ -69,7 +68,7 @@ class PHPExcel_Settings
*
* @var string
*/
private static $_zipClass = self::ZIPARCHIVE;
private static $zipClass = self::ZIPARCHIVE;
/**
@ -79,14 +78,14 @@ class PHPExcel_Settings
*
* @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;
/**
@ -96,21 +95,21 @@ class PHPExcel_Settings
*
* @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;
private static $libXmlLoaderOptions = null;
/**
* Set the Zip handler Class that PHPExcel should use for Zip file management (PCLZip or ZipArchive)
@ -123,11 +122,11 @@ class PHPExcel_Settings
{
if (($zipClass === self::PCLZIP) ||
($zipClass === self::ZIPARCHIVE)) {
self::$_zipClass = $zipClass;
return TRUE;
self::$zipClass = $zipClass;
return true;
}
return false;
}
return FALSE;
} // function setZipClass()
/**
@ -140,8 +139,8 @@ class PHPExcel_Settings
*/
public static function getZipClass()
{
return self::$_zipClass;
} // function getZipClass()
return self::$zipClass;
}
/**
@ -152,7 +151,7 @@ class PHPExcel_Settings
public static function getCacheStorageMethod()
{
return PHPExcel_CachedObjectStorageFactory::getCacheStorageMethod();
} // function getCacheStorageMethod()
}
/**
@ -163,7 +162,7 @@ class PHPExcel_Settings
public static function getCacheStorageClass()
{
return PHPExcel_CachedObjectStorageFactory::getCacheStorageClass();
} // function getCacheStorageClass()
}
/**
@ -173,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()
}
/**
@ -188,10 +184,10 @@ 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()
}
/**
@ -205,10 +201,11 @@ class PHPExcel_Settings
*/
public static function setChartRenderer($libraryName, $libraryBaseDir)
{
if (!self::setChartRendererName($libraryName))
return FALSE;
if (!self::setChartRendererName($libraryName)) {
return false;
}
return self::setChartRendererPath($libraryBaseDir);
} // function setChartRenderer()
}
/**
@ -221,14 +218,13 @@ class PHPExcel_Settings
*/
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;
}
/**
@ -240,12 +236,12 @@ class PHPExcel_Settings
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;
}
/**
@ -257,8 +253,8 @@ class PHPExcel_Settings
*/
public static function getChartRendererName()
{
return self::$_chartRendererName;
} // function getChartRendererName()
return self::$chartRendererName;
}
/**
@ -269,8 +265,8 @@ class PHPExcel_Settings
*/
public static function getChartRendererPath()
{
return self::$_chartRendererPath;
} // function getChartRendererPath()
return self::$chartRendererPath;
}
/**
@ -286,10 +282,11 @@ 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()
}
/**
@ -304,14 +301,13 @@ class PHPExcel_Settings
*/
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;
}
/**
@ -323,12 +319,12 @@ 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;
}
/**
@ -342,8 +338,8 @@ class PHPExcel_Settings
*/
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
@ -353,39 +349,41 @@ class PHPExcel_Settings
*/
public static function getPdfRendererPath()
{
return self::$_pdfRendererPath;
} // function getPdfRendererPath()
return self::$pdfRendererPath;
}
/**
* Set default options for libxml loader
* Set options for libxml loader
*
* @param int $options Default options for libxml loader
* @param int $options Options for libxml loader
*/
public static function setLibXmlLoaderOptions($options = null)
{
if (is_null($options) && defined(LIBXML_DTDLOAD)) {
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($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
@libxml_disable_entity_loader((bool) $options);
}
self::$libXmlLoaderOptions = $options;
}
self::$_libXmlLoaderOptions = $options;
} // function setLibXmlLoaderOptions
/**
* Get default options for libxml loader.
* 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)) {
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(self::$_libXmlLoaderOptions == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
@libxml_disable_entity_loader((bool) self::$libXmlLoaderOptions);
}
return self::$libXmlLoaderOptions;
}
return self::$_libXmlLoaderOptions;
} // function getLibXmlLoaderOptions
}

View file

@ -1,8 +1,9 @@
<?php
/**
* PHPExcel
* PHPExcel_Shared_CodePage
*
* Copyright (c) 2006 - 2014 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_Shared
* @copyright Copyright (c) 2006 - 2014 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_Shared_CodePage
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_CodePage
{
/**
@ -46,61 +38,119 @@ class PHPExcel_Shared_CodePage
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 10001: return 'CP932'; break; // Macintosh Japanese
case 10002: return 'CP950'; break; // Macintosh Chinese Traditional
case 10003: return 'CP1361'; break; // Macintosh Korean
case 10006: return 'MACGREEK'; break; // Macintosh Greek
case 10007: return 'MACCYRILLIC'; break; // Macintosh Cyrillic
case 10008: return 'CP936'; break; // Macintosh - Simplified Chinese (GB 2312)
case 10029: return 'MACCENTRALEUROPE'; break; // Macintosh Central Europe
case 10079: return 'MACICELAND'; break; // Macintosh Icelandic
case 10081: return 'MACTURKISH'; break; // Macintosh Turkish
case 21010: return 'UTF-16LE'; break; // UTF-16 (BIFF8) This isn't correct, but some Excel writer libraries erroneously use Codepage 21010 for UTF-16LE
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)
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 - 2014 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_Shared
* @copyright Copyright (c) 2006 - 2014 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_Shared_Date
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Date
{
/** constants */
@ -47,7 +38,8 @@ class PHPExcel_Shared_Date
* @public
* @var string[]
*/
public static $_monthNames = array( 'Jan' => 'January',
public static $monthNames = array(
'Jan' => 'January',
'Feb' => 'February',
'Mar' => 'March',
'Apr' => 'April',
@ -68,7 +60,8 @@ class PHPExcel_Shared_Date
* @public
* @var string[]
*/
public static $_numberSuffixes = array( 'st',
public static $numberSuffixes = array(
'st',
'nd',
'rd',
'th',
@ -80,7 +73,7 @@ class PHPExcel_Shared_Date
* @private
* @var int
*/
protected static $_excelBaseDate = self::CALENDAR_WINDOWS_1900;
protected static $excelBaseDate = self::CALENDAR_WINDOWS_1900;
/**
* Set the Excel calendar (Windows 1900 or Mac 1904)
@ -88,14 +81,15 @@ class PHPExcel_Shared_Date
* @param integer $baseDate Excel base date (1900 or 1904)
* @return boolean Success or failure
*/
public static function setExcelCalendar($baseDate) {
public static function setExcelCalendar($baseDate)
{
if (($baseDate == self::CALENDAR_WINDOWS_1900) ||
($baseDate == self::CALENDAR_MAC_1904)) {
self::$_excelBaseDate = $baseDate;
return TRUE;
self::$excelBaseDate = $baseDate;
return true;
}
return false;
}
return FALSE;
} // function setExcelCalendar()
/**
@ -103,34 +97,36 @@ class PHPExcel_Shared_Date
*
* @return integer Excel base date (1900 or 1904)
*/
public static function getExcelCalendar() {
return self::$_excelBaseDate;
} // function getExcelCalendar()
public static function getExcelCalendar()
{
return self::$excelBaseDate;
}
/**
* Convert a date from Excel to PHP
*
* @param long $dateValue Excel date/time value
* @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 long PHP serialized date/time
* @return integer PHP serialized date/time
*/
public static function ExcelToPHP($dateValue = 0, $adjustToTimezone = FALSE, $timezone = NULL) {
if (self::$_excelBaseDate == self::CALENDAR_WINDOWS_1900) {
$my_excelBaseDate = 25569;
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) {
--$my_excelBaseDate;
--$myexcelBaseDate;
}
} else {
$my_excelBaseDate = 24107;
$myexcelBaseDate = 24107;
}
// Perform conversion
if ($dateValue >= 1) {
$utcDays = $dateValue - $my_excelBaseDate;
$utcDays = $dateValue - $myexcelBaseDate;
$returnValue = round($utcDays * 86400);
if (($returnValue <= PHP_INT_MAX) && ($returnValue >= -PHP_INT_MAX)) {
$returnValue = (integer) $returnValue;
@ -146,9 +142,8 @@ class PHPExcel_Shared_Date
PHPExcel_Shared_TimeZone::getTimezoneAdjustment($timezone, $returnValue) :
0;
// Return
return $returnValue + $timezoneAdjustment;
} // function ExcelToPHP()
}
/**
@ -157,7 +152,8 @@ class PHPExcel_Shared_Date
* @param integer $dateValue Excel date/time value
* @return DateTime PHP date/time object
*/
public static function ExcelToPHPObject($dateValue = 0) {
public static function ExcelToPHPObject($dateValue = 0)
{
$dateTime = self::ExcelToPHP($dateValue);
$days = floor($dateTime / 86400);
$time = round((($dateTime / 86400) - $days) * 86400);
@ -166,10 +162,10 @@ class PHPExcel_Shared_Date
$seconds = round($time) - ($hours * 3600) - ($minutes * 60);
$dateObj = date_create('1-Jan-1970+'.$days.' days');
$dateObj->setTime($hours,$minutes,$seconds);
$dateObj->setTime($hours, $minutes, $seconds);
return $dateObj;
} // function ExcelToPHPObject()
}
/**
@ -182,48 +178,57 @@ class PHPExcel_Shared_Date
* @return mixed Excel date/time value
* or boolean FALSE on failure
*/
public static function PHPToExcel($dateValue = 0, $adjustToTimezone = FALSE, $timezone = NULL) {
public static function PHPToExcel($dateValue = 0, $adjustToTimezone = false, $timezone = null)
{
$saveTimeZone = date_default_timezone_get();
date_default_timezone_set('UTC');
$retValue = FALSE;
$timezoneAdjustment = ($adjustToTimezone) ?
PHPExcel_Shared_TimeZone::getTimezoneAdjustment($timezone ? $timezone : $saveTimeZone, $dateValue) :
0;
$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')
);
$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)) {
$retValue = self::FormattedPHPToExcel( date('Y',$dateValue), date('m',$dateValue), date('d',$dateValue),
date('H',$dateValue), date('i',$dateValue), date('s',$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;
} // function PHPToExcel()
}
/**
* 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
* @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) {
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;
$excel1900isLeapYear = true;
if (($year == 1900) && ($month <= 2)) {
$excel1900isLeapYear = false;
}
$myexcelBaseDate = 2415020;
} else {
$my_excelBaseDate = 2416481;
$excel1900isLeapYear = FALSE;
$myexcelBaseDate = 2416481;
$excel1900isLeapYear = false;
}
// Julian base date Adjustment
@ -235,14 +240,14 @@ class PHPExcel_Shared_Date
}
// 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;
$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;
return (float) $excelDate + $excelTime;
} // function FormattedPHPToExcel()
}
/**
@ -251,13 +256,14 @@ class PHPExcel_Shared_Date
* @param PHPExcel_Cell $pCell
* @return boolean
*/
public static function isDateTime(PHPExcel_Cell $pCell) {
public static function isDateTime(PHPExcel_Cell $pCell)
{
return self::isDateTimeFormat(
$pCell->getWorksheet()->getStyle(
$pCell->getCoordinate()
)->getNumberFormat()
);
} // function isDateTime()
}
/**
@ -266,9 +272,10 @@ class PHPExcel_Shared_Date
* @param PHPExcel_Style_NumberFormat $pFormat
* @return boolean
*/
public static function isDateTimeFormat(PHPExcel_Style_NumberFormat $pFormat) {
public static function isDateTimeFormat(PHPExcel_Style_NumberFormat $pFormat)
{
return self::isDateTimeFormatCode($pFormat->getFormatCode());
} // function isDateTimeFormat()
}
private static $possibleDateFormatCharacters = 'eymdHs';
@ -279,13 +286,17 @@ class PHPExcel_Shared_Date
* @param string $pFormatCode
* @return boolean
*/
public static function isDateTimeFormatCode($pFormatCode = '') {
if (strtolower($pFormatCode) === strtolower(PHPExcel_Style_NumberFormat::FORMAT_GENERAL))
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))
return false;
}
if (preg_match('/[0#]E[+-]0/i', $pFormatCode)) {
// Scientific format
return FALSE;
return false;
}
// Switch on formatcode
switch ($pFormatCode) {
// Explicitly defined date formats
@ -311,34 +322,34 @@ class PHPExcel_Shared_Date
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX16:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX17:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX22:
return TRUE;
return true;
}
// Typically number, currency or accounting (or occasionally fraction) formats
if ((substr($pFormatCode,0,1) == '_') || (substr($pFormatCode,0,2) == '0 ')) {
return FALSE;
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)) {
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) {
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;
(preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i', $subVal))) {
return true;
}
}
return FALSE;
return false;
}
return TRUE;
return true;
}
// No date...
return FALSE;
} // function isDateTimeFormatCode()
return false;
}
/**
@ -347,33 +358,41 @@ class PHPExcel_Shared_Date
* @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;
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);
if ($dateValueNew === PHPExcel_Calculation_Functions::VALUE()) {
return FALSE;
} else {
if (strpos($dateValue, ':') !== FALSE) {
return false;
}
if (strpos($dateValue, ':') !== false) {
$timeValue = PHPExcel_Calculation_DateTime::TIMEVALUE($dateValue);
if ($timeValue === PHPExcel_Calculation_Functions::VALUE()) {
return FALSE;
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;
}
@ -382,12 +401,18 @@ class PHPExcel_Shared_Date
return $month;
}
public static function dayStringToNumber($day) {
$strippedDayValue = (str_replace(self::$_numberSuffixes,'',$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 $strippedDayValue;
return (integer) $strippedDayValue;
}
return $day;
}
}

View file

@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 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_Shared
* @copyright Copyright (c) 2006 - 2014 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 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Drawing
{
@ -41,7 +41,8 @@ class PHPExcel_Shared_Drawing
* @param int $pValue Value in pixels
* @return int Value in EMU
*/
public static function pixelsToEMU($pValue = 0) {
public static function pixelsToEMU($pValue = 0)
{
return round($pValue * 9525);
}
@ -51,7 +52,8 @@ class PHPExcel_Shared_Drawing
* @param int $pValue Value in EMU
* @return int Value in pixels
*/
public static function EMUToPixels($pValue = 0) {
public static function EMUToPixels($pValue = 0)
{
if ($pValue != 0) {
return round($pValue / 9525);
} else {
@ -68,22 +70,19 @@ class PHPExcel_Shared_Drawing
* @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook
* @return int Value in cell dimension
*/
public static function pixelsToCellDimension($pValue = 0, PHPExcel_Style_Font $pDefaultFont) {
public static function pixelsToCellDimension($pValue = 0, PHPExcel_Style_Font $pDefaultFont)
{
// Font name and size
$name = $pDefaultFont->getName();
$size = $pDefaultFont->getSize();
if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) {
// Exact width can be determined
$colWidth = $pValue
* PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width']
/ PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px'];
$colWidth = $pValue * PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width'] / PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px'];
} else {
// We don't have data for this particular font and size, use approximation by
// extrapolating from Calibri 11
$colWidth = $pValue * 11
* PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width']
/ PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px'] / $size;
$colWidth = $pValue * 11 * PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width'] / PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px'] / $size;
}
return $colWidth;
@ -96,23 +95,19 @@ class PHPExcel_Shared_Drawing
* @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook
* @return int Value in pixels
*/
public static function cellDimensionToPixels($pValue = 0, PHPExcel_Style_Font $pDefaultFont) {
public static function cellDimensionToPixels($pValue = 0, PHPExcel_Style_Font $pDefaultFont)
{
// Font name and size
$name = $pDefaultFont->getName();
$size = $pDefaultFont->getSize();
if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) {
// Exact width can be determined
$colWidth = $pValue
* PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px']
/ PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width'];
$colWidth = $pValue * PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px'] / PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width'];
} else {
// We don't have data for this particular font and size, use approximation by
// extrapolating from Calibri 11
$colWidth = $pValue * $size
* PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px']
/ PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width'] / 11;
$colWidth = $pValue * $size * PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px'] / PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width'] / 11;
}
// Round pixels to closest integer
@ -127,7 +122,8 @@ class PHPExcel_Shared_Drawing
* @param int $pValue Value in pixels
* @return int Value in points
*/
public static function pixelsToPoints($pValue = 0) {
public static function pixelsToPoints($pValue = 0)
{
return $pValue * 0.67777777;
}
@ -137,7 +133,8 @@ class PHPExcel_Shared_Drawing
* @param int $pValue Value in points
* @return int Value in pixels
*/
public static function pointsToPixels($pValue = 0) {
public static function pointsToPixels($pValue = 0)
{
if ($pValue != 0) {
return (int) ceil($pValue * 1.333333333);
} else {
@ -151,7 +148,8 @@ class PHPExcel_Shared_Drawing
* @param int $pValue Degrees
* @return int Angle
*/
public static function degreesToAngle($pValue = 0) {
public static function degreesToAngle($pValue = 0)
{
return (int)round($pValue * 60000);
}
@ -161,7 +159,8 @@ class PHPExcel_Shared_Drawing
* @param int $pValue Angle
* @return int Degrees
*/
public static function angleToDegrees($pValue = 0) {
public static function angleToDegrees($pValue = 0)
{
if ($pValue != 0) {
return round($pValue / 60000);
} else {
@ -179,21 +178,21 @@ class PHPExcel_Shared_Drawing
public static function imagecreatefrombmp($p_sFile)
{
// Load the image into a string
$file = fopen($p_sFile,"rb");
$read = fread($file,10);
while(!feof($file)&&($read<>""))
$read .= fread($file,1024);
$file = fopen($p_sFile, "rb");
$read = fread($file, 10);
while (!feof($file) && ($read<>"")) {
$read .= fread($file, 1024);
}
$temp = unpack("H*",$read);
$temp = unpack("H*", $read);
$hex = $temp[1];
$header = substr($hex,0,108);
$header = substr($hex, 0, 108);
// Process the header
// Structure: http://www.fastgraph.com/help/bmp_header_format.html
if (substr($header,0,4)=="424d")
{
if (substr($header, 0, 4)=="424d") {
// Cut it in parts of 2 bytes
$header_parts = str_split($header,2);
$header_parts = str_split($header, 2);
// Get the width 4 bytes
$width = hexdec($header_parts[19].$header_parts[18]);
@ -210,10 +209,10 @@ class PHPExcel_Shared_Drawing
$y = 1;
// Create newimage
$image = imagecreatetruecolor($width,$height);
$image = imagecreatetruecolor($width, $height);
// Grab the body from the image
$body = substr($hex,108);
$body = substr($hex, 108);
// Calculate if padding at the end-line is needed
// Divided by two to keep overview.
@ -226,15 +225,14 @@ class PHPExcel_Shared_Drawing
// Using a for-loop with index-calculation instaid of str_split to avoid large memory consumption
// Calculate the next DWORD-position in the body
for ($i=0;$i<$body_size;$i+=3)
{
for ($i = 0; $i < $body_size; $i += 3) {
// Calculate line-ending and padding
if ($x>=$width)
{
if ($x >= $width) {
// If padding needed, ignore image-padding
// Shift i to the ending of the current 32-bit-block
if ($usePadding)
if ($usePadding) {
$i += $width%4;
}
// Reset horizontal position
$x = 0;
@ -243,20 +241,21 @@ class PHPExcel_Shared_Drawing
$y++;
// Reached the image-height? Break the for-loop
if ($y>$height)
if ($y > $height) {
break;
}
}
// Calculation of the RGB-pixel (defined as BGR in image-data)
// Define $i_pos as absolute position in the body
$i_pos = $i*2;
$i_pos = $i * 2;
$r = hexdec($body[$i_pos+4].$body[$i_pos+5]);
$g = hexdec($body[$i_pos+2].$body[$i_pos+3]);
$b = hexdec($body[$i_pos].$body[$i_pos+1]);
// Calculate and draw the pixel
$color = imagecolorallocate($image,$r,$g,$b);
imagesetpixel($image,$x,$height-$y,$color);
$color = imagecolorallocate($image, $r, $g, $b);
imagesetpixel($image, $x, $height-$y, $color);
// Raise the horizontal position
$x++;
@ -268,5 +267,4 @@ class PHPExcel_Shared_Drawing
// Return image-object
return $image;
}
}

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