adding setCountry() for localization
git-svn-id: https://svn.php.net/repository/pear/packages/Spreadsheet_Excel_Writer/trunk@146042 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
1fd5af1b49
commit
f6ea05798f
|
|
@ -153,6 +153,12 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri
|
||||||
*/
|
*/
|
||||||
var $_codepage;
|
var $_codepage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The country code used for localization
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
var $_country_code;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class constructor
|
* Class constructor
|
||||||
*
|
*
|
||||||
|
|
@ -180,6 +186,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri
|
||||||
$this->_formats = array();
|
$this->_formats = array();
|
||||||
$this->_palette = array();
|
$this->_palette = array();
|
||||||
$this->_codepage = 0x04E4; // FIXME: should change for BIFF8
|
$this->_codepage = 0x04E4; // FIXME: should change for BIFF8
|
||||||
|
$this->_country_code = -1;
|
||||||
|
|
||||||
// Add the default format for hyperlinks
|
// Add the default format for hyperlinks
|
||||||
$this->_url_format =& $this->addFormat(array('color' => 'blue', 'underline' => 1));
|
$this->_url_format =& $this->addFormat(array('color' => 'blue', 'underline' => 1));
|
||||||
|
|
@ -268,6 +275,18 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
* Add a new worksheet to the Excel workbook.
|
||||||
* If no name is given the name of the worksheet will be Sheeti$i, with
|
* If no name is given the name of the worksheet will be Sheeti$i, with
|
||||||
|
|
@ -499,7 +518,9 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri
|
||||||
$this->_storeBoundsheet($this->_worksheets[$i]->name,$this->_worksheets[$i]->offset);
|
$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) {
|
if ($this->_BIFF_version == 0x0600) {
|
||||||
//$this->_storeSupbookInternal();
|
//$this->_storeSupbookInternal();
|
||||||
|
|
@ -569,6 +590,9 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri
|
||||||
// add the length of the SST
|
// add the length of the SST
|
||||||
/* TODO: check this works for a lot of strings (> 8224 bytes) */
|
/* TODO: check this works for a lot of strings (> 8224 bytes) */
|
||||||
$offset += $this->_calculateSharedStringsSizes();
|
$offset += $this->_calculateSharedStringsSizes();
|
||||||
|
if ($this->_country_code != -1) {
|
||||||
|
$offset += 8; // adding COUNTRY record
|
||||||
|
}
|
||||||
// add the lenght of SUPBOOK, EXTERNSHEET and NAME records
|
// add the lenght of SUPBOOK, EXTERNSHEET and NAME records
|
||||||
//$offset += 8; // FIXME: calculate real value when storing the records
|
//$offset += 8; // FIXME: calculate real value when storing the records
|
||||||
}
|
}
|
||||||
|
|
@ -1200,8 +1224,23 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri
|
||||||
$data .= pack("C", 0x10);
|
$data .= pack("C", 0x10);
|
||||||
$this->_append($header.$data);
|
$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.
|
* Stores the PALETTE biff record.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue