cvs: pear /Spreadsheet_Excel_Writer/Writer Workbook.php
| From: | Xavier Noguer Gallego | Date: | Tue, 09 Dec 2003 17:26:47 +0000 |
| Subject: | cvs: pear /Spreadsheet_Excel_Writer/Writer Workbook.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-14732@lists.php.net to get a copy of this message | ||
xnoguer Tue Dec 9 12:26:47 2003 EDT
Modified files:
/pear/Spreadsheet_Excel_Writer/Writer Workbook.php
Log:
adding setCountry() for localization
Index: pear/Spreadsheet_Excel_Writer/Writer/Workbook.php
diff -u pear/Spreadsheet_Excel_Writer/Writer/Workbook.php:1.20
pear/Spreadsheet_Excel_Writer/Writer/Workbook.php:1.21
--- pear/Spreadsheet_Excel_Writer/Writer/Workbook.php:1.20 Sat Nov 15 15:53:18 2003
+++ pear/Spreadsheet_Excel_Writer/Writer/Workbook.php Tue Dec 9 12:26:47 2003
@@ -154,6 +154,12 @@
var $_codepage;
/**
+ * The country code used for localization
+ * @var integer
+ */
+ var $_country_code;
+
+ /**
* Class constructor
*
* @param string filename for storing the workbook. "-" for writing to stdout.
@@ -180,6 +186,7 @@
$this->_formats = array();
$this->_palette = array();
$this->_codepage = 0x04E4; // FIXME: should change for BIFF8
+ $this->_country_code = -1;
// Add the default format for hyperlinks
$this->_url_format =& $this->addFormat(array('color' =>
'blue', 'underline' => 1));
@@ -269,6 +276,18 @@
}
/**
+ * Set the country identifier for the workbook
+ *
+ * @access public
+ * @param integer $code Is the international calling country code for the
+ * chosen country.
+ */
+ function setCountry($code)
+ {
+ $this->_country_code = $code;
+ }
+
+ /**
* Add a new worksheet to the Excel workbook.
* If no name is given the name of the worksheet will be Sheeti$i, with
* $i in [1..].
@@ -499,7 +518,9 @@
$this->_storeBoundsheet($this->_worksheets[$i]->name,$this->_worksheets[$i]->offset);
}
- /* TODO: store COUNTRY record? */
+ if ($this->_country_code != -1) {
+ $this->_storeCountry();
+ }
if ($this->_BIFF_version == 0x0600) {
//$this->_storeSupbookInternal();
@@ -569,6 +590,9 @@
// add the length of the SST
/* TODO: check this works for a lot of strings (> 8224 bytes) */
$offset += $this->_calculateSharedStringsSizes();
+ if ($this->_country_code != -1) {
+ $offset += 8; // adding COUNTRY record
+ }
// add the lenght of SUPBOOK, EXTERNSHEET and NAME records
//$offset += 8; // FIXME: calculate real value when storing the records
}
@@ -1200,8 +1224,23 @@
$data .= pack("C", 0x10);
$this->_append($header.$data);
}
-
-
+
+ /**
+ * Stores the COUNTRY record for localization
+ *
+ * @access private
+ */
+ function _storeCountry()
+ {
+ $record = 0x008C; // Record identifier
+ $length = 4; // Number of bytes to follow
+
+ $header = pack('vv', $record, $length);
+ /* using the same country code always for simplicity */
+ $data = pack('vv', $this->_country_code, $this->_country_code);
+ $this->_append($header.$data);
+ }
+
/**
* Stores the PALETTE biff record.
*