ef803d84 by Marty Penner

Change all incorrect capitalization of the Tz\Wordpress namespace to Tz\WordPress

1 parent a1b952c1
Showing 55 changed files with 1809 additions and 1809 deletions
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelReader; 2 namespace Tz\WordPress\Tools\ExcelReader;
3 3
4 define('NUM_BIG_BLOCK_DEPOT_BLOCKS_POS', 0x2c); 4 define('NUM_BIG_BLOCK_DEPOT_BLOCKS_POS', 0x2c);
5 define('SMALL_BLOCK_DEPOT_BLOCK_POS', 0x3c); 5 define('SMALL_BLOCK_DEPOT_BLOCK_POS', 0x3c);
6 define('ROOT_START_BLOCK_POS', 0x30); 6 define('ROOT_START_BLOCK_POS', 0x30);
7 define('BIG_BLOCK_SIZE', 0x200); 7 define('BIG_BLOCK_SIZE', 0x200);
8 define('SMALL_BLOCK_SIZE', 0x40); 8 define('SMALL_BLOCK_SIZE', 0x40);
9 define('EXTENSION_BLOCK_POS', 0x44); 9 define('EXTENSION_BLOCK_POS', 0x44);
10 define('NUM_EXTENSION_BLOCK_POS', 0x48); 10 define('NUM_EXTENSION_BLOCK_POS', 0x48);
11 define('PROPERTY_STORAGE_BLOCK_SIZE', 0x80); 11 define('PROPERTY_STORAGE_BLOCK_SIZE', 0x80);
12 define('BIG_BLOCK_DEPOT_BLOCKS_POS', 0x4c); 12 define('BIG_BLOCK_DEPOT_BLOCKS_POS', 0x4c);
13 define('SMALL_BLOCK_THRESHOLD', 0x1000); 13 define('SMALL_BLOCK_THRESHOLD', 0x1000);
14 // property storage offsets 14 // property storage offsets
15 define('SIZE_OF_NAME_POS', 0x40); 15 define('SIZE_OF_NAME_POS', 0x40);
16 define('TYPE_POS', 0x42); 16 define('TYPE_POS', 0x42);
17 define('START_BLOCK_POS', 0x74); 17 define('START_BLOCK_POS', 0x74);
18 define('SIZE_POS', 0x78); 18 define('SIZE_POS', 0x78);
19 define('IDENTIFIER_OLE', pack("CCCCCCCC",0xd0,0xcf,0x11,0xe0,0xa1,0xb1,0x1a,0xe1)); 19 define('IDENTIFIER_OLE', pack("CCCCCCCC",0xd0,0xcf,0x11,0xe0,0xa1,0xb1,0x1a,0xe1));
20 20
21 //echo 'ROOT_START_BLOCK_POS = '.ROOT_START_BLOCK_POS."\n"; 21 //echo 'ROOT_START_BLOCK_POS = '.ROOT_START_BLOCK_POS."\n";
22 22
23 //echo bin2hex($data[ROOT_START_BLOCK_POS])."\n"; 23 //echo bin2hex($data[ROOT_START_BLOCK_POS])."\n";
24 //echo "a="; 24 //echo "a=";
25 //echo $data[ROOT_START_BLOCK_POS]; 25 //echo $data[ROOT_START_BLOCK_POS];
26 //function log 26 //function log
27 27
28 function GetInt4d($data, $pos) 28 function GetInt4d($data, $pos)
29 { 29 {
30 $value = ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | (ord($data[$pos+3]) << 24); 30 $value = ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | (ord($data[$pos+3]) << 24);
31 if ($value>=4294967294) 31 if ($value>=4294967294)
32 { 32 {
33 $value=-2; 33 $value=-2;
34 } 34 }
35 return $value; 35 return $value;
36 } 36 }
37 37
38 38
39 class OLERead { 39 class OLERead {
40 var $data = ''; 40 var $data = '';
41 41
42 42
43 function OLERead(){ 43 function OLERead(){
44 44
45 45
46 } 46 }
47 47
48 function read($sFileName){ 48 function read($sFileName){
49 49
50 // check if file exist and is readable (Darko Miljanovic) 50 // check if file exist and is readable (Darko Miljanovic)
51 if(!is_readable($sFileName)) { 51 if(!is_readable($sFileName)) {
52 $this->error = 1; 52 $this->error = 1;
53 return false; 53 return false;
54 } 54 }
55 55
56 $this->data = @file_get_contents($sFileName); 56 $this->data = @file_get_contents($sFileName);
57 if (!$this->data) { 57 if (!$this->data) {
58 $this->error = 1; 58 $this->error = 1;
59 return false; 59 return false;
60 } 60 }
61 //echo IDENTIFIER_OLE; 61 //echo IDENTIFIER_OLE;
62 //echo 'start'; 62 //echo 'start';
63 if (substr($this->data, 0, 8) != IDENTIFIER_OLE) { 63 if (substr($this->data, 0, 8) != IDENTIFIER_OLE) {
64 $this->error = 1; 64 $this->error = 1;
65 return false; 65 return false;
66 } 66 }
67 $this->numBigBlockDepotBlocks = GetInt4d($this->data, NUM_BIG_BLOCK_DEPOT_BLOCKS_POS); 67 $this->numBigBlockDepotBlocks = GetInt4d($this->data, NUM_BIG_BLOCK_DEPOT_BLOCKS_POS);
68 $this->sbdStartBlock = GetInt4d($this->data, SMALL_BLOCK_DEPOT_BLOCK_POS); 68 $this->sbdStartBlock = GetInt4d($this->data, SMALL_BLOCK_DEPOT_BLOCK_POS);
69 $this->rootStartBlock = GetInt4d($this->data, ROOT_START_BLOCK_POS); 69 $this->rootStartBlock = GetInt4d($this->data, ROOT_START_BLOCK_POS);
70 $this->extensionBlock = GetInt4d($this->data, EXTENSION_BLOCK_POS); 70 $this->extensionBlock = GetInt4d($this->data, EXTENSION_BLOCK_POS);
71 $this->numExtensionBlocks = GetInt4d($this->data, NUM_EXTENSION_BLOCK_POS); 71 $this->numExtensionBlocks = GetInt4d($this->data, NUM_EXTENSION_BLOCK_POS);
72 72
73 /* 73 /*
74 echo $this->numBigBlockDepotBlocks." "; 74 echo $this->numBigBlockDepotBlocks." ";
75 echo $this->sbdStartBlock." "; 75 echo $this->sbdStartBlock." ";
76 echo $this->rootStartBlock." "; 76 echo $this->rootStartBlock." ";
77 echo $this->extensionBlock." "; 77 echo $this->extensionBlock." ";
78 echo $this->numExtensionBlocks." "; 78 echo $this->numExtensionBlocks." ";
79 */ 79 */
80 //echo "sbdStartBlock = $this->sbdStartBlock\n"; 80 //echo "sbdStartBlock = $this->sbdStartBlock\n";
81 $bigBlockDepotBlocks = array(); 81 $bigBlockDepotBlocks = array();
82 $pos = BIG_BLOCK_DEPOT_BLOCKS_POS; 82 $pos = BIG_BLOCK_DEPOT_BLOCKS_POS;
83 // echo "pos = $pos"; 83 // echo "pos = $pos";
84 $bbdBlocks = $this->numBigBlockDepotBlocks; 84 $bbdBlocks = $this->numBigBlockDepotBlocks;
85 85
86 if ($this->numExtensionBlocks != 0) { 86 if ($this->numExtensionBlocks != 0) {
87 $bbdBlocks = (BIG_BLOCK_SIZE - BIG_BLOCK_DEPOT_BLOCKS_POS)/4; 87 $bbdBlocks = (BIG_BLOCK_SIZE - BIG_BLOCK_DEPOT_BLOCKS_POS)/4;
88 } 88 }
89 89
90 for ($i = 0; $i < $bbdBlocks; $i++) { 90 for ($i = 0; $i < $bbdBlocks; $i++) {
91 $bigBlockDepotBlocks[$i] = GetInt4d($this->data, $pos); 91 $bigBlockDepotBlocks[$i] = GetInt4d($this->data, $pos);
92 $pos += 4; 92 $pos += 4;
93 } 93 }
94 94
95 95
96 for ($j = 0; $j < $this->numExtensionBlocks; $j++) { 96 for ($j = 0; $j < $this->numExtensionBlocks; $j++) {
97 $pos = ($this->extensionBlock + 1) * BIG_BLOCK_SIZE; 97 $pos = ($this->extensionBlock + 1) * BIG_BLOCK_SIZE;
98 $blocksToRead = min($this->numBigBlockDepotBlocks - $bbdBlocks, BIG_BLOCK_SIZE / 4 - 1); 98 $blocksToRead = min($this->numBigBlockDepotBlocks - $bbdBlocks, BIG_BLOCK_SIZE / 4 - 1);
99 99
100 for ($i = $bbdBlocks; $i < $bbdBlocks + $blocksToRead; $i++) { 100 for ($i = $bbdBlocks; $i < $bbdBlocks + $blocksToRead; $i++) {
101 $bigBlockDepotBlocks[$i] = GetInt4d($this->data, $pos); 101 $bigBlockDepotBlocks[$i] = GetInt4d($this->data, $pos);
102 $pos += 4; 102 $pos += 4;
103 } 103 }
104 104
105 $bbdBlocks += $blocksToRead; 105 $bbdBlocks += $blocksToRead;
106 if ($bbdBlocks < $this->numBigBlockDepotBlocks) { 106 if ($bbdBlocks < $this->numBigBlockDepotBlocks) {
107 $this->extensionBlock = GetInt4d($this->data, $pos); 107 $this->extensionBlock = GetInt4d($this->data, $pos);
108 } 108 }
109 } 109 }
110 110
111 // var_dump($bigBlockDepotBlocks); 111 // var_dump($bigBlockDepotBlocks);
112 112
113 // readBigBlockDepot 113 // readBigBlockDepot
114 $pos = 0; 114 $pos = 0;
115 $index = 0; 115 $index = 0;
116 $this->bigBlockChain = array(); 116 $this->bigBlockChain = array();
117 117
118 for ($i = 0; $i < $this->numBigBlockDepotBlocks; $i++) { 118 for ($i = 0; $i < $this->numBigBlockDepotBlocks; $i++) {
119 $pos = ($bigBlockDepotBlocks[$i] + 1) * BIG_BLOCK_SIZE; 119 $pos = ($bigBlockDepotBlocks[$i] + 1) * BIG_BLOCK_SIZE;
120 //echo "pos = $pos"; 120 //echo "pos = $pos";
121 for ($j = 0 ; $j < BIG_BLOCK_SIZE / 4; $j++) { 121 for ($j = 0 ; $j < BIG_BLOCK_SIZE / 4; $j++) {
122 $this->bigBlockChain[$index] = GetInt4d($this->data, $pos); 122 $this->bigBlockChain[$index] = GetInt4d($this->data, $pos);
123 $pos += 4 ; 123 $pos += 4 ;
124 $index++; 124 $index++;
125 } 125 }
126 } 126 }
127 127
128 //var_dump($this->bigBlockChain); 128 //var_dump($this->bigBlockChain);
129 //echo '=====2'; 129 //echo '=====2';
130 // readSmallBlockDepot(); 130 // readSmallBlockDepot();
131 $pos = 0; 131 $pos = 0;
132 $index = 0; 132 $index = 0;
133 $sbdBlock = $this->sbdStartBlock; 133 $sbdBlock = $this->sbdStartBlock;
134 $this->smallBlockChain = array(); 134 $this->smallBlockChain = array();
135 135
136 while ($sbdBlock != -2) { 136 while ($sbdBlock != -2) {
137 137
138 $pos = ($sbdBlock + 1) * BIG_BLOCK_SIZE; 138 $pos = ($sbdBlock + 1) * BIG_BLOCK_SIZE;
139 139
140 for ($j = 0; $j < BIG_BLOCK_SIZE / 4; $j++) { 140 for ($j = 0; $j < BIG_BLOCK_SIZE / 4; $j++) {
141 $this->smallBlockChain[$index] = GetInt4d($this->data, $pos); 141 $this->smallBlockChain[$index] = GetInt4d($this->data, $pos);
142 $pos += 4; 142 $pos += 4;
143 $index++; 143 $index++;
144 } 144 }
145 145
146 $sbdBlock = $this->bigBlockChain[$sbdBlock]; 146 $sbdBlock = $this->bigBlockChain[$sbdBlock];
147 } 147 }
148 148
149 149
150 // readData(rootStartBlock) 150 // readData(rootStartBlock)
151 $block = $this->rootStartBlock; 151 $block = $this->rootStartBlock;
152 $pos = 0; 152 $pos = 0;
153 $this->entry = $this->__readData($block); 153 $this->entry = $this->__readData($block);
154 154
155 /* 155 /*
156 while ($block != -2) { 156 while ($block != -2) {
157 $pos = ($block + 1) * BIG_BLOCK_SIZE; 157 $pos = ($block + 1) * BIG_BLOCK_SIZE;
158 $this->entry = $this->entry.substr($this->data, $pos, BIG_BLOCK_SIZE); 158 $this->entry = $this->entry.substr($this->data, $pos, BIG_BLOCK_SIZE);
159 $block = $this->bigBlockChain[$block]; 159 $block = $this->bigBlockChain[$block];
160 } 160 }
161 */ 161 */
162 //echo '==='.$this->entry."==="; 162 //echo '==='.$this->entry."===";
163 $this->__readPropertySets(); 163 $this->__readPropertySets();
164 164
165 } 165 }
166 166
167 function __readData($bl) { 167 function __readData($bl) {
168 $block = $bl; 168 $block = $bl;
169 $pos = 0; 169 $pos = 0;
170 $data = ''; 170 $data = '';
171 171
172 while ($block != -2) { 172 while ($block != -2) {
173 $pos = ($block + 1) * BIG_BLOCK_SIZE; 173 $pos = ($block + 1) * BIG_BLOCK_SIZE;
174 $data = $data.substr($this->data, $pos, BIG_BLOCK_SIZE); 174 $data = $data.substr($this->data, $pos, BIG_BLOCK_SIZE);
175 //echo "pos = $pos data=$data\n"; 175 //echo "pos = $pos data=$data\n";
176 $block = $this->bigBlockChain[$block]; 176 $block = $this->bigBlockChain[$block];
177 } 177 }
178 return $data; 178 return $data;
179 } 179 }
180 180
181 function __readPropertySets(){ 181 function __readPropertySets(){
182 $offset = 0; 182 $offset = 0;
183 //var_dump($this->entry); 183 //var_dump($this->entry);
184 while ($offset < strlen($this->entry)) { 184 while ($offset < strlen($this->entry)) {
185 $d = substr($this->entry, $offset, PROPERTY_STORAGE_BLOCK_SIZE); 185 $d = substr($this->entry, $offset, PROPERTY_STORAGE_BLOCK_SIZE);
186 186
187 $nameSize = ord($d[SIZE_OF_NAME_POS]) | (ord($d[SIZE_OF_NAME_POS+1]) << 8); 187 $nameSize = ord($d[SIZE_OF_NAME_POS]) | (ord($d[SIZE_OF_NAME_POS+1]) << 8);
188 188
189 $type = ord($d[TYPE_POS]); 189 $type = ord($d[TYPE_POS]);
190 //$maxBlock = strlen($d) / BIG_BLOCK_SIZE - 1; 190 //$maxBlock = strlen($d) / BIG_BLOCK_SIZE - 1;
191 191
192 $startBlock = GetInt4d($d, START_BLOCK_POS); 192 $startBlock = GetInt4d($d, START_BLOCK_POS);
193 $size = GetInt4d($d, SIZE_POS); 193 $size = GetInt4d($d, SIZE_POS);
194 194
195 $name = ''; 195 $name = '';
196 for ($i = 0; $i < $nameSize ; $i++) { 196 for ($i = 0; $i < $nameSize ; $i++) {
197 $name .= $d[$i]; 197 $name .= $d[$i];
198 } 198 }
199 199
200 $name = str_replace("\x00", "", $name); 200 $name = str_replace("\x00", "", $name);
201 201
202 $this->props[] = array ( 202 $this->props[] = array (
203 'name' => $name, 203 'name' => $name,
204 'type' => $type, 204 'type' => $type,
205 'startBlock' => $startBlock, 205 'startBlock' => $startBlock,
206 'size' => $size); 206 'size' => $size);
207 207
208 if (($name == "Workbook") || ($name == "Book")) { 208 if (($name == "Workbook") || ($name == "Book")) {
209 $this->wrkbook = count($this->props) - 1; 209 $this->wrkbook = count($this->props) - 1;
210 } 210 }
211 211
212 if ($name == "Root Entry") { 212 if ($name == "Root Entry") {
213 $this->rootentry = count($this->props) - 1; 213 $this->rootentry = count($this->props) - 1;
214 } 214 }
215 215
216 //echo "name ==$name=\n"; 216 //echo "name ==$name=\n";
217 217
218 218
219 $offset += PROPERTY_STORAGE_BLOCK_SIZE; 219 $offset += PROPERTY_STORAGE_BLOCK_SIZE;
220 } 220 }
221 221
222 } 222 }
223 223
224 224
225 function getWorkBook(){ 225 function getWorkBook(){
226 if ($this->props[$this->wrkbook]['size'] < SMALL_BLOCK_THRESHOLD){ 226 if ($this->props[$this->wrkbook]['size'] < SMALL_BLOCK_THRESHOLD){
227 // getSmallBlockStream(PropertyStorage ps) 227 // getSmallBlockStream(PropertyStorage ps)
228 228
229 $rootdata = $this->__readData($this->props[$this->rootentry]['startBlock']); 229 $rootdata = $this->__readData($this->props[$this->rootentry]['startBlock']);
230 230
231 $streamData = ''; 231 $streamData = '';
232 $block = $this->props[$this->wrkbook]['startBlock']; 232 $block = $this->props[$this->wrkbook]['startBlock'];
233 //$count = 0; 233 //$count = 0;
234 $pos = 0; 234 $pos = 0;
235 while ($block != -2) { 235 while ($block != -2) {
236 $pos = $block * SMALL_BLOCK_SIZE; 236 $pos = $block * SMALL_BLOCK_SIZE;
237 $streamData .= substr($rootdata, $pos, SMALL_BLOCK_SIZE); 237 $streamData .= substr($rootdata, $pos, SMALL_BLOCK_SIZE);
238 238
239 $block = $this->smallBlockChain[$block]; 239 $block = $this->smallBlockChain[$block];
240 } 240 }
241 241
242 return $streamData; 242 return $streamData;
243 243
244 244
245 }else{ 245 }else{
246 246
247 $numBlocks = $this->props[$this->wrkbook]['size'] / BIG_BLOCK_SIZE; 247 $numBlocks = $this->props[$this->wrkbook]['size'] / BIG_BLOCK_SIZE;
248 if ($this->props[$this->wrkbook]['size'] % BIG_BLOCK_SIZE != 0) { 248 if ($this->props[$this->wrkbook]['size'] % BIG_BLOCK_SIZE != 0) {
249 $numBlocks++; 249 $numBlocks++;
250 } 250 }
251 251
252 if ($numBlocks == 0) return ''; 252 if ($numBlocks == 0) return '';
253 253
254 //echo "numBlocks = $numBlocks\n"; 254 //echo "numBlocks = $numBlocks\n";
255 //byte[] streamData = new byte[numBlocks * BIG_BLOCK_SIZE]; 255 //byte[] streamData = new byte[numBlocks * BIG_BLOCK_SIZE];
256 //print_r($this->wrkbook); 256 //print_r($this->wrkbook);
257 $streamData = ''; 257 $streamData = '';
258 $block = $this->props[$this->wrkbook]['startBlock']; 258 $block = $this->props[$this->wrkbook]['startBlock'];
259 //$count = 0; 259 //$count = 0;
260 $pos = 0; 260 $pos = 0;
261 //echo "block = $block"; 261 //echo "block = $block";
262 while ($block != -2) { 262 while ($block != -2) {
263 $pos = ($block + 1) * BIG_BLOCK_SIZE; 263 $pos = ($block + 1) * BIG_BLOCK_SIZE;
264 $streamData .= substr($this->data, $pos, BIG_BLOCK_SIZE); 264 $streamData .= substr($this->data, $pos, BIG_BLOCK_SIZE);
265 $block = $this->bigBlockChain[$block]; 265 $block = $this->bigBlockChain[$block];
266 } 266 }
267 //echo 'stream'.$streamData; 267 //echo 'stream'.$streamData;
268 return $streamData; 268 return $streamData;
269 } 269 }
270 } 270 }
271 271
272 } 272 }
273 ?> 273 ?>
...\ No newline at end of file ...\ No newline at end of file
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelReader; 2 namespace Tz\WordPress\Tools\ExcelReader;
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4 4
5 /** 5 /**
6 * A class for reading Microsoft Excel Spreadsheets. 6 * A class for reading Microsoft Excel Spreadsheets.
7 * 7 *
8 * Originally developed by Vadim Tkachenko under the name PHPExcelReader. 8 * Originally developed by Vadim Tkachenko under the name PHPExcelReader.
9 * (http://sourceforge.net/projects/phpexcelreader) 9 * (http://sourceforge.net/projects/phpexcelreader)
10 * Based on the Java version by Andy Khan (http://www.andykhan.com). Now 10 * Based on the Java version by Andy Khan (http://www.andykhan.com). Now
11 * maintained by David Sanders. Reads only Biff 7 and Biff 8 formats. 11 * maintained by David Sanders. Reads only Biff 7 and Biff 8 formats.
12 * 12 *
13 * PHP versions 4 and 5 13 * PHP versions 4 and 5
14 * 14 *
15 * LICENSE: This source file is subject to version 3.0 of the PHP license 15 * LICENSE: This source file is subject to version 3.0 of the PHP license
16 * that is available through the world-wide-web at the following URI: 16 * that is available through the world-wide-web at the following URI:
17 * http://www.php.net/license/3_0.txt. If you did not receive a copy of 17 * http://www.php.net/license/3_0.txt. If you did not receive a copy of
18 * the PHP License and are unable to obtain it through the web, please 18 * the PHP License and are unable to obtain it through the web, please
19 * send a note to license@php.net so we can mail you a copy immediately. 19 * send a note to license@php.net so we can mail you a copy immediately.
20 * 20 *
21 * @category Spreadsheet 21 * @category Spreadsheet
22 * @package Spreadsheet_Excel_Reader 22 * @package Spreadsheet_Excel_Reader
23 * @author Vadim Tkachenko <vt@apachephp.com> 23 * @author Vadim Tkachenko <vt@apachephp.com>
24 * @license http://www.php.net/license/3_0.txt PHP License 3.0 24 * @license http://www.php.net/license/3_0.txt PHP License 3.0
25 * @version CVS: $Id: reader.php 19 2007-03-13 12:42:41Z shangxiao $ 25 * @version CVS: $Id: reader.php 19 2007-03-13 12:42:41Z shangxiao $
26 * @link http://pear.php.net/package/Spreadsheet_Excel_Reader 26 * @link http://pear.php.net/package/Spreadsheet_Excel_Reader
27 * @see OLE, Spreadsheet_Excel_Writer 27 * @see OLE, Spreadsheet_Excel_Writer
28 */ 28 */
29 29
30 30
31 //require_once 'PEAR.php'; 31 //require_once 'PEAR.php';
32 //require_once 'Spreadsheet/Excel/Reader/OLERead.php'; 32 //require_once 'Spreadsheet/Excel/Reader/OLERead.php';
33 //require_once 'OLE.php'; 33 //require_once 'OLE.php';
34 require_once 'oleread.inc'; 34 require_once 'oleread.inc';
35 35
36 define('SPREADSHEET_EXCEL_READER_BIFF8', 0x600); 36 define('SPREADSHEET_EXCEL_READER_BIFF8', 0x600);
37 define('SPREADSHEET_EXCEL_READER_BIFF7', 0x500); 37 define('SPREADSHEET_EXCEL_READER_BIFF7', 0x500);
38 define('SPREADSHEET_EXCEL_READER_WORKBOOKGLOBALS', 0x5); 38 define('SPREADSHEET_EXCEL_READER_WORKBOOKGLOBALS', 0x5);
39 define('SPREADSHEET_EXCEL_READER_WORKSHEET', 0x10); 39 define('SPREADSHEET_EXCEL_READER_WORKSHEET', 0x10);
40 40
41 define('SPREADSHEET_EXCEL_READER_TYPE_BOF', 0x809); 41 define('SPREADSHEET_EXCEL_READER_TYPE_BOF', 0x809);
42 define('SPREADSHEET_EXCEL_READER_TYPE_EOF', 0x0a); 42 define('SPREADSHEET_EXCEL_READER_TYPE_EOF', 0x0a);
43 define('SPREADSHEET_EXCEL_READER_TYPE_BOUNDSHEET', 0x85); 43 define('SPREADSHEET_EXCEL_READER_TYPE_BOUNDSHEET', 0x85);
44 define('SPREADSHEET_EXCEL_READER_TYPE_DIMENSION', 0x200); 44 define('SPREADSHEET_EXCEL_READER_TYPE_DIMENSION', 0x200);
45 define('SPREADSHEET_EXCEL_READER_TYPE_ROW', 0x208); 45 define('SPREADSHEET_EXCEL_READER_TYPE_ROW', 0x208);
46 define('SPREADSHEET_EXCEL_READER_TYPE_DBCELL', 0xd7); 46 define('SPREADSHEET_EXCEL_READER_TYPE_DBCELL', 0xd7);
47 define('SPREADSHEET_EXCEL_READER_TYPE_FILEPASS', 0x2f); 47 define('SPREADSHEET_EXCEL_READER_TYPE_FILEPASS', 0x2f);
48 define('SPREADSHEET_EXCEL_READER_TYPE_NOTE', 0x1c); 48 define('SPREADSHEET_EXCEL_READER_TYPE_NOTE', 0x1c);
49 define('SPREADSHEET_EXCEL_READER_TYPE_TXO', 0x1b6); 49 define('SPREADSHEET_EXCEL_READER_TYPE_TXO', 0x1b6);
50 define('SPREADSHEET_EXCEL_READER_TYPE_RK', 0x7e); 50 define('SPREADSHEET_EXCEL_READER_TYPE_RK', 0x7e);
51 define('SPREADSHEET_EXCEL_READER_TYPE_RK2', 0x27e); 51 define('SPREADSHEET_EXCEL_READER_TYPE_RK2', 0x27e);
52 define('SPREADSHEET_EXCEL_READER_TYPE_MULRK', 0xbd); 52 define('SPREADSHEET_EXCEL_READER_TYPE_MULRK', 0xbd);
53 define('SPREADSHEET_EXCEL_READER_TYPE_MULBLANK', 0xbe); 53 define('SPREADSHEET_EXCEL_READER_TYPE_MULBLANK', 0xbe);
54 define('SPREADSHEET_EXCEL_READER_TYPE_INDEX', 0x20b); 54 define('SPREADSHEET_EXCEL_READER_TYPE_INDEX', 0x20b);
55 define('SPREADSHEET_EXCEL_READER_TYPE_SST', 0xfc); 55 define('SPREADSHEET_EXCEL_READER_TYPE_SST', 0xfc);
56 define('SPREADSHEET_EXCEL_READER_TYPE_EXTSST', 0xff); 56 define('SPREADSHEET_EXCEL_READER_TYPE_EXTSST', 0xff);
57 define('SPREADSHEET_EXCEL_READER_TYPE_CONTINUE', 0x3c); 57 define('SPREADSHEET_EXCEL_READER_TYPE_CONTINUE', 0x3c);
58 define('SPREADSHEET_EXCEL_READER_TYPE_LABEL', 0x204); 58 define('SPREADSHEET_EXCEL_READER_TYPE_LABEL', 0x204);
59 define('SPREADSHEET_EXCEL_READER_TYPE_LABELSST', 0xfd); 59 define('SPREADSHEET_EXCEL_READER_TYPE_LABELSST', 0xfd);
60 define('SPREADSHEET_EXCEL_READER_TYPE_NUMBER', 0x203); 60 define('SPREADSHEET_EXCEL_READER_TYPE_NUMBER', 0x203);
61 define('SPREADSHEET_EXCEL_READER_TYPE_NAME', 0x18); 61 define('SPREADSHEET_EXCEL_READER_TYPE_NAME', 0x18);
62 define('SPREADSHEET_EXCEL_READER_TYPE_ARRAY', 0x221); 62 define('SPREADSHEET_EXCEL_READER_TYPE_ARRAY', 0x221);
63 define('SPREADSHEET_EXCEL_READER_TYPE_STRING', 0x207); 63 define('SPREADSHEET_EXCEL_READER_TYPE_STRING', 0x207);
64 define('SPREADSHEET_EXCEL_READER_TYPE_FORMULA', 0x406); 64 define('SPREADSHEET_EXCEL_READER_TYPE_FORMULA', 0x406);
65 define('SPREADSHEET_EXCEL_READER_TYPE_FORMULA2', 0x6); 65 define('SPREADSHEET_EXCEL_READER_TYPE_FORMULA2', 0x6);
66 define('SPREADSHEET_EXCEL_READER_TYPE_FORMAT', 0x41e); 66 define('SPREADSHEET_EXCEL_READER_TYPE_FORMAT', 0x41e);
67 define('SPREADSHEET_EXCEL_READER_TYPE_XF', 0xe0); 67 define('SPREADSHEET_EXCEL_READER_TYPE_XF', 0xe0);
68 define('SPREADSHEET_EXCEL_READER_TYPE_BOOLERR', 0x205); 68 define('SPREADSHEET_EXCEL_READER_TYPE_BOOLERR', 0x205);
69 define('SPREADSHEET_EXCEL_READER_TYPE_UNKNOWN', 0xffff); 69 define('SPREADSHEET_EXCEL_READER_TYPE_UNKNOWN', 0xffff);
70 define('SPREADSHEET_EXCEL_READER_TYPE_NINETEENFOUR', 0x22); 70 define('SPREADSHEET_EXCEL_READER_TYPE_NINETEENFOUR', 0x22);
71 define('SPREADSHEET_EXCEL_READER_TYPE_MERGEDCELLS', 0xE5); 71 define('SPREADSHEET_EXCEL_READER_TYPE_MERGEDCELLS', 0xE5);
72 72
73 define('SPREADSHEET_EXCEL_READER_UTCOFFSETDAYS' , 25569); 73 define('SPREADSHEET_EXCEL_READER_UTCOFFSETDAYS' , 25569);
74 define('SPREADSHEET_EXCEL_READER_UTCOFFSETDAYS1904', 24107); 74 define('SPREADSHEET_EXCEL_READER_UTCOFFSETDAYS1904', 24107);
75 define('SPREADSHEET_EXCEL_READER_MSINADAY', 86400); 75 define('SPREADSHEET_EXCEL_READER_MSINADAY', 86400);
76 //define('SPREADSHEET_EXCEL_READER_MSINADAY', 24 * 60 * 60); 76 //define('SPREADSHEET_EXCEL_READER_MSINADAY', 24 * 60 * 60);
77 77
78 //define('SPREADSHEET_EXCEL_READER_DEF_NUM_FORMAT', "%.2f"); 78 //define('SPREADSHEET_EXCEL_READER_DEF_NUM_FORMAT', "%.2f");
79 define('SPREADSHEET_EXCEL_READER_DEF_NUM_FORMAT', "%s"); 79 define('SPREADSHEET_EXCEL_READER_DEF_NUM_FORMAT', "%s");
80 80
81 81
82 /* 82 /*
83 * Place includes, constant defines and $_GLOBAL settings here. 83 * Place includes, constant defines and $_GLOBAL settings here.
84 * Make sure they have appropriate docblocks to avoid phpDocumentor 84 * Make sure they have appropriate docblocks to avoid phpDocumentor
85 * construing they are documented by the page-level docblock. 85 * construing they are documented by the page-level docblock.
86 */ 86 */
87 87
88 /** 88 /**
89 * A class for reading Microsoft Excel Spreadsheets. 89 * A class for reading Microsoft Excel Spreadsheets.
90 * 90 *
91 * Originally developed by Vadim Tkachenko under the name PHPExcelReader. 91 * Originally developed by Vadim Tkachenko under the name PHPExcelReader.
92 * (http://sourceforge.net/projects/phpexcelreader) 92 * (http://sourceforge.net/projects/phpexcelreader)
93 * Based on the Java version by Andy Khan (http://www.andykhan.com). Now 93 * Based on the Java version by Andy Khan (http://www.andykhan.com). Now
94 * maintained by David Sanders. Reads only Biff 7 and Biff 8 formats. 94 * maintained by David Sanders. Reads only Biff 7 and Biff 8 formats.
95 * 95 *
96 * @category Spreadsheet 96 * @category Spreadsheet
97 * @package Spreadsheet_Excel_Reader 97 * @package Spreadsheet_Excel_Reader
98 * @author Vadim Tkachenko <vt@phpapache.com> 98 * @author Vadim Tkachenko <vt@phpapache.com>
99 * @copyright 1997-2005 The PHP Group 99 * @copyright 1997-2005 The PHP Group
100 * @license http://www.php.net/license/3_0.txt PHP License 3.0 100 * @license http://www.php.net/license/3_0.txt PHP License 3.0
101 * @version Release: @package_version@ 101 * @version Release: @package_version@
102 * @link http://pear.php.net/package/PackageName 102 * @link http://pear.php.net/package/PackageName
103 * @see OLE, Spreadsheet_Excel_Writer 103 * @see OLE, Spreadsheet_Excel_Writer
104 */ 104 */
105 class Spreadsheet_Excel_Reader 105 class Spreadsheet_Excel_Reader
106 { 106 {
107 /** 107 /**
108 * Array of worksheets found 108 * Array of worksheets found
109 * 109 *
110 * @var array 110 * @var array
111 * @access public 111 * @access public
112 */ 112 */
113 var $boundsheets = array(); 113 var $boundsheets = array();
114 114
115 /** 115 /**
116 * Array of format records found 116 * Array of format records found
117 * 117 *
118 * @var array 118 * @var array
119 * @access public 119 * @access public
120 */ 120 */
121 var $formatRecords = array(); 121 var $formatRecords = array();
122 122
123 /** 123 /**
124 * todo 124 * todo
125 * 125 *
126 * @var array 126 * @var array
127 * @access public 127 * @access public
128 */ 128 */
129 var $sst = array(); 129 var $sst = array();
130 130
131 /** 131 /**
132 * Array of worksheets 132 * Array of worksheets
133 * 133 *
134 * The data is stored in 'cells' and the meta-data is stored in an array 134 * The data is stored in 'cells' and the meta-data is stored in an array
135 * called 'cellsInfo' 135 * called 'cellsInfo'
136 * 136 *
137 * Example: 137 * Example:
138 * 138 *
139 * $sheets --> 'cells' --> row --> column --> Interpreted value 139 * $sheets --> 'cells' --> row --> column --> Interpreted value
140 * --> 'cellsInfo' --> row --> column --> 'type' - Can be 'date', 'number', or 'unknown' 140 * --> 'cellsInfo' --> row --> column --> 'type' - Can be 'date', 'number', or 'unknown'
141 * --> 'raw' - The raw data that Excel stores for that data cell 141 * --> 'raw' - The raw data that Excel stores for that data cell
142 * 142 *
143 * @var array 143 * @var array
144 * @access public 144 * @access public
145 */ 145 */
146 var $sheets = array(); 146 var $sheets = array();
147 147
148 /** 148 /**
149 * The data returned by OLE 149 * The data returned by OLE
150 * 150 *
151 * @var string 151 * @var string
152 * @access public 152 * @access public
153 */ 153 */
154 var $data; 154 var $data;
155 155
156 /** 156 /**
157 * OLE object for reading the file 157 * OLE object for reading the file
158 * 158 *
159 * @var OLE object 159 * @var OLE object
160 * @access private 160 * @access private
161 */ 161 */
162 var $_ole; 162 var $_ole;
163 163
164 /** 164 /**
165 * Default encoding 165 * Default encoding
166 * 166 *
167 * @var string 167 * @var string
168 * @access private 168 * @access private
169 */ 169 */
170 var $_defaultEncoding; 170 var $_defaultEncoding;
171 171
172 /** 172 /**
173 * Default number format 173 * Default number format
174 * 174 *
175 * @var integer 175 * @var integer
176 * @access private 176 * @access private
177 */ 177 */
178 var $_defaultFormat = SPREADSHEET_EXCEL_READER_DEF_NUM_FORMAT; 178 var $_defaultFormat = SPREADSHEET_EXCEL_READER_DEF_NUM_FORMAT;
179 179
180 /** 180 /**
181 * todo 181 * todo
182 * List of formats to use for each column 182 * List of formats to use for each column
183 * 183 *
184 * @var array 184 * @var array
185 * @access private 185 * @access private
186 */ 186 */
187 var $_columnsFormat = array(); 187 var $_columnsFormat = array();
188 188
189 /** 189 /**
190 * todo 190 * todo
191 * 191 *
192 * @var integer 192 * @var integer
193 * @access private 193 * @access private
194 */ 194 */
195 var $_rowoffset = 1; 195 var $_rowoffset = 1;
196 196
197 /** 197 /**
198 * todo 198 * todo
199 * 199 *
200 * @var integer 200 * @var integer
201 * @access private 201 * @access private
202 */ 202 */
203 var $_coloffset = 1; 203 var $_coloffset = 1;
204 204
205 /** 205 /**
206 * List of default date formats used by Excel 206 * List of default date formats used by Excel
207 * 207 *
208 * @var array 208 * @var array
209 * @access public 209 * @access public
210 */ 210 */
211 var $dateFormats = array ( 211 var $dateFormats = array (
212 0xe => "d/m/Y", 212 0xe => "d/m/Y",
213 0xf => "d-M-Y", 213 0xf => "d-M-Y",
214 0x10 => "d-M", 214 0x10 => "d-M",
215 0x11 => "M-Y", 215 0x11 => "M-Y",
216 0x12 => "h:i a", 216 0x12 => "h:i a",
217 0x13 => "h:i:s a", 217 0x13 => "h:i:s a",
218 0x14 => "H:i", 218 0x14 => "H:i",
219 0x15 => "H:i:s", 219 0x15 => "H:i:s",
220 0x16 => "d/m/Y H:i", 220 0x16 => "d/m/Y H:i",
221 0x2d => "i:s", 221 0x2d => "i:s",
222 0x2e => "H:i:s", 222 0x2e => "H:i:s",
223 0x2f => "i:s.S"); 223 0x2f => "i:s.S");
224 224
225 /** 225 /**
226 * Default number formats used by Excel 226 * Default number formats used by Excel
227 * 227 *
228 * @var array 228 * @var array
229 * @access public 229 * @access public
230 */ 230 */
231 var $numberFormats = array( 231 var $numberFormats = array(
232 0x1 => "%1.0f", // "0" 232 0x1 => "%1.0f", // "0"
233 0x2 => "%1.2f", // "0.00", 233 0x2 => "%1.2f", // "0.00",
234 0x3 => "%1.0f", //"#,##0", 234 0x3 => "%1.0f", //"#,##0",
235 0x4 => "%1.2f", //"#,##0.00", 235 0x4 => "%1.2f", //"#,##0.00",
236 0x5 => "%1.0f", /*"$#,##0;($#,##0)",*/ 236 0x5 => "%1.0f", /*"$#,##0;($#,##0)",*/
237 0x6 => '$%1.0f', /*"$#,##0;($#,##0)",*/ 237 0x6 => '$%1.0f', /*"$#,##0;($#,##0)",*/
238 0x7 => '$%1.2f', //"$#,##0.00;($#,##0.00)", 238 0x7 => '$%1.2f', //"$#,##0.00;($#,##0.00)",
239 0x8 => '$%1.2f', //"$#,##0.00;($#,##0.00)", 239 0x8 => '$%1.2f', //"$#,##0.00;($#,##0.00)",
240 0x9 => '%1.0f%%', // "0%" 240 0x9 => '%1.0f%%', // "0%"
241 0xa => '%1.2f%%', // "0.00%" 241 0xa => '%1.2f%%', // "0.00%"
242 0xb => '%1.2f', // 0.00E00", 242 0xb => '%1.2f', // 0.00E00",
243 0x25 => '%1.0f', // "#,##0;(#,##0)", 243 0x25 => '%1.0f', // "#,##0;(#,##0)",
244 0x26 => '%1.0f', //"#,##0;(#,##0)", 244 0x26 => '%1.0f', //"#,##0;(#,##0)",
245 0x27 => '%1.2f', //"#,##0.00;(#,##0.00)", 245 0x27 => '%1.2f', //"#,##0.00;(#,##0.00)",
246 0x28 => '%1.2f', //"#,##0.00;(#,##0.00)", 246 0x28 => '%1.2f', //"#,##0.00;(#,##0.00)",
247 0x29 => '%1.0f', //"#,##0;(#,##0)", 247 0x29 => '%1.0f', //"#,##0;(#,##0)",
248 0x2a => '$%1.0f', //"$#,##0;($#,##0)", 248 0x2a => '$%1.0f', //"$#,##0;($#,##0)",
249 0x2b => '%1.2f', //"#,##0.00;(#,##0.00)", 249 0x2b => '%1.2f', //"#,##0.00;(#,##0.00)",
250 0x2c => '$%1.2f', //"$#,##0.00;($#,##0.00)", 250 0x2c => '$%1.2f', //"$#,##0.00;($#,##0.00)",
251 0x30 => '%1.0f'); //"##0.0E0"; 251 0x30 => '%1.0f'); //"##0.0E0";
252 252
253 // }}} 253 // }}}
254 // {{{ Spreadsheet_Excel_Reader() 254 // {{{ Spreadsheet_Excel_Reader()
255 255
256 /** 256 /**
257 * Constructor 257 * Constructor
258 * 258 *
259 * Some basic initialisation 259 * Some basic initialisation
260 */ 260 */
261 function Spreadsheet_Excel_Reader() 261 function Spreadsheet_Excel_Reader()
262 { 262 {
263 $this->_ole =& new OLERead(); 263 $this->_ole =& new OLERead();
264 $this->setUTFEncoder('iconv'); 264 $this->setUTFEncoder('iconv');
265 } 265 }
266 266
267 // }}} 267 // }}}
268 // {{{ setOutputEncoding() 268 // {{{ setOutputEncoding()
269 269
270 /** 270 /**
271 * Set the encoding method 271 * Set the encoding method
272 * 272 *
273 * @param string Encoding to use 273 * @param string Encoding to use
274 * @access public 274 * @access public
275 */ 275 */
276 function setOutputEncoding($encoding) 276 function setOutputEncoding($encoding)
277 { 277 {
278 $this->_defaultEncoding = $encoding; 278 $this->_defaultEncoding = $encoding;
279 } 279 }
280 280
281 // }}} 281 // }}}
282 // {{{ setUTFEncoder() 282 // {{{ setUTFEncoder()
283 283
284 /** 284 /**
285 * $encoder = 'iconv' or 'mb' 285 * $encoder = 'iconv' or 'mb'
286 * set iconv if you would like use 'iconv' for encode UTF-16LE to your encoding 286 * set iconv if you would like use 'iconv' for encode UTF-16LE to your encoding
287 * set mb if you would like use 'mb_convert_encoding' for encode UTF-16LE to your encoding 287 * set mb if you would like use 'mb_convert_encoding' for encode UTF-16LE to your encoding
288 * 288 *
289 * @access public 289 * @access public
290 * @param string Encoding type to use. Either 'iconv' or 'mb' 290 * @param string Encoding type to use. Either 'iconv' or 'mb'
291 */ 291 */
292 function setUTFEncoder($encoder = 'iconv') 292 function setUTFEncoder($encoder = 'iconv')
293 { 293 {
294 $this->_encoderFunction = ''; 294 $this->_encoderFunction = '';
295 295
296 if ($encoder == 'iconv') { 296 if ($encoder == 'iconv') {
297 $this->_encoderFunction = function_exists('iconv') ? 'iconv' : ''; 297 $this->_encoderFunction = function_exists('iconv') ? 'iconv' : '';
298 } elseif ($encoder == 'mb') { 298 } elseif ($encoder == 'mb') {
299 $this->_encoderFunction = function_exists('mb_convert_encoding') ? 299 $this->_encoderFunction = function_exists('mb_convert_encoding') ?
300 'mb_convert_encoding' : 300 'mb_convert_encoding' :
301 ''; 301 '';
302 } 302 }
303 } 303 }
304 304
305 // }}} 305 // }}}
306 // {{{ setRowColOffset() 306 // {{{ setRowColOffset()
307 307
308 /** 308 /**
309 * todo 309 * todo
310 * 310 *
311 * @access public 311 * @access public
312 * @param offset 312 * @param offset
313 */ 313 */
314 function setRowColOffset($iOffset) 314 function setRowColOffset($iOffset)
315 { 315 {
316 $this->_rowoffset = $iOffset; 316 $this->_rowoffset = $iOffset;
317 $this->_coloffset = $iOffset; 317 $this->_coloffset = $iOffset;
318 } 318 }
319 319
320 // }}} 320 // }}}
321 // {{{ setDefaultFormat() 321 // {{{ setDefaultFormat()
322 322
323 /** 323 /**
324 * Set the default number format 324 * Set the default number format
325 * 325 *
326 * @access public 326 * @access public
327 * @param Default format 327 * @param Default format
328 */ 328 */
329 function setDefaultFormat($sFormat) 329 function setDefaultFormat($sFormat)
330 { 330 {
331 $this->_defaultFormat = $sFormat; 331 $this->_defaultFormat = $sFormat;
332 } 332 }
333 333
334 // }}} 334 // }}}
335 // {{{ setColumnFormat() 335 // {{{ setColumnFormat()
336 336
337 /** 337 /**
338 * Force a column to use a certain format 338 * Force a column to use a certain format
339 * 339 *
340 * @access public 340 * @access public
341 * @param integer Column number 341 * @param integer Column number
342 * @param string Format 342 * @param string Format
343 */ 343 */
344 function setColumnFormat($column, $sFormat) 344 function setColumnFormat($column, $sFormat)
345 { 345 {
346 $this->_columnsFormat[$column] = $sFormat; 346 $this->_columnsFormat[$column] = $sFormat;
347 } 347 }
348 348
349 349
350 // }}} 350 // }}}
351 // {{{ read() 351 // {{{ read()
352 352
353 /** 353 /**
354 * Read the spreadsheet file using OLE, then parse 354 * Read the spreadsheet file using OLE, then parse
355 * 355 *
356 * @access public 356 * @access public
357 * @param filename 357 * @param filename
358 * @todo return a valid value 358 * @todo return a valid value
359 */ 359 */
360 function read($sFileName) 360 function read($sFileName)
361 { 361 {
362 /* 362 /*
363 require_once 'OLE.php'; 363 require_once 'OLE.php';
364 $ole = new OLE(); 364 $ole = new OLE();
365 $ole->read($sFileName); 365 $ole->read($sFileName);
366 366
367 foreach ($ole->_list as $i => $pps) { 367 foreach ($ole->_list as $i => $pps) {
368 if (($pps->Name == 'Workbook' || $pps->Name == 'Book') && 368 if (($pps->Name == 'Workbook' || $pps->Name == 'Book') &&
369 $pps->Size >= SMALL_BLOCK_THRESHOLD) { 369 $pps->Size >= SMALL_BLOCK_THRESHOLD) {
370 370
371 $this->data = $ole->getData($i, 0, $ole->getDataLength($i)); 371 $this->data = $ole->getData($i, 0, $ole->getDataLength($i));
372 } elseif ($pps->Name == 'Root Entry') { 372 } elseif ($pps->Name == 'Root Entry') {
373 $this->data = $ole->getData($i, 0, $ole->getDataLength($i)); 373 $this->data = $ole->getData($i, 0, $ole->getDataLength($i));
374 } 374 }
375 //var_dump(strlen($ole->getData($i, 0, $ole->getDataLength($i))), $pps->Name, md5($this->data), $ole->getDataLength($i)); 375 //var_dump(strlen($ole->getData($i, 0, $ole->getDataLength($i))), $pps->Name, md5($this->data), $ole->getDataLength($i));
376 } 376 }
377 //exit; 377 //exit;
378 $this->_parse(); 378 $this->_parse();
379 379
380 return sizeof($this->sheets) > 0; 380 return sizeof($this->sheets) > 0;
381 */ 381 */
382 382
383 $res = $this->_ole->read($sFileName); 383 $res = $this->_ole->read($sFileName);
384 384
385 // oops, something goes wrong (Darko Miljanovic) 385 // oops, something goes wrong (Darko Miljanovic)
386 if($res === false) { 386 if($res === false) {
387 // check error code 387 // check error code
388 if($this->_ole->error == 1) { 388 if($this->_ole->error == 1) {
389 // bad file 389 // bad file
390 die('The filename ' . $sFileName . ' is not readable'); 390 die('The filename ' . $sFileName . ' is not readable');
391 } 391 }
392 // check other error codes here (eg bad fileformat, etc...) 392 // check other error codes here (eg bad fileformat, etc...)
393 } 393 }
394 394
395 $this->data = $this->_ole->getWorkBook(); 395 $this->data = $this->_ole->getWorkBook();
396 396
397 397
398 /* 398 /*
399 $res = $this->_ole->read($sFileName); 399 $res = $this->_ole->read($sFileName);
400 400
401 if ($this->isError($res)) { 401 if ($this->isError($res)) {
402 // var_dump($res); 402 // var_dump($res);
403 return $this->raiseError($res); 403 return $this->raiseError($res);
404 } 404 }
405 405
406 $total = $this->_ole->ppsTotal(); 406 $total = $this->_ole->ppsTotal();
407 for ($i = 0; $i < $total; $i++) { 407 for ($i = 0; $i < $total; $i++) {
408 if ($this->_ole->isFile($i)) { 408 if ($this->_ole->isFile($i)) {
409 $type = unpack("v", $this->_ole->getData($i, 0, 2)); 409 $type = unpack("v", $this->_ole->getData($i, 0, 2));
410 if ($type[''] == 0x0809) { // check if it's a BIFF stream 410 if ($type[''] == 0x0809) { // check if it's a BIFF stream
411 $this->_index = $i; 411 $this->_index = $i;
412 $this->data = $this->_ole->getData($i, 0, $this->_ole->getDataLength($i)); 412 $this->data = $this->_ole->getData($i, 0, $this->_ole->getDataLength($i));
413 break; 413 break;
414 } 414 }
415 } 415 }
416 } 416 }
417 417
418 if ($this->_index === null) { 418 if ($this->_index === null) {
419 return $this->raiseError("$file doesn't seem to be an Excel file"); 419 return $this->raiseError("$file doesn't seem to be an Excel file");
420 } 420 }
421 421
422 */ 422 */
423 423
424 //echo "data =".$this->data; 424 //echo "data =".$this->data;
425 //$this->readRecords(); 425 //$this->readRecords();
426 $this->_parse(); 426 $this->_parse();
427 } 427 }
428 428
429 429
430 // }}} 430 // }}}
431 // {{{ _parse() 431 // {{{ _parse()
432 432
433 /** 433 /**
434 * Parse a workbook 434 * Parse a workbook
435 * 435 *
436 * @access private 436 * @access private
437 * @return bool 437 * @return bool
438 */ 438 */
439 function _parse() 439 function _parse()
440 { 440 {
441 $pos = 0; 441 $pos = 0;
442 442
443 $code = ord($this->data[$pos]) | ord($this->data[$pos+1])<<8; 443 $code = ord($this->data[$pos]) | ord($this->data[$pos+1])<<8;
444 $length = ord($this->data[$pos+2]) | ord($this->data[$pos+3])<<8; 444 $length = ord($this->data[$pos+2]) | ord($this->data[$pos+3])<<8;
445 445
446 $version = ord($this->data[$pos + 4]) | ord($this->data[$pos + 5])<<8; 446 $version = ord($this->data[$pos + 4]) | ord($this->data[$pos + 5])<<8;
447 $substreamType = ord($this->data[$pos + 6]) | ord($this->data[$pos + 7])<<8; 447 $substreamType = ord($this->data[$pos + 6]) | ord($this->data[$pos + 7])<<8;
448 //echo "Start parse code=".base_convert($code,10,16)." version=".base_convert($version,10,16)." substreamType=".base_convert($substreamType,10,16).""."\n"; 448 //echo "Start parse code=".base_convert($code,10,16)." version=".base_convert($version,10,16)." substreamType=".base_convert($substreamType,10,16).""."\n";
449 449
450 if (($version != SPREADSHEET_EXCEL_READER_BIFF8) && 450 if (($version != SPREADSHEET_EXCEL_READER_BIFF8) &&
451 ($version != SPREADSHEET_EXCEL_READER_BIFF7)) { 451 ($version != SPREADSHEET_EXCEL_READER_BIFF7)) {
452 return false; 452 return false;
453 } 453 }
454 454
455 if ($substreamType != SPREADSHEET_EXCEL_READER_WORKBOOKGLOBALS){ 455 if ($substreamType != SPREADSHEET_EXCEL_READER_WORKBOOKGLOBALS){
456 return false; 456 return false;
457 } 457 }
458 458
459 //print_r($rec); 459 //print_r($rec);
460 $pos += $length + 4; 460 $pos += $length + 4;
461 461
462 $code = ord($this->data[$pos]) | ord($this->data[$pos+1])<<8; 462 $code = ord($this->data[$pos]) | ord($this->data[$pos+1])<<8;
463 $length = ord($this->data[$pos+2]) | ord($this->data[$pos+3])<<8; 463 $length = ord($this->data[$pos+2]) | ord($this->data[$pos+3])<<8;
464 464
465 while ($code != SPREADSHEET_EXCEL_READER_TYPE_EOF) { 465 while ($code != SPREADSHEET_EXCEL_READER_TYPE_EOF) {
466 switch ($code) { 466 switch ($code) {
467 case SPREADSHEET_EXCEL_READER_TYPE_SST: 467 case SPREADSHEET_EXCEL_READER_TYPE_SST:
468 //echo "Type_SST\n"; 468 //echo "Type_SST\n";
469 $spos = $pos + 4; 469 $spos = $pos + 4;
470 $limitpos = $spos + $length; 470 $limitpos = $spos + $length;
471 $uniqueStrings = $this->_GetInt4d($this->data, $spos+4); 471 $uniqueStrings = $this->_GetInt4d($this->data, $spos+4);
472 $spos += 8; 472 $spos += 8;
473 for ($i = 0; $i < $uniqueStrings; $i++) { 473 for ($i = 0; $i < $uniqueStrings; $i++) {
474 // Read in the number of characters 474 // Read in the number of characters
475 if ($spos == $limitpos) { 475 if ($spos == $limitpos) {
476 $opcode = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; 476 $opcode = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8;
477 $conlength = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; 477 $conlength = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8;
478 if ($opcode != 0x3c) { 478 if ($opcode != 0x3c) {
479 return -1; 479 return -1;
480 } 480 }
481 $spos += 4; 481 $spos += 4;
482 $limitpos = $spos + $conlength; 482 $limitpos = $spos + $conlength;
483 } 483 }
484 $numChars = ord($this->data[$spos]) | (ord($this->data[$spos+1]) << 8); 484 $numChars = ord($this->data[$spos]) | (ord($this->data[$spos+1]) << 8);
485 //echo "i = $i pos = $pos numChars = $numChars "; 485 //echo "i = $i pos = $pos numChars = $numChars ";
486 $spos += 2; 486 $spos += 2;
487 $optionFlags = ord($this->data[$spos]); 487 $optionFlags = ord($this->data[$spos]);
488 $spos++; 488 $spos++;
489 $asciiEncoding = (($optionFlags & 0x01) == 0) ; 489 $asciiEncoding = (($optionFlags & 0x01) == 0) ;
490 $extendedString = ( ($optionFlags & 0x04) != 0); 490 $extendedString = ( ($optionFlags & 0x04) != 0);
491 491
492 // See if string contains formatting information 492 // See if string contains formatting information
493 $richString = ( ($optionFlags & 0x08) != 0); 493 $richString = ( ($optionFlags & 0x08) != 0);
494 494
495 if ($richString) { 495 if ($richString) {
496 // Read in the crun 496 // Read in the crun
497 $formattingRuns = ord($this->data[$spos]) | (ord($this->data[$spos+1]) << 8); 497 $formattingRuns = ord($this->data[$spos]) | (ord($this->data[$spos+1]) << 8);
498 $spos += 2; 498 $spos += 2;
499 } 499 }
500 500
501 if ($extendedString) { 501 if ($extendedString) {
502 // Read in cchExtRst 502 // Read in cchExtRst
503 $extendedRunLength = $this->_GetInt4d($this->data, $spos); 503 $extendedRunLength = $this->_GetInt4d($this->data, $spos);
504 $spos += 4; 504 $spos += 4;
505 } 505 }
506 506
507 $len = ($asciiEncoding)? $numChars : $numChars*2; 507 $len = ($asciiEncoding)? $numChars : $numChars*2;
508 if ($spos + $len < $limitpos) { 508 if ($spos + $len < $limitpos) {
509 $retstr = substr($this->data, $spos, $len); 509 $retstr = substr($this->data, $spos, $len);
510 $spos += $len; 510 $spos += $len;
511 }else{ 511 }else{
512 // found countinue 512 // found countinue
513 $retstr = substr($this->data, $spos, $limitpos - $spos); 513 $retstr = substr($this->data, $spos, $limitpos - $spos);
514 $bytesRead = $limitpos - $spos; 514 $bytesRead = $limitpos - $spos;
515 $charsLeft = $numChars - (($asciiEncoding) ? $bytesRead : ($bytesRead / 2)); 515 $charsLeft = $numChars - (($asciiEncoding) ? $bytesRead : ($bytesRead / 2));
516 $spos = $limitpos; 516 $spos = $limitpos;
517 517
518 while ($charsLeft > 0){ 518 while ($charsLeft > 0){
519 $opcode = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; 519 $opcode = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8;
520 $conlength = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; 520 $conlength = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8;
521 if ($opcode != 0x3c) { 521 if ($opcode != 0x3c) {
522 return -1; 522 return -1;
523 } 523 }
524 $spos += 4; 524 $spos += 4;
525 $limitpos = $spos + $conlength; 525 $limitpos = $spos + $conlength;
526 $option = ord($this->data[$spos]); 526 $option = ord($this->data[$spos]);
527 $spos += 1; 527 $spos += 1;
528 if ($asciiEncoding && ($option == 0)) { 528 if ($asciiEncoding && ($option == 0)) {
529 $len = min($charsLeft, $limitpos - $spos); // min($charsLeft, $conlength); 529 $len = min($charsLeft, $limitpos - $spos); // min($charsLeft, $conlength);
530 $retstr .= substr($this->data, $spos, $len); 530 $retstr .= substr($this->data, $spos, $len);
531 $charsLeft -= $len; 531 $charsLeft -= $len;
532 $asciiEncoding = true; 532 $asciiEncoding = true;
533 }elseif (!$asciiEncoding && ($option != 0)){ 533 }elseif (!$asciiEncoding && ($option != 0)){
534 $len = min($charsLeft * 2, $limitpos - $spos); // min($charsLeft, $conlength); 534 $len = min($charsLeft * 2, $limitpos - $spos); // min($charsLeft, $conlength);
535 $retstr .= substr($this->data, $spos, $len); 535 $retstr .= substr($this->data, $spos, $len);
536 $charsLeft -= $len/2; 536 $charsLeft -= $len/2;
537 $asciiEncoding = false; 537 $asciiEncoding = false;
538 }elseif (!$asciiEncoding && ($option == 0)) { 538 }elseif (!$asciiEncoding && ($option == 0)) {
539 // Bummer - the string starts off as Unicode, but after the 539 // Bummer - the string starts off as Unicode, but after the
540 // continuation it is in straightforward ASCII encoding 540 // continuation it is in straightforward ASCII encoding
541 $len = min($charsLeft, $limitpos - $spos); // min($charsLeft, $conlength); 541 $len = min($charsLeft, $limitpos - $spos); // min($charsLeft, $conlength);
542 for ($j = 0; $j < $len; $j++) { 542 for ($j = 0; $j < $len; $j++) {
543 $retstr .= $this->data[$spos + $j].chr(0); 543 $retstr .= $this->data[$spos + $j].chr(0);
544 } 544 }
545 $charsLeft -= $len; 545 $charsLeft -= $len;
546 $asciiEncoding = false; 546 $asciiEncoding = false;
547 }else{ 547 }else{
548 $newstr = ''; 548 $newstr = '';
549 for ($j = 0; $j < strlen($retstr); $j++) { 549 for ($j = 0; $j < strlen($retstr); $j++) {
550 $newstr = $retstr[$j].chr(0); 550 $newstr = $retstr[$j].chr(0);
551 } 551 }
552 $retstr = $newstr; 552 $retstr = $newstr;
553 $len = min($charsLeft * 2, $limitpos - $spos); // min($charsLeft, $conlength); 553 $len = min($charsLeft * 2, $limitpos - $spos); // min($charsLeft, $conlength);
554 $retstr .= substr($this->data, $spos, $len); 554 $retstr .= substr($this->data, $spos, $len);
555 $charsLeft -= $len/2; 555 $charsLeft -= $len/2;
556 $asciiEncoding = false; 556 $asciiEncoding = false;
557 //echo "Izavrat\n"; 557 //echo "Izavrat\n";
558 } 558 }
559 $spos += $len; 559 $spos += $len;
560 560
561 } 561 }
562 } 562 }
563 $retstr = ($asciiEncoding) ? $retstr : $this->_encodeUTF16($retstr); 563 $retstr = ($asciiEncoding) ? $retstr : $this->_encodeUTF16($retstr);
564 // echo "Str $i = $retstr\n"; 564 // echo "Str $i = $retstr\n";
565 if ($richString){ 565 if ($richString){
566 $spos += 4 * $formattingRuns; 566 $spos += 4 * $formattingRuns;
567 } 567 }
568 568
569 // For extended strings, skip over the extended string data 569 // For extended strings, skip over the extended string data
570 if ($extendedString) { 570 if ($extendedString) {
571 $spos += $extendedRunLength; 571 $spos += $extendedRunLength;
572 } 572 }
573 //if ($retstr == 'Derby'){ 573 //if ($retstr == 'Derby'){
574 // echo "bb\n"; 574 // echo "bb\n";
575 //} 575 //}
576 $this->sst[]=$retstr; 576 $this->sst[]=$retstr;
577 } 577 }
578 /*$continueRecords = array(); 578 /*$continueRecords = array();
579 while ($this->getNextCode() == Type_CONTINUE) { 579 while ($this->getNextCode() == Type_CONTINUE) {
580 $continueRecords[] = &$this->nextRecord(); 580 $continueRecords[] = &$this->nextRecord();
581 } 581 }
582 //echo " 1 Type_SST\n"; 582 //echo " 1 Type_SST\n";
583 $this->shareStrings = new SSTRecord($r, $continueRecords); 583 $this->shareStrings = new SSTRecord($r, $continueRecords);
584 //print_r($this->shareStrings->strings); 584 //print_r($this->shareStrings->strings);
585 */ 585 */
586 // echo 'SST read: '.($time_end-$time_start)."\n"; 586 // echo 'SST read: '.($time_end-$time_start)."\n";
587 break; 587 break;
588 588
589 case SPREADSHEET_EXCEL_READER_TYPE_FILEPASS: 589 case SPREADSHEET_EXCEL_READER_TYPE_FILEPASS:
590 return false; 590 return false;
591 break; 591 break;
592 case SPREADSHEET_EXCEL_READER_TYPE_NAME: 592 case SPREADSHEET_EXCEL_READER_TYPE_NAME:
593 //echo "Type_NAME\n"; 593 //echo "Type_NAME\n";
594 break; 594 break;
595 case SPREADSHEET_EXCEL_READER_TYPE_FORMAT: 595 case SPREADSHEET_EXCEL_READER_TYPE_FORMAT:
596 $indexCode = ord($this->data[$pos+4]) | ord($this->data[$pos+5]) << 8; 596 $indexCode = ord($this->data[$pos+4]) | ord($this->data[$pos+5]) << 8;
597 597
598 if ($version == SPREADSHEET_EXCEL_READER_BIFF8) { 598 if ($version == SPREADSHEET_EXCEL_READER_BIFF8) {
599 $numchars = ord($this->data[$pos+6]) | ord($this->data[$pos+7]) << 8; 599 $numchars = ord($this->data[$pos+6]) | ord($this->data[$pos+7]) << 8;
600 if (ord($this->data[$pos+8]) == 0){ 600 if (ord($this->data[$pos+8]) == 0){
601 $formatString = substr($this->data, $pos+9, $numchars); 601 $formatString = substr($this->data, $pos+9, $numchars);
602 } else { 602 } else {
603 $formatString = substr($this->data, $pos+9, $numchars*2); 603 $formatString = substr($this->data, $pos+9, $numchars*2);
604 } 604 }
605 } else { 605 } else {
606 $numchars = ord($this->data[$pos+6]); 606 $numchars = ord($this->data[$pos+6]);
607 $formatString = substr($this->data, $pos+7, $numchars*2); 607 $formatString = substr($this->data, $pos+7, $numchars*2);
608 } 608 }
609 609
610 $this->formatRecords[$indexCode] = $formatString; 610 $this->formatRecords[$indexCode] = $formatString;
611 // echo "Type.FORMAT\n"; 611 // echo "Type.FORMAT\n";
612 break; 612 break;
613 case SPREADSHEET_EXCEL_READER_TYPE_XF: 613 case SPREADSHEET_EXCEL_READER_TYPE_XF:
614 //global $dateFormats, $numberFormats; 614 //global $dateFormats, $numberFormats;
615 $indexCode = ord($this->data[$pos+6]) | ord($this->data[$pos+7]) << 8; 615 $indexCode = ord($this->data[$pos+6]) | ord($this->data[$pos+7]) << 8;
616 //echo "\nType.XF ".count($this->formatRecords['xfrecords'])." $indexCode "; 616 //echo "\nType.XF ".count($this->formatRecords['xfrecords'])." $indexCode ";
617 if (array_key_exists($indexCode, $this->dateFormats)) { 617 if (array_key_exists($indexCode, $this->dateFormats)) {
618 //echo "isdate ".$dateFormats[$indexCode]; 618 //echo "isdate ".$dateFormats[$indexCode];
619 $this->formatRecords['xfrecords'][] = array( 619 $this->formatRecords['xfrecords'][] = array(
620 'type' => 'date', 620 'type' => 'date',
621 'format' => $this->dateFormats[$indexCode] 621 'format' => $this->dateFormats[$indexCode]
622 ); 622 );
623 }elseif (array_key_exists($indexCode, $this->numberFormats)) { 623 }elseif (array_key_exists($indexCode, $this->numberFormats)) {
624 //echo "isnumber ".$this->numberFormats[$indexCode]; 624 //echo "isnumber ".$this->numberFormats[$indexCode];
625 $this->formatRecords['xfrecords'][] = array( 625 $this->formatRecords['xfrecords'][] = array(
626 'type' => 'number', 626 'type' => 'number',
627 'format' => $this->numberFormats[$indexCode] 627 'format' => $this->numberFormats[$indexCode]
628 ); 628 );
629 }else{ 629 }else{
630 $isdate = FALSE; 630 $isdate = FALSE;
631 if ($indexCode > 0){ 631 if ($indexCode > 0){
632 if (isset($this->formatRecords[$indexCode])) 632 if (isset($this->formatRecords[$indexCode]))
633 $formatstr = $this->formatRecords[$indexCode]; 633 $formatstr = $this->formatRecords[$indexCode];
634 //echo '.other.'; 634 //echo '.other.';
635 //echo "\ndate-time=$formatstr=\n"; 635 //echo "\ndate-time=$formatstr=\n";
636 if ($formatstr) 636 if ($formatstr)
637 if (preg_match("/[^hmsday\/\-:\s]/i", $formatstr) == 0) { // found day and time format 637 if (preg_match("/[^hmsday\/\-:\s]/i", $formatstr) == 0) { // found day and time format
638 $isdate = TRUE; 638 $isdate = TRUE;
639 $formatstr = str_replace('mm', 'i', $formatstr); 639 $formatstr = str_replace('mm', 'i', $formatstr);
640 $formatstr = str_replace('h', 'H', $formatstr); 640 $formatstr = str_replace('h', 'H', $formatstr);
641 //echo "\ndate-time $formatstr \n"; 641 //echo "\ndate-time $formatstr \n";
642 } 642 }
643 } 643 }
644 644
645 if ($isdate){ 645 if ($isdate){
646 $this->formatRecords['xfrecords'][] = array( 646 $this->formatRecords['xfrecords'][] = array(
647 'type' => 'date', 647 'type' => 'date',
648 'format' => $formatstr, 648 'format' => $formatstr,
649 ); 649 );
650 }else{ 650 }else{
651 $this->formatRecords['xfrecords'][] = array( 651 $this->formatRecords['xfrecords'][] = array(
652 'type' => 'other', 652 'type' => 'other',
653 'format' => '', 653 'format' => '',
654 'code' => $indexCode 654 'code' => $indexCode
655 ); 655 );
656 } 656 }
657 } 657 }
658 //echo "\n"; 658 //echo "\n";
659 break; 659 break;
660 case SPREADSHEET_EXCEL_READER_TYPE_NINETEENFOUR: 660 case SPREADSHEET_EXCEL_READER_TYPE_NINETEENFOUR:
661 //echo "Type.NINETEENFOUR\n"; 661 //echo "Type.NINETEENFOUR\n";
662 $this->nineteenFour = (ord($this->data[$pos+4]) == 1); 662 $this->nineteenFour = (ord($this->data[$pos+4]) == 1);
663 break; 663 break;
664 case SPREADSHEET_EXCEL_READER_TYPE_BOUNDSHEET: 664 case SPREADSHEET_EXCEL_READER_TYPE_BOUNDSHEET:
665 //echo "Type.BOUNDSHEET\n"; 665 //echo "Type.BOUNDSHEET\n";
666 $rec_offset = $this->_GetInt4d($this->data, $pos+4); 666 $rec_offset = $this->_GetInt4d($this->data, $pos+4);
667 $rec_typeFlag = ord($this->data[$pos+8]); 667 $rec_typeFlag = ord($this->data[$pos+8]);
668 $rec_visibilityFlag = ord($this->data[$pos+9]); 668 $rec_visibilityFlag = ord($this->data[$pos+9]);
669 $rec_length = ord($this->data[$pos+10]); 669 $rec_length = ord($this->data[$pos+10]);
670 670
671 if ($version == SPREADSHEET_EXCEL_READER_BIFF8){ 671 if ($version == SPREADSHEET_EXCEL_READER_BIFF8){
672 $chartype = ord($this->data[$pos+11]); 672 $chartype = ord($this->data[$pos+11]);
673 if ($chartype == 0){ 673 if ($chartype == 0){
674 $rec_name = substr($this->data, $pos+12, $rec_length); 674 $rec_name = substr($this->data, $pos+12, $rec_length);
675 } else { 675 } else {
676 $rec_name = $this->_encodeUTF16(substr($this->data, $pos+12, $rec_length*2)); 676 $rec_name = $this->_encodeUTF16(substr($this->data, $pos+12, $rec_length*2));
677 } 677 }
678 }elseif ($version == SPREADSHEET_EXCEL_READER_BIFF7){ 678 }elseif ($version == SPREADSHEET_EXCEL_READER_BIFF7){
679 $rec_name = substr($this->data, $pos+11, $rec_length); 679 $rec_name = substr($this->data, $pos+11, $rec_length);
680 } 680 }
681 $this->boundsheets[] = array('name'=>$rec_name, 681 $this->boundsheets[] = array('name'=>$rec_name,
682 'offset'=>$rec_offset); 682 'offset'=>$rec_offset);
683 683
684 break; 684 break;
685 685
686 } 686 }
687 687
688 //echo "Code = ".base_convert($r['code'],10,16)."\n"; 688 //echo "Code = ".base_convert($r['code'],10,16)."\n";
689 $pos += $length + 4; 689 $pos += $length + 4;
690 $code = ord($this->data[$pos]) | ord($this->data[$pos+1])<<8; 690 $code = ord($this->data[$pos]) | ord($this->data[$pos+1])<<8;
691 $length = ord($this->data[$pos+2]) | ord($this->data[$pos+3])<<8; 691 $length = ord($this->data[$pos+2]) | ord($this->data[$pos+3])<<8;
692 692
693 //$r = &$this->nextRecord(); 693 //$r = &$this->nextRecord();
694 //echo "1 Code = ".base_convert($r['code'],10,16)."\n"; 694 //echo "1 Code = ".base_convert($r['code'],10,16)."\n";
695 } 695 }
696 696
697 foreach ($this->boundsheets as $key=>$val){ 697 foreach ($this->boundsheets as $key=>$val){
698 $this->sn = $key; 698 $this->sn = $key;
699 $this->_parsesheet($val['offset']); 699 $this->_parsesheet($val['offset']);
700 } 700 }
701 return true; 701 return true;
702 702
703 } 703 }
704 704
705 /** 705 /**
706 * Parse a worksheet 706 * Parse a worksheet
707 * 707 *
708 * @access private 708 * @access private
709 * @param todo 709 * @param todo
710 * @todo fix return codes 710 * @todo fix return codes
711 */ 711 */
712 function _parsesheet($spos) 712 function _parsesheet($spos)
713 { 713 {
714 $cont = true; 714 $cont = true;
715 // read BOF 715 // read BOF
716 $code = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; 716 $code = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8;
717 $length = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; 717 $length = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8;
718 718
719 $version = ord($this->data[$spos + 4]) | ord($this->data[$spos + 5])<<8; 719 $version = ord($this->data[$spos + 4]) | ord($this->data[$spos + 5])<<8;
720 $substreamType = ord($this->data[$spos + 6]) | ord($this->data[$spos + 7])<<8; 720 $substreamType = ord($this->data[$spos + 6]) | ord($this->data[$spos + 7])<<8;
721 721
722 if (($version != SPREADSHEET_EXCEL_READER_BIFF8) && ($version != SPREADSHEET_EXCEL_READER_BIFF7)) { 722 if (($version != SPREADSHEET_EXCEL_READER_BIFF8) && ($version != SPREADSHEET_EXCEL_READER_BIFF7)) {
723 return -1; 723 return -1;
724 } 724 }
725 725
726 if ($substreamType != SPREADSHEET_EXCEL_READER_WORKSHEET){ 726 if ($substreamType != SPREADSHEET_EXCEL_READER_WORKSHEET){
727 return -2; 727 return -2;
728 } 728 }
729 //echo "Start parse code=".base_convert($code,10,16)." version=".base_convert($version,10,16)." substreamType=".base_convert($substreamType,10,16).""."\n"; 729 //echo "Start parse code=".base_convert($code,10,16)." version=".base_convert($version,10,16)." substreamType=".base_convert($substreamType,10,16).""."\n";
730 $spos += $length + 4; 730 $spos += $length + 4;
731 //var_dump($this->formatRecords); 731 //var_dump($this->formatRecords);
732 //echo "code $code $length"; 732 //echo "code $code $length";
733 while($cont) { 733 while($cont) {
734 //echo "mem= ".memory_get_usage()."\n"; 734 //echo "mem= ".memory_get_usage()."\n";
735 // $r = &$this->file->nextRecord(); 735 // $r = &$this->file->nextRecord();
736 $lowcode = ord($this->data[$spos]); 736 $lowcode = ord($this->data[$spos]);
737 if ($lowcode == SPREADSHEET_EXCEL_READER_TYPE_EOF) break; 737 if ($lowcode == SPREADSHEET_EXCEL_READER_TYPE_EOF) break;
738 $code = $lowcode | ord($this->data[$spos+1])<<8; 738 $code = $lowcode | ord($this->data[$spos+1])<<8;
739 $length = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; 739 $length = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8;
740 $spos += 4; 740 $spos += 4;
741 $this->sheets[$this->sn]['maxrow'] = $this->_rowoffset - 1; 741 $this->sheets[$this->sn]['maxrow'] = $this->_rowoffset - 1;
742 $this->sheets[$this->sn]['maxcol'] = $this->_coloffset - 1; 742 $this->sheets[$this->sn]['maxcol'] = $this->_coloffset - 1;
743 //echo "Code=".base_convert($code,10,16)." $code\n"; 743 //echo "Code=".base_convert($code,10,16)." $code\n";
744 unset($this->rectype); 744 unset($this->rectype);
745 $this->multiplier = 1; // need for format with % 745 $this->multiplier = 1; // need for format with %
746 switch ($code) { 746 switch ($code) {
747 case SPREADSHEET_EXCEL_READER_TYPE_DIMENSION: 747 case SPREADSHEET_EXCEL_READER_TYPE_DIMENSION:
748 //echo 'Type_DIMENSION '; 748 //echo 'Type_DIMENSION ';
749 if (!isset($this->numRows)) { 749 if (!isset($this->numRows)) {
750 if (($length == 10) || ($version == SPREADSHEET_EXCEL_READER_BIFF7)){ 750 if (($length == 10) || ($version == SPREADSHEET_EXCEL_READER_BIFF7)){
751 $this->sheets[$this->sn]['numRows'] = ord($this->data[$spos+2]) | ord($this->data[$spos+3]) << 8; 751 $this->sheets[$this->sn]['numRows'] = ord($this->data[$spos+2]) | ord($this->data[$spos+3]) << 8;
752 $this->sheets[$this->sn]['numCols'] = ord($this->data[$spos+6]) | ord($this->data[$spos+7]) << 8; 752 $this->sheets[$this->sn]['numCols'] = ord($this->data[$spos+6]) | ord($this->data[$spos+7]) << 8;
753 } else { 753 } else {
754 $this->sheets[$this->sn]['numRows'] = ord($this->data[$spos+4]) | ord($this->data[$spos+5]) << 8; 754 $this->sheets[$this->sn]['numRows'] = ord($this->data[$spos+4]) | ord($this->data[$spos+5]) << 8;
755 $this->sheets[$this->sn]['numCols'] = ord($this->data[$spos+10]) | ord($this->data[$spos+11]) << 8; 755 $this->sheets[$this->sn]['numCols'] = ord($this->data[$spos+10]) | ord($this->data[$spos+11]) << 8;
756 } 756 }
757 } 757 }
758 //echo 'numRows '.$this->numRows.' '.$this->numCols."\n"; 758 //echo 'numRows '.$this->numRows.' '.$this->numCols."\n";
759 break; 759 break;
760 case SPREADSHEET_EXCEL_READER_TYPE_MERGEDCELLS: 760 case SPREADSHEET_EXCEL_READER_TYPE_MERGEDCELLS:
761 $cellRanges = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; 761 $cellRanges = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8;
762 for ($i = 0; $i < $cellRanges; $i++) { 762 for ($i = 0; $i < $cellRanges; $i++) {
763 $fr = ord($this->data[$spos + 8*$i + 2]) | ord($this->data[$spos + 8*$i + 3])<<8; 763 $fr = ord($this->data[$spos + 8*$i + 2]) | ord($this->data[$spos + 8*$i + 3])<<8;
764 $lr = ord($this->data[$spos + 8*$i + 4]) | ord($this->data[$spos + 8*$i + 5])<<8; 764 $lr = ord($this->data[$spos + 8*$i + 4]) | ord($this->data[$spos + 8*$i + 5])<<8;
765 $fc = ord($this->data[$spos + 8*$i + 6]) | ord($this->data[$spos + 8*$i + 7])<<8; 765 $fc = ord($this->data[$spos + 8*$i + 6]) | ord($this->data[$spos + 8*$i + 7])<<8;
766 $lc = ord($this->data[$spos + 8*$i + 8]) | ord($this->data[$spos + 8*$i + 9])<<8; 766 $lc = ord($this->data[$spos + 8*$i + 8]) | ord($this->data[$spos + 8*$i + 9])<<8;
767 //$this->sheets[$this->sn]['mergedCells'][] = array($fr + 1, $fc + 1, $lr + 1, $lc + 1); 767 //$this->sheets[$this->sn]['mergedCells'][] = array($fr + 1, $fc + 1, $lr + 1, $lc + 1);
768 if ($lr - $fr > 0) { 768 if ($lr - $fr > 0) {
769 $this->sheets[$this->sn]['cellsInfo'][$fr+1][$fc+1]['rowspan'] = $lr - $fr + 1; 769 $this->sheets[$this->sn]['cellsInfo'][$fr+1][$fc+1]['rowspan'] = $lr - $fr + 1;
770 } 770 }
771 if ($lc - $fc > 0) { 771 if ($lc - $fc > 0) {
772 $this->sheets[$this->sn]['cellsInfo'][$fr+1][$fc+1]['colspan'] = $lc - $fc + 1; 772 $this->sheets[$this->sn]['cellsInfo'][$fr+1][$fc+1]['colspan'] = $lc - $fc + 1;
773 } 773 }
774 } 774 }
775 //echo "Merged Cells $cellRanges $lr $fr $lc $fc\n"; 775 //echo "Merged Cells $cellRanges $lr $fr $lc $fc\n";
776 break; 776 break;
777 case SPREADSHEET_EXCEL_READER_TYPE_RK: 777 case SPREADSHEET_EXCEL_READER_TYPE_RK:
778 case SPREADSHEET_EXCEL_READER_TYPE_RK2: 778 case SPREADSHEET_EXCEL_READER_TYPE_RK2:
779 //echo 'SPREADSHEET_EXCEL_READER_TYPE_RK'."\n"; 779 //echo 'SPREADSHEET_EXCEL_READER_TYPE_RK'."\n";
780 $row = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; 780 $row = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8;
781 $column = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; 781 $column = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8;
782 $rknum = $this->_GetInt4d($this->data, $spos + 6); 782 $rknum = $this->_GetInt4d($this->data, $spos + 6);
783 $numValue = $this->_GetIEEE754($rknum); 783 $numValue = $this->_GetIEEE754($rknum);
784 //echo $numValue." "; 784 //echo $numValue." ";
785 if ($this->isDate($spos)) { 785 if ($this->isDate($spos)) {
786 list($string, $raw) = $this->createDate($numValue); 786 list($string, $raw) = $this->createDate($numValue);
787 }else{ 787 }else{
788 $raw = $numValue; 788 $raw = $numValue;
789 if (isset($this->_columnsFormat[$column + 1])){ 789 if (isset($this->_columnsFormat[$column + 1])){
790 $this->curformat = $this->_columnsFormat[$column + 1]; 790 $this->curformat = $this->_columnsFormat[$column + 1];
791 } 791 }
792 $string = sprintf($this->curformat, $numValue * $this->multiplier); 792 $string = sprintf($this->curformat, $numValue * $this->multiplier);
793 //$this->addcell(RKRecord($r)); 793 //$this->addcell(RKRecord($r));
794 } 794 }
795 $this->addcell($row, $column, $string, $raw); 795 $this->addcell($row, $column, $string, $raw);
796 //echo "Type_RK $row $column $string $raw {$this->curformat}\n"; 796 //echo "Type_RK $row $column $string $raw {$this->curformat}\n";
797 break; 797 break;
798 case SPREADSHEET_EXCEL_READER_TYPE_LABELSST: 798 case SPREADSHEET_EXCEL_READER_TYPE_LABELSST:
799 $row = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; 799 $row = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8;
800 $column = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; 800 $column = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8;
801 $xfindex = ord($this->data[$spos+4]) | ord($this->data[$spos+5])<<8; 801 $xfindex = ord($this->data[$spos+4]) | ord($this->data[$spos+5])<<8;
802 $index = $this->_GetInt4d($this->data, $spos + 6); 802 $index = $this->_GetInt4d($this->data, $spos + 6);
803 //var_dump($this->sst); 803 //var_dump($this->sst);
804 $this->addcell($row, $column, $this->sst[$index]); 804 $this->addcell($row, $column, $this->sst[$index]);
805 //echo "LabelSST $row $column $string\n"; 805 //echo "LabelSST $row $column $string\n";
806 break; 806 break;
807 case SPREADSHEET_EXCEL_READER_TYPE_MULRK: 807 case SPREADSHEET_EXCEL_READER_TYPE_MULRK:
808 $row = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; 808 $row = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8;
809 $colFirst = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; 809 $colFirst = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8;
810 $colLast = ord($this->data[$spos + $length - 2]) | ord($this->data[$spos + $length - 1])<<8; 810 $colLast = ord($this->data[$spos + $length - 2]) | ord($this->data[$spos + $length - 1])<<8;
811 $columns = $colLast - $colFirst + 1; 811 $columns = $colLast - $colFirst + 1;
812 $tmppos = $spos+4; 812 $tmppos = $spos+4;
813 for ($i = 0; $i < $columns; $i++) { 813 for ($i = 0; $i < $columns; $i++) {
814 $numValue = $this->_GetIEEE754($this->_GetInt4d($this->data, $tmppos + 2)); 814 $numValue = $this->_GetIEEE754($this->_GetInt4d($this->data, $tmppos + 2));
815 if ($this->isDate($tmppos-4)) { 815 if ($this->isDate($tmppos-4)) {
816 list($string, $raw) = $this->createDate($numValue); 816 list($string, $raw) = $this->createDate($numValue);
817 }else{ 817 }else{
818 $raw = $numValue; 818 $raw = $numValue;
819 if (isset($this->_columnsFormat[$colFirst + $i + 1])){ 819 if (isset($this->_columnsFormat[$colFirst + $i + 1])){
820 $this->curformat = $this->_columnsFormat[$colFirst + $i + 1]; 820 $this->curformat = $this->_columnsFormat[$colFirst + $i + 1];
821 } 821 }
822 $string = sprintf($this->curformat, $numValue * $this->multiplier); 822 $string = sprintf($this->curformat, $numValue * $this->multiplier);
823 } 823 }
824 //$rec['rknumbers'][$i]['xfindex'] = ord($rec['data'][$pos]) | ord($rec['data'][$pos+1]) << 8; 824 //$rec['rknumbers'][$i]['xfindex'] = ord($rec['data'][$pos]) | ord($rec['data'][$pos+1]) << 8;
825 $tmppos += 6; 825 $tmppos += 6;
826 $this->addcell($row, $colFirst + $i, $string, $raw); 826 $this->addcell($row, $colFirst + $i, $string, $raw);
827 //echo "MULRK $row ".($colFirst + $i)." $string\n"; 827 //echo "MULRK $row ".($colFirst + $i)." $string\n";
828 } 828 }
829 //MulRKRecord($r); 829 //MulRKRecord($r);
830 // Get the individual cell records from the multiple record 830 // Get the individual cell records from the multiple record
831 //$num = ; 831 //$num = ;
832 832
833 break; 833 break;
834 case SPREADSHEET_EXCEL_READER_TYPE_NUMBER: 834 case SPREADSHEET_EXCEL_READER_TYPE_NUMBER:
835 $row = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; 835 $row = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8;
836 $column = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; 836 $column = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8;
837 $tmp = unpack("ddouble", substr($this->data, $spos + 6, 8)); // It machine machine dependent 837 $tmp = unpack("ddouble", substr($this->data, $spos + 6, 8)); // It machine machine dependent
838 if ($this->isDate($spos)) { 838 if ($this->isDate($spos)) {
839 list($string, $raw) = $this->createDate($tmp['double']); 839 list($string, $raw) = $this->createDate($tmp['double']);
840 // $this->addcell(DateRecord($r, 1)); 840 // $this->addcell(DateRecord($r, 1));
841 }else{ 841 }else{
842 //$raw = $tmp['']; 842 //$raw = $tmp[''];
843 if (isset($this->_columnsFormat[$column + 1])){ 843 if (isset($this->_columnsFormat[$column + 1])){
844 $this->curformat = $this->_columnsFormat[$column + 1]; 844 $this->curformat = $this->_columnsFormat[$column + 1];
845 } 845 }
846 $raw = $this->createNumber($spos); 846 $raw = $this->createNumber($spos);
847 $string = sprintf($this->curformat, $raw * $this->multiplier); 847 $string = sprintf($this->curformat, $raw * $this->multiplier);
848 848
849 // $this->addcell(NumberRecord($r)); 849 // $this->addcell(NumberRecord($r));
850 } 850 }
851 $this->addcell($row, $column, $string, $raw); 851 $this->addcell($row, $column, $string, $raw);
852 //echo "Number $row $column $string\n"; 852 //echo "Number $row $column $string\n";
853 break; 853 break;
854 case SPREADSHEET_EXCEL_READER_TYPE_FORMULA: 854 case SPREADSHEET_EXCEL_READER_TYPE_FORMULA:
855 case SPREADSHEET_EXCEL_READER_TYPE_FORMULA2: 855 case SPREADSHEET_EXCEL_READER_TYPE_FORMULA2:
856 $row = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; 856 $row = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8;
857 $column = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; 857 $column = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8;
858 if ((ord($this->data[$spos+6])==0) && (ord($this->data[$spos+12])==255) && (ord($this->data[$spos+13])==255)) { 858 if ((ord($this->data[$spos+6])==0) && (ord($this->data[$spos+12])==255) && (ord($this->data[$spos+13])==255)) {
859 //String formula. Result follows in a STRING record 859 //String formula. Result follows in a STRING record
860 //echo "FORMULA $row $column Formula with a string<br>\n"; 860 //echo "FORMULA $row $column Formula with a string<br>\n";
861 } elseif ((ord($this->data[$spos+6])==1) && (ord($this->data[$spos+12])==255) && (ord($this->data[$spos+13])==255)) { 861 } elseif ((ord($this->data[$spos+6])==1) && (ord($this->data[$spos+12])==255) && (ord($this->data[$spos+13])==255)) {
862 //Boolean formula. Result is in +2; 0=false,1=true 862 //Boolean formula. Result is in +2; 0=false,1=true
863 } elseif ((ord($this->data[$spos+6])==2) && (ord($this->data[$spos+12])==255) && (ord($this->data[$spos+13])==255)) { 863 } elseif ((ord($this->data[$spos+6])==2) && (ord($this->data[$spos+12])==255) && (ord($this->data[$spos+13])==255)) {
864 //Error formula. Error code is in +2; 864 //Error formula. Error code is in +2;
865 } elseif ((ord($this->data[$spos+6])==3) && (ord($this->data[$spos+12])==255) && (ord($this->data[$spos+13])==255)) { 865 } elseif ((ord($this->data[$spos+6])==3) && (ord($this->data[$spos+12])==255) && (ord($this->data[$spos+13])==255)) {
866 //Formula result is a null string. 866 //Formula result is a null string.
867 } else { 867 } else {
868 // result is a number, so first 14 bytes are just like a _NUMBER record 868 // result is a number, so first 14 bytes are just like a _NUMBER record
869 $tmp = unpack("ddouble", substr($this->data, $spos + 6, 8)); // It machine machine dependent 869 $tmp = unpack("ddouble", substr($this->data, $spos + 6, 8)); // It machine machine dependent
870 if ($this->isDate($spos)) { 870 if ($this->isDate($spos)) {
871 list($string, $raw) = $this->createDate($tmp['double']); 871 list($string, $raw) = $this->createDate($tmp['double']);
872 // $this->addcell(DateRecord($r, 1)); 872 // $this->addcell(DateRecord($r, 1));
873 }else{ 873 }else{
874 //$raw = $tmp['']; 874 //$raw = $tmp[''];
875 if (isset($this->_columnsFormat[$column + 1])){ 875 if (isset($this->_columnsFormat[$column + 1])){
876 $this->curformat = $this->_columnsFormat[$column + 1]; 876 $this->curformat = $this->_columnsFormat[$column + 1];
877 } 877 }
878 $raw = $this->createNumber($spos); 878 $raw = $this->createNumber($spos);
879 $string = sprintf($this->curformat, $raw * $this->multiplier); 879 $string = sprintf($this->curformat, $raw * $this->multiplier);
880 880
881 // $this->addcell(NumberRecord($r)); 881 // $this->addcell(NumberRecord($r));
882 } 882 }
883 $this->addcell($row, $column, $string, $raw); 883 $this->addcell($row, $column, $string, $raw);
884 //echo "Number $row $column $string\n"; 884 //echo "Number $row $column $string\n";
885 } 885 }
886 break; 886 break;
887 case SPREADSHEET_EXCEL_READER_TYPE_BOOLERR: 887 case SPREADSHEET_EXCEL_READER_TYPE_BOOLERR:
888 $row = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; 888 $row = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8;
889 $column = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; 889 $column = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8;
890 $string = ord($this->data[$spos+6]); 890 $string = ord($this->data[$spos+6]);
891 $this->addcell($row, $column, $string); 891 $this->addcell($row, $column, $string);
892 //echo 'Type_BOOLERR '."\n"; 892 //echo 'Type_BOOLERR '."\n";
893 break; 893 break;
894 case SPREADSHEET_EXCEL_READER_TYPE_ROW: 894 case SPREADSHEET_EXCEL_READER_TYPE_ROW:
895 case SPREADSHEET_EXCEL_READER_TYPE_DBCELL: 895 case SPREADSHEET_EXCEL_READER_TYPE_DBCELL:
896 case SPREADSHEET_EXCEL_READER_TYPE_MULBLANK: 896 case SPREADSHEET_EXCEL_READER_TYPE_MULBLANK:
897 break; 897 break;
898 case SPREADSHEET_EXCEL_READER_TYPE_LABEL: 898 case SPREADSHEET_EXCEL_READER_TYPE_LABEL:
899 $row = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; 899 $row = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8;
900 $column = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; 900 $column = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8;
901 $this->addcell($row, $column, substr($this->data, $spos + 8, ord($this->data[$spos + 6]) | ord($this->data[$spos + 7])<<8)); 901 $this->addcell($row, $column, substr($this->data, $spos + 8, ord($this->data[$spos + 6]) | ord($this->data[$spos + 7])<<8));
902 902
903 // $this->addcell(LabelRecord($r)); 903 // $this->addcell(LabelRecord($r));
904 break; 904 break;
905 905
906 case SPREADSHEET_EXCEL_READER_TYPE_EOF: 906 case SPREADSHEET_EXCEL_READER_TYPE_EOF:
907 $cont = false; 907 $cont = false;
908 break; 908 break;
909 default: 909 default:
910 //echo ' unknown :'.base_convert($r['code'],10,16)."\n"; 910 //echo ' unknown :'.base_convert($r['code'],10,16)."\n";
911 break; 911 break;
912 912
913 } 913 }
914 $spos += $length; 914 $spos += $length;
915 } 915 }
916 916
917 if (!isset($this->sheets[$this->sn]['numRows'])) 917 if (!isset($this->sheets[$this->sn]['numRows']))
918 $this->sheets[$this->sn]['numRows'] = $this->sheets[$this->sn]['maxrow']; 918 $this->sheets[$this->sn]['numRows'] = $this->sheets[$this->sn]['maxrow'];
919 if (!isset($this->sheets[$this->sn]['numCols'])) 919 if (!isset($this->sheets[$this->sn]['numCols']))
920 $this->sheets[$this->sn]['numCols'] = $this->sheets[$this->sn]['maxcol']; 920 $this->sheets[$this->sn]['numCols'] = $this->sheets[$this->sn]['maxcol'];
921 921
922 } 922 }
923 923
924 /** 924 /**
925 * Check whether the current record read is a date 925 * Check whether the current record read is a date
926 * 926 *
927 * @param todo 927 * @param todo
928 * @return boolean True if date, false otherwise 928 * @return boolean True if date, false otherwise
929 */ 929 */
930 function isDate($spos) 930 function isDate($spos)
931 { 931 {
932 //$xfindex = GetInt2d(, 4); 932 //$xfindex = GetInt2d(, 4);
933 $xfindex = ord($this->data[$spos+4]) | ord($this->data[$spos+5]) << 8; 933 $xfindex = ord($this->data[$spos+4]) | ord($this->data[$spos+5]) << 8;
934 //echo 'check is date '.$xfindex.' '.$this->formatRecords['xfrecords'][$xfindex]['type']."\n"; 934 //echo 'check is date '.$xfindex.' '.$this->formatRecords['xfrecords'][$xfindex]['type']."\n";
935 //var_dump($this->formatRecords['xfrecords'][$xfindex]); 935 //var_dump($this->formatRecords['xfrecords'][$xfindex]);
936 if ($this->formatRecords['xfrecords'][$xfindex]['type'] == 'date') { 936 if ($this->formatRecords['xfrecords'][$xfindex]['type'] == 'date') {
937 $this->curformat = $this->formatRecords['xfrecords'][$xfindex]['format']; 937 $this->curformat = $this->formatRecords['xfrecords'][$xfindex]['format'];
938 $this->rectype = 'date'; 938 $this->rectype = 'date';
939 return true; 939 return true;
940 } else { 940 } else {
941 if ($this->formatRecords['xfrecords'][$xfindex]['type'] == 'number') { 941 if ($this->formatRecords['xfrecords'][$xfindex]['type'] == 'number') {
942 $this->curformat = $this->formatRecords['xfrecords'][$xfindex]['format']; 942 $this->curformat = $this->formatRecords['xfrecords'][$xfindex]['format'];
943 $this->rectype = 'number'; 943 $this->rectype = 'number';
944 if (($xfindex == 0x9) || ($xfindex == 0xa)){ 944 if (($xfindex == 0x9) || ($xfindex == 0xa)){
945 $this->multiplier = 100; 945 $this->multiplier = 100;
946 } 946 }
947 }else{ 947 }else{
948 $this->curformat = $this->_defaultFormat; 948 $this->curformat = $this->_defaultFormat;
949 $this->rectype = 'unknown'; 949 $this->rectype = 'unknown';
950 } 950 }
951 return false; 951 return false;
952 } 952 }
953 } 953 }
954 954
955 //}}} 955 //}}}
956 //{{{ createDate() 956 //{{{ createDate()
957 957
958 /** 958 /**
959 * Convert the raw Excel date into a human readable format 959 * Convert the raw Excel date into a human readable format
960 * 960 *
961 * Dates in Excel are stored as number of seconds from an epoch. On 961 * Dates in Excel are stored as number of seconds from an epoch. On
962 * Windows, the epoch is 30/12/1899 and on Mac it's 01/01/1904 962 * Windows, the epoch is 30/12/1899 and on Mac it's 01/01/1904
963 * 963 *
964 * @access private 964 * @access private
965 * @param integer The raw Excel value to convert 965 * @param integer The raw Excel value to convert
966 * @return array First element is the converted date, the second element is number a unix timestamp 966 * @return array First element is the converted date, the second element is number a unix timestamp
967 */ 967 */
968 function createDate($numValue) 968 function createDate($numValue)
969 { 969 {
970 if ($numValue > 1) { 970 if ($numValue > 1) {
971 $utcDays = $numValue - ($this->nineteenFour ? SPREADSHEET_EXCEL_READER_UTCOFFSETDAYS1904 : SPREADSHEET_EXCEL_READER_UTCOFFSETDAYS); 971 $utcDays = $numValue - ($this->nineteenFour ? SPREADSHEET_EXCEL_READER_UTCOFFSETDAYS1904 : SPREADSHEET_EXCEL_READER_UTCOFFSETDAYS);
972 $utcValue = round(($utcDays+1) * SPREADSHEET_EXCEL_READER_MSINADAY); 972 $utcValue = round(($utcDays+1) * SPREADSHEET_EXCEL_READER_MSINADAY);
973 $string = date ($this->curformat, $utcValue); 973 $string = date ($this->curformat, $utcValue);
974 $raw = $utcValue; 974 $raw = $utcValue;
975 } else { 975 } else {
976 $raw = $numValue; 976 $raw = $numValue;
977 $hours = floor($numValue * 24); 977 $hours = floor($numValue * 24);
978 $mins = floor($numValue * 24 * 60) - $hours * 60; 978 $mins = floor($numValue * 24 * 60) - $hours * 60;
979 $secs = floor($numValue * SPREADSHEET_EXCEL_READER_MSINADAY) - $hours * 60 * 60 - $mins * 60; 979 $secs = floor($numValue * SPREADSHEET_EXCEL_READER_MSINADAY) - $hours * 60 * 60 - $mins * 60;
980 $string = date ($this->curformat, mktime($hours, $mins, $secs)); 980 $string = date ($this->curformat, mktime($hours, $mins, $secs));
981 } 981 }
982 982
983 return array($string, $raw); 983 return array($string, $raw);
984 } 984 }
985 985
986 function createNumber($spos) 986 function createNumber($spos)
987 { 987 {
988 $rknumhigh = $this->_GetInt4d($this->data, $spos + 10); 988 $rknumhigh = $this->_GetInt4d($this->data, $spos + 10);
989 $rknumlow = $this->_GetInt4d($this->data, $spos + 6); 989 $rknumlow = $this->_GetInt4d($this->data, $spos + 6);
990 //for ($i=0; $i<8; $i++) { echo ord($this->data[$i+$spos+6]) . " "; } echo "<br>"; 990 //for ($i=0; $i<8; $i++) { echo ord($this->data[$i+$spos+6]) . " "; } echo "<br>";
991 $sign = ($rknumhigh & 0x80000000) >> 31; 991 $sign = ($rknumhigh & 0x80000000) >> 31;
992 $exp = ($rknumhigh & 0x7ff00000) >> 20; 992 $exp = ($rknumhigh & 0x7ff00000) >> 20;
993 $mantissa = (0x100000 | ($rknumhigh & 0x000fffff)); 993 $mantissa = (0x100000 | ($rknumhigh & 0x000fffff));
994 $mantissalow1 = ($rknumlow & 0x80000000) >> 31; 994 $mantissalow1 = ($rknumlow & 0x80000000) >> 31;
995 $mantissalow2 = ($rknumlow & 0x7fffffff); 995 $mantissalow2 = ($rknumlow & 0x7fffffff);
996 $value = $mantissa / pow( 2 , (20- ($exp - 1023))); 996 $value = $mantissa / pow( 2 , (20- ($exp - 1023)));
997 if ($mantissalow1 != 0) $value += 1 / pow (2 , (21 - ($exp - 1023))); 997 if ($mantissalow1 != 0) $value += 1 / pow (2 , (21 - ($exp - 1023)));
998 $value += $mantissalow2 / pow (2 , (52 - ($exp - 1023))); 998 $value += $mantissalow2 / pow (2 , (52 - ($exp - 1023)));
999 //echo "Sign = $sign, Exp = $exp, mantissahighx = $mantissa, mantissalow1 = $mantissalow1, mantissalow2 = $mantissalow2<br>\n"; 999 //echo "Sign = $sign, Exp = $exp, mantissahighx = $mantissa, mantissalow1 = $mantissalow1, mantissalow2 = $mantissalow2<br>\n";
1000 if ($sign) {$value = -1 * $value;} 1000 if ($sign) {$value = -1 * $value;}
1001 return $value; 1001 return $value;
1002 } 1002 }
1003 1003
1004 function addcell($row, $col, $string, $raw = '') 1004 function addcell($row, $col, $string, $raw = '')
1005 { 1005 {
1006 //echo "ADD cel $row-$col $string\n"; 1006 //echo "ADD cel $row-$col $string\n";
1007 $this->sheets[$this->sn]['maxrow'] = max($this->sheets[$this->sn]['maxrow'], $row + $this->_rowoffset); 1007 $this->sheets[$this->sn]['maxrow'] = max($this->sheets[$this->sn]['maxrow'], $row + $this->_rowoffset);
1008 $this->sheets[$this->sn]['maxcol'] = max($this->sheets[$this->sn]['maxcol'], $col + $this->_coloffset); 1008 $this->sheets[$this->sn]['maxcol'] = max($this->sheets[$this->sn]['maxcol'], $col + $this->_coloffset);
1009 $this->sheets[$this->sn]['cells'][$row + $this->_rowoffset][$col + $this->_coloffset] = $string; 1009 $this->sheets[$this->sn]['cells'][$row + $this->_rowoffset][$col + $this->_coloffset] = $string;
1010 if ($raw) 1010 if ($raw)
1011 $this->sheets[$this->sn]['cellsInfo'][$row + $this->_rowoffset][$col + $this->_coloffset]['raw'] = $raw; 1011 $this->sheets[$this->sn]['cellsInfo'][$row + $this->_rowoffset][$col + $this->_coloffset]['raw'] = $raw;
1012 if (isset($this->rectype)) 1012 if (isset($this->rectype))
1013 $this->sheets[$this->sn]['cellsInfo'][$row + $this->_rowoffset][$col + $this->_coloffset]['type'] = $this->rectype; 1013 $this->sheets[$this->sn]['cellsInfo'][$row + $this->_rowoffset][$col + $this->_coloffset]['type'] = $this->rectype;
1014 1014
1015 } 1015 }
1016 1016
1017 1017
1018 function _GetIEEE754($rknum) 1018 function _GetIEEE754($rknum)
1019 { 1019 {
1020 if (($rknum & 0x02) != 0) { 1020 if (($rknum & 0x02) != 0) {
1021 $value = $rknum >> 2; 1021 $value = $rknum >> 2;
1022 } else { 1022 } else {
1023 //mmp 1023 //mmp
1024 // first comment out the previously existing 7 lines of code here 1024 // first comment out the previously existing 7 lines of code here
1025 // $tmp = unpack("d", pack("VV", 0, ($rknum & 0xfffffffc))); 1025 // $tmp = unpack("d", pack("VV", 0, ($rknum & 0xfffffffc)));
1026 // //$value = $tmp['']; 1026 // //$value = $tmp[''];
1027 // if (array_key_exists(1, $tmp)) { 1027 // if (array_key_exists(1, $tmp)) {
1028 // $value = $tmp[1]; 1028 // $value = $tmp[1];
1029 // } else { 1029 // } else {
1030 // $value = $tmp['']; 1030 // $value = $tmp[''];
1031 // } 1031 // }
1032 // I got my info on IEEE754 encoding from 1032 // I got my info on IEEE754 encoding from
1033 // http://research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html 1033 // http://research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html
1034 // The RK format calls for using only the most significant 30 bits of the 1034 // The RK format calls for using only the most significant 30 bits of the
1035 // 64 bit floating point value. The other 34 bits are assumed to be 0 1035 // 64 bit floating point value. The other 34 bits are assumed to be 0
1036 // So, we use the upper 30 bits of $rknum as follows... 1036 // So, we use the upper 30 bits of $rknum as follows...
1037 $sign = ($rknum & 0x80000000) >> 31; 1037 $sign = ($rknum & 0x80000000) >> 31;
1038 $exp = ($rknum & 0x7ff00000) >> 20; 1038 $exp = ($rknum & 0x7ff00000) >> 20;
1039 $mantissa = (0x100000 | ($rknum & 0x000ffffc)); 1039 $mantissa = (0x100000 | ($rknum & 0x000ffffc));
1040 $value = $mantissa / pow( 2 , (20- ($exp - 1023))); 1040 $value = $mantissa / pow( 2 , (20- ($exp - 1023)));
1041 if ($sign) {$value = -1 * $value;} 1041 if ($sign) {$value = -1 * $value;}
1042 //end of changes by mmp 1042 //end of changes by mmp
1043 1043
1044 } 1044 }
1045 1045
1046 if (($rknum & 0x01) != 0) { 1046 if (($rknum & 0x01) != 0) {
1047 $value /= 100; 1047 $value /= 100;
1048 } 1048 }
1049 return $value; 1049 return $value;
1050 } 1050 }
1051 1051
1052 function _encodeUTF16($string) 1052 function _encodeUTF16($string)
1053 { 1053 {
1054 $result = $string; 1054 $result = $string;
1055 if ($this->_defaultEncoding){ 1055 if ($this->_defaultEncoding){
1056 switch ($this->_encoderFunction){ 1056 switch ($this->_encoderFunction){
1057 case 'iconv' : $result = iconv('UTF-16LE', $this->_defaultEncoding, $string); 1057 case 'iconv' : $result = iconv('UTF-16LE', $this->_defaultEncoding, $string);
1058 break; 1058 break;
1059 case 'mb_convert_encoding' : $result = mb_convert_encoding($string, $this->_defaultEncoding, 'UTF-16LE' ); 1059 case 'mb_convert_encoding' : $result = mb_convert_encoding($string, $this->_defaultEncoding, 'UTF-16LE' );
1060 break; 1060 break;
1061 } 1061 }
1062 } 1062 }
1063 return $result; 1063 return $result;
1064 } 1064 }
1065 1065
1066 function _GetInt4d($data, $pos) 1066 function _GetInt4d($data, $pos)
1067 { 1067 {
1068 $value = ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | (ord($data[$pos+3]) << 24); 1068 $value = ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | (ord($data[$pos+3]) << 24);
1069 if ($value>=4294967294) 1069 if ($value>=4294967294)
1070 { 1070 {
1071 $value=-2; 1071 $value=-2;
1072 } 1072 }
1073 return $value; 1073 return $value;
1074 } 1074 }
1075 1075
1076 } 1076 }
1077 1077
1078 /* 1078 /*
1079 * Local variables: 1079 * Local variables:
1080 * tab-width: 4 1080 * tab-width: 4
1081 * c-basic-offset: 4 1081 * c-basic-offset: 4
1082 * c-hanging-comment-ender-p: nil 1082 * c-hanging-comment-ender-p: nil
1083 * End: 1083 * End:
1084 */ 1084 */
1085 1085
1086 ?> 1086 ?>
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 /** 2 /**
3 * PHPExcel 3 * PHPExcel
4 * 4 *
5 * Copyright (c) 2006 - 2011 PHPExcel 5 * Copyright (c) 2006 - 2011 PHPExcel
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public 8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version. 10 * version 2.1 of the License, or (at your option) any later version.
11 * 11 *
12 * This library is distributed in the hope that it will be useful, 12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details. 15 * Lesser General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU Lesser General Public 17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software 18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * 20 *
21 * @category PHPExcel 21 * @category PHPExcel
22 * @package PHPExcel_CachedObjectStorage 22 * @package PHPExcel_CachedObjectStorage
23 * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) 23 * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
24 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL 24 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25 * @version 1.7.6, 2011-02-27 25 * @version 1.7.6, 2011-02-27
26 */ 26 */
27 27
28 28
29 /** 29 /**
30 * PHPExcel_CachedObjectStorage_CacheBase 30 * PHPExcel_CachedObjectStorage_CacheBase
31 * 31 *
32 * @category PHPExcel 32 * @category PHPExcel
33 * @package PHPExcel_CachedObjectStorage 33 * @package PHPExcel_CachedObjectStorage
34 * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) 34 * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
35 */ 35 */
36 class PHPExcel_CachedObjectStorage_CacheBase { 36 class PHPExcel_CachedObjectStorage_CacheBase {
37 37
38 /** 38 /**
39 * Parent worksheet 39 * Parent worksheet
40 * 40 *
41 * @var PHPExcel_Worksheet 41 * @var PHPExcel_Worksheet
42 */ 42 */
43 protected $_parent; 43 protected $_parent;
44 44
45 /** 45 /**
46 * The currently active Cell 46 * The currently active Cell
47 * 47 *
48 * @var PHPExcel_Cell 48 * @var PHPExcel_Cell
49 */ 49 */
50 protected $_currentObject = null; 50 protected $_currentObject = null;
51 51
52 /** 52 /**
53 * Coordinate address of the currently active Cell 53 * Coordinate address of the currently active Cell
54 * 54 *
55 * @var string 55 * @var string
56 */ 56 */
57 protected $_currentObjectID = null; 57 protected $_currentObjectID = null;
58 58
59 59
60 /** 60 /**
61 * An array of cells or cell pointers for the worksheet cells held in this cache, 61 * An array of cells or cell pointers for the worksheet cells held in this cache,
62 * and indexed by their coordinate address within the worksheet 62 * and indexed by their coordinate address within the worksheet
63 * 63 *
64 * @var array of mixed 64 * @var array of mixed
65 */ 65 */
66 protected $_cellCache = array(); 66 protected $_cellCache = array();
67 67
68 68
69 public function __construct(Tz\Wordpress\Tools\ExcelWriter\PHPExcel_Worksheet $parent) { 69 public function __construct(Tz\WordPress\Tools\ExcelWriter\PHPExcel_Worksheet $parent) {
70 // Set our parent worksheet. 70 // Set our parent worksheet.
71 // This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when 71 // This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when
72 // they are woken from a serialized state 72 // they are woken from a serialized state
73 $this->_parent = $parent; 73 $this->_parent = $parent;
74 } // function __construct() 74 } // function __construct()
75 75
76 76
77 /** 77 /**
78 * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? 78 * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
79 * 79 *
80 * @param string $pCoord Coordinate address of the cell to check 80 * @param string $pCoord Coordinate address of the cell to check
81 * @return void 81 * @return void
82 * @return boolean 82 * @return boolean
83 */ 83 */
84 public function isDataSet($pCoord) { 84 public function isDataSet($pCoord) {
85 if ($pCoord === $this->_currentObjectID) { 85 if ($pCoord === $this->_currentObjectID) {
86 return true; 86 return true;
87 } 87 }
88 // Check if the requested entry exists in the cache 88 // Check if the requested entry exists in the cache
89 return isset($this->_cellCache[$pCoord]); 89 return isset($this->_cellCache[$pCoord]);
90 } // function isDataSet() 90 } // function isDataSet()
91 91
92 92
93 /** 93 /**
94 * Add or Update a cell in cache 94 * Add or Update a cell in cache
95 * 95 *
96 * @param PHPExcel_Cell $cell Cell to update 96 * @param PHPExcel_Cell $cell Cell to update
97 * @return void 97 * @return void
98 * @throws Exception 98 * @throws Exception
99 */ 99 */
100 public function updateCacheData(Tz\Wordpress\Tools\ExcelWriter\PHPExcel_Cell $cell) { 100 public function updateCacheData(Tz\WordPress\Tools\ExcelWriter\PHPExcel_Cell $cell) {
101 return $this->addCacheData($cell->getCoordinate(),$cell); 101 return $this->addCacheData($cell->getCoordinate(),$cell);
102 } // function updateCacheData() 102 } // function updateCacheData()
103 103
104 104
105 /** 105 /**
106 * Delete a cell in cache identified by coordinate address 106 * Delete a cell in cache identified by coordinate address
107 * 107 *
108 * @param string $pCoord Coordinate address of the cell to delete 108 * @param string $pCoord Coordinate address of the cell to delete
109 * @throws Exception 109 * @throws Exception
110 */ 110 */
111 public function deleteCacheData($pCoord) { 111 public function deleteCacheData($pCoord) {
112 if ($pCoord === $this->_currentObjectID) { 112 if ($pCoord === $this->_currentObjectID) {
113 $this->_currentObject->detach(); 113 $this->_currentObject->detach();
114 $this->_currentObjectID = $this->_currentObject = null; 114 $this->_currentObjectID = $this->_currentObject = null;
115 } 115 }
116 116
117 if (is_object($this->_cellCache[$pCoord])) { 117 if (is_object($this->_cellCache[$pCoord])) {
118 $this->_cellCache[$pCoord]->detach(); 118 $this->_cellCache[$pCoord]->detach();
119 unset($this->_cellCache[$pCoord]); 119 unset($this->_cellCache[$pCoord]);
120 } 120 }
121 } // function deleteCacheData() 121 } // function deleteCacheData()
122 122
123 123
124 /** 124 /**
125 * Get a list of all cell addresses currently held in cache 125 * Get a list of all cell addresses currently held in cache
126 * 126 *
127 * @return array of string 127 * @return array of string
128 */ 128 */
129 public function getCellList() { 129 public function getCellList() {
130 return array_keys($this->_cellCache); 130 return array_keys($this->_cellCache);
131 } // function getCellList() 131 } // function getCellList()
132 132
133 133
134 /** 134 /**
135 * Sort the list of all cell addresses currently held in cache by row and column 135 * Sort the list of all cell addresses currently held in cache by row and column
136 * 136 *
137 * @return void 137 * @return void
138 */ 138 */
139 public function getSortedCellList() { 139 public function getSortedCellList() {
140 $sortKeys = array(); 140 $sortKeys = array();
141 foreach (array_keys($this->_cellCache) as $coord) { 141 foreach (array_keys($this->_cellCache) as $coord) {
142 list($column,$row) = sscanf($coord,'%[A-Z]%d'); 142 list($column,$row) = sscanf($coord,'%[A-Z]%d');
143 $sortKeys[sprintf('%09d%3s',$row,$column)] = $coord; 143 $sortKeys[sprintf('%09d%3s',$row,$column)] = $coord;
144 } 144 }
145 ksort($sortKeys); 145 ksort($sortKeys);
146 146
147 return array_values($sortKeys); 147 return array_values($sortKeys);
148 } // function sortCellList() 148 } // function sortCellList()
149 149
150 150
151 protected function _getUniqueID() { 151 protected function _getUniqueID() {
152 if (function_exists('posix_getpid')) { 152 if (function_exists('posix_getpid')) {
153 $baseUnique = posix_getpid(); 153 $baseUnique = posix_getpid();
154 } else { 154 } else {
155 $baseUnique = mt_rand(); 155 $baseUnique = mt_rand();
156 } 156 }
157 return uniqid($baseUnique,true); 157 return uniqid($baseUnique,true);
158 } 158 }
159 159
160 /** 160 /**
161 * Clone the cell collection 161 * Clone the cell collection
162 * 162 *
163 * @return void 163 * @return void
164 */ 164 */
165 public function copyCellCollection(PHPExcel_Worksheet $parent) { 165 public function copyCellCollection(PHPExcel_Worksheet $parent) {
166 $this->_parent = $parent; 166 $this->_parent = $parent;
167 if ((!is_null($this->_currentObject)) && (is_object($this->_currentObject))) { 167 if ((!is_null($this->_currentObject)) && (is_object($this->_currentObject))) {
168 $this->_currentObject->attach($parent); 168 $this->_currentObject->attach($parent);
169 } 169 }
170 } // function copyCellCollection() 170 } // function copyCellCollection()
171 171
172 } 172 }
......
1 <?php 1 <?php
2 /** 2 /**
3 * PHPExcel 3 * PHPExcel
4 * 4 *
5 * Copyright (c) 2006 - 2011 PHPExcel 5 * Copyright (c) 2006 - 2011 PHPExcel
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public 8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version. 10 * version 2.1 of the License, or (at your option) any later version.
11 * 11 *
12 * This library is distributed in the hope that it will be useful, 12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details. 15 * Lesser General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU Lesser General Public 17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software 18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * 20 *
21 * @category PHPExcel 21 * @category PHPExcel
22 * @package PHPExcel_CachedObjectStorage 22 * @package PHPExcel_CachedObjectStorage
23 * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) 23 * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
24 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL 24 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25 * @version 1.7.6, 2011-02-27 25 * @version 1.7.6, 2011-02-27
26 */ 26 */
27 27
28 28
29 /** 29 /**
30 * PHPExcel_CachedObjectStorage_Memory 30 * PHPExcel_CachedObjectStorage_Memory
31 * 31 *
32 * @category PHPExcel 32 * @category PHPExcel
33 * @package PHPExcel_CachedObjectStorage 33 * @package PHPExcel_CachedObjectStorage
34 * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) 34 * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
35 */ 35 */
36 class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { 36 class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
37 37
38 /** 38 /**
39 * Add or Update a cell in cache identified by coordinate address 39 * Add or Update a cell in cache identified by coordinate address
40 * 40 *
41 * @param string $pCoord Coordinate address of the cell to update 41 * @param string $pCoord Coordinate address of the cell to update
42 * @param PHPExcel_Cell $cell Cell to update 42 * @param PHPExcel_Cell $cell Cell to update
43 * @return void 43 * @return void
44 * @throws Exception 44 * @throws Exception
45 */ 45 */
46 public function addCacheData($pCoord, Tz\Wordpress\Tools\ExcelWriter\PHPExcel_Cell $cell) { 46 public function addCacheData($pCoord, Tz\WordPress\Tools\ExcelWriter\PHPExcel_Cell $cell) {
47 $this->_cellCache[$pCoord] = $cell; 47 $this->_cellCache[$pCoord] = $cell;
48 return $cell; 48 return $cell;
49 } // function addCacheData() 49 } // function addCacheData()
50 50
51 51
52 /** 52 /**
53 * Get cell at a specific coordinate 53 * Get cell at a specific coordinate
54 * 54 *
55 * @param string $pCoord Coordinate of the cell 55 * @param string $pCoord Coordinate of the cell
56 * @throws Exception 56 * @throws Exception
57 * @return PHPExcel_Cell Cell that was found, or null if not found 57 * @return PHPExcel_Cell Cell that was found, or null if not found
58 */ 58 */
59 public function getCacheData($pCoord) { 59 public function getCacheData($pCoord) {
60 // Check if the entry that has been requested actually exists 60 // Check if the entry that has been requested actually exists
61 if (!isset($this->_cellCache[$pCoord])) { 61 if (!isset($this->_cellCache[$pCoord])) {
62 // Return null if requested entry doesn't exist in cache 62 // Return null if requested entry doesn't exist in cache
63 return null; 63 return null;
64 } 64 }
65 65
66 // Return requested entry 66 // Return requested entry
67 return $this->_cellCache[$pCoord]; 67 return $this->_cellCache[$pCoord];
68 } // function getCacheData() 68 } // function getCacheData()
69 69
70 70
71 public function copyCellCollection(PHPExcel_Worksheet $parent) { 71 public function copyCellCollection(PHPExcel_Worksheet $parent) {
72 parent::copyCellCollection($parent); 72 parent::copyCellCollection($parent);
73 73
74 $newCollection = array(); 74 $newCollection = array();
75 foreach($this->_cellCache as $k => &$cell) { 75 foreach($this->_cellCache as $k => &$cell) {
76 $newCollection[$k] = clone $cell; 76 $newCollection[$k] = clone $cell;
77 $newCollection[$k]->attach($parent); 77 $newCollection[$k]->attach($parent);
78 } 78 }
79 79
80 $this->_cellCache = $newCollection; 80 $this->_cellCache = $newCollection;
81 } 81 }
82 82
83 83
84 public function unsetWorksheetCells() { 84 public function unsetWorksheetCells() {
85 // Because cells are all stored as intact objects in memory, we need to detach each one from the parent 85 // Because cells are all stored as intact objects in memory, we need to detach each one from the parent
86 foreach($this->_cellCache as $k => &$cell) { 86 foreach($this->_cellCache as $k => &$cell) {
87 $cell->detach(); 87 $cell->detach();
88 $this->_cellCache[$k] = null; 88 $this->_cellCache[$k] = null;
89 } 89 }
90 unset($cell); 90 unset($cell);
91 91
92 $this->_cellCache = array(); 92 $this->_cellCache = array();
93 93
94 // detach ourself from the worksheet, so that it can then delete this object successfully 94 // detach ourself from the worksheet, so that it can then delete this object successfully
95 $this->_parent = null; 95 $this->_parent = null;
96 } // function unsetWorksheetCells() 96 } // function unsetWorksheetCells()
97 97
98 } 98 }
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 3
4 class PHPExcel_CachedObjectStorageFactory { 4 class PHPExcel_CachedObjectStorageFactory {
5 const cache_in_memory = 'Memory'; 5 const cache_in_memory = 'Memory';
6 const cache_in_memory_gzip = 'MemoryGZip'; 6 const cache_in_memory_gzip = 'MemoryGZip';
7 const cache_in_memory_serialized = 'MemorySerialized'; 7 const cache_in_memory_serialized = 'MemorySerialized';
8 const cache_to_discISAM = 'DiscISAM'; 8 const cache_to_discISAM = 'DiscISAM';
9 const cache_to_apc = 'APC'; 9 const cache_to_apc = 'APC';
10 const cache_to_memcache = 'Memcache'; 10 const cache_to_memcache = 'Memcache';
11 const cache_to_phpTemp = 'PHPTemp'; 11 const cache_to_phpTemp = 'PHPTemp';
12 const cache_to_wincache = 'Wincache'; 12 const cache_to_wincache = 'Wincache';
13 13
14 14
15 private static $_cacheStorageMethod = null; 15 private static $_cacheStorageMethod = null;
16 16
17 private static $_cacheStorageClass = null; 17 private static $_cacheStorageClass = null;
18 18
19 19
20 private static $_storageMethods = array( 20 private static $_storageMethods = array(
21 self::cache_in_memory, 21 self::cache_in_memory,
22 self::cache_in_memory_gzip, 22 self::cache_in_memory_gzip,
23 self::cache_in_memory_serialized, 23 self::cache_in_memory_serialized,
24 self::cache_to_phpTemp, 24 self::cache_to_phpTemp,
25 self::cache_to_discISAM, 25 self::cache_to_discISAM,
26 self::cache_to_apc, 26 self::cache_to_apc,
27 self::cache_to_memcache, 27 self::cache_to_memcache,
28 self::cache_to_wincache, 28 self::cache_to_wincache,
29 ); 29 );
30 30
31 31
32 private static $_storageMethodDefaultParameters = array( 32 private static $_storageMethodDefaultParameters = array(
33 self::cache_in_memory => array( 33 self::cache_in_memory => array(
34 ), 34 ),
35 self::cache_in_memory_gzip => array( 35 self::cache_in_memory_gzip => array(
36 ), 36 ),
37 self::cache_in_memory_serialized => array( 37 self::cache_in_memory_serialized => array(
38 ), 38 ),
39 self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB' 39 self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB'
40 ), 40 ),
41 self::cache_to_discISAM => array( 41 self::cache_to_discISAM => array(
42 ), 42 ),
43 self::cache_to_apc => array( 'cacheTime' => 600 43 self::cache_to_apc => array( 'cacheTime' => 600
44 ), 44 ),
45 self::cache_to_memcache => array( 'memcacheServer' => 'localhost', 45 self::cache_to_memcache => array( 'memcacheServer' => 'localhost',
46 'memcachePort' => 11211, 46 'memcachePort' => 11211,
47 'cacheTime' => 600 47 'cacheTime' => 600
48 ), 48 ),
49 self::cache_to_wincache => array( 'cacheTime' => 600 49 self::cache_to_wincache => array( 'cacheTime' => 600
50 ) 50 )
51 ); 51 );
52 52
53 53
54 private static $_storageMethodParameters = array(); 54 private static $_storageMethodParameters = array();
55 55
56 56
57 public static function getCacheStorageMethod() { 57 public static function getCacheStorageMethod() {
58 if (!is_null(self::$_cacheStorageMethod)) { 58 if (!is_null(self::$_cacheStorageMethod)) {
59 return self::$_cacheStorageMethod; 59 return self::$_cacheStorageMethod;
60 } 60 }
61 return null; 61 return null;
62 } // function getCacheStorageMethod() 62 } // function getCacheStorageMethod()
63 63
64 64
65 public static function getCacheStorageClass() { 65 public static function getCacheStorageClass() {
66 if (!is_null(self::$_cacheStorageClass)) { 66 if (!is_null(self::$_cacheStorageClass)) {
67 return self::$_cacheStorageClass; 67 return self::$_cacheStorageClass;
68 } 68 }
69 return null; 69 return null;
70 } // function getCacheStorageClass() 70 } // function getCacheStorageClass()
71 71
72 72
73 public static function getCacheStorageMethods() { 73 public static function getCacheStorageMethods() {
74 return self::$_storageMethods; 74 return self::$_storageMethods;
75 } // function getCacheStorageMethods() 75 } // function getCacheStorageMethods()
76 76
77 77
78 public static function initialize($method = self::cache_in_memory, $arguments = array()) { 78 public static function initialize($method = self::cache_in_memory, $arguments = array()) {
79 if (!in_array($method,self::$_storageMethods)) { 79 if (!in_array($method,self::$_storageMethods)) {
80 return false; 80 return false;
81 } 81 }
82 82
83 switch($method) { 83 switch($method) {
84 case self::cache_to_apc : 84 case self::cache_to_apc :
85 if (!function_exists('apc_store')) { 85 if (!function_exists('apc_store')) {
86 return false; 86 return false;
87 } 87 }
88 if (apc_sma_info() === false) { 88 if (apc_sma_info() === false) {
89 return false; 89 return false;
90 } 90 }
91 break; 91 break;
92 case self::cache_to_memcache : 92 case self::cache_to_memcache :
93 if (!function_exists('memcache_add')) { 93 if (!function_exists('memcache_add')) {
94 return false; 94 return false;
95 } 95 }
96 break; 96 break;
97 case self::cache_to_wincache : 97 case self::cache_to_wincache :
98 if (!function_exists('wincache_ucache_add')) { 98 if (!function_exists('wincache_ucache_add')) {
99 return false; 99 return false;
100 } 100 }
101 break; 101 break;
102 } 102 }
103 103
104 self::$_storageMethodParameters[$method] = self::$_storageMethodDefaultParameters[$method]; 104 self::$_storageMethodParameters[$method] = self::$_storageMethodDefaultParameters[$method];
105 foreach($arguments as $k => $v) { 105 foreach($arguments as $k => $v) {
106 if (isset(self::$_storageMethodParameters[$method][$k])) { 106 if (isset(self::$_storageMethodParameters[$method][$k])) {
107 self::$_storageMethodParameters[$method][$k] = $v; 107 self::$_storageMethodParameters[$method][$k] = $v;
108 } 108 }
109 } 109 }
110 110
111 if (is_null(self::$_cacheStorageMethod)) { 111 if (is_null(self::$_cacheStorageMethod)) {
112 self::$_cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method; 112 self::$_cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method;
113 self::$_cacheStorageMethod = $method; 113 self::$_cacheStorageMethod = $method;
114 } 114 }
115 return true; 115 return true;
116 } // function initialize() 116 } // function initialize()
117 117
118 118
119 public static function getInstance(PHPExcel_Worksheet $parent) { 119 public static function getInstance(PHPExcel_Worksheet $parent) {
120 if (is_null(self::$_cacheStorageMethod)) { 120 if (is_null(self::$_cacheStorageMethod)) {
121 self::initialize(); 121 self::initialize();
122 } 122 }
123 123
124 $instance = new self::$_cacheStorageClass($parent,self::$_storageMethodParameters[self::$_cacheStorageMethod]); 124 $instance = new self::$_cacheStorageClass($parent,self::$_storageMethodParameters[self::$_cacheStorageMethod]);
125 if (!is_null($instance)) { 125 if (!is_null($instance)) {
126 return $instance; 126 return $instance;
127 } 127 }
128 128
129 return false; 129 return false;
130 } // function getInstance() 130 } // function getInstance()
131 131
132 } 132 }
...\ No newline at end of file ...\ No newline at end of file
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /* vim: set expandtab tabstop=4 shiftwidth=4: */ 3 /* vim: set expandtab tabstop=4 shiftwidth=4: */
4 // +----------------------------------------------------------------------+ 4 // +----------------------------------------------------------------------+
5 // | PHP Version 4 | 5 // | PHP Version 4 |
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /* vim: set expandtab tabstop=4 shiftwidth=4: */ 3 /* vim: set expandtab tabstop=4 shiftwidth=4: */
4 // +----------------------------------------------------------------------+ 4 // +----------------------------------------------------------------------+
5 // | PHP Version 4 | 5 // | PHP Version 4 |
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /* vim: set expandtab tabstop=4 shiftwidth=4: */ 3 /* vim: set expandtab tabstop=4 shiftwidth=4: */
4 // +----------------------------------------------------------------------+ 4 // +----------------------------------------------------------------------+
5 // | PHP Version 4 | 5 // | PHP Version 4 |
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /* vim: set expandtab tabstop=4 shiftwidth=4: */ 3 /* vim: set expandtab tabstop=4 shiftwidth=4: */
4 // +----------------------------------------------------------------------+ 4 // +----------------------------------------------------------------------+
5 // | PHP Version 4 | 5 // | PHP Version 4 |
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
1 <?php 1 <?php
2 namespace Tz\Wordpress\Tools\ExcelWriter; 2 namespace Tz\WordPress\Tools\ExcelWriter;
3 /** 3 /**
4 * PHPExcel 4 * PHPExcel
5 * 5 *
......
...@@ -122,7 +122,7 @@ function CSVExport($arr) { ...@@ -122,7 +122,7 @@ function CSVExport($arr) {
122 return $out; 122 return $out;
123 } 123 }
124 124
125 function XLSExport ($arr, \Tz\Wordpress\Tools\ExcelWriter\PHPExcel $writer) { 125 function XLSExport ($arr, \Tz\WordPress\Tools\ExcelWriter\PHPExcel $writer) {
126 if (count($arr) < 1) return false; 126 if (count($arr) < 1) return false;
127 127
128 $sheet = $writer->getActiveSheet(); 128 $sheet = $writer->getActiveSheet();
......