本文整理汇总了PHP中PHPExcel_Worksheet::setSharedStyle方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Worksheet::setSharedStyle方法的具体用法?PHP PHPExcel_Worksheet::setSharedStyle怎么用?PHP PHPExcel_Worksheet::setSharedStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel_Worksheet
的用法示例。
在下文中一共展示了PHPExcel_Worksheet::setSharedStyle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _signupSheet
protected function _signupSheet($event, $includeEndingTerms, $includeNotEndingTerms)
{
$sheet = new PHPExcel_Worksheet($this->_excelDoc, 'Signup Sheet for Workshop ' . $event['workshopTitle']);
// Set up the margins so the header doesn't bleed into the page
$sheet->getPageMargins()->setTop(1.5);
// Make a three column page layout
$sheet->getColumnDimension('A')->setWidth(16);
$sheet->getColumnDimension('B')->setWidth(16);
$sheet->getColumnDimension('C')->setWidth(45);
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/config.xml', 'production');
$date = new DateTime($event['date']);
$startTime = new DateTime($event['startTime']);
$endTime = new DateTime($event['endTime']);
// Set the header on odd pages.
// The code formatting is off because the header doesn't ignore spaces.
/*
* Format:
* Title
* Room name
* date('D, M d, Y') (startTime('g:i A') - endTime('g:i A'))
* Instructors
*
*/
$sheet->getHeaderFooter()->setOddHeader('&C&B&14' . $event['workshopTitle'] . '&14&B&12 ' . chr(10) . $event['location'] . chr(10) . $date->format('l, M d, Y') . '(' . $startTime->format('g:i A') . ' - ' . $endTime->format('g:i A') . ')' . chr(10) . 'Instructor: ' . implode(',', $event['instructors']) . '&12&C');
// Write Column Headers for the table
$sheet->setCellValue('A1', 'First Name');
$sheet->setCellValue('B1', 'Last Name');
$sheet->setCellValue('C1', 'Signature');
// reformat it a little bit in a simpler way for us to use it in our
// spreadsheet printin' loop
$rows = array();
foreach ($event['attendeeList'] as $a) {
$rows[] = array($a['firstName'], $a['lastName']);
}
$signin = new PHPExcel_Style();
$signin->applyFromArray(array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN))));
$rowCounter = 3;
foreach ($rows as $row) {
$row = array_values($row);
// put the totals in the row
$char = self::A;
foreach ($row as $cell) {
$sheet->setCellValue(chr($char) . $rowCounter, $cell);
$char++;
}
$rowCounter++;
}
$tableHeaderStyle = new PHPExcel_Style();
$tableHeaderStyle->applyFromArray($this->_tableHeaderStyleArray);
$tableBodyStyle = new PHPExcel_Style();
$tableBodyStyle->applyFromArray($this->_contentStyleArray);
$sheet->setSharedStyle($tableHeaderStyle, 'A1:C1');
$sheet->setSharedStyle($tableBodyStyle, 'A3:B' . ($rowCounter - 1));
$sheet->setSharedStyle($signin, 'C3:C' . ($rowCounter - 1));
return $sheet;
}
示例2: _addTableFooter
/**
*
* @param DOMElement $table
* @return boolean
*/
protected function _addTableFooter($table)
{
$tfoot = $table->getElementsByTagName('tfoot');
if (empty($tfoot->length)) {
return false;
}
$tfoot = $tfoot->item(0);
$rows = $tfoot->getElementsByTagName('tr');
$rowStarted = $this->_currentRow;
foreach ($rows as $row) {
$this->_currentCell = $this->_startCol;
$cells = $row->getElementsByTagName('th');
// Insert each row cell
foreach ($cells as $cell) {
$this->_addCell($cell);
}
$this->_currentRow++;
}
$range = array(PHPExcel_Cell::stringFromColumnIndex($this->_startCol) . $rowStarted, PHPExcel_Cell::stringFromColumnIndex($this->_currentCell - 1) . ($this->_currentRow - 1));
$range = implode(':', $range);
$this->_mainSheet->setSharedStyle($this->_styles['table_footer'], $range);
}
示例3: render
/**
* Inserts data into worksheet and returns it
*
* @return PHPExcel_Worksheet
*/
public function render()
{
// Set worksheet header
$this->_set_row(1, $this->columns, TRUE);
//set header style
$obj_style = new PHPExcel_Style();
$style = Kohana::$config->load('phpexcel.header');
$obj_style->applyFromArray($style);
$column_dim = PHPExcel_Cell::stringFromColumnIndex(count($this->columns) - 1);
$this->_worksheet->setSharedStyle($obj_style, 'A1:' . $column_dim . '1');
// Set data
$rows = 0;
foreach ($this->data as $row => $data) {
$this->_set_row($row + 2, $data);
$rows++;
}
// Set column styles and width
$column = 0;
foreach (array_keys($this->columns) as $key) {
$column_dim = PHPExcel_Cell::stringFromColumnIndex($column);
$format = Arr::get($this->formats, $key);
if ($format !== NULL) {
$this->_worksheet->getStyle($column_dim . 2 . ':' . $column_dim . (2 + $rows))->getNumberFormat()->setFormatCode($format);
}
if ($this->auto_size === TRUE) {
$this->_worksheet->getColumnDimension($column_dim)->setAutoSize(TRUE);
}
$column++;
}
return $this->_worksheet;
}