本文整理汇总了PHP中PHPExcel_Style_Font::getColor方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Style_Font::getColor方法的具体用法?PHP PHPExcel_Style_Font::getColor怎么用?PHP PHPExcel_Style_Font::getColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel_Style_Font
的用法示例。
在下文中一共展示了PHPExcel_Style_Font::getColor方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _writeFont
/**
* Write Font
*
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
* @param PHPExcel_Style_Font $pFont Font style
* @throws Exception
*/
private function _writeFont(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_Font $pFont = null)
{
// font
$objWriter->startElement('font');
// Name
$objWriter->startElement('name');
$objWriter->writeAttribute('val', $pFont->getName());
$objWriter->endElement();
// Size
$objWriter->startElement('sz');
$objWriter->writeAttribute('val', $pFont->getSize());
$objWriter->endElement();
// Bold. We explicitly write this element also when false (like MS Office Excel 2007 does
// for conditional formatting). Otherwise it will apparently not be picked up in conditional
// formatting style dialog
$objWriter->startElement('b');
$objWriter->writeAttribute('val', $pFont->getBold() ? '1' : '0');
$objWriter->endElement();
// Italic
$objWriter->startElement('i');
$objWriter->writeAttribute('val', $pFont->getItalic() ? '1' : '0');
$objWriter->endElement();
// Superscript / subscript
if ($pFont->getSuperScript() || $pFont->getSubScript()) {
$objWriter->startElement('vertAlign');
if ($pFont->getSuperScript()) {
$objWriter->writeAttribute('val', 'superscript');
} else {
if ($pFont->getSubScript()) {
$objWriter->writeAttribute('val', 'subscript');
}
}
$objWriter->endElement();
}
// Underline
$objWriter->startElement('u');
$objWriter->writeAttribute('val', $pFont->getUnderline());
$objWriter->endElement();
// Strikethrough
$objWriter->startElement('strike');
$objWriter->writeAttribute('val', $pFont->getStrikethrough() ? '1' : '0');
$objWriter->endElement();
// Foreground color
$objWriter->startElement('color');
$objWriter->writeAttribute('rgb', $pFont->getColor()->getARGB());
$objWriter->endElement();
$objWriter->endElement();
}
示例2: _createCSSStyleFont
/**
* Create CSS style (PHPExcel_Style_Font)
*
* @param PHPExcel_Style_Font $pStyle PHPExcel_Style_Font
* @return array
*/
private function _createCSSStyleFont(PHPExcel_Style_Font $pStyle)
{
// Construct CSS
$css = array();
// Create CSS
if ($pStyle->getBold()) {
$css['font-weight'] = 'bold';
}
if ($pStyle->getUnderline() != PHPExcel_Style_Font::UNDERLINE_NONE && $pStyle->getStrikethrough()) {
$css['text-decoration'] = 'underline line-through';
} else {
if ($pStyle->getUnderline() != PHPExcel_Style_Font::UNDERLINE_NONE) {
$css['text-decoration'] = 'underline';
} else {
if ($pStyle->getStrikethrough()) {
$css['text-decoration'] = 'line-through';
}
}
}
if ($pStyle->getItalic()) {
$css['font-style'] = 'italic';
}
$css['color'] = '#' . $pStyle->getColor()->getRGB();
$css['font-family'] = '\'' . $pStyle->getName() . '\'';
$css['font-size'] = $pStyle->getSize() . 'pt';
// Return
return $css;
}
示例3: addFont
/**
* Add a font to added fonts
*
* @param PHPExcel_Style_Font $font
* @return int Index to FONT record
*/
public function addFont(PHPExcel_Style_Font $font)
{
$fontHashCode = $font->getHashCode();
if (isset($this->addedFonts[$fontHashCode])) {
$fontIndex = $this->addedFonts[$fontHashCode];
} else {
$countFonts = count($this->fontWriters);
$fontIndex = $countFonts < 4 ? $countFonts : $countFonts + 1;
$fontWriter = new PHPExcel_Writer_Excel5_Font($font);
$fontWriter->setColorIndex($this->addColor($font->getColor()->getRGB()));
$this->fontWriters[] = $fontWriter;
$this->addedFonts[$fontHashCode] = $fontIndex;
}
return $fontIndex;
}
示例4: _writeFont
/**
* Write Font
*
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
* @param PHPExcel_Style_Font $pFont Font style
* @throws Exception
*/
private function _writeFont(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_Font $pFont = null)
{
// font
$objWriter->startElement('font');
// Name
$objWriter->startElement('name');
$objWriter->writeAttribute('val', $pFont->getName());
$objWriter->endElement();
// Size
$objWriter->startElement('sz');
$objWriter->writeAttribute('val', $pFont->getSize());
$objWriter->endElement();
// Bold
if ($pFont->getBold()) {
$objWriter->startElement('b');
$objWriter->writeAttribute('val', 'true');
$objWriter->endElement();
}
// Italic
if ($pFont->getItalic()) {
$objWriter->startElement('i');
$objWriter->writeAttribute('val', 'true');
$objWriter->endElement();
}
// Superscript / subscript
if ($pFont->getSuperScript() || $pFont->getSubScript()) {
$objWriter->startElement('vertAlign');
if ($pFont->getSuperScript()) {
$objWriter->writeAttribute('val', 'superscript');
} else {
if ($pFont->getSubScript()) {
$objWriter->writeAttribute('val', 'subscript');
}
}
$objWriter->endElement();
}
// Underline
$objWriter->startElement('u');
$objWriter->writeAttribute('val', $pFont->getUnderline());
$objWriter->endElement();
// Striketrough
if ($pFont->getStriketrough()) {
$objWriter->startElement('strike');
$objWriter->writeAttribute('val', 'true');
$objWriter->endElement();
}
// Foreground color
$objWriter->startElement('color');
$objWriter->writeAttribute('rgb', $pFont->getColor()->getARGB());
$objWriter->endElement();
$objWriter->endElement();
}
示例5: _writeFont
/**
* Write Font
*
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
* @param PHPExcel_Style_Font $pFont Font style
* @throws PHPExcel_Writer_Exception
*/
private function _writeFont(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_Font $pFont = null)
{
// font
$objWriter->startElement('font');
// Weird! The order of these elements actually makes a difference when opening Excel2007
// files in Excel2003 with the compatibility pack. It's not documented behaviour,
// and makes for a real WTF!
// Bold. We explicitly write this element also when false (like MS Office Excel 2007 does
// for conditional formatting). Otherwise it will apparently not be picked up in conditional
// formatting style dialog
if ($pFont->getBold() !== NULL) {
$objWriter->startElement('b');
$objWriter->writeAttribute('val', $pFont->getBold() ? '1' : '0');
$objWriter->endElement();
}
// Italic
if ($pFont->getItalic() !== NULL) {
$objWriter->startElement('i');
$objWriter->writeAttribute('val', $pFont->getItalic() ? '1' : '0');
$objWriter->endElement();
}
// Strikethrough
if ($pFont->getStrikethrough() !== NULL) {
$objWriter->startElement('strike');
$objWriter->writeAttribute('val', $pFont->getStrikethrough() ? '1' : '0');
$objWriter->endElement();
}
// Underline
if ($pFont->getUnderline() !== NULL) {
$objWriter->startElement('u');
$objWriter->writeAttribute('val', $pFont->getUnderline());
$objWriter->endElement();
}
// Superscript / subscript
if ($pFont->getSuperScript() === TRUE || $pFont->getSubScript() === TRUE) {
$objWriter->startElement('vertAlign');
if ($pFont->getSuperScript() === TRUE) {
$objWriter->writeAttribute('val', 'superscript');
} else {
if ($pFont->getSubScript() === TRUE) {
$objWriter->writeAttribute('val', 'subscript');
}
}
$objWriter->endElement();
}
// Size
if ($pFont->getSize() !== NULL) {
$objWriter->startElement('sz');
$objWriter->writeAttribute('val', $pFont->getSize());
$objWriter->endElement();
}
// Foreground color
if ($pFont->getColor()->getARGB() !== NULL) {
$objWriter->startElement('color');
$objWriter->writeAttribute('rgb', $pFont->getColor()->getARGB());
$objWriter->endElement();
}
// Name
if ($pFont->getName() !== NULL) {
$objWriter->startElement('name');
$objWriter->writeAttribute('val', $pFont->getName());
$objWriter->endElement();
}
$objWriter->endElement();
}
示例6: _createCSSStyleFont
/**
* Create CSS style (PHPExcel_Style_Font)
*
* @param PHPExcel_Style_Font $pStyle PHPExcel_Style_Font
* @return string
*/
private function _createCSSStyleFont(PHPExcel_Style_Font $pStyle)
{
// Construct HTML
$html = '';
// Create CSS
if ($pStyle->getBold()) {
$html .= ' font-weight: bold;' . "\r\n";
}
if ($pStyle->getUnderline() != PHPExcel_Style_Font::UNDERLINE_NONE && $pStyle->getStriketrough()) {
$html .= ' text-decoration: underline line-through;' . "\r\n";
} else {
if ($pStyle->getUnderline() != PHPExcel_Style_Font::UNDERLINE_NONE) {
$html .= ' text-decoration: underline;' . "\r\n";
} else {
if ($pStyle->getStriketrough()) {
$html .= ' text-decoration: line-through;' . "\r\n";
}
}
}
if ($pStyle->getItalic()) {
$html .= ' font-style: italic;' . "\r\n";
}
$html .= ' color: ' . '#' . $pStyle->getColor()->getRGB() . ';' . "\r\n";
$html .= ' font-family: ' . $pStyle->getName() . ';' . "\r\n";
$html .= ' font-size: ' . $pStyle->getSize() . 'pt;' . "\r\n";
// Return
return $html;
}
示例7: _writeFont
/**
* Write Font
*
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
* @param PHPExcel_Style_Font $pFont Font style
* @throws Exception
*/
private function _writeFont(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_Font $pFont = null)
{
// font
$objWriter->startElement('font');
// Name
$objWriter->startElement('name');
$objWriter->writeAttribute('val', $pFont->getName());
$objWriter->endElement();
// Size
$objWriter->startElement('sz');
$objWriter->writeAttribute('val', $pFont->getSize());
$objWriter->endElement();
// Bold
$objWriter->startElement('b');
$objWriter->writeAttribute('val', $pFont->getBold() ? 'true' : 'false');
$objWriter->endElement();
// Italic
$objWriter->startElement('i');
$objWriter->writeAttribute('val', $pFont->getItalic() ? 'true' : 'false');
$objWriter->endElement();
// Underline
$objWriter->startElement('u');
$objWriter->writeAttribute('val', $pFont->getUnderline());
$objWriter->endElement();
// Striketrough
$objWriter->startElement('strike');
$objWriter->writeAttribute('val', $pFont->getStriketrough() ? 'true' : 'false');
$objWriter->endElement();
// Foreground color
$objWriter->startElement('color');
$objWriter->writeAttribute('rgb', $pFont->getColor()->getARGB());
$objWriter->endElement();
$objWriter->endElement();
}