本文整理汇总了PHP中PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort方法的具体用法?PHP PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort怎么用?PHP PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel_Shared_String
的用法示例。
在下文中一共展示了PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeFont
/**
* Get font record data
*
* @return string
*/
public function writeFont()
{
$font_outline = 0;
$font_shadow = 0;
$icv = $this->_colorIndex;
// Index to color palette
if ($this->_font->getSuperScript()) {
$sss = 1;
} else {
if ($this->_font->getSubScript()) {
$sss = 2;
} else {
$sss = 0;
}
}
$bFamily = 0;
// Font family
$bCharSet = PHPExcel_Shared_Font::getCharsetFromFontName($this->_font->getName());
// Character set
$record = 0x31;
// Record identifier
$reserved = 0x0;
// Reserved
$grbit = 0x0;
// Font attributes
if ($this->_font->getItalic()) {
$grbit |= 0x2;
}
if ($this->_font->getStrikethrough()) {
$grbit |= 0x8;
}
if ($font_outline) {
$grbit |= 0x10;
}
if ($font_shadow) {
$grbit |= 0x20;
}
if ($this->_BIFFVersion == 0x500) {
$data = pack("vvvvvCCCCC", $this->_font->getSize() * 20, $grbit, $icv, $this->_mapBold($this->_font->getBold()), $sss, $this->_mapUnderline($this->_font->getUnderline()), $bFamily, $bCharSet, $reserved, strlen($this->_font->getName()));
$data .= $this->_font->getName();
} elseif ($this->_BIFFVersion == 0x600) {
$data = pack("vvvvvCCCC", $this->_font->getSize() * 20, $grbit, $icv, $this->_mapBold($this->_font->getBold()), $sss, $this->_mapUnderline($this->_font->getUnderline()), $bFamily, $bCharSet, $reserved);
$data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($this->_font->getName());
}
$length = strlen($data);
$header = pack("vv", $record, $length);
return $header . $data;
}
示例2: _writeRichTextString
/**
* Write a LABELSST record or a LABEL record. Which one depends on BIFF version
* It differs from _writeString by the writing of rich text strings.
* @param int $row Row index (0-based)
* @param int $col Column index (0-based)
* @param string $str The string
* @param mixed $xfIndex The XF format index for the cell
* @param array $arrcRun Index to Font record and characters beginning
*/
private function _writeRichTextString($row, $col, $str, $xfIndex, $arrcRun)
{
$record = 0xfd;
// Record identifier
$length = 0xa;
// Bytes to follow
$str = PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($str, $arrcRun);
/* check if string is already present */
if (!isset($this->_str_table[$str])) {
$this->_str_table[$str] = $this->_str_unique++;
}
$this->_str_total++;
$header = pack('vv', $record, $length);
$data = pack('vvvV', $row, $col, $xfIndex, $this->_str_table[$str]);
$this->_append($header . $data);
}
示例3: _convertString
/**
* Convert a string token to ptgStr
*
* @access private
* @param string $string A string for conversion to its ptg value.
* @return mixed the converted token on success
*/
function _convertString($string)
{
// chop away beggining and ending quotes
$string = substr($string, 1, strlen($string) - 2);
if (strlen($string) > 255) {
throw new Exception("String is too long");
}
if ($this->_BIFF_version == 0x500) {
return pack("CC", $this->ptg['ptgStr'], strlen($string)) . $string;
} elseif ($this->_BIFF_version == 0x600) {
return pack('C', $this->ptg['ptgStr']) . PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($string);
}
}
示例4: writeBoundSheet
/**
* Writes Excel BIFF BOUNDSHEET record.
*
* @param PHPExcel_Worksheet $sheet Worksheet name
* @param integer $offset Location of worksheet BOF
*/
private function writeBoundSheet($sheet, $offset)
{
$sheetname = $sheet->getTitle();
$record = 0x85;
// Record identifier
// sheet state
switch ($sheet->getSheetState()) {
case PHPExcel_Worksheet::SHEETSTATE_VISIBLE:
$ss = 0x0;
break;
case PHPExcel_Worksheet::SHEETSTATE_HIDDEN:
$ss = 0x1;
break;
case PHPExcel_Worksheet::SHEETSTATE_VERYHIDDEN:
$ss = 0x2;
break;
default:
$ss = 0x0;
break;
}
// sheet type
$st = 0x0;
$grbit = 0x0;
// Visibility and sheet type
$data = pack("VCC", $offset, $ss, $st);
$data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($sheetname);
$length = strlen($data);
$header = pack("vv", $record, $length);
$this->append($header . $data);
}
示例5: _convertString
/**
* Convert a string token to ptgStr
*
* @access private
* @param string $string A string for conversion to its ptg value.
* @return mixed the converted token on success
*/
function _convertString($string)
{
// chop away beggining and ending quotes
$string = substr($string, 1, strlen($string) - 2);
if (strlen($string) > 255) {
throw new PHPExcel_Reader_Exception("String is too long");
}
return pack('C', $this->ptg['ptgStr']) . PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($string);
}
示例6: _storeBoundsheet
/**
* Writes Excel BIFF BOUNDSHEET record.
*
* @param string $sheetname Worksheet name
* @param integer $offset Location of worksheet BOF
* @access private
*/
function _storeBoundsheet($sheetname, $offset)
{
$record = 0x85;
// Record identifier
$grbit = 0x0;
// Visibility and sheet type
if ($this->_BIFF_version == 0x600) {
$data = pack("Vv", $offset, $grbit);
$data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($sheetname);
} else {
$cch = strlen($sheetname);
// Length of sheet name
$data = pack("VvC", $offset, $grbit, $cch);
$data .= $sheetname;
}
$length = strlen($data);
$header = pack("vv", $record, $length);
$this->_append($header . $data);
}
示例7: _storeBoundsheet
/**
* Writes Excel BIFF BOUNDSHEET record.
* FIXME: inconsistent with BIFF documentation
*
* @param string $sheetname Worksheet name
* @param integer $offset Location of worksheet BOF
* @access private
*/
function _storeBoundsheet($sheetname, $offset)
{
$record = 0x85;
// Record identifier
if ($this->_BIFF_version == 0x600) {
//$recordData = $this->_writeUnicodeDataShort($sheetname);
$recordData = PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($sheetname);
$length = 0x6 + strlen($recordData);
// Number of bytes to follow
} else {
$length = 0x7 + strlen($sheetname);
// Number of bytes to follow
}
$grbit = 0x0;
// Visibility and sheet type
$header = pack("vv", $record, $length);
if ($this->_BIFF_version == 0x600) {
$data = pack("Vv", $offset, $grbit);
$this->_append($header . $data . $recordData);
} else {
$cch = strlen($sheetname);
// Length of sheet name
$data = pack("VvC", $offset, $grbit, $cch);
$this->_append($header . $data . $sheetname);
}
}