本文整理汇总了PHP中PHPExcel_Style::setFont方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Style::setFont方法的具体用法?PHP PHPExcel_Style::setFont怎么用?PHP PHPExcel_Style::setFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel_Style
的用法示例。
在下文中一共展示了PHPExcel_Style::setFont方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setStyle
public function setStyle($cellRange, $fontFamily = 'Arial', $fontSize = 10, $colorRGB = '00000000', $bold = false, $italic = false, $underline = false)
{
require_once \GO::config()->root_path . 'go/vendor/PHPExcel/PHPExcel/Style.php';
require_once \GO::config()->root_path . 'go/vendor/PHPExcel/PHPExcel/Style/Font.php';
require_once \GO::config()->root_path . 'go/vendor/PHPExcel/PHPExcel/Style/Color.php';
$colorObj = new \PHPExcel_Style_Color();
$colorObj->setRGB($colorRGB);
$fontObj = new \PHPExcel_Style_Font();
$fontObj->setName($fontFamily);
$fontObj->setSize($fontSize);
$fontObj->setColor($colorObj);
$fontObj->setBold($bold);
$fontObj->setItalic($italic);
$fontObj->setUnderline($underline);
$styleObj = new \PHPExcel_Style();
$styleObj->setFont($fontObj);
$this->getActiveSheet()->setSharedStyle($styleObj, $cellRange);
}
示例2: _readDefault
/**
* Reads a general type of BIFF record. Does nothing except for moving stream pointer forward to next record.
*/
private function _readDefault()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
// $recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
}
/**
* The NOTE record specifies a comment associated with a particular cell. In Excel 95 (BIFF7) and earlier versions,
* this record stores a note (cell note). This feature was significantly enhanced in Excel 97.
*/
private function _readNote()
{
// echo '<b>Read Cell Annotation</b><br>';
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if ($this->_readDataOnly) {
return;
}
$cellAddress = $this->_readBIFF8CellAddress(substr($recordData, 0, 4));
if ($this->_version == self::XLS_BIFF8) {
$noteObjID = self::_GetInt2d($recordData, 6);
$noteAuthor = self::_readUnicodeStringLong(substr($recordData, 8));
$noteAuthor = $noteAuthor['value'];
// echo 'Note Address=',$cellAddress,'<br>';
// echo 'Note Object ID=',$noteObjID,'<br>';
// echo 'Note Author=',$noteAuthor,'<hr />';
//
$this->_cellNotes[$noteObjID] = array('cellRef' => $cellAddress, 'objectID' => $noteObjID, 'author' => $noteAuthor);
} else {
$extension = false;
if ($cellAddress == '$B$65536') {
// If the address row is -1 and the column is 0, (which translates as $B$65536) then this is a continuation
// note from the previous cell annotation. We're not yet handling this, so annotations longer than the
// max 2048 bytes will probably throw a wobbly.
$row = self::_GetInt2d($recordData, 0);
$extension = true;
$cellAddress = array_pop(array_keys($this->_phpSheet->getComments()));
}
// echo 'Note Address=',$cellAddress,'<br>';
$cellAddress = str_replace('$', '', $cellAddress);
$noteLength = self::_GetInt2d($recordData, 4);
$noteText = trim(substr($recordData, 6));
// echo 'Note Length=',$noteLength,'<br>';
// echo 'Note Text=',$noteText,'<br>';
if ($extension) {
// Concatenate this extension with the currently set comment for the cell
$comment = $this->_phpSheet->getComment($cellAddress);
$commentText = $comment->getText()->getPlainText();
$comment->setText($this->_parseRichText($commentText . $noteText));
} else {
// Set comment for the cell
$this->_phpSheet->getComment($cellAddress)->setText($this->_parseRichText($noteText));
}
}
}
/**
* The TEXT Object record contains the text associated with a cell annotation.
*/
private function _readTextObject()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if ($this->_readDataOnly) {
return;
}
// recordData consists of an array of subrecords looking like this:
// grbit: 2 bytes; Option Flags
// rot: 2 bytes; rotation
// cchText: 2 bytes; length of the text (in the first continue record)
// cbRuns: 2 bytes; length of the formatting (in the second continue record)
// followed by the continuation records containing the actual text and formatting
$grbitOpts = self::_GetInt2d($recordData, 0);
$rot = self::_GetInt2d($recordData, 2);
$cchText = self::_GetInt2d($recordData, 10);
$cbRuns = self::_GetInt2d($recordData, 12);
$text = $this->_getSplicedRecordData();
$this->_textObjects[$this->textObjRef] = array('text' => substr($text["recordData"], $text["spliceOffsets"][0] + 1, $cchText), 'format' => substr($text["recordData"], $text["spliceOffsets"][1], $cbRuns), 'alignment' => $grbitOpts, 'rotation' => $rot);
// echo '<b>_readTextObject()</b><br>';
// var_dump($this->_textObjects[$this->textObjRef]);
// echo '<br>';
}
/**
* Read BOF
*/
private function _readBof()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// offset: 2; size: 2; type of the following data
$substreamType = self::_GetInt2d($recordData, 2);
//.........这里部分代码省略.........