Пример #1
0
	/**
	 * Get hash code
	 *
	 * @return string	Hash code
	 */
	public function getHashCode() {
    	return md5(
    		  $this->getText()
    		. $this->_font->getHashCode()
    		. __CLASS__
    	);
    }
Пример #2
0
 /**
  * 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;
 }
Пример #3
0
 /**
  * Get hash code
  *
  * @return string	Hash code
  */
 public function getHashCode()
 {
     $hashConditionals = '';
     foreach ($this->_conditionalStyles as $conditional) {
         $hashConditionals .= $conditional->getHashCode();
     }
     return md5($this->_fill->getHashCode() . $this->_font->getHashCode() . $this->_borders->getHashCode() . $this->_alignment->getHashCode() . $this->_numberFormat->getHashCode() . $hashConditionals . $this->_protection->getHashCode() . __CLASS__);
 }
Пример #4
0
 /**
  * Get hash code
  *
  * @return string Hash code
  */
 public function getHashCode()
 {
     $hashConditionals = '';
     foreach ($this->conditionalStyles as $conditional) {
         $hashConditionals .= $conditional->getHashCode();
     }
     return md5($this->fill->getHashCode() . $this->font->getHashCode() . $this->borders->getHashCode() . $this->alignment->getHashCode() . $this->numberFormat->getHashCode() . $hashConditionals . $this->protection->getHashCode() . ($this->quotePrefix ? 't' : 'f') . __CLASS__);
 }
Пример #5
0
 /**
  * Create a new PHPExcel_Style
  *
  * @param boolean $isSupervisor
  */
 public function __construct($isSupervisor = false)
 {
     // Supervisor?
     $this->_isSupervisor = $isSupervisor;
     // Initialise values
     $this->_conditionalStyles = array();
     $this->_font = new PHPExcel_Style_Font($isSupervisor);
     $this->_fill = new PHPExcel_Style_Fill($isSupervisor);
     $this->_borders = new PHPExcel_Style_Borders($isSupervisor);
     $this->_alignment = new PHPExcel_Style_Alignment($isSupervisor);
     $this->_numberFormat = new PHPExcel_Style_NumberFormat($isSupervisor);
     $this->_protection = new PHPExcel_Style_Protection($isSupervisor);
     // bind parent if we are a supervisor
     if ($isSupervisor) {
         $this->_font->bindParent($this);
         $this->_fill->bindParent($this);
         $this->_borders->bindParent($this);
         $this->_alignment->bindParent($this);
         $this->_numberFormat->bindParent($this);
         $this->_protection->bindParent($this);
     }
 }
Пример #6
0
 private function generateadvchecklist($advlist)
 {
     //Set column dimensions
     $advlist->getColumnDimension('A')->setWidth(65);
     for ($i = 'B'; $i < 'Q'; $i++) {
         $advlist->getColumnDimension("{$i}")->setWidth(6.5);
     }
     //Set Styles for cells
     $advlist->getStyle("A1:P14")->getBorders()->getAllBorders()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
     $advlist->getStyle("A1:P14")->getFont()->setBold(true);
     $advlist->getStyle("A1:P2")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $advlist->getStyle("A1:P2")->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
     $advlist->getStyle("A1:A14")->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
     //Set background for header cells
     $advlist->getStyle("B1:P2")->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setRGB('EEEEEE');
     $advlist->getStyle("A3:A14")->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setRGB('EEEEEE');
     //Set up top row (header) cells
     $advlist->mergeCells("A1:A2");
     for ($y = 0, $fc = 'B', $lc = 'D'; $y < 5; $y++) {
         $advlist->mergeCells("{$fc}" . '1:' . "{$lc}" . '1');
         $advlist->getCell("{$fc}" . '2')->setValue("F");
         $fc++;
         $lc++;
         $advlist->getCell("{$fc}" . '2')->setValue("W");
         $fc++;
         $lc++;
         $advlist->getCell("{$fc}" . '2')->setValue("Sp");
         $fc++;
         $lc++;
     }
     //Set text for row titles (Should be hard coded)
     $advlist->getStyle("A1:A14")->getAlignment()->setWrapText(true);
     $advlist->getCell("A14")->SetValue("The student has been released on BOSS or CICS screen 7R3.");
     $advlist->getCell("A1")->setValue("Put your initials in the appropriate cell when completed");
     $advlist->getCell("A3")->SetValue("The term, year, and grade of courses already taken have been updated on the check sheet.");
     //Style needed for EVERY (9) following rich text run
     $fontstyle = new PHPExcel_Style_Font();
     $fontstyle->setName("Arial")->setSize(10)->setBold(true);
     //Cell A4 -- A lot of code to make a single word green
     $text = new PHPExcel_RichText();
     $run1 = $text->createTextRun("The term and year of current (ongoing) courses have been highlighted in ");
     $run1->setFont($fontstyle);
     $run2 = $text->createTextRun("green");
     $run2->getFont()->setColor(new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_GREEN))->setName("Arial")->setSize(10)->setBold(true);
     $run3 = $text->createTextRun(" on the check sheet.");
     $run3->setFont($fontstyle);
     $advlist->getCell("A4")->SetValue($text);
     //Cell A5 -- A lot of code to make a single word yellow
     $text = new PHPExcel_RichText();
     $run1 = $text->createTextRun("The term and year of courses scheduled for the next term are highlighted in ");
     $run1->setFont($fontstyle);
     $run2 = $text->createTextRun("yellow");
     $run2->getFont()->setColor(new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_YELLOW))->setName('Arial')->setSize(10)->setBold(true);
     $run3 = $text->createTextRun(" on the check sheet.");
     $run3->setFont($fontstyle);
     $advlist->getCell("A5")->SetValue($text);
     //Cell A6 -- A lot of code to make a single word red
     $text = new PHPExcel_RichText();
     $run1 = $text->createTextRun("Problems have been highlighted in ");
     $run1->setFont($fontstyle);
     $run2 = $text->createTextRun("red");
     $run2->getFont()->setColor(new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_RED))->setName('Arial')->setSize(10)->setBold(true);
     $run3 = $text->createTextRun(" on the check sheet and have been discussed with the student.");
     $run3->setFont($fontstyle);
     $advlist->getCell("A6")->SetValue($text);
     $advlist->getCell("A7")->SetValue("All course substitutions have been approved either in the system (BOSS/CICS) or by the Program Chair.");
     $advlist->getCell("A8")->SetValue("The student has taken all COES prerequisites (and earned a 'C' or better) for all COES courses on the advisement sheet.");
     $advlist->getCell("A9")->SetValue("The student was informed of the requirement for a minimum 2.0 GPA on all CSC courses, including all attempts.");
     $advlist->getCell("A10")->SetValue("The student was informed of the requirement for a minimum 2.0 GPA on the MATH 240 series, including all attempts.");
     $advlist->getCell("A11")->SetValue("A sanity check was done to ensure that the student doesn't get into trouble with once-a-year classes and is subsequently unduly delayed.");
     $advlist->getCell("A12")->SetValue("All deviances have been documented on a completed petition (one copy has been put in the Program Chair's box, and one copy has been sent to the Associate Dean of Undergraduate Studies).");
     $advlist->getCell("A13")->SetValue("The check sheet has been uploaded/copied to the cloud space.");
     $advlist->getCell("A14")->SetValue("The student has been released on BOSS or CICS screen 7R3.");
     //Set row heights
     //  There's an issue with excel
     //	  A row can't have autosized height, so it must be hard coded
     $advlist->getRowDimension(3)->setRowHeight(14 * 2);
     $advlist->getRowDimension(4)->setRowHeight(14 * 2);
     $advlist->getRowDimension(5)->setRowHeight(14 * 2);
     $advlist->getRowDimension(6)->setRowHeight(14 * 2);
     $advlist->getRowDimension(7)->setRowHeight(14 * 2);
     $advlist->getRowDimension(8)->setRowHeight(14 * 2);
     $advlist->getRowDimension(9)->setRowHeight(14 * 2);
     $advlist->getRowDimension(10)->setRowHeight(14 * 2);
     $advlist->getRowDimension(11)->setRowHeight(14 * 2);
     $advlist->getRowDimension(12)->setRowHeight(14 * 3);
     $advlist->getRowDimension(13)->setRowHeight(14 * 1);
     $advlist->getRowDimension(14)->setRowHeight(14 * 1);
 }
Пример #7
0
 /**
  * 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;
 }
Пример #8
0
     case 0x2:
         //	2 byte signed integer
         $value = self::_GetInt2d($this->_documentSummaryInformation, $secOffset + 4 + $offset);
         break;
     case 0x3:
         //	4 byte signed integer
         $value = self::_GetInt4d($this->_documentSummaryInformation, $secOffset + 4 + $offset);
         break;
     case 0x13:
         //	4 byte unsigned integer
         // not needed yet, fix later if necessary
         break;
     case 0x1e:
         //	null-terminated string prepended by dword string length
         $byteLength = self::_GetInt4d($this->_documentSummaryInformation, $secOffset + 4 + $offset);
         $value = substr($this->_documentSummaryInformation, $secOffset + 8 + $offset, $byteLength);
         $value = PHPExcel_Shared_String::ConvertEncoding($value, 'UTF-8', $codePage);
         $value = rtrim($value);
         break;
     case 0x40:
         //	Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
         // PHP-Time
         $value = PHPExcel_Shared_OLE::OLE2LocalDate(substr($this->_documentSummaryInformation, $secOffset + 4 + $offset, 8));
         break;
     case 0x47:
         //	Clipboard format
         // not needed yet, fix later if necessary
         break;
 }
 switch ($id) {
     case 0x1:
         //	Code Page
         $codePage = PHPExcel_Shared_CodePage::NumberToName($value);
         break;
     case 0x2:
         //	Category
         $this->_phpExcel->getProperties()->setCategory($value);
         break;
     case 0x3:
         //	Presentation Target
         //	Not supported by PHPExcel
         break;
     case 0x4:
         //	Bytes
         //	Not supported by PHPExcel
         break;
     case 0x5:
         //	Lines
         //	Not supported by PHPExcel
         break;
     case 0x6:
         //	Paragraphs
         //	Not supported by PHPExcel
         break;
     case 0x7:
         //	Slides
         //	Not supported by PHPExcel
         break;
     case 0x8:
         //	Notes
         //	Not supported by PHPExcel
         break;
     case 0x9:
         //	Hidden Slides
         //	Not supported by PHPExcel
         break;
     case 0xa:
         //	MM Clips
         //	Not supported by PHPExcel
         break;
     case 0xb:
         //	Scale Crop
         //	Not supported by PHPExcel
         break;
     case 0xc:
         //	Heading Pairs
         //	Not supported by PHPExcel
         break;
Пример #9
0
 /**
  * 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();
 }
Пример #10
0
 /**
  * Convert column width from (intrinsic) Excel units to pixels
  *
  * @param 	float	$pValue		Value in cell dimension
  * @param 	PHPExcel_Style_Font $pDefaultFont	Default font of the workbook
  * @return 	int		Value in pixels
  */
 public static function cellDimensionToPixels($pValue = 0, PHPExcel_Style_Font $pDefaultFont)
 {
     // Font name and size
     $name = $pDefaultFont->getName();
     $size = $pDefaultFont->getSize();
     if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) {
         // Exact width can be determined
         $colWidth = $pValue * PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px'] / PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width'];
     } else {
         // We don't have data for this particular font and size, use approximation by
         // extrapolating from Calibri 11
         $colWidth = $pValue * $size * PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px'] / PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width'] / 11;
     }
     // Round pixels to closest integer
     $colWidth = (int) round($colWidth);
     return $colWidth;
 }
Пример #11
0
 /**
  * Get Font
  *
  * @return PHPExcel_Style_Font
  */
 public function getFont()
 {
     if (isset($this->_font)) {
         return $this->_font;
     }
     $property = new PHPExcel_Style_Font();
     $property->propertyPrepareBind($this, "_font");
     return $property;
 }
Пример #12
0
 /**
  * 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;
 }
Пример #13
0
 /**
  * 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();
 }
Пример #14
0
 /**
  * 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();
 }
Пример #15
0
 /**
  * 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();
 }
Пример #16
0
 /**
  * Get the effective row height for rows without a row dimension or rows with height -1
  * For example, for Calibri 11 this is 15 points
  *
  * @param PHPExcel_Style_Font $font The workbooks default font
  * @return float Row height in points
  */
 public static function getDefaultRowHeightByFont(PHPExcel_Style_Font $font)
 {
     switch ($font->getName()) {
         case 'Arial':
             switch ($font->getSize()) {
                 case 10:
                     // inspection of Arial 10 workbook says 12.75pt ~17px
                     $rowHeight = 12.75;
                     break;
                 case 9:
                     // inspection of Arial 9 workbook says 12.00pt ~16px
                     $rowHeight = 12;
                     break;
                 case 8:
                     // inspection of Arial 8 workbook says 11.25pt ~15px
                     $rowHeight = 11.25;
                     break;
                 case 7:
                     // inspection of Arial 7 workbook says 9.00pt ~12px
                     $rowHeight = 9;
                     break;
                 case 6:
                 case 5:
                     // inspection of Arial 5,6 workbook says 8.25pt ~11px
                     $rowHeight = 8.25;
                     break;
                 case 4:
                     // inspection of Arial 4 workbook says 6.75pt ~9px
                     $rowHeight = 6.75;
                     break;
                 case 3:
                     // inspection of Arial 3 workbook says 6.00pt ~8px
                     $rowHeight = 6;
                     break;
                 case 2:
                 case 1:
                     // inspection of Arial 1,2 workbook says 5.25pt ~7px
                     $rowHeight = 5.25;
                     break;
                 default:
                     // use Arial 10 workbook as an approximation, extrapolation
                     $rowHeight = 12.75 * $font->getSize() / 10;
                     break;
             }
             break;
         case 'Calibri':
             switch ($font->getSize()) {
                 case 11:
                     // inspection of Calibri 11 workbook says 15.00pt ~20px
                     $rowHeight = 15;
                     break;
                 case 10:
                     // inspection of Calibri 10 workbook says 12.75pt ~17px
                     $rowHeight = 12.75;
                     break;
                 case 9:
                     // inspection of Calibri 9 workbook says 12.00pt ~16px
                     $rowHeight = 12;
                     break;
                 case 8:
                     // inspection of Calibri 8 workbook says 11.25pt ~15px
                     $rowHeight = 11.25;
                     break;
                 case 7:
                     // inspection of Calibri 7 workbook says 9.00pt ~12px
                     $rowHeight = 9;
                     break;
                 case 6:
                 case 5:
                     // inspection of Calibri 5,6 workbook says 8.25pt ~11px
                     $rowHeight = 8.25;
                     break;
                 case 4:
                     // inspection of Calibri 4 workbook says 6.75pt ~9px
                     $rowHeight = 6.75;
                     break;
                 case 3:
                     // inspection of Calibri 3 workbook says 6.00pt ~8px
                     $rowHeight = 6.0;
                     break;
                 case 2:
                 case 1:
                     // inspection of Calibri 1,2 workbook says 5.25pt ~7px
                     $rowHeight = 5.25;
                     break;
                 default:
                     // use Calibri 11 workbook as an approximation, extrapolation
                     $rowHeight = 15 * $font->getSize() / 11;
                     break;
             }
             break;
         case 'Verdana':
             switch ($font->getSize()) {
                 case 10:
                     // inspection of Verdana 10 workbook says 12.75pt ~17px
                     $rowHeight = 12.75;
                     break;
                 case 9:
                     // inspection of Verdana 9 workbook says 11.25pt ~15px
                     $rowHeight = 11.25;
                     break;
                 case 8:
                     // inspection of Verdana 8 workbook says 10.50pt ~14px
                     $rowHeight = 10.5;
                     break;
                 case 7:
                     // inspection of Verdana 7 workbook says 9.00pt ~12px
                     $rowHeight = 9.0;
                     break;
                 case 6:
                 case 5:
                     // inspection of Verdana 5,6 workbook says 8.25pt ~11px
                     $rowHeight = 8.25;
                     break;
                 case 4:
                     // inspection of Verdana 4 workbook says 6.75pt ~9px
                     $rowHeight = 6.75;
                     break;
                 case 3:
                     // inspection of Verdana 3 workbook says 6.00pt ~8px
                     $rowHeight = 6;
                     break;
                 case 2:
                 case 1:
                     // inspection of Verdana 1,2 workbook says 5.25pt ~7px
                     $rowHeight = 5.25;
                     break;
                 default:
                     // use Verdana 10 workbook as an approximation, extrapolation
                     $rowHeight = 12.75 * $font->getSize() / 10;
                     break;
             }
             break;
         default:
             // just use Calibri as an approximation
             $rowHeight = 15 * $font->getSize() / 11;
             break;
     }
     return $rowHeight;
 }
Пример #17
0
 /**
  * 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;
 }
Пример #18
-2
 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);
 }