本文整理汇总了PHP中PHPExcel_Worksheet::getPageMargins方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Worksheet::getPageMargins方法的具体用法?PHP PHPExcel_Worksheet::getPageMargins怎么用?PHP PHPExcel_Worksheet::getPageMargins使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel_Worksheet
的用法示例。
在下文中一共展示了PHPExcel_Worksheet::getPageMargins方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: _writeMarginBottom
/**
* Store the BOTTOMMARGIN BIFF record.
*/
private function _writeMarginBottom()
{
$record = 0x29;
// Record identifier
$length = 0x8;
// Bytes to follow
$margin = $this->_phpSheet->getPageMargins()->getBottom();
// Margin in inches
$header = pack("vv", $record, $length);
$data = pack("d", $margin);
if (self::getByteOrder()) {
// if it's Big Endian
$data = strrev($data);
}
$this->_append($header . $data);
}
示例3: _setMargins
private function _setMargins(PHPExcel_Worksheet $pSheet)
{
$htmlPage = '@page { ';
$htmlBody = 'body { ';
$left = PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getLeft()) . 'in; ';
$htmlPage .= 'left-margin: ' . $left;
$htmlBody .= 'left-margin: ' . $left;
$right = PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getRight()) . 'in; ';
$htmlPage .= 'right-margin: ' . $right;
$htmlBody .= 'right-margin: ' . $right;
$top = PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getTop()) . 'in; ';
$htmlPage .= 'top-margin: ' . $top;
$htmlBody .= 'top-margin: ' . $top;
$bottom = PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getBottom()) . 'in; ';
$htmlPage .= 'bottom-margin: ' . $bottom;
$htmlBody .= 'bottom-margin: ' . $bottom;
$htmlPage .= "}\n";
$htmlBody .= "}\n";
return "<style>\n" . $htmlPage . $htmlBody . "</style>\n";
}
示例4: _writePageMargins
/**
* Write PageMargins
*
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
* @param PHPExcel_Worksheet $pSheet Worksheet
* @throws Exception
*/
private function _writePageMargins(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null)
{
// pageMargins
$objWriter->startElement('pageMargins');
$objWriter->writeAttribute('left', PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getLeft()));
$objWriter->writeAttribute('right', PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getRight()));
$objWriter->writeAttribute('top', PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getTop()));
$objWriter->writeAttribute('bottom', PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getBottom()));
$objWriter->writeAttribute('header', PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getHeader()));
$objWriter->writeAttribute('footer', PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getFooter()));
$objWriter->endElement();
}
示例5: pack
/**
* Store the BOTTOMMARGIN BIFF record.
*
* @access private
*/
function _storeMarginBottom()
{
$record = 0x29;
// Record identifier
$length = 0x8;
// Bytes to follow
$margin = $this->_phpSheet->getPageMargins()->getBottom();
// Margin in inches
$header = pack("vv", $record, $length);
$data = pack("d", $margin);
if ($this->_byte_order) {
// if it's Big Endian
$data = strrev($data);
}
$this->_prepend($header . $data);
}
示例6: calculateColumnWidth
/**
* Calculates the column width, based on the papersize and orientation
*
* @param \PHPExcel_Worksheet $sheet
* @param array $columns
*/
protected function calculateColumnWidth(\PHPExcel_Worksheet $sheet, array $columns)
{
// First make sure the columns width is 100 "percent"
$this->calculateColumnWidthPercent($columns);
// width is in mm
$paperWidth = $this->getPaperWidth();
// remove margins (they are in inches!)
$paperWidth -= $sheet->getPageMargins()->getLeft() / 0.0393700787402;
$paperWidth -= $sheet->getPageMargins()->getRight() / 0.0393700787402;
$paperWidth /= 2;
$factor = $paperWidth / 100;
foreach ($columns as $column) {
/* @var $column \ZfcDatagrid\Column\AbstractColumn */
$column->setWidth($column->getWidth() * $factor);
}
}
示例7: _writeSetup
/**
* Store the page setup SETUP BIFF record.
*/
private function _writeSetup()
{
$record = 0xa1;
// Record identifier
$length = 0x22;
// Number of bytes to follow
$iPaperSize = $this->_phpSheet->getPageSetup()->getPaperSize();
// Paper size
$iScale = $this->_phpSheet->getPageSetup()->getScale() ? $this->_phpSheet->getPageSetup()->getScale() : 100;
// Print scaling factor
$iPageStart = 0x1;
// Starting page number
$iFitWidth = (int) $this->_phpSheet->getPageSetup()->getFitToWidth();
// Fit to number of pages wide
$iFitHeight = (int) $this->_phpSheet->getPageSetup()->getFitToHeight();
// Fit to number of pages high
$grbit = 0x0;
// Option flags
$iRes = 0x258;
// Print resolution
$iVRes = 0x258;
// Vertical print resolution
$numHdr = $this->_phpSheet->getPageMargins()->getHeader();
// Header Margin
$numFtr = $this->_phpSheet->getPageMargins()->getFooter();
// Footer Margin
$iCopies = 0x1;
// Number of copies
$fLeftToRight = 0x0;
// Print over then down
// Page orientation
$fLandscape = $this->_phpSheet->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 0x0 : 0x1;
$fNoPls = 0x0;
// Setup not read from printer
$fNoColor = 0x0;
// Print black and white
$fDraft = 0x0;
// Print draft quality
$fNotes = 0x0;
// Print notes
$fNoOrient = 0x0;
// Orientation not set
$fUsePage = 0x0;
// Use custom starting page
$grbit = $fLeftToRight;
$grbit |= $fLandscape << 1;
$grbit |= $fNoPls << 2;
$grbit |= $fNoColor << 3;
$grbit |= $fDraft << 4;
$grbit |= $fNotes << 5;
$grbit |= $fNoOrient << 6;
$grbit |= $fUsePage << 7;
$numHdr = pack("d", $numHdr);
$numFtr = pack("d", $numFtr);
if (self::getByteOrder()) {
// if it's Big Endian
$numHdr = strrev($numHdr);
$numFtr = strrev($numFtr);
}
$header = pack("vv", $record, $length);
$data1 = pack("vvvvvvvv", $iPaperSize, $iScale, $iPageStart, $iFitWidth, $iFitHeight, $grbit, $iRes, $iVRes);
$data2 = $numHdr . $numFtr;
$data3 = pack("v", $iCopies);
$this->_append($header . $data1 . $data2 . $data3);
}
示例8: _readSst
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
// get spliced record data
$splicedRecordData = $this->_getSplicedRecordData();
$recordData = $splicedRecordData['recordData'];
$this->_drawingGroupData .= $recordData;
}
/**
* SST - Shared String Table
*
* This record contains a list of all strings used anywhere
* in the workbook. Each string occurs only once. The
* workbook uses indexes into the list to reference the
* strings.
*
* -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format"
**/
private function _readSst()
{
// offset within (spliced) record data
$pos = 0;
// get spliced record data
$splicedRecordData = $this->_getSplicedRecordData();
$recordData = $splicedRecordData['recordData'];
$spliceOffsets = $splicedRecordData['spliceOffsets'];
// offset: 0; size: 4; total number of strings in the workbook
$pos += 4;
// offset: 4; size: 4; number of following strings ($nm)
$nm = self::_GetInt4d($recordData, 4);
$pos += 4;
// loop through the Unicode strings (16-bit length)
for ($i = 0; $i < $nm; ++$i) {
// number of characters in the Unicode string
$numChars = self::_GetInt2d($recordData, $pos);
$pos += 2;
// option flags
$optionFlags = ord($recordData[$pos]);
++$pos;
// bit: 0; mask: 0x01; 0 = compressed; 1 = uncompressed
$isCompressed = ($optionFlags & 0x1) == 0;
// bit: 2; mask: 0x02; 0 = ordinary; 1 = Asian phonetic
$hasAsian = ($optionFlags & 0x4) != 0;
// bit: 3; mask: 0x03; 0 = ordinary; 1 = Rich-Text
$hasRichText = ($optionFlags & 0x8) != 0;