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


PHP PHPExcel_Shared_Font类代码示例

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


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

示例1: calculateColumnWidth

 /**
  * Calculate an (approximate) OpenXML column width, based on font size and text contained
  *
  * @param 	int		$fontSize			Font size (in pixels or points)
  * @param 	bool	$fontSizeInPixels	Is the font size specified in pixels (true) or in points (false) ?
  * @param 	string	$columnText			Text to calculate width
  * @param 	int		$rotation			Rotation angle
  * @return 	int		Column width
  */
 public static function calculateColumnWidth($fontSize = 9, $fontSizeInPixels = false, $columnText = '', $rotation = 0)
 {
     if (!$fontSizeInPixels) {
         // Translate points size to pixel size
         $fontSize = PHPExcel_Shared_Font::fontSizeToPixels($fontSize);
     }
     // If it is rich text, use rich text...
     if ($columnText instanceof PHPExcel_RichText) {
         $columnText = $columnText->getPlainText();
     }
     // Only measure the part before the first newline character
     if (strpos($columnText, "\r") !== false) {
         $columnText = substr($columnText, 0, strpos($columnText, "\r"));
     }
     if (strpos($columnText, "\n") !== false) {
         $columnText = substr($columnText, 0, strpos($columnText, "\n"));
     }
     // Calculate column width
     $columnWidth = (strlen($columnText) * $fontSize + 5) / $fontSize * 256 / 256;
     // Calculate approximate rotated column width
     if ($rotation !== 0) {
         if ($rotation == -165) {
             // stacked text
             $columnWidth = 4;
             // approximation
         } else {
             // rotated text
             $columnWidth = $columnWidth * cos(deg2rad($rotation)) + $fontSize * abs(sin(deg2rad($rotation))) / 5;
             // approximation
         }
     }
     // Return
     return round($columnWidth, 6);
 }
开发者ID:nagiro,项目名称:hospici_cultural,代码行数:43,代码来源:Font.php

示例2: __construct

 public function __construct(LoggerInterface $logger, PHPExcelFactory $phpExcel)
 {
     parent::__construct($logger);
     $this->phpexcel = $phpExcel;
     $this->handle = $this->phpexcel->createPHPExcelObject();
     \PHPExcel_Shared_Font::setAutoSizeMethod(\PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT);
 }
开发者ID:rushi,项目名称:XolaReportWriterBundle,代码行数:7,代码来源:ExcelWriter.php

示例3: calculateColumnWidth

 /**
  * Calculate an (approximate) OpenXML column width, based on font size and text contained
  *
  * @param 	int		$fontSize			Font size (in pixels or points)
  * @param 	bool	$fontSizeInPixels	Is the font size specified in pixels (true) or in points (false) ?
  * @param 	string	$columnText			Text to calculate width
  * @return 	int		Column width
  */
 public static function calculateColumnWidth($fontSize = 9, $fontSizeInPixels = false, $columnText = '')
 {
     if (!$fontSizeInPixels) {
         // Translate points size to pixel size
         $fontSize = PHPExcel_Shared_Font::fontSizeToPixels($fontSize);
     }
     // If it is rich text, use rich text...
     if ($columnText instanceof PHPExcel_RichText) {
         $columnText = $columnText->getPlainText();
     }
     // Calculate column width
     return round((strlen($columnText) * $fontSize + 5) / $fontSize * 256 / 256, 6);
 }
开发者ID:laiello,项目名称:myopensources,代码行数:21,代码来源:Font.php

示例4: create_excel

 function create_excel($data = array(), $category)
 {
     $data['product_details'] = $data;
     $category_name = $this->products_model->get_category_details($category)->category_name;
     //activate worksheet number 1
     $this->excel->setActiveSheetIndex(0);
     //name the worksheet
     $this->excel->getActiveSheet()->setTitle($category_name . '-Product Catalog');
     //set cell A1 content with some text
     $this->excel->getActiveSheet()->setCellValue('A1', $category_name);
     $testArray = ['Product Name', 'Description', 'Price per Unit', 'Color'];
     PHPExcel_Shared_Font::setAutoSizeMethod(PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT);
     foreach (range('A', 'D') as $columnID) {
         $this->excel->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
     }
     $this->excel->getActiveSheet()->getStyle("A2:D2")->getFont()->setBold(true);
     //change the font size
     $this->excel->getActiveSheet()->getStyle('A1')->getFont()->setSize(20);
     //make the font become bold
     $this->excel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true);
     //merge cell A1 until D1
     $this->excel->getActiveSheet()->mergeCells('A1:D1');
     // //set aligment to center for that merged cell (A1 to D1)
     $this->excel->getActiveSheet()->getStyle('A1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $this->excel->getActiveSheet()->fromArray($testArray, NULL, 'A2');
     $product_details = array();
     foreach ($data['product_details'] as $key => $value) {
         $clean_data = array();
         foreach ($value as $k => $v) {
             if ($k == 'product_name' || $k == 'description' || $k == 'price' || $k == 'color') {
                 $clean_data[$k] = $v;
             }
         }
         $product_details[] = $clean_data;
     }
     $this->excel->getActiveSheet()->fromArray($product_details, NULL, 'A3');
     $filename = date("d-m-Y-h:i:s") . '.xls';
     //save our workbook as this file name
     header('Content-Type: application/vnd.ms-excel');
     //mime type
     header('Content-Disposition: attachment;filename="' . $filename . '"');
     //tell browser what's the file name
     header('Cache-Control: max-age=0');
     //no cache
     //save it to Excel5 format (excel 2003 .XLS file), change this to 'Excel2007' (and adjust the filename extension, also the header mime type)
     //if you want to save it as .XLSX Excel 2007 format
     $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
     //force user to download the Excel file without writing it to server's HD
     $objWriter->save('php://output');
 }
开发者ID:karsanrichard,项目名称:zerotech,代码行数:50,代码来源:export.php

示例5: calculateColumnWidth

 /**
  * Calculate an (approximate) OpenXML column width, based on font size and text contained
  *
  * @param 	int		$fontSize			Font size (in pixels or points)
  * @param 	bool	$fontSizeInPixels	Is the font size specified in pixels (true) or in points (false) ?
  * @param 	string	$columnText			Text to calculate width
  * @return 	int		Column width
  */
 public static function calculateColumnWidth($fontSize = 9, $fontSizeInPixels = false, $columnText = '')
 {
     if (!$fontSizeInPixels) {
         // Translate points size to pixel size
         $fontSize = PHPExcel_Shared_Font::fontSizeToPixels($fontSize);
     }
     // If it is rich text, use rich text...
     if ($columnText instanceof PHPExcel_RichText) {
         $columnText = $columnText->getPlainText();
     }
     // Only measure the part before the first newline character
     if (strpos($columnText, "\r") !== false) {
         $columnText = substr($columnText, 0, strpos($columnText, "\r"));
     }
     if (strpos($columnText, "\n") !== false) {
         $columnText = substr($columnText, 0, strpos($columnText, "\n"));
     }
     // Calculate column width
     return round((strlen($columnText) * $fontSize + 5) / $fontSize * 256 / 256, 6);
 }
开发者ID:eficklin,项目名称:Spreadsheet,代码行数:28,代码来源:Font.php

示例6: 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;
     } elseif ($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;
     }
     $data = pack("vvvvvCCCC", $this->font->getSize() * 20, $grbit, $icv, self::mapBold($this->font->getBold()), $sss, self::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;
 }
开发者ID:alyayazilim,项目名称:E-Ticaret-2015,代码行数:46,代码来源:Font.php

示例7: calculateColumnWidth

 /**
  * Calculate an (approximate) OpenXML column width, based on font size and text contained
  *
  * @param 	int		$fontSize			Font size (in pixels or points)
  * @param 	bool	$fontSizeInPixels	Is the font size specified in pixels (true) or in points (false) ?
  * @param 	string	$columnText			Text to calculate width
  * @param 	int		$rotation			Rotation angle
  * @return 	int		Column width
  */
 public static function calculateColumnWidth($fontSize = 9, $fontSizeInPixels = false, $columnText = '', $rotation = 0)
 {
     if (!$fontSizeInPixels) {
         // Translate points size to pixel size
         $fontSize = PHPExcel_Shared_Font::fontSizeToPixels($fontSize);
     }
     // If it is rich text, use rich text...
     if ($columnText instanceof PHPExcel_RichText) {
         $columnText = $columnText->getPlainText();
     }
     // Only measure the part before the first newline character
     if (strpos($columnText, "\r") !== false) {
         $columnText = substr($columnText, 0, strpos($columnText, "\r"));
     }
     if (strpos($columnText, "\n") !== false) {
         $columnText = substr($columnText, 0, strpos($columnText, "\n"));
     }
     // Calculate column width
     // values 1.025 and 0.584 found via interpolation by inspecting real Excel files with
     // Calibri font. May need further adjustment
     $columnWidth = 1.025 * strlen($columnText) + 0.584;
     // Excel adds some padding
     // Calculate approximate rotated column width
     if ($rotation !== 0) {
         if ($rotation == -165) {
             // stacked text
             $columnWidth = 4;
             // approximation
         } else {
             // rotated text
             $columnWidth = $columnWidth * cos(deg2rad($rotation)) + $fontSize * abs(sin(deg2rad($rotation))) / 5;
             // approximation
         }
     }
     // Return
     return round($columnWidth, 6);
 }
开发者ID:linhanwei,项目名称:TP,代码行数:46,代码来源:Font.php

示例8: range

 *
 * ----------------------------------------------------------------------
 */
$t_display = $this->getVar('t_display');
$va_display_list = $this->getVar('display_list');
$vo_result = $this->getVar('result');
$vn_items_per_page = $this->getVar('current_items_per_page');
$vs_current_sort = $this->getVar('current_sort');
$vn_ratio_pixels_to_excel_height = 0.85;
$vn_ratio_pixels_to_excel_width = 0.135;
$va_supercol_a_to_z = range('A', 'Z');
$vs_supercol = '';
$va_a_to_z = range('A', 'Z');
$workbook = new PHPExcel();
// more accurate (but slower) automatic cell size calculation
PHPExcel_Shared_Font::setAutoSizeMethod(PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT);
$o_sheet = $workbook->getActiveSheet();
// mise en forme
$columntitlestyle = array('font' => array('name' => 'Arial', 'size' => 12, 'bold' => true), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER, 'wrap' => true, 'shrinkToFit' => true), 'borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THICK)));
$cellstyle = array('font' => array('name' => 'Arial', 'size' => 11, 'bold' => false), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER, 'wrap' => true, 'shrinkToFit' => true), 'borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN)));
$o_sheet->getDefaultStyle()->applyFromArray($cellstyle);
$o_sheet->setTitle("CollectiveAccess");
$vn_line = 1;
$vs_column = reset($va_a_to_z);
// Column headers
$o_sheet->getRowDimension($vn_line)->setRowHeight(30);
foreach ($va_display_list as $vn_placement_id => $va_info) {
    if ($vs_column) {
        $o_sheet->setCellValue($vs_supercol . $vs_column . $vn_line, $va_info['display']);
        $o_sheet->getStyle($vs_supercol . $vs_column . $vn_line)->applyFromArray($columntitlestyle);
        if (!($vs_column = next($va_a_to_z))) {
开发者ID:samrahman,项目名称:providence,代码行数:31,代码来源:xlsx_results.php

示例9: close

 /**
  * Add data to the beginning of the workbook (note the reverse order)
  * and to the end of the workbook.
  *
  * @access public
  * @see PHPExcel_Writer_Excel5_Workbook::storeWorkbook()
  */
 function close()
 {
     $num_sheets = count($this->_phpSheet->getParent()->getAllSheets());
     // Write BOF record
     $this->_storeBof(0x10);
     // Write PRINTHEADERS
     $this->_writePrintHeaders();
     // Write PRINTGRIDLINES
     $this->_writePrintGridlines();
     // Write GRIDSET
     $this->_writeGridset();
     // Calculate column widths
     $this->_phpSheet->calculateColumnWidths();
     // Column dimensions
     $columnDimensions = $this->_phpSheet->getColumnDimensions();
     for ($i = 0; $i < 256; ++$i) {
         $hidden = 0;
         $level = 0;
         $xfIndex = 15;
         // there are 15 cell style Xfs
         if ($this->_phpSheet->getDefaultColumnDimension()->getWidth() >= 0) {
             $width = $this->_phpSheet->getDefaultColumnDimension()->getWidth();
         } else {
             $width = PHPExcel_Shared_Font::getDefaultColumnWidthByFont($this->_phpSheet->getParent()->getDefaultStyle()->getFont());
         }
         $columnLetter = PHPExcel_Cell::stringFromColumnIndex($i);
         if (isset($columnDimensions[$columnLetter])) {
             $columnDimension = $columnDimensions[$columnLetter];
             if ($columnDimension->getWidth() >= 0) {
                 $width = $columnDimension->getWidth();
             }
             $hidden = $columnDimension->getVisible() ? 0 : 1;
             $level = $columnDimension->getOutlineLevel();
             $xfIndex = $columnDimension->getXfIndex() + 15;
             // there are 15 cell style Xfs
         }
         // Components of _colinfo:
         // $firstcol first column on the range
         // $lastcol  last column on the range
         // $width	width to set
         // $xfIndex  The optional cell style Xf index to apply to the columns
         // $hidden   The optional hidden atribute
         // $level	The optional outline level
         $this->_colinfo[] = array($i, $i, $width, $xfIndex, $hidden, $level);
     }
     // Write GUTS
     $this->_writeGuts();
     // Write DEFAULTROWHEIGHT
     if ($this->_BIFF_version == 0x600) {
         $this->_writeDefaultRowHeight();
     }
     // Write WSBOOL
     $this->_writeWsbool();
     // Write horizontal and vertical page breaks
     $this->_writeBreaks();
     // Write page header
     $this->_writeHeader();
     // Write page footer
     $this->_writeFooter();
     // Write page horizontal centering
     $this->_writeHcenter();
     // Write page vertical centering
     $this->_writeVcenter();
     // Write left margin
     $this->_writeMarginLeft();
     // Write right margin
     $this->_writeMarginRight();
     // Write top margin
     $this->_writeMarginTop();
     // Write bottom margin
     $this->_writeMarginBottom();
     // Write page setup
     $this->_writeSetup();
     // Write sheet protection
     $this->_writeProtect();
     // Write SCENPROTECT
     $this->_writeScenProtect();
     // Write OBJECTPROTECT
     $this->_writeObjectProtect();
     // Write sheet password
     $this->_writePassword();
     // Write DEFCOLWIDTH record
     $this->_writeDefcol();
     // Write the COLINFO records if they exist
     if (!empty($this->_colinfo)) {
         $colcount = count($this->_colinfo);
         for ($i = 0; $i < $colcount; ++$i) {
             $this->_writeColinfo($this->_colinfo[$i]);
         }
     }
     // Write EXTERNCOUNT of external references
     if ($this->_BIFF_version == 0x500) {
         $this->_writeExterncount($num_sheets);
//.........这里部分代码省略.........
开发者ID:kumarsivarajan,项目名称:ctrl-dock,代码行数:101,代码来源:Worksheet.php

示例10: bearbeiterExportierenExcel

 function bearbeiterExportierenExcel(&$bearbeiterDaten)
 {
     $jahr = date('Y');
     $monat = date('m');
     $tag = date('d');
     $sheetname = 'TYPO3_Redakteure' . '_' . $jahr . '_' . $monat . '_' . $tag;
     $dateiname = $sheetname . '.xlsx';
     $spaltenTitel = array('Name', 'E-Mail', 'Seitenbereiche', 'letzter Login');
     $phpExcelService = t3lib_div::makeInstance('tx_phpexcel_service');
     $phpExcel = $phpExcelService->getPHPExcel();
     $phpExcel->getProperties()->setTitle('TYPO3_Redakteure')->setSubject('TYPO3 Redakteure');
     $phpExcel->getActiveSheet()->setTitle('TYPO3 Redakteure');
     $sheet = $phpExcel->getActiveSheet();
     PHPExcel_Shared_Font::setAutoSizeMethod(PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT);
     $spalte = 0;
     foreach ($spaltenTitel as $titelText) {
         $objRichText = $phpExcelService->getInstanceOf('PHPExcel_RichText');
         $titel = $objRichText->createTextRun($titelText);
         $titel->getFont()->setSize('12');
         $titel->getFont()->setName('Arial');
         $titel->getFont()->setBold(true);
         $zelle = chr(ord('A') + $spalte) . '1';
         $sheet->setCellValue($zelle, $objRichText);
         $sheet->getStyle($zelle)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
         $spalte++;
     }
     $zeile = 2;
     foreach ($bearbeiterDaten as $daten) {
         $sheet->setCellValueByColumnAndRow(0, $zeile, $this->cleanStringForExport($daten['name']));
         $sheet->setCellValueByColumnAndRow(1, $zeile, $this->cleanStringForExport($daten['email']));
         $sheet->setCellValueByColumnAndRow(2, $zeile, $this->cleanStringForExport($daten['seiten']));
         $sheet->setCellValueByColumnAndRow(3, $zeile, $this->cleanStringForExport($daten['lastLogin']));
         $sheet->getStyle('C' . $zeile)->getAlignment()->setWrapText(true);
         $zeile++;
     }
     $sheet->getDefaultRowDimension()->setRowHeight(-1);
     $sheet->getColumnDimension('A')->setWidth(30);
     $sheet->getColumnDimension('B')->setWidth(30);
     $sheet->getColumnDimension('C')->setWidth(80);
     header("Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
     header('Content-Type: application/vnd.ms-excel');
     header('Content-Disposition: attachment;filename="' . $dateiname . '"');
     /*
     header('Content-Disposition: attachment;filename="' . $dateiname . '"');
     header('Cache-Control: max-age=0');
     */
     $excelWriter = $phpExcelService->getInstanceOf('PHPExcel_Writer_Excel5', $phpExcel);
     $excelWriter->save('php://output');
     exit;
 }
开发者ID:mmirsch,项目名称:he_tools1,代码行数:50,代码来源:index.php

示例11: ExcelApplyValues

 private function ExcelApplyValues($sheet, $rows, $params = [])
 {
     /* Границы таблицы */
     $ramka = array('borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN)));
     /* Жирный шрифт для шапки таблицы */
     $font = array('font' => array('bold' => true), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER));
     foreach ($rows->fields as $col => $attr) {
         $sheet->setCellValueByColumnAndRow($col, 1, $attr->label);
         $sheet->getStyleByColumnAndRow($col, 1)->applyFromArray($ramka);
         $sheet->getStyleByColumnAndRow($col, 1)->applyFromArray($font);
     }
     if (count((array) $rows) > 0) {
         foreach ($rows->values as $i => $row) {
             foreach ($rows->fields as $col => $attr) {
                 if (isset($params['date']) && in_array($attr->fieldname, $params['date']) && $rows->values[$i][$attr->fieldname] !== NULL) {
                     $rows->values[$i][$attr->fieldname] = date('d.m.Y', strtotime($rows->values[$i][$attr->fieldname]));
                 }
                 if (isset($params['case']) && in_array($attr->fieldname, array_keys($params['case']))) {
                     $rows->values[$i][$attr->fieldname] = $params['case'][$attr->fieldname][$rows->values[$i][$attr->fieldname]];
                 }
                 $sheet->getStyleByColumnAndRow($col, $i + 2)->applyFromArray($ramka);
                 if (isset($params['string']) && in_array($attr->fieldname, $params['string'])) {
                     $sheet->getStyleByColumnAndRow($col, $i + 2)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
                     $sheet->setCellValueExplicitByColumnAndRow($col, $i + 2, $rows->values[$i][$attr->fieldname], PHPExcel_Cell_DataType::TYPE_STRING);
                 } else {
                     $sheet->setCellValueByColumnAndRow($col, $i + 2, $rows->values[$i][$attr->fieldname]);
                 }
             }
         }
     }
     $c = count($rows->fields);
     /* Авторазмер колонок Excel */
     PHPExcel_Shared_Font::setAutoSizeMethod(PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT);
     foreach (range(0, $c) as $col) {
         $sheet->getColumnDimensionByColumn($col)->setAutoSize(true);
         $sheet->calculateColumnWidths();
         if ($sheet->getColumnDimensionByColumn($col)->getWidth() > 70) {
             $sheet->getColumnDimensionByColumn($col)->setAutoSize(false);
             $sheet->getColumnDimensionByColumn($col)->setWidth(70);
         }
     }
 }
开发者ID:vovancho,项目名称:baseportal,代码行数:42,代码来源:FregatController.php

示例12: nitro_render_pdf


//.........这里部分代码省略.........
		' . $tab_notes_feedback . '
	</table>';
                $mpdf->WriteHTML($tab_notes);
                if ($generate_html_file) {
                    $html_contents .= $tab_notes . '<hr noshade>';
                }
            }
            // $quiz_count if grades = 0
            if ($GENERATE_EXCEL) {
                $SheetCount = $objPHPExcel->getSheetCount();
                $objPHPExcel->createSheet(NULL, $SheetCount);
                $objPHPExcel->setActiveSheetIndex($SheetCount);
                $objPHPExcel->getActiveSheet()->setTitle(get_string('evaluation', 'quiz_nitroreportpdf'));
                $objPHPExcel->getActiveSheet()->setCellValue('A1', get_string('evaluation', 'quiz_nitroreportpdf'))->setCellValue('A2', get_string('percents', 'quiz_nitroreportpdf'))->setCellValue('C2', get_string('points', 'quiz_nitroreportpdf'))->setCellValue('A3', get_string('from', 'quiz_nitroreportpdf'))->setCellValue('B3', get_string('to', 'quiz_nitroreportpdf'))->setCellValue('C3', get_string('from', 'quiz_nitroreportpdf'))->setCellValue('D3', get_string('to', 'quiz_nitroreportpdf'))->setCellValue('E2', get_string('grade', 'quiz_nitroreportpdf'));
                $objPHPExcel->getActiveSheet()->mergeCells('A1:E1')->mergeCells('A2:B2')->mergeCells('C2:D2')->mergeCells('E2:E3');
                $objPHPExcel->getActiveSheet()->getStyle('A1:E3')->getFont()->setBold(true);
                for ($i = 0; $i < count($tab_notes2); $i++) {
                    $objPHPExcel->getActiveSheet()->setCellValue('A' . (4 + $i), $tab_notes2[$i]['mingrade_precent'])->setCellValue('B' . (4 + $i), $tab_notes2[$i]['maxgrade_precent'])->setCellValue('C' . (4 + $i), $tab_notes2[$i]['mingrade_points'])->setCellValue('D' . (4 + $i), $tab_notes2[$i]['maxgrade_points'])->setCellValue('E' . (4 + $i), strip_tags($tab_notes2[$i]['feedback']));
                    if ($i % 2 == 1) {
                        $objPHPExcel->getActiveSheet()->getStyle('A' . (4 + $i) . ':E' . (4 + $i))->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
                        $objPHPExcel->getActiveSheet()->getStyle('A' . (4 + $i) . ':E' . (4 + $i))->getFill()->getStartColor()->setRGB('FFFFA1');
                    }
                    $objPHPExcel->getActiveSheet()->getRowDimension(4 + $i)->setRowHeight(19.83);
                }
                $objPHPExcel->getActiveSheet()->getStyle('A1:E' . (4 + $i))->getFont()->setSize(14);
                $objPHPExcel->getActiveSheet()->getStyle('A1:E' . (4 + $i))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
                $objPHPExcel->getActiveSheet()->getStyle('E2')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
                $objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(19.83);
                $objPHPExcel->getActiveSheet()->getRowDimension(2)->setRowHeight(19.83);
                $objPHPExcel->getActiveSheet()->getRowDimension(3)->setRowHeight(19.83);
                $objPHPExcel->getActiveSheet()->getStyle('A1:E3')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
                $objPHPExcel->getActiveSheet()->getStyle('A1:E3')->getFill()->getStartColor()->setRGB('0057AF');
                $objPHPExcel->getActiveSheet()->getStyle('A1:E3')->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_WHITE);
                PHPExcel_Shared_Font::setAutoSizeMethod(PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT);
                $objPHPExcel->getActiveSheet()->getStyle('A1:E' . (4 + $i))->getAlignment()->setWrapText(false);
                $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(-1);
                $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(-1);
                $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(-1);
                $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(-1);
                $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(-1);
                $styleArray = array('borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN, 'color' => array('rgb' => '000000'))));
                $objPHPExcel->getActiveSheet()->getStyle('A1:E8')->applyFromArray($styleArray);
                $objPHPExcel->getActiveSheet()->getProtection()->setPassword(substr(hash('sha512', rand()), 0, 12));
                $objPHPExcel->getActiveSheet()->getProtection()->setSheet(true);
                $objPHPExcel->getActiveSheet()->getProtection()->setFormatCells(true);
                $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&D, &T &R &P / &N');
            }
            /*	6. Quiz filled by exams		*/
            $this->SetBarWidth(number_format(floor(6 * (100 / $PROGRESSBAR_PARTS)), 2, '.', ''));
            @ob_flush();
            @flush();
            $mpdf->AddPage();
            $mpdf->Bookmark('6. ' . get_string('exam_tests', 'quiz_nitroreportpdf'), 0);
            $NREQ = '<p style="text-align: center;font-weight: bold;font-size:14pt;text-transform:uppercase;">' . get_string('exam_tests', 'quiz_nitroreportpdf') . '</p><p></p>';
            $mpdf->WriteHTML($NREQ);
            if ($generate_html_file) {
                $html_contents .= $NREQ;
            }
            $tab_users = array();
            /*	5. Get users who filled exam		*/
            $quiz_users = $DB->get_records_sql('SELECT DISTINCT(qa.userid) AS userid  FROM {quiz_attempts} qa,{user} u WHERE qa.quiz="' . $quizid . '" AND userid=u.id AND qa.state="finished" ORDER BY u.lastname ASC, u.firstname ASC, u.username ASC');
            if (count($quiz_users) == 0) {
                $progress_user = number_format(floor(7 * (100 / $PROGRESSBAR_PARTS)), 2, '.', '');
            } else {
                $progress_user = number_format(floor(7 * (100 / $PROGRESSBAR_PARTS) / count($quiz_users)), 2, '.', '');
            }
开发者ID:nitro2010,项目名称:nitro_moodle_plugins,代码行数:67,代码来源:report.php

示例13: exportTerminPlan

 public function exportTerminPlan(&$terminKalender)
 {
     $dateiname = 'termine_gesundheitstag.xls';
     $phpExcelService = t3lib_div::makeInstance('tx_phpexcel_service');
     $phpExcel = $phpExcelService->getPHPExcel();
     $title = 'Anmeldungen - Gesundheitstag 2015';
     $phpExcel->getProperties()->setTitle($title)->setSubject($title);
     PHPExcel_Shared_Font::setAutoSizeMethod(PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT);
     // das erste worksheet anwaehlen
     $sheet = $phpExcel->getActiveSheet();
     $sheet->setTitle('Anmeldungen2015');
     $zeile = 1;
     foreach ($terminKalender as $veranstaltungsDaten) {
         $titelEintrag = $veranstaltungsDaten['title'] . ' - (Raum ' . $veranstaltungsDaten['raum'] . ')';
         $objRichText = new PHPExcel_RichText();
         $cellTitle = $objRichText->createTextRun($titelEintrag);
         $cellTitle->getFont()->setSize('14');
         $cellTitle->getFont()->setName('Arial');
         $sheet->setCellValueByColumnAndRow(0, $zeile, $objRichText);
         $zelle = 'A' . $zeile;
         $zellRaum = 'A' . $zeile . ':B' . $zeile;
         $sheet->mergeCells($zellRaum);
         $sheet->getStyle($zelle)->getAlignment()->setWrapText(true);
         $sheet->getRowDimension($zeile)->setRowHeight(40);
         $zeile++;
         $objRichText = new PHPExcel_RichText();
         $cellTitle = $objRichText->createTextRun('Uhrzeit');
         $cellTitle->getFont()->setSize('12');
         $cellTitle->getFont()->setName('Arial');
         $sheet->setCellValueByColumnAndRow(0, $zeile, $objRichText);
         $zelle = 'A' . $zeile;
         $sheet->getStyle($zelle)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
         $sheet->getStyle($zelle)->getAlignment()->setWrapText(true);
         $objRichText = new PHPExcel_RichText();
         $cellTitle = $objRichText->createTextRun('Person');
         $cellTitle->getFont()->setSize('12');
         $cellTitle->getFont()->setName('Arial');
         $sheet->setCellValueByColumnAndRow(1, $zeile, $objRichText);
         $zelle = 'B' . $zeile;
         $sheet->getStyle($zelle)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
         $zelle = 'A' . $zeile;
         $sheet->getStyle($zelle)->getAlignment()->setWrapText(true);
         $sheet->getRowDimension($zeile)->setRowHeight(40);
         $zeile++;
         foreach ($veranstaltungsDaten['belegung'] as $terminDaten) {
             $sheet->setCellValueByColumnAndRow(0, $zeile, $terminDaten['zeit']);
             $zelle = 'A' . $zeile;
             $sheet->getStyle($zelle)->getAlignment()->setWrapText(true);
             $zelle = 'B' . $zeile;
             $sheet->setCellValueByColumnAndRow(1, $zeile, $terminDaten['user']);
             $sheet->getStyle($zelle)->getAlignment()->setWrapText(true);
             $zeile++;
         }
     }
     $sheet->getColumnDimension('A')->setWidth(15);
     $sheet->getColumnDimension('B')->setWidth(80);
     header('Content-Type: application/vnd.ms-excel');
     header('Content-Disposition: attachment;filename="' . $dateiname . '"');
     header('Cache-Control: max-age=0');
     $excelWriter = $phpExcelService->getInstanceOf('PHPExcel_Writer_Excel2007', $phpExcel);
     $excelWriter->save('php://output');
     exit;
 }
开发者ID:mmirsch,项目名称:he_tools1,代码行数:63,代码来源:class.tx_he_tools_veranstaltungs_buchung.php

示例14: datenExportierenMentees

 protected function datenExportierenMentees($monat = 1, $jahr = 2013)
 {
     $startTstamp = mktime(0, 0, 0, $monat, 1, $jahr);
     $felder = array();
     $seite = PID_MENTEES;
     $exportListe = $this->exportFelder['MENTEES'];
     $where = 'deleted=0 AND hidden=0 AND pid=' . $seite . ' AND tstamp>=' . $startTstamp;
     $where = 'deleted=0 AND hidden=0 AND pid=' . $seite;
     $abfrageFelder = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'tx_powermail_mails', $where, '', 'uid');
     $eintraege = array();
     while ($daten = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($abfrageFelder)) {
         $eintraege[] = $daten[uid];
         foreach ($exportListe as $feldId => $feldTitel) {
             $wert = $this->gibFormularFeldwert($daten[uid], $feldId, 'AAA');
             $zeile[] = '"' . iconv('UTF-8', 'CP1252', $wert) . '"';
         }
     }
     if (count($eintraege) == 0) {
         return '<br/><div style="padding-left: 20px;"><span class="error">Momentan sind keine Anmeldungen für Mentees vorhanden!</span></div><br />';
     }
     $exportTitle = 'Anmeldungen Mentees';
     $workbook = t3lib_div::makeInstance('PHPExcel');
     $workbook->getProperties()->setTitle($exportTitle)->setSubject($exportTitle);
     PHPExcel_Shared_Font::setAutoSizeMethod(PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT);
     $sheet = $workbook->getActiveSheet();
     $sheet->setTitle('Anmeldungen Mentees');
     $spalte = 0;
     $anzSpalten = count($exportListe);
     foreach ($exportListe as $feldId => $feldTitel) {
         $feldTitel = trim(str_replace(':', '', $feldTitel));
         $sheet->setCellValueByColumnAndRow($spalte, 1, $feldTitel);
         $spalte++;
     }
     for ($zeile = 0; $zeile < count($eintraege); $zeile++) {
         $spalte = 0;
         foreach ($exportListe as $feldId => $feldTitel) {
             $wert = $this->gibFormularFeldwert($eintraege[$zeile], $feldId);
             $sheet->setCellValueByColumnAndRow($spalte, $zeile + 2, $wert);
             $spalte++;
         }
     }
     for ($spalte = 0; $spalte < $anzSpalten; $spalte++) {
         $sheet->getColumnDimension(chr(ord('A') + $spalte))->setAutoSize(true);
         //			$sheet->getColumnDimension(chr(ord('A')+ $spalte))->setWidth(50);
     }
     $dateiname = 'anmeldedaten_export_mentees.xls';
     header('Content-Type: application/vnd.ms-excel');
     header('Content-Disposition: attachment;filename="' . $dateiname . '"');
     header('Cache-Control: max-age=0');
     $objWriter = PHPExcel_IOFactory::createWriter($workbook, 'Excel5');
     $objWriter->save('php://output');
     exit;
 }
开发者ID:mmirsch,项目名称:he_tools1,代码行数:53,代码来源:class.tx_he_tools_powermail.php

示例15: buildCSS


//.........这里部分代码省略.........
         $css['table']['page-break-after'] = 'always';
     }
     // .gridlines td { }
     $css['.gridlines td']['border'] = '1px dotted black';
     // .b {}
     $css['.b']['text-align'] = 'center';
     // BOOL
     // .e {}
     $css['.e']['text-align'] = 'center';
     // ERROR
     // .f {}
     $css['.f']['text-align'] = 'right';
     // FORMULA
     // .inlineStr {}
     $css['.inlineStr']['text-align'] = 'left';
     // INLINE
     // .n {}
     $css['.n']['text-align'] = 'right';
     // NUMERIC
     // .s {}
     $css['.s']['text-align'] = 'left';
     // STRING
     // Calculate cell style hashes
     foreach ($this->_phpExcel->getCellXfCollection() as $index => $style) {
         $css['td.style' . $index] = $this->_createCSSStyle($style);
     }
     // Fetch sheets
     $sheets = array();
     if (is_null($this->_sheetIndex)) {
         $sheets = $this->_phpExcel->getAllSheets();
     } else {
         $sheets[] = $this->_phpExcel->getSheet($this->_sheetIndex);
     }
     // Build styles per sheet
     foreach ($sheets as $sheet) {
         // Calculate hash code
         $sheetIndex = $sheet->getParent()->getIndex($sheet);
         // Build styles
         // Calculate column widths
         $sheet->calculateColumnWidths();
         // col elements, initialize
         $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($sheet->getHighestColumn()) - 1;
         $column = -1;
         while ($column++ < $highestColumnIndex) {
             $this->_columnWidths[$sheetIndex][$column] = 42;
             // approximation
             $css['table.sheet' . $sheetIndex . ' col.col' . $column]['width'] = '42pt';
         }
         // col elements, loop through columnDimensions and set width
         foreach ($sheet->getColumnDimensions() as $columnDimension) {
             if (($width = PHPExcel_Shared_Drawing::cellDimensionToPixels($columnDimension->getWidth(), $this->_defaultFont)) >= 0) {
                 $width = PHPExcel_Shared_Drawing::pixelsToPoints($width);
                 $column = PHPExcel_Cell::columnIndexFromString($columnDimension->getColumnIndex()) - 1;
                 $this->_columnWidths[$sheetIndex][$column] = $width;
                 $css['table.sheet' . $sheetIndex . ' col.col' . $column]['width'] = $width . 'pt';
                 if ($columnDimension->getVisible() === false) {
                     $css['table.sheet' . $sheetIndex . ' col.col' . $column]['visibility'] = 'collapse';
                     $css['table.sheet' . $sheetIndex . ' col.col' . $column]['*display'] = 'none';
                     // target IE6+7
                 }
             }
         }
         // Default row height
         $rowDimension = $sheet->getDefaultRowDimension();
         // table.sheetN tr { }
         $css['table.sheet' . $sheetIndex . ' tr'] = array();
         if ($rowDimension->getRowHeight() == -1) {
             $pt_height = PHPExcel_Shared_Font::getDefaultRowHeightByFont($this->_phpExcel->getDefaultStyle()->getFont());
         } else {
             $pt_height = $rowDimension->getRowHeight();
         }
         $css['table.sheet' . $sheetIndex . ' tr']['height'] = $pt_height . 'pt';
         if ($rowDimension->getVisible() === false) {
             $css['table.sheet' . $sheetIndex . ' tr']['display'] = 'none';
             $css['table.sheet' . $sheetIndex . ' tr']['visibility'] = 'hidden';
         }
         // Calculate row heights
         foreach ($sheet->getRowDimensions() as $rowDimension) {
             $row = $rowDimension->getRowIndex() - 1;
             // table.sheetN tr.rowYYYYYY { }
             $css['table.sheet' . $sheetIndex . ' tr.row' . $row] = array();
             if ($rowDimension->getRowHeight() == -1) {
                 $pt_height = PHPExcel_Shared_Font::getDefaultRowHeightByFont($this->_phpExcel->getDefaultStyle()->getFont());
             } else {
                 $pt_height = $rowDimension->getRowHeight();
             }
             $css['table.sheet' . $sheetIndex . ' tr.row' . $row]['height'] = $pt_height . 'pt';
             if ($rowDimension->getVisible() === false) {
                 $css['table.sheet' . $sheetIndex . ' tr.row' . $row]['display'] = 'none';
                 $css['table.sheet' . $sheetIndex . ' tr.row' . $row]['visibility'] = 'hidden';
             }
         }
     }
     // Cache
     if (is_null($this->_cssStyles)) {
         $this->_cssStyles = $css;
     }
     // Return
     return $css;
 }
开发者ID:adit-gudhel,项目名称:simpus-dev,代码行数:101,代码来源:HTML.php


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