PageRenderTime 53ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/branches/v1.6.3/Classes/PHPExcel/Writer/Excel5/Workbook.php

#
PHP | 1586 lines | 860 code | 187 blank | 539 comment | 120 complexity | 1fa5f9674668faf107082f4836a8baed MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.0, LGPL-2.1, GPL-3.0, LGPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /*
  3. * Module written/ported by Xavier Noguer <xnoguer@rezebra.com>
  4. *
  5. * The majority of this is _NOT_ my code. I simply ported it from the
  6. * PERL Spreadsheet::WriteExcel module.
  7. *
  8. * The author of the Spreadsheet::WriteExcel module is John McNamara
  9. * <jmcnamara@cpan.org>
  10. *
  11. * I _DO_ maintain this code, and John McNamara has nothing to do with the
  12. * porting of this code to PHP. Any questions directly related to this
  13. * class library should be directed to me.
  14. *
  15. * License Information:
  16. *
  17. * PHPExcel_Writer_Excel5_Writer: A library for generating Excel Spreadsheets
  18. * Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
  19. *
  20. * This library is free software; you can redistribute it and/or
  21. * modify it under the terms of the GNU Lesser General Public
  22. * License as published by the Free Software Foundation; either
  23. * version 2.1 of the License, or (at your option) any later version.
  24. *
  25. * This library is distributed in the hope that it will be useful,
  26. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  28. * Lesser General Public License for more details.
  29. *
  30. * You should have received a copy of the GNU Lesser General Public
  31. * License along with this library; if not, write to the Free Software
  32. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  33. */
  34. require_once 'PHPExcel/Writer/Excel5/Format.php';
  35. require_once 'PHPExcel/Writer/Excel5/BIFFwriter.php';
  36. require_once 'PHPExcel/Writer/Excel5/Worksheet.php';
  37. require_once 'PHPExcel/Writer/Excel5/Parser.php';
  38. require_once 'PHPExcel/Shared/OLE/OLE_Root.php';
  39. require_once 'PHPExcel/Shared/OLE/OLE_File.php';
  40. /**
  41. * Class for generating Excel Spreadsheets
  42. *
  43. * @author Xavier Noguer <xnoguer@rezebra.com>
  44. * @category FileFormats
  45. * @package PHPExcel_Writer_Excel5_Writer
  46. */
  47. class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
  48. {
  49. /**
  50. * Filename for the Workbook
  51. * @var string
  52. */
  53. var $_filename;
  54. /**
  55. * Formula parser
  56. * @var object Parser
  57. */
  58. var $_parser;
  59. /**
  60. * Flag for 1904 date system (0 => base date is 1900, 1 => base date is 1904)
  61. * @var integer
  62. */
  63. var $_1904;
  64. /**
  65. * The active worksheet of the workbook (0 indexed)
  66. * @var integer
  67. */
  68. var $_activesheet;
  69. /**
  70. * 1st displayed worksheet in the workbook (0 indexed)
  71. * @var integer
  72. */
  73. var $_firstsheet;
  74. /**
  75. * Number of workbook tabs selected
  76. * @var integer
  77. */
  78. var $_selected;
  79. /**
  80. * Index for creating adding new formats to the workbook
  81. * @var integer
  82. */
  83. var $_xf_index;
  84. /**
  85. * Flag for preventing close from being called twice.
  86. * @var integer
  87. * @see close()
  88. */
  89. var $_fileclosed;
  90. /**
  91. * The BIFF file size for the workbook.
  92. * @var integer
  93. * @see _calcSheetOffsets()
  94. */
  95. var $_biffsize;
  96. /**
  97. * The default sheetname for all sheets created.
  98. * @var string
  99. */
  100. var $_sheetname;
  101. /**
  102. * The default XF format.
  103. * @var object Format
  104. */
  105. var $_tmp_format;
  106. /**
  107. * Array containing references to all of this workbook's worksheets
  108. * @var array
  109. */
  110. var $_worksheets;
  111. /**
  112. * Array of sheetnames for creating the EXTERNSHEET records
  113. * @var array
  114. */
  115. var $_sheetnames;
  116. /**
  117. * Array containing references to all of this workbook's formats
  118. * @var array
  119. */
  120. var $_formats;
  121. /**
  122. * Array containing the colour palette
  123. * @var array
  124. */
  125. var $_palette;
  126. /**
  127. * The default format for URLs.
  128. * @var object Format
  129. */
  130. var $_url_format;
  131. /**
  132. * The codepage indicates the text encoding used for strings
  133. * @var integer
  134. */
  135. var $_codepage;
  136. /**
  137. * The country code used for localization
  138. * @var integer
  139. */
  140. var $_country_code;
  141. /**
  142. * The temporary dir for storing the OLE file
  143. * @var string
  144. */
  145. var $_tmp_dir;
  146. /**
  147. * number of bytes for sizeinfo of strings
  148. * @var integer
  149. */
  150. var $_string_sizeinfo_size;
  151. /**
  152. * Class constructor
  153. *
  154. * @param string filename for storing the workbook. "-" for writing to stdout.
  155. * @access public
  156. */
  157. function PHPExcel_Writer_Excel5_Workbook($filename)
  158. {
  159. // It needs to call its parent's constructor explicitly
  160. $this->PHPExcel_Writer_Excel5_BIFFwriter();
  161. $this->_filename = $filename;
  162. $this->_parser = new PHPExcel_Writer_Excel5_Parser($this->_byte_order, $this->_BIFF_version);
  163. $this->_1904 = 0;
  164. $this->_activesheet = 0;
  165. $this->_firstsheet = 0;
  166. $this->_selected = 0;
  167. $this->_xf_index = 16; // 15 style XF's and 1 cell XF.
  168. $this->_fileclosed = 0;
  169. $this->_biffsize = 0;
  170. $this->_sheetname = 'Sheet';
  171. $this->_tmp_format = new PHPExcel_Writer_Excel5_Format($this->_BIFF_version);
  172. $this->_worksheets = array();
  173. $this->_sheetnames = array();
  174. $this->_formats = array();
  175. $this->_palette = array();
  176. $this->_codepage = 0x04E4; // FIXME: should change for BIFF8
  177. $this->_country_code = -1;
  178. $this->_string_sizeinfo = 3;
  179. // Add the default format for hyperlinks
  180. $this->_url_format =& $this->addFormat(array('color' => 'blue', 'underline' => 1));
  181. $this->_str_total = 0;
  182. $this->_str_unique = 0;
  183. $this->_str_table = array();
  184. $this->_setPaletteXl97();
  185. $this->_tmp_dir = '';
  186. }
  187. /**
  188. * Calls finalization methods.
  189. * This method should always be the last one to be called on every workbook
  190. *
  191. * @access public
  192. * @return mixed true on success
  193. */
  194. function close()
  195. {
  196. if ($this->_fileclosed) { // Prevent close() from being called twice.
  197. return true;
  198. }
  199. $res = $this->_storeWorkbook();
  200. foreach ($this->_worksheets as $sheet) {
  201. $sheet->cleanup();
  202. }
  203. $this->_fileclosed = 1;
  204. return true;
  205. }
  206. /**
  207. * An accessor for the _worksheets[] array
  208. * Returns an array of the worksheet objects in a workbook
  209. * It actually calls to worksheets()
  210. *
  211. * @access public
  212. * @see worksheets()
  213. * @return array
  214. */
  215. function sheets()
  216. {
  217. return $this->worksheets();
  218. }
  219. /**
  220. * An accessor for the _worksheets[] array.
  221. * Returns an array of the worksheet objects in a workbook
  222. *
  223. * @access public
  224. * @return array
  225. */
  226. function worksheets()
  227. {
  228. return $this->_worksheets;
  229. }
  230. /**
  231. * Sets the BIFF version.
  232. * This method exists just to access experimental functionality
  233. * from BIFF8. It will be deprecated !
  234. * Only possible value is 8 (Excel 97/2000).
  235. * For any other value it fails silently.
  236. *
  237. * @access public
  238. * @param integer $version The BIFF version
  239. */
  240. function setVersion($version)
  241. {
  242. if ($version == 8) { // only accept version 8
  243. $version = 0x0600;
  244. $this->_BIFF_version = $version;
  245. // change BIFFwriter limit for CONTINUE records
  246. $this->_limit = 8228;
  247. $this->_tmp_format->_BIFF_version = $version;
  248. $this->_url_format->_BIFF_version = $version;
  249. $this->_parser->_BIFF_version = $version;
  250. $this->_codepage = 0x04B0;
  251. $total_worksheets = count($this->_worksheets);
  252. // change version for all worksheets too
  253. for ($i = 0; $i < $total_worksheets; $i++) {
  254. $this->_worksheets[$i]->_BIFF_version = $version;
  255. }
  256. $total_formats = count($this->_formats);
  257. // change version for all formats too
  258. for ($i = 0; $i < $total_formats; $i++) {
  259. $this->_formats[$i]->_BIFF_version = $version;
  260. }
  261. }
  262. }
  263. /**
  264. * Set the country identifier for the workbook
  265. *
  266. * @access public
  267. * @param integer $code Is the international calling country code for the
  268. * chosen country.
  269. */
  270. function setCountry($code)
  271. {
  272. $this->_country_code = $code;
  273. }
  274. var $_biff8_input_encoding = 'UTF-16LE';
  275. function setBIFF8InputEncoding($encoding) {
  276. $this->_biff8_input_encoding = $encoding;
  277. }
  278. /**
  279. * Add a new worksheet to the Excel workbook.
  280. * If no name is given the name of the worksheet will be Sheeti$i, with
  281. * $i in [1..].
  282. *
  283. * @access public
  284. * @param string $name the optional name of the worksheet
  285. * @return mixed reference to a worksheet object on success
  286. */
  287. function &addWorksheet($name = '')
  288. {
  289. $index = count($this->_worksheets);
  290. $sheetname = $this->_sheetname;
  291. if ($name == '') {
  292. $name = $sheetname.($index+1);
  293. }
  294. // Check that sheetname is <= 31 chars (Excel limit before BIFF8).
  295. if ($this->_BIFF_version != 0x0600)
  296. {
  297. if (strlen($name) > 31) {
  298. throw new Exception("Sheetname $name must be <= 31 chars");
  299. }
  300. }
  301. // Check that the worksheet name doesn't already exist: a fatal Excel error.
  302. $total_worksheets = count($this->_worksheets);
  303. for ($i = 0; $i < $total_worksheets; $i++) {
  304. if ($this->_worksheets[$i]->getName() == $name) {
  305. throw new Exception("Worksheet '$name' already exists");
  306. }
  307. }
  308. $worksheet = new PHPExcel_Writer_Excel5_Worksheet($this->_BIFF_version,
  309. $name, $index,
  310. $this->_activesheet, $this->_firstsheet,
  311. $this->_str_total, $this->_str_unique,
  312. $this->_str_table, $this->_url_format,
  313. $this->_parser, $this->_tmp_dir);
  314. $worksheet->setBIFF8InputEncoding($this->_biff8_input_encoding);
  315. $this->_worksheets[$index] = &$worksheet; // Store ref for iterator
  316. $this->_sheetnames[$index] = $name; // Store EXTERNSHEET names
  317. $this->_parser->setExtSheet($name, $index); // Register worksheet name with parser
  318. return $worksheet;
  319. }
  320. /**
  321. * Add a new format to the Excel workbook.
  322. * Also, pass any properties to the Format constructor.
  323. *
  324. * @access public
  325. * @param array $properties array with properties for initializing the format.
  326. * @return &PHPExcel_Writer_Excel5_Format reference to an Excel Format
  327. */
  328. function &addFormat($properties = array())
  329. {
  330. $format = new PHPExcel_Writer_Excel5_Format($this->_BIFF_version, $this->_xf_index, $properties);
  331. $this->_xf_index += 1;
  332. $this->_formats[] = &$format;
  333. return $format;
  334. }
  335. /**
  336. * Change the RGB components of the elements in the colour palette.
  337. *
  338. * @access public
  339. * @param integer $index colour index
  340. * @param integer $red red RGB value [0-255]
  341. * @param integer $green green RGB value [0-255]
  342. * @param integer $blue blue RGB value [0-255]
  343. * @return integer The palette index for the custom color
  344. */
  345. function setCustomColor($index, $red, $green, $blue)
  346. {
  347. // Match a HTML #xxyyzz style parameter
  348. /*if (defined $_[1] and $_[1] =~ /^#(\w\w)(\w\w)(\w\w)/ ) {
  349. @_ = ($_[0], hex $1, hex $2, hex $3);
  350. }*/
  351. // Check that the colour index is the right range
  352. if ($index < 8 or $index > 64) {
  353. // TODO: assign real error codes
  354. throw new Exception("Color index $index outside range: 8 <= index <= 64");
  355. }
  356. // Check that the colour components are in the right range
  357. if (($red < 0 or $red > 255) ||
  358. ($green < 0 or $green > 255) ||
  359. ($blue < 0 or $blue > 255))
  360. {
  361. throw new Exception("Color component outside range: 0 <= color <= 255");
  362. }
  363. $index -= 8; // Adjust colour index (wingless dragonfly)
  364. // Set the RGB value
  365. $this->_palette[$index] = array($red, $green, $blue, 0);
  366. return($index + 8);
  367. }
  368. /**
  369. * Sets the colour palette to the Excel 97+ default.
  370. *
  371. * @access private
  372. */
  373. function _setPaletteXl97()
  374. {
  375. $this->_palette = array(
  376. array(0x00, 0x00, 0x00, 0x00), // 8
  377. array(0xff, 0xff, 0xff, 0x00), // 9
  378. array(0xff, 0x00, 0x00, 0x00), // 10
  379. array(0x00, 0xff, 0x00, 0x00), // 11
  380. array(0x00, 0x00, 0xff, 0x00), // 12
  381. array(0xff, 0xff, 0x00, 0x00), // 13
  382. array(0xff, 0x00, 0xff, 0x00), // 14
  383. array(0x00, 0xff, 0xff, 0x00), // 15
  384. array(0x80, 0x00, 0x00, 0x00), // 16
  385. array(0x00, 0x80, 0x00, 0x00), // 17
  386. array(0x00, 0x00, 0x80, 0x00), // 18
  387. array(0x80, 0x80, 0x00, 0x00), // 19
  388. array(0x80, 0x00, 0x80, 0x00), // 20
  389. array(0x00, 0x80, 0x80, 0x00), // 21
  390. array(0xc0, 0xc0, 0xc0, 0x00), // 22
  391. array(0x80, 0x80, 0x80, 0x00), // 23
  392. array(0x99, 0x99, 0xff, 0x00), // 24
  393. array(0x99, 0x33, 0x66, 0x00), // 25
  394. array(0xff, 0xff, 0xcc, 0x00), // 26
  395. array(0xcc, 0xff, 0xff, 0x00), // 27
  396. array(0x66, 0x00, 0x66, 0x00), // 28
  397. array(0xff, 0x80, 0x80, 0x00), // 29
  398. array(0x00, 0x66, 0xcc, 0x00), // 30
  399. array(0xcc, 0xcc, 0xff, 0x00), // 31
  400. array(0x00, 0x00, 0x80, 0x00), // 32
  401. array(0xff, 0x00, 0xff, 0x00), // 33
  402. array(0xff, 0xff, 0x00, 0x00), // 34
  403. array(0x00, 0xff, 0xff, 0x00), // 35
  404. array(0x80, 0x00, 0x80, 0x00), // 36
  405. array(0x80, 0x00, 0x00, 0x00), // 37
  406. array(0x00, 0x80, 0x80, 0x00), // 38
  407. array(0x00, 0x00, 0xff, 0x00), // 39
  408. array(0x00, 0xcc, 0xff, 0x00), // 40
  409. array(0xcc, 0xff, 0xff, 0x00), // 41
  410. array(0xcc, 0xff, 0xcc, 0x00), // 42
  411. array(0xff, 0xff, 0x99, 0x00), // 43
  412. array(0x99, 0xcc, 0xff, 0x00), // 44
  413. array(0xff, 0x99, 0xcc, 0x00), // 45
  414. array(0xcc, 0x99, 0xff, 0x00), // 46
  415. array(0xff, 0xcc, 0x99, 0x00), // 47
  416. array(0x33, 0x66, 0xff, 0x00), // 48
  417. array(0x33, 0xcc, 0xcc, 0x00), // 49
  418. array(0x99, 0xcc, 0x00, 0x00), // 50
  419. array(0xff, 0xcc, 0x00, 0x00), // 51
  420. array(0xff, 0x99, 0x00, 0x00), // 52
  421. array(0xff, 0x66, 0x00, 0x00), // 53
  422. array(0x66, 0x66, 0x99, 0x00), // 54
  423. array(0x96, 0x96, 0x96, 0x00), // 55
  424. array(0x00, 0x33, 0x66, 0x00), // 56
  425. array(0x33, 0x99, 0x66, 0x00), // 57
  426. array(0x00, 0x33, 0x00, 0x00), // 58
  427. array(0x33, 0x33, 0x00, 0x00), // 59
  428. array(0x99, 0x33, 0x00, 0x00), // 60
  429. array(0x99, 0x33, 0x66, 0x00), // 61
  430. array(0x33, 0x33, 0x99, 0x00), // 62
  431. array(0x33, 0x33, 0x33, 0x00), // 63
  432. );
  433. }
  434. /**
  435. * Assemble worksheets into a workbook and send the BIFF data to an OLE
  436. * storage.
  437. *
  438. * @access private
  439. * @return mixed true on success
  440. */
  441. function _storeWorkbook()
  442. {
  443. if (count($this->_worksheets) == 0) {
  444. return true;
  445. }
  446. // Ensure that at least one worksheet has been selected.
  447. if ($this->_activesheet == 0) {
  448. $this->_worksheets[0]->selected = 1;
  449. }
  450. // Calculate the number of selected worksheet tabs and call the finalization
  451. // methods for each worksheet
  452. $total_worksheets = count($this->_worksheets);
  453. for ($i = 0; $i < $total_worksheets; $i++) {
  454. if ($this->_worksheets[$i]->selected) {
  455. $this->_selected++;
  456. }
  457. $this->_worksheets[$i]->close($this->_sheetnames);
  458. }
  459. // Add Workbook globals
  460. $this->_storeBof(0x0005);
  461. $this->_storeCodepage();
  462. if ($this->_BIFF_version == 0x0600) {
  463. $this->_storeWindow1();
  464. }
  465. if ($this->_BIFF_version == 0x0500) {
  466. $this->_storeExterns(); // For print area and repeat rows
  467. }
  468. $this->_storeNames(); // For print area and repeat rows
  469. if ($this->_BIFF_version == 0x0500) {
  470. $this->_storeWindow1();
  471. }
  472. $this->_storeDatemode();
  473. $this->_storeAllFonts();
  474. $this->_storeAllNumFormats();
  475. $this->_storeAllXfs();
  476. $this->_storeAllStyles();
  477. $this->_storePalette();
  478. $this->_calcSheetOffsets();
  479. // Add BOUNDSHEET records
  480. for ($i = 0; $i < $total_worksheets; $i++) {
  481. $this->_storeBoundsheet($this->_worksheets[$i]->name,$this->_worksheets[$i]->offset);
  482. }
  483. if ($this->_country_code != -1) {
  484. $this->_storeCountry();
  485. }
  486. if ($this->_BIFF_version == 0x0600) {
  487. //$this->_storeSupbookInternal();
  488. /* TODO: store external SUPBOOK records and XCT and CRN records
  489. in case of external references for BIFF8 */
  490. //$this->_storeExternsheetBiff8();
  491. $this->_storeSharedStringsTable();
  492. }
  493. // End Workbook globals
  494. $this->_storeEof();
  495. // Store the workbook in an OLE container
  496. $res = $this->_storeOLEFile();
  497. return true;
  498. }
  499. /**
  500. * Sets the temp dir used for storing the OLE file
  501. *
  502. * @access public
  503. * @param string $dir The dir to be used as temp dir
  504. * @return true if given dir is valid, false otherwise
  505. */
  506. function setTempDir($dir)
  507. {
  508. if (is_dir($dir)) {
  509. $this->_tmp_dir = $dir;
  510. return true;
  511. }
  512. return false;
  513. }
  514. /**
  515. * Store the workbook in an OLE container
  516. *
  517. * @access private
  518. * @return mixed true on success
  519. */
  520. function _storeOLEFile()
  521. {
  522. $OLE = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs('Book'));
  523. if ($this->_tmp_dir != '') {
  524. $OLE->setTempDir($this->_tmp_dir);
  525. }
  526. $res = $OLE->init();
  527. $OLE->append($this->_data);
  528. $total_worksheets = count($this->_worksheets);
  529. for ($i = 0; $i < $total_worksheets; $i++) {
  530. while ($tmp = $this->_worksheets[$i]->getData()) {
  531. $OLE->append($tmp);
  532. }
  533. }
  534. $root = new PHPExcel_Shared_OLE_PPS_Root(time(), time(), array($OLE));
  535. if ($this->_tmp_dir != '') {
  536. $root->setTempDir($this->_tmp_dir);
  537. }
  538. $res = $root->save($this->_filename);
  539. return true;
  540. }
  541. /**
  542. * Calculate offsets for Worksheet BOF records.
  543. *
  544. * @access private
  545. */
  546. function _calcSheetOffsets()
  547. {
  548. if ($this->_BIFF_version == 0x0600) {
  549. $boundsheet_length = 12; // fixed length for a BOUNDSHEET record
  550. } else {
  551. $boundsheet_length = 11;
  552. }
  553. $EOF = 4;
  554. $offset = $this->_datasize;
  555. if ($this->_BIFF_version == 0x0600) {
  556. // add the length of the SST
  557. /* TODO: check this works for a lot of strings (> 8224 bytes) */
  558. $offset += $this->_calculateSharedStringsSizes();
  559. if ($this->_country_code != -1) {
  560. $offset += 8; // adding COUNTRY record
  561. }
  562. // add the lenght of SUPBOOK, EXTERNSHEET and NAME records
  563. //$offset += 8; // FIXME: calculate real value when storing the records
  564. }
  565. $total_worksheets = count($this->_worksheets);
  566. // add the length of the BOUNDSHEET records
  567. for ($i = 0; $i < $total_worksheets; $i++) {
  568. $offset += $boundsheet_length + strlen($this->_worksheets[$i]->name);
  569. }
  570. $offset += $EOF;
  571. for ($i = 0; $i < $total_worksheets; $i++) {
  572. $this->_worksheets[$i]->offset = $offset;
  573. $offset += $this->_worksheets[$i]->_datasize;
  574. }
  575. $this->_biffsize = $offset;
  576. }
  577. /**
  578. * Store the Excel FONT records.
  579. *
  580. * @access private
  581. */
  582. function _storeAllFonts()
  583. {
  584. // tmp_format is added by the constructor. We use this to write the default XF's
  585. $format = $this->_tmp_format;
  586. $font = $format->getFont();
  587. // Note: Fonts are 0-indexed. According to the SDK there is no index 4,
  588. // so the following fonts are 0, 1, 2, 3, 5
  589. //
  590. for ($i = 1; $i <= 5; $i++){
  591. $this->_append($font);
  592. }
  593. // Iterate through the XF objects and write a FONT record if it isn't the
  594. // same as the default FONT and if it hasn't already been used.
  595. //
  596. $fonts = array();
  597. $index = 6; // The first user defined FONT
  598. $key = $format->getFontKey(); // The default font from _tmp_format
  599. $fonts[$key] = 0; // Index of the default font
  600. $total_formats = count($this->_formats);
  601. for ($i = 0; $i < $total_formats; $i++) {
  602. $key = $this->_formats[$i]->getFontKey();
  603. if (isset($fonts[$key])) {
  604. // FONT has already been used
  605. $this->_formats[$i]->font_index = $fonts[$key];
  606. } else {
  607. // Add a new FONT record
  608. $fonts[$key] = $index;
  609. $this->_formats[$i]->font_index = $index;
  610. $index++;
  611. $font = $this->_formats[$i]->getFont();
  612. $this->_append($font);
  613. }
  614. }
  615. }
  616. /**
  617. * Store user defined numerical formats i.e. FORMAT records
  618. *
  619. * @access private
  620. */
  621. function _storeAllNumFormats()
  622. {
  623. // Leaning num_format syndrome
  624. $hash_num_formats = array();
  625. $num_formats = array();
  626. $index = 164;
  627. // Iterate through the XF objects and write a FORMAT record if it isn't a
  628. // built-in format type and if the FORMAT string hasn't already been used.
  629. $total_formats = count($this->_formats);
  630. for ($i = 0; $i < $total_formats; $i++) {
  631. $num_format = $this->_formats[$i]->_num_format;
  632. // Check if $num_format is an index to a built-in format.
  633. // Also check for a string of zeros, which is a valid format string
  634. // but would evaluate to zero.
  635. //
  636. if (!preg_match("/^0+\d/", $num_format)) {
  637. if (preg_match("/^\d+$/", $num_format)) { // built-in format
  638. continue;
  639. }
  640. }
  641. if (isset($hash_num_formats[$num_format])) {
  642. // FORMAT has already been used
  643. $this->_formats[$i]->_num_format = $hash_num_formats[$num_format];
  644. } else{
  645. // Add a new FORMAT
  646. $hash_num_formats[$num_format] = $index;
  647. $this->_formats[$i]->_num_format = $index;
  648. array_push($num_formats,$num_format);
  649. $index++;
  650. }
  651. }
  652. // Write the new FORMAT records starting from 0xA4
  653. $index = 164;
  654. foreach ($num_formats as $num_format) {
  655. $this->_storeNumFormat($num_format,$index);
  656. $index++;
  657. }
  658. }
  659. /**
  660. * Write all XF records.
  661. *
  662. * @access private
  663. */
  664. function _storeAllXfs()
  665. {
  666. // _tmp_format is added by the constructor. We use this to write the default XF's
  667. // The default font index is 0
  668. //
  669. $format = $this->_tmp_format;
  670. for ($i = 0; $i <= 14; $i++) {
  671. $xf = $format->getXf('style'); // Style XF
  672. $this->_append($xf);
  673. }
  674. $xf = $format->getXf('cell'); // Cell XF
  675. $this->_append($xf);
  676. // User defined XFs
  677. $total_formats = count($this->_formats);
  678. for ($i = 0; $i < $total_formats; $i++) {
  679. $xf = $this->_formats[$i]->getXf('cell');
  680. $this->_append($xf);
  681. }
  682. }
  683. /**
  684. * Write all STYLE records.
  685. *
  686. * @access private
  687. */
  688. function _storeAllStyles()
  689. {
  690. $this->_storeStyle();
  691. }
  692. /**
  693. * Write the EXTERNCOUNT and EXTERNSHEET records. These are used as indexes for
  694. * the NAME records.
  695. *
  696. * @access private
  697. */
  698. function _storeExterns()
  699. {
  700. // Create EXTERNCOUNT with number of worksheets
  701. $this->_storeExterncount(count($this->_worksheets));
  702. // Create EXTERNSHEET for each worksheet
  703. foreach ($this->_sheetnames as $sheetname) {
  704. $this->_storeExternsheet($sheetname);
  705. }
  706. }
  707. /**
  708. * Write the NAME record to define the print area and the repeat rows and cols.
  709. *
  710. * @access private
  711. */
  712. function _storeNames()
  713. {
  714. // Create the print area NAME records
  715. $total_worksheets = count($this->_worksheets);
  716. for ($i = 0; $i < $total_worksheets; $i++) {
  717. // Write a Name record if the print area has been defined
  718. if (isset($this->_worksheets[$i]->print_rowmin)) {
  719. $this->_storeNameShort(
  720. $this->_worksheets[$i]->index,
  721. 0x06, // NAME type
  722. $this->_worksheets[$i]->print_rowmin,
  723. $this->_worksheets[$i]->print_rowmax,
  724. $this->_worksheets[$i]->print_colmin,
  725. $this->_worksheets[$i]->print_colmax
  726. );
  727. }
  728. }
  729. // Create the print title NAME records
  730. $total_worksheets = count($this->_worksheets);
  731. for ($i = 0; $i < $total_worksheets; $i++) {
  732. $rowmin = $this->_worksheets[$i]->title_rowmin;
  733. $rowmax = $this->_worksheets[$i]->title_rowmax;
  734. $colmin = $this->_worksheets[$i]->title_colmin;
  735. $colmax = $this->_worksheets[$i]->title_colmax;
  736. // Determine if row + col, row, col or nothing has been defined
  737. // and write the appropriate record
  738. //
  739. if (isset($rowmin) && isset($colmin)) {
  740. // Row and column titles have been defined.
  741. // Row title has been defined.
  742. $this->_storeNameLong(
  743. $this->_worksheets[$i]->index,
  744. 0x07, // NAME type
  745. $rowmin,
  746. $rowmax,
  747. $colmin,
  748. $colmax
  749. );
  750. } elseif (isset($rowmin)) {
  751. // Row title has been defined.
  752. $this->_storeNameShort(
  753. $this->_worksheets[$i]->index,
  754. 0x07, // NAME type
  755. $rowmin,
  756. $rowmax,
  757. 0x00,
  758. 0xff
  759. );
  760. } elseif (isset($colmin)) {
  761. // Column title has been defined.
  762. $this->_storeNameShort(
  763. $this->_worksheets[$i]->index,
  764. 0x07, // NAME type
  765. 0x0000,
  766. 0x3fff,
  767. $colmin,
  768. $colmax
  769. );
  770. } else {
  771. // Print title hasn't been defined.
  772. }
  773. }
  774. }
  775. /******************************************************************************
  776. *
  777. * BIFF RECORDS
  778. *
  779. */
  780. /**
  781. * Stores the CODEPAGE biff record.
  782. *
  783. * @access private
  784. */
  785. function _storeCodepage()
  786. {
  787. $record = 0x0042; // Record identifier
  788. $length = 0x0002; // Number of bytes to follow
  789. $cv = $this->_codepage; // The code page
  790. $header = pack('vv', $record, $length);
  791. $data = pack('v', $cv);
  792. $this->_append($header . $data);
  793. }
  794. /**
  795. * Write Excel BIFF WINDOW1 record.
  796. *
  797. * @access private
  798. */
  799. function _storeWindow1()
  800. {
  801. $record = 0x003D; // Record identifier
  802. $length = 0x0012; // Number of bytes to follow
  803. $xWn = 0x0000; // Horizontal position of window
  804. $yWn = 0x0000; // Vertical position of window
  805. $dxWn = 0x25BC; // Width of window
  806. $dyWn = 0x1572; // Height of window
  807. $grbit = 0x0038; // Option flags
  808. $ctabsel = $this->_selected; // Number of workbook tabs selected
  809. $wTabRatio = 0x0258; // Tab to scrollbar ratio
  810. $itabFirst = $this->_firstsheet; // 1st displayed worksheet
  811. $itabCur = $this->_activesheet; // Active worksheet
  812. $header = pack("vv", $record, $length);
  813. $data = pack("vvvvvvvvv", $xWn, $yWn, $dxWn, $dyWn,
  814. $grbit,
  815. $itabCur, $itabFirst,
  816. $ctabsel, $wTabRatio);
  817. $this->_append($header . $data);
  818. }
  819. /**
  820. * Writes Excel BIFF BOUNDSHEET record.
  821. * FIXME: inconsistent with BIFF documentation
  822. *
  823. * @param string $sheetname Worksheet name
  824. * @param integer $offset Location of worksheet BOF
  825. * @access private
  826. */
  827. function _storeBoundsheet($sheetname,$offset)
  828. {
  829. $record = 0x0085; // Record identifier
  830. if ($this->_BIFF_version == 0x0600) {
  831. $length = 0x08 + strlen($sheetname); // Number of bytes to follow
  832. } else {
  833. $length = 0x07 + strlen($sheetname); // Number of bytes to follow
  834. }
  835. $grbit = 0x0000; // Visibility and sheet type
  836. $cch = strlen($sheetname); // Length of sheet name
  837. $header = pack("vv", $record, $length);
  838. if ($this->_BIFF_version == 0x0600) {
  839. $data = pack("Vvv", $offset, $grbit, $cch);
  840. } else {
  841. $data = pack("VvC", $offset, $grbit, $cch);
  842. }
  843. $this->_append($header.$data.$sheetname);
  844. }
  845. /**
  846. * Write Internal SUPBOOK record
  847. *
  848. * @access private
  849. */
  850. function _storeSupbookInternal()
  851. {
  852. $record = 0x01AE; // Record identifier
  853. $length = 0x0004; // Bytes to follow
  854. $header = pack("vv", $record, $length);
  855. $data = pack("vv", count($this->_worksheets), 0x0104);
  856. $this->_append($header . $data);
  857. }
  858. /**
  859. * Writes the Excel BIFF EXTERNSHEET record. These references are used by
  860. * formulas.
  861. *
  862. * @param string $sheetname Worksheet name
  863. * @access private
  864. */
  865. function _storeExternsheetBiff8()
  866. {
  867. $total_references = count($this->_parser->_references);
  868. $record = 0x0017; // Record identifier
  869. $length = 2 + 6 * $total_references; // Number of bytes to follow
  870. $supbook_index = 0; // FIXME: only using internal SUPBOOK record
  871. $header = pack("vv", $record, $length);
  872. $data = pack('v', $total_references);
  873. for ($i = 0; $i < $total_references; $i++) {
  874. $data .= $this->_parser->_references[$i];
  875. }
  876. $this->_append($header . $data);
  877. }
  878. /**
  879. * Write Excel BIFF STYLE records.
  880. *
  881. * @access private
  882. */
  883. function _storeStyle()
  884. {
  885. $record = 0x0293; // Record identifier
  886. $length = 0x0004; // Bytes to follow
  887. $ixfe = 0x8000; // Index to style XF
  888. $BuiltIn = 0x00; // Built-in style
  889. $iLevel = 0xff; // Outline style level
  890. $header = pack("vv", $record, $length);
  891. $data = pack("vCC", $ixfe, $BuiltIn, $iLevel);
  892. $this->_append($header . $data);
  893. }
  894. /**
  895. * Writes Excel FORMAT record for non "built-in" numerical formats.
  896. *
  897. * @param string $format Custom format string
  898. * @param integer $ifmt Format index code
  899. * @access private
  900. */
  901. function _storeNumFormat($format, $ifmt)
  902. {
  903. $record = 0x041E; // Record identifier
  904. if ($this->_BIFF_version == 0x0600) {
  905. $length = 5 + strlen($format); // Number of bytes to follow
  906. $encoding = 0x0;
  907. } elseif ($this->_BIFF_version == 0x0500) {
  908. $length = 3 + strlen($format); // Number of bytes to follow
  909. }
  910. $cch = strlen($format); // Length of format string
  911. $header = pack("vv", $record, $length);
  912. if ($this->_BIFF_version == 0x0600) {
  913. $data = pack("vvC", $ifmt, $cch, $encoding);
  914. } elseif ($this->_BIFF_version == 0x0500) {
  915. $data = pack("vC", $ifmt, $cch);
  916. }
  917. $this->_append($header . $data . $format);
  918. }
  919. /**
  920. * Write DATEMODE record to indicate the date system in use (1904 or 1900).
  921. *
  922. * @access private
  923. */
  924. function _storeDatemode()
  925. {
  926. $record = 0x0022; // Record identifier
  927. $length = 0x0002; // Bytes to follow
  928. $f1904 = $this->_1904; // Flag for 1904 date system
  929. $header = pack("vv", $record, $length);
  930. $data = pack("v", $f1904);
  931. $this->_append($header . $data);
  932. }
  933. /**
  934. * Write BIFF record EXTERNCOUNT to indicate the number of external sheet
  935. * references in the workbook.
  936. *
  937. * Excel only stores references to external sheets that are used in NAME.
  938. * The workbook NAME record is required to define the print area and the repeat
  939. * rows and columns.
  940. *
  941. * A similar method is used in Worksheet.php for a slightly different purpose.
  942. *
  943. * @param integer $cxals Number of external references
  944. * @access private
  945. */
  946. function _storeExterncount($cxals)
  947. {
  948. $record = 0x0016; // Record identifier
  949. $length = 0x0002; // Number of bytes to follow
  950. $header = pack("vv", $record, $length);
  951. $data = pack("v", $cxals);
  952. $this->_append($header . $data);
  953. }
  954. /**
  955. * Writes the Excel BIFF EXTERNSHEET record. These references are used by
  956. * formulas. NAME record is required to define the print area and the repeat
  957. * rows and columns.
  958. *
  959. * A similar method is used in Worksheet.php for a slightly different purpose.
  960. *
  961. * @param string $sheetname Worksheet name
  962. * @access private
  963. */
  964. function _storeExternsheet($sheetname)
  965. {
  966. $record = 0x0017; // Record identifier
  967. $length = 0x02 + strlen($sheetname); // Number of bytes to follow
  968. $cch = strlen($sheetname); // Length of sheet name
  969. $rgch = 0x03; // Filename encoding
  970. $header = pack("vv", $record, $length);
  971. $data = pack("CC", $cch, $rgch);
  972. $this->_append($header . $data . $sheetname);
  973. }
  974. /**
  975. * Store the NAME record in the short format that is used for storing the print
  976. * area, repeat rows only and repeat columns only.
  977. *
  978. * @param integer $index Sheet index
  979. * @param integer $type Built-in name type
  980. * @param integer $rowmin Start row
  981. * @param integer $rowmax End row
  982. * @param integer $colmin Start colum
  983. * @param integer $colmax End column
  984. * @access private
  985. */
  986. function _storeNameShort($index, $type, $rowmin, $rowmax, $colmin, $colmax)
  987. {
  988. $record = 0x0018; // Record identifier
  989. $length = 0x0024; // Number of bytes to follow
  990. $grbit = 0x0020; // Option flags
  991. $chKey = 0x00; // Keyboard shortcut
  992. $cch = 0x01; // Length of text name
  993. $cce = 0x0015; // Length of text definition
  994. $ixals = $index + 1; // Sheet index
  995. $itab = $ixals; // Equal to ixals
  996. $cchCustMenu = 0x00; // Length of cust menu text
  997. $cchDescription = 0x00; // Length of description text
  998. $cchHelptopic = 0x00; // Length of help topic text
  999. $cchStatustext = 0x00; // Length of status bar text
  1000. $rgch = $type; // Built-in name type
  1001. $unknown03 = 0x3b;
  1002. $unknown04 = 0xffff-$index;
  1003. $unknown05 = 0x0000;
  1004. $unknown06 = 0x0000;
  1005. $unknown07 = 0x1087;
  1006. $unknown08 = 0x8005;
  1007. $header = pack("vv", $record, $length);
  1008. $data = pack("v", $grbit);
  1009. $data .= pack("C", $chKey);
  1010. $data .= pack("C", $cch);
  1011. $data .= pack("v", $cce);
  1012. $data .= pack("v", $ixals);
  1013. $data .= pack("v", $itab);
  1014. $data .= pack("C", $cchCustMenu);
  1015. $data .= pack("C", $cchDescription);
  1016. $data .= pack("C", $cchHelptopic);
  1017. $data .= pack("C", $cchStatustext);
  1018. $data .= pack("C", $rgch);
  1019. $data .= pack("C", $unknown03);
  1020. $data .= pack("v", $unknown04);
  1021. $data .= pack("v", $unknown05);
  1022. $data .= pack("v", $unknown06);
  1023. $data .= pack("v", $unknown07);
  1024. $data .= pack("v", $unknown08);
  1025. $data .= pack("v", $index);
  1026. $data .= pack("v", $index);
  1027. $data .= pack("v", $rowmin);
  1028. $data .= pack("v", $rowmax);
  1029. $data .= pack("C", $colmin);
  1030. $data .= pack("C", $colmax);
  1031. $this->_append($header . $data);
  1032. }
  1033. /**
  1034. * Store the NAME record in the long format that is used for storing the repeat
  1035. * rows and columns when both are specified. This shares a lot of code with
  1036. * _storeNameShort() but we use a separate method to keep the code clean.
  1037. * Code abstraction for reuse can be carried too far, and I should know. ;-)
  1038. *
  1039. * @param integer $index Sheet index
  1040. * @param integer $type Built-in name type
  1041. * @param integer $rowmin Start row
  1042. * @param integer $rowmax End row
  1043. * @param integer $colmin Start colum
  1044. * @param integer $colmax End column
  1045. * @access private
  1046. */
  1047. function _storeNameLong($index, $type, $rowmin, $rowmax, $colmin, $colmax)
  1048. {
  1049. $record = 0x0018; // Record identifier
  1050. $length = 0x003d; // Number of bytes to follow
  1051. $grbit = 0x0020; // Option flags
  1052. $chKey = 0x00; // Keyboard shortcut
  1053. $cch = 0x01; // Length of text name
  1054. $cce = 0x002e; // Length of text definition
  1055. $ixals = $index + 1; // Sheet index
  1056. $itab = $ixals; // Equal to ixals
  1057. $cchCustMenu = 0x00; // Length of cust menu text
  1058. $cchDescription = 0x00; // Length of description text
  1059. $cchHelptopic = 0x00; // Length of help topic text
  1060. $cchStatustext = 0x00; // Length of status bar text
  1061. $rgch = $type; // Built-in name type
  1062. $unknown01 = 0x29;
  1063. $unknown02 = 0x002b;
  1064. $unknown03 = 0x3b;
  1065. $unknown04 = 0xffff-$index;
  1066. $unknown05 = 0x0000;
  1067. $unknown06 = 0x0000;
  1068. $unknown07 = 0x1087;
  1069. $unknown08 = 0x8008;
  1070. $header = pack("vv", $record, $length);
  1071. $data = pack("v", $grbit);
  1072. $data .= pack("C", $chKey);
  1073. $data .= pack("C", $cch);
  1074. $data .= pack("v", $cce);
  1075. $data .= pack("v", $ixals);
  1076. $data .= pack("v", $itab);
  1077. $data .= pack("C", $cchCustMenu);
  1078. $data .= pack("C", $cchDescription);
  1079. $data .= pack("C", $cchHelptopic);
  1080. $data .= pack("C", $cchStatustext);
  1081. $data .= pack("C", $rgch);
  1082. $data .= pack("C", $unknown01);
  1083. $data .= pack("v", $unknown02);
  1084. // Column definition
  1085. $data .= pack("C", $unknown03);
  1086. $data .= pack("v", $unknown04);
  1087. $data .= pack("v", $unknown05);
  1088. $data .= pack("v", $unknown06);
  1089. $data .= pack("v", $unknown07);
  1090. $data .= pack("v", $unknown08);
  1091. $data .= pack("v", $index);
  1092. $data .= pack("v", $index);
  1093. $data .= pack("v", 0x0000);
  1094. $data .= pack("v", 0x3fff);
  1095. $data .= pack("C", $colmin);
  1096. $data .= pack("C", $colmax);
  1097. // Row definition
  1098. $data .= pack("C", $unknown03);
  1099. $data .= pack("v", $unknown04);
  1100. $data .= pack("v", $unknown05);
  1101. $data .= pack("v", $unknown06);
  1102. $data .= pack("v", $unknown07);
  1103. $data .= pack("v", $unknown08);
  1104. $data .= pack("v", $index);
  1105. $data .= pack("v", $index);
  1106. $data .= pack("v", $rowmin);
  1107. $data .= pack("v", $rowmax);
  1108. $data .= pack("C", 0x00);
  1109. $data .= pack("C", 0xff);
  1110. // End of data
  1111. $data .= pack("C", 0x10);
  1112. $this->_append($header . $data);
  1113. }
  1114. /**
  1115. * Stores the COUNTRY record for localization
  1116. *
  1117. * @access private
  1118. */
  1119. function _storeCountry()
  1120. {
  1121. $record = 0x008C; // Record identifier
  1122. $length = 4; // Number of bytes to follow
  1123. $header = pack('vv', $record, $length);
  1124. /* using the same country code always for simplicity */
  1125. $data = pack('vv', $this->_country_code, $this->_country_code);
  1126. $this->_append($header . $data);
  1127. }
  1128. /**
  1129. * Stores the PALETTE biff record.
  1130. *
  1131. * @access private
  1132. */
  1133. function _storePalette()
  1134. {
  1135. $aref = $this->_palette;
  1136. $record = 0x0092; // Record identifier
  1137. $length = 2 + 4 * count($aref); // Number of bytes to follow
  1138. $ccv = count($aref); // Number of RGB values to follow
  1139. $data = ''; // The RGB data
  1140. // Pack the RGB data
  1141. foreach ($aref as $color) {
  1142. foreach ($color as $byte) {
  1143. $data .= pack("C",$byte);
  1144. }
  1145. }
  1146. $header = pack("vvv", $record, $length, $ccv);
  1147. $this->_append($header . $data);
  1148. }
  1149. /**
  1150. * Calculate
  1151. * Handling of the SST continue blocks is complicated by the need to include an
  1152. * additional continuation byte depending on whether the string is split between
  1153. * blocks or whether it starts at the beginning of the block. (There are also
  1154. * additional complications that will arise later when/if Rich Strings are
  1155. * supported).
  1156. *
  1157. * @access private
  1158. */
  1159. function _calculateSharedStringsSizes()
  1160. {
  1161. /* Iterate through the strings to calculate the CONTINUE block sizes.
  1162. For simplicity we use the same size for the SST and CONTINUE records:
  1163. 8228 : Maximum Excel97 block size
  1164. -4 : Length of block header
  1165. -8 : Length of additional SST header information
  1166. = 8216
  1167. */
  1168. $continue_limit = 8208;
  1169. $block_length = 0;
  1170. $written = 0;
  1171. $this->_block_sizes = array();
  1172. $continue = 0;
  1173. foreach (array_keys($this->_str_table) as $string) {
  1174. $string_length = strlen($string);
  1175. $headerinfo = unpack("vlength/Cencoding", $string);
  1176. $encoding = $headerinfo["encoding"];
  1177. $split_string = 0;
  1178. // Block length is the total length of the strings that will be
  1179. // written out in a single SST or CONTINUE block.
  1180. $block_length += $string_length;
  1181. // We can write the string if it doesn't cross a CONTINUE boundary
  1182. if ($block_length < $continue_limit) {
  1183. $written += $string_length;
  1184. continue;
  1185. }
  1186. // Deal with the cases where the next string to be written will exceed
  1187. // the CONTINUE boundary. If the string is very long it may need to be
  1188. // written in more than one CONTINUE record.
  1189. while ($block_length >= $continue_limit) {
  1190. // We need to avoid the case where a string is continued in the first
  1191. // n bytes that contain the string header information.
  1192. $header_length = 3; // Min string + header size -1
  1193. $space_remaining = $continue_limit - $written - $continue;
  1194. /* TODO: Unicode data should only be split on char (2 byte)
  1195. boundaries. Therefore, in some cases we need to reduce the
  1196. amount of available
  1197. */
  1198. $align = 0;
  1199. // Only applies to Unicode strings
  1200. if ($encoding == 1) {
  1201. // Min string + header size -1
  1202. $header_length = 4;
  1203. if ($space_remaining > $header_length) {
  1204. // String contains 3 byte header => split on odd boundary
  1205. if (!$split_string && $space_remaining % 2 != 1) {
  1206. $space_remaining--;
  1207. $align = 1;
  1208. }
  1209. // Split section without header => split on even boundary
  1210. else if ($split_string && $space_remaining % 2 == 1) {
  1211. $space_remaining--;
  1212. $align = 1;
  1213. }
  1214. $split_string = 1;
  1215. }
  1216. }
  1217. if ($space_remaining > $header_length) {
  1218. // Write as much as possible of the string in the current block
  1219. $written += $space_remaining;
  1220. // Reduce the current block length by the amount written
  1221. $block_length -= $continue_limit - $continue - $align;
  1222. // Store the max size for this block
  1223. $this->_block_sizes[] = $continue_limit - $align;
  1224. // If the current string was split then the next CONTINUE block
  1225. // should have the string continue flag (grbit) set unless the
  1226. // split string fits exactly into the remaining space.
  1227. if ($block_length > 0) {
  1228. $continue = 1;
  1229. } else {
  1230. $continue = 0;
  1231. }
  1232. } else {
  1233. // Store the max size for this block
  1234. $this->_block_sizes[] = $written + $continue;
  1235. // Not enough space to start the string in the current block
  1236. $block_length -= $continue_limit - $space_remaining - $continue;
  1237. $continue = 0;
  1238. }
  1239. // If the string (or substr) is small enough we can write it in the
  1240. // new CONTINUE block. Else, go through the loop again to write it in
  1241. // one or more CONTINUE blocks
  1242. if ($block_length < $continue_limit) {
  1243. $written = $block_length;
  1244. } else {
  1245. $written = 0;
  1246. }
  1247. }
  1248. }
  1249. // Store the max size for the last block unless it is empty
  1250. if ($written + $continue) {
  1251. $this->_block_sizes[] = $written + $continue;
  1252. }
  1253. /* Calculate the total length of the SST and associated CONTINUEs (if any).
  1254. The SST record will have a length even if it contains no strings.
  1255. This length is required to set the offsets in the BOUNDSHEET records since
  1256. they must be written before the SST records
  1257. */
  1258. $tmp_block_sizes = array();
  1259. $tmp_block_sizes = $this->_block_sizes;
  1260. $length = 12;
  1261. if (!empty($

Large files files are truncated, but you can click here to view the full file