当前位置: 首页>>代码示例>>PHP>>正文


PHP Style::setFont方法代码示例

本文整理汇总了PHP中Style::setFont方法的典型用法代码示例。如果您正苦于以下问题:PHP Style::setFont方法的具体用法?PHP Style::setFont怎么用?PHP Style::setFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Style的用法示例。


在下文中一共展示了Style::setFont方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _readXf

 /**
  * XF - Extended Format
  *
  * This record contains formatting information for cells, rows, columns or styles.
  * According to http://support.microsoft.com/kb/147732 there are always at least 15 cell style XF
  * and 1 cell XF.
  * Inspection of Excel files generated by MS Office Excel shows that XF records 0-14 are cell style XF
  * and XF record 15 is a cell XF
  * We only read the first cell style XF and skip the remaining cell style XF records
  * We read all cell XF records.
  *
  * --	"OpenOffice.org's Documentation of the Microsoft
  * 		Excel File Format"
  */
 private function _readXf()
 {
     $length = $this->_GetInt2d($this->_data, $this->_pos + 2);
     $recordData = substr($this->_data, $this->_pos + 4, $length);
     // move stream pointer to next record
     $this->_pos += 4 + $length;
     $objStyle = new Style();
     if (!$this->_readDataOnly) {
         // offset:  0; size: 2; Index to FONT record
         if ($this->_GetInt2d($recordData, 0) < 4) {
             $fontIndex = $this->_GetInt2d($recordData, 0);
         } else {
             // this has to do with that index 4 is omitted in all BIFF versions for some strange reason
             // check the OpenOffice documentation of the FONT record
             $fontIndex = $this->_GetInt2d($recordData, 0) - 1;
         }
         $objStyle->setFont($this->_objFonts[$fontIndex]);
         // offset:  2; size: 2; Index to FORMAT record
         $numberFormatIndex = $this->_GetInt2d($recordData, 2);
         if (isset($this->_formats[$numberFormatIndex])) {
             // then we have user-defined format code
             $numberformat = array('code' => $this->_formats[$numberFormatIndex]);
         } elseif (($code = Style_NumberFormat::builtInFormatCode($numberFormatIndex)) !== '') {
             // then we have built-in format code
             $numberformat = array('code' => $code);
         } else {
             // we set the general format code
             $numberformat = array('code' => 'General');
         }
         $objStyle->getNumberFormat()->setFormatCode($numberformat['code']);
         // offset:  4; size: 2; XF type, cell protection, and parent style XF
         // bit 2-0; mask 0x0007; XF_TYPE_PROT
         $xfTypeProt = $this->_GetInt2d($recordData, 4);
         // bit 0; mask 0x01; 1 = cell is locked
         $isLocked = (0x1 & $xfTypeProt) >> 0;
         $objStyle->getProtection()->setLocked($isLocked ? Style_Protection::PROTECTION_INHERIT : Style_Protection::PROTECTION_UNPROTECTED);
         // bit 1; mask 0x02; 1 = Formula is hidden
         $isHidden = (0x2 & $xfTypeProt) >> 1;
         $objStyle->getProtection()->setHidden($isHidden ? Style_Protection::PROTECTION_PROTECTED : Style_Protection::PROTECTION_UNPROTECTED);
         // bit 2; mask 0x04; 0 = Cell XF, 1 = Cell Style XF
         $isCellStyleXf = (0x4 & $xfTypeProt) >> 2;
         // offset:  6; size: 1; Alignment and text break
         // bit 2-0, mask 0x07; horizontal alignment
         $horAlign = (0x7 & ord($recordData[6])) >> 0;
         switch ($horAlign) {
             case 0:
                 $objStyle->getAlignment()->setHorizontal(Style_Alignment::HORIZONTAL_GENERAL);
                 break;
             case 1:
                 $objStyle->getAlignment()->setHorizontal(Style_Alignment::HORIZONTAL_LEFT);
                 break;
             case 2:
                 $objStyle->getAlignment()->setHorizontal(Style_Alignment::HORIZONTAL_CENTER);
                 break;
             case 3:
                 $objStyle->getAlignment()->setHorizontal(Style_Alignment::HORIZONTAL_RIGHT);
                 break;
             case 5:
                 $objStyle->getAlignment()->setHorizontal(Style_Alignment::HORIZONTAL_JUSTIFY);
                 break;
             case 6:
                 $objStyle->getAlignment()->setHorizontal(Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS);
                 break;
         }
         // bit 3, mask 0x08; wrap text
         $wrapText = (0x8 & ord($recordData[6])) >> 3;
         switch ($wrapText) {
             case 0:
                 $objStyle->getAlignment()->setWrapText(false);
                 break;
             case 1:
                 $objStyle->getAlignment()->setWrapText(true);
                 break;
         }
         // bit 6-4, mask 0x70; vertical alignment
         $vertAlign = (0x70 & ord($recordData[6])) >> 4;
         switch ($vertAlign) {
             case 0:
                 $objStyle->getAlignment()->setVertical(Style_Alignment::VERTICAL_TOP);
                 break;
             case 1:
                 $objStyle->getAlignment()->setVertical(Style_Alignment::VERTICAL_CENTER);
                 break;
             case 2:
                 $objStyle->getAlignment()->setVertical(Style_Alignment::VERTICAL_BOTTOM);
                 break;
//.........这里部分代码省略.........
开发者ID:bestgoodz,项目名称:toko-baju,代码行数:101,代码来源:Excel5.php


注:本文中的Style::setFont方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。