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


PHP PHPExcel_Shared_Drawing::cellDimensionToPixels方法代码示例

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


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

示例1: save

	/**
	 * Save PHPExcel to file
	 *
	 * @param 	string 		$pFileName
	 * @throws 	Exception
	 */
	public function save($pFilename = null) {
		// Open file
		global $cnf;
		$pFilename= $cnf['path']['Temp'] . $pFilename;

		$fileHandle = fopen($pFilename, 'w');
		if ($fileHandle === false) {
			throw new Exception("Could not open file $pFilename for writing.");
		}

		// Fetch sheets
		$sheets = array();
		if (is_null($this->_sheetIndex)) {
			$sheets = $this->_phpExcel->getAllSheets();
		} else {
			$sheets[] = $this->_phpExcel->getSheet($this->_sheetIndex);
		}

    	// PDF paper size
    	$paperSize = 'A4';

		// Create PDF
		$pdf = new FPDF('P', 'pt', $paperSize);

		// Loop all sheets
		foreach ($sheets as $sheet) {
	    	// PDF orientation
	    	$orientation = 'P';
	    	if ($sheet->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) {
		    	$orientation = 'L';
	    	}

			// Start sheet
			$pdf->SetAutoPageBreak(true);
			$pdf->SetFont('Arial', '', 10);
			$pdf->AddPage($orientation);

	    	// Get worksheet dimension
	    	$dimension = explode(':', $sheet->calculateWorksheetDimension());
	    	$dimension[0] = PHPExcel_Cell::coordinateFromString($dimension[0]);
	    	$dimension[0][0] = PHPExcel_Cell::columnIndexFromString($dimension[0][0]) - 1;
	    	$dimension[1] = PHPExcel_Cell::coordinateFromString($dimension[1]);
	    	$dimension[1][0] = PHPExcel_Cell::columnIndexFromString($dimension[1][0]) - 1;

	    	// Calculate column widths
	    	$sheet->calculateColumnWidths();

	    	// Loop trough cells
	    	for ($row = $dimension[0][1]; $row <= $dimension[1][1]; $row++) {
	    		// Line height
	    		$lineHeight = 0;

	    		// Calulate line height
	    		for ($column = $dimension[0][0]; $column <= $dimension[1][0]; $column++) {
	    		    $rowDimension = $sheet->getRowDimension($row);
	    			$cellHeight = PHPExcel_Shared_Drawing::pixelsToPoints(
	    				PHPExcel_Shared_Drawing::cellDimensionToPixels($rowDimension->getRowHeight())
	    			);
	    			if ($cellHeight <= 0) {
		    			$cellHeight = PHPExcel_Shared_Drawing::pixelsToPoints(
		    				PHPExcel_Shared_Drawing::cellDimensionToPixels($sheet->getDefaultRowDimension()->getRowHeight())
		    			);
	    			}
	    			if ($cellHeight <= 0) {
	    				$cellHeight = $sheet->getStyleByColumnAndRow($column, $row)->getFont()->getSize();
	    			}
	    			if ($cellHeight > $lineHeight) {
	    				$lineHeight = $cellHeight;
	    			}
	    		}

	    		// Output values
	    		for ($column = $dimension[0][0]; $column <= $dimension[1][0]; $column++) {
	    			// Start with defaults...
	    			$pdf->SetFont('Arial', '', 10);
	    			$pdf->SetTextColor(0, 0, 0);
	    			$pdf->SetDrawColor(100, 100, 100);
	    			$pdf->SetFillColor(255, 255, 255);

			    	// Coordinates
			    	$startX = $pdf->GetX();
			    	$startY = $pdf->GetY();

	    			// Cell exists?
	    			$cellData = '';
	    			if ($sheet->cellExistsByColumnAndRow($column, $row)) {
	    				if ($sheet->getCellByColumnAndRow($column, $row)->getValue() instanceof PHPExcel_RichText) {
	    					$cellData = $sheet->getCellByColumnAndRow($column, $row)->getValue()->getPlainText();
	    				} else {
		    				if ($this->_preCalculateFormulas) {
		    					$cellData = PHPExcel_Style_NumberFormat::ToFormattedString(
		    						$sheet->getCellByColumnAndRow($column, $row)->getCalculatedValue(),
		    						$sheet->getstyle( $sheet->getCellByColumnAndRow($column, $row)->getCoordinate() )->getNumberFormat()->getFormatCode()
		    					);
//.........这里部分代码省略.........
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:101,代码来源:PDF.php

示例2: sizeCol

 /**
  * Get the width of a column in pixels. We use the relationship y = ceil(7x) where
  * x is the width in intrinsic Excel units (measuring width in number of normal characters)
  * This holds for Arial 10
  *
  * @param PHPExcel_Worksheet $sheet The sheet
  * @param string $col The column
  * @return integer The width in pixels
  */
 public static function sizeCol($sheet, $col = 'A')
 {
     // default font of the workbook
     $font = $sheet->getParent()->getDefaultStyle()->getFont();
     $columnDimensions = $sheet->getColumnDimensions();
     // first find the true column width in pixels (uncollapsed and unhidden)
     if (isset($columnDimensions[$col]) and $columnDimensions[$col]->getWidth() != -1) {
         // then we have column dimension with explicit width
         $columnDimension = $columnDimensions[$col];
         $width = $columnDimension->getWidth();
         $pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font);
     } else {
         if ($sheet->getDefaultColumnDimension()->getWidth() != -1) {
             // then we have default column dimension with explicit width
             $defaultColumnDimension = $sheet->getDefaultColumnDimension();
             $width = $defaultColumnDimension->getWidth();
             $pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font);
         } else {
             // we don't even have any default column dimension. Width depends on default font
             $pixelWidth = PHPExcel_Shared_Font::getDefaultColumnWidthByFont($font, true);
         }
     }
     // now find the effective column width in pixels
     if (isset($columnDimensions[$col]) and !$columnDimensions[$col]->getVisible()) {
         $effectivePixelWidth = 0;
     } else {
         $effectivePixelWidth = $pixelWidth;
     }
     return $effectivePixelWidth;
 }
开发者ID:mehulsbhatt,项目名称:sale_purchase_tracking,代码行数:39,代码来源:Excel5.php

示例3: sizeCol

 /**
  * Get the width of a column in pixels. We use the relationship y = ceil(7x) where
  * x is the width in intrinsic Excel units (measuring width in number of normal characters)
  * This holds for Arial 10
  *
  * @param PHPExcel_Worksheet $sheet The sheet
  * @param integer $col The column
  * @return integer The width in pixels
  */
 public static function sizeCol($sheet, $col = 'A')
 {
     // default font size of workbook
     $fontSize = $sheet->getParent()->getDefaultStyle()->getFont()->getSize();
     $columnDimensions = $sheet->getColumnDimensions();
     // first find the true column width in pixels (uncollapsed and unhidden)
     if (isset($columnDimensions[$col]) and $columnDimensions[$col]->getWidth() != -1) {
         // then we have column dimension with explicit width
         $columnDimension = $columnDimensions[$col];
         $width = $columnDimension->getWidth();
         $pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $fontSize);
     } else {
         if ($sheet->getDefaultColumnDimension()->getWidth() != -1) {
             // then we have default column dimension with explicit width
             $defaultColumnDimension = $sheet->getDefaultColumnDimension();
             $width = $defaultColumnDimension->getWidth();
             $pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $fontSize);
         } else {
             $pixelWidth = (int) 64 * $fontSize / 11;
             // here we interpolate from Calibri 11
         }
     }
     // now find the effective column width in pixels
     if (isset($columnDimensions[$col]) and !$columnDimensions[$col]->getVisible()) {
         $effectivePixelWidth = 0;
     } else {
         $effectivePixelWidth = $pixelWidth;
     }
     return $effectivePixelWidth;
 }
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:39,代码来源:Excel5.php

示例4: buildCSS

 /**
  * Build CSS styles
  *
  * @param	boolean	$generateSurroundingHTML	Generate surrounding HTML style? (html { })
  * @return	array
  * @throws	PHPExcel_Writer_Exception
  */
 public function buildCSS($generateSurroundingHTML = true)
 {
     // PHPExcel object known?
     if (is_null($this->_phpExcel)) {
         throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.');
     }
     // Cached?
     if (!is_null($this->_cssStyles)) {
         return $this->_cssStyles;
     }
     // Ensure that spans have been calculated
     if (!$this->_spansAreCalculated) {
         $this->_calculateSpans();
     }
     // Construct CSS
     $css = array();
     // Start styles
     if ($generateSurroundingHTML) {
         // html { }
         $css['html']['font-family'] = 'Calibri, Arial, Helvetica, sans-serif';
         $css['html']['font-size'] = '11pt';
         $css['html']['background-color'] = 'white';
     }
     // table { }
     $css['table']['border-collapse'] = 'collapse';
     if (!$this->_isPdf) {
         $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) {
//.........这里部分代码省略.........
开发者ID:adit-gudhel,项目名称:simpus-dev,代码行数:101,代码来源:HTML.php

示例5: _writeStyles

 /**
  * Write styles to file
  * 
  * @param	mixed				$pFileHandle	PHP filehandle
  * @param	PHPExcel_Worksheet 	$pSheet			PHPExcel_Worksheet
  * @throws	Exception
  */
 private function _writeStyles($pFileHandle = null, PHPExcel_Worksheet $pSheet)
 {
     if (!is_null($pFileHandle)) {
         // Construct HTML
         $html = '';
         // Start styles
         $html .= '    <style>' . "\r\n";
         $html .= '    <!--' . "\r\n";
         $html .= '      html {' . "\r\n";
         $html .= '        font-family: Calibri, Arial, Helvetica, Sans Serif;' . "\r\n";
         $html .= '        font-size: 10pt;' . "\r\n";
         $html .= '        background-color: white;' . "\r\n";
         $html .= '      }' . "\r\n";
         $html .= '      table.sheet, table.sheet td {' . "\r\n";
         if ($pSheet->getShowGridlines()) {
             $html .= '        border: 1px dotted black;' . "\r\n";
         }
         $html .= '      }' . "\r\n";
         // Calculate column widths
         $pSheet->calculateColumnWidths();
         foreach ($pSheet->getColumnDimensions() as $columnDimension) {
             $column = PHPExcel_Cell::columnIndexFromString($columnDimension->getColumnIndex()) - 1;
             $html .= '      td.column' . $column . ' {' . "\r\n";
             $html .= '        width: ' . PHPExcel_Shared_Drawing::cellDimensionToPixels($columnDimension->getWidth()) . 'px;' . "\r\n";
             if ($columnDimension->getVisible() === false) {
                 $html .= '        display: none;' . "\r\n";
                 $html .= '        visibility: hidden;' . "\r\n";
             }
             $html .= '      }' . "\r\n";
         }
         // Calculate row heights
         foreach ($pSheet->getRowDimensions() as $rowDimension) {
             $html .= '      tr.row' . ($rowDimension->getRowIndex() - 1) . ' {' . "\r\n";
             // height is disproportionately large
             $px_height = round(PHPExcel_Shared_Drawing::cellDimensionToPixels($rowDimension->getRowHeight()) / 12);
             $html .= '        height: ' . $px_height . 'px;' . "\r\n";
             if ($rowDimension->getVisible() === false) {
                 $html .= '        display: none;' . "\r\n";
                 $html .= '        visibility: hidden;' . "\r\n";
             }
             $html .= '      }' . "\r\n";
         }
         // Calculate cell style hashes
         $cellStyleHashes = new PHPExcel_HashTable();
         $cellStyleHashes->addFromSource($pSheet->getStyles());
         for ($i = 0; $i < $cellStyleHashes->count(); $i++) {
             $html .= $this->_createCSSStyle($cellStyleHashes->getByIndex($i));
         }
         // End styles
         $html .= '    -->' . "\r\n";
         $html .= '    </style>' . "\r\n";
         // Write to file
         fwrite($pFileHandle, $html);
     } else {
         throw new Exception("Invalid parameters passed.");
     }
 }
开发者ID:laiello,项目名称:myopensources,代码行数:64,代码来源:HTML.php

示例6: buildCSS

 /**
  * Build CSS styles
  *
  * @param	boolean	$generateSurroundingHTML	Generate surrounding HTML style? (html { })
  * @return	array
  * @throws	Exception
  */
 public function buildCSS($generateSurroundingHTML = true)
 {
     // PHPExcel object known?
     if (is_null($this->_phpExcel)) {
         throw new Exception('Internal PHPExcel object not set to an instance of an object.');
     }
     // Cached?
     if (!is_null($this->_cssStyles)) {
         return $this->_cssStyles;
     }
     // Construct CSS
     $css = array();
     // Start styles
     if ($generateSurroundingHTML) {
         // html { }
         $css['html'] = 'font-family: Calibri, Arial, Helvetica, sans-serif; ';
         $css['html'] .= 'font-size: 10pt; ';
         $css['html'] .= 'background-color: white; ';
     }
     // 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
         $hashCode = $sheet->getHashCode();
         // Build styles
         // table.sheetXXXXXX { }
         $css['table.sheet' . $hashCode] = '';
         if ($sheet->getShowGridlines()) {
             $css['table.sheet' . $hashCode] .= 'border: 1px dotted black; ';
         }
         $css['table.sheet' . $hashCode] .= 'page-break-after: always; ';
         // table.sheetXXXXXX td { }
         $css['table.sheet' . $hashCode . ' td'] = $css['table.sheet' . $hashCode];
         // Default column width
         $columnDimension = $sheet->getDefaultColumnDimension();
         $css['table.sheet' . $hashCode . ' td'] .= 'width: ' . PHPExcel_Shared_Drawing::cellDimensionToPixels($columnDimension->getWidth()) . 'px; ';
         if ($columnDimension->getVisible() === false) {
             $css['table.sheet' . $hashCode . ' td'] .= 'display: none; ';
             $css['table.sheet' . $hashCode . ' td'] .= 'visibility: hidden; ';
         }
         // Calculate column widths
         $sheet->calculateColumnWidths();
         foreach ($sheet->getColumnDimensions() as $columnDimension) {
             $column = PHPExcel_Cell::columnIndexFromString($columnDimension->getColumnIndex()) - 1;
             // table.sheetXXXXXX td.columnYYYYYY { }
             $css['table.sheet' . $hashCode . ' td.column' . $column] = 'width: ' . PHPExcel_Shared_Drawing::cellDimensionToPixels($columnDimension->getWidth()) . 'px; ';
             if ($columnDimension->getVisible() === false) {
                 $css['table.sheet' . $hashCode . ' td.column' . $column] .= 'display: none; ';
                 $css['table.sheet' . $hashCode . ' td.column' . $column] .= 'visibility: hidden; ';
             }
         }
         // Default row height
         $rowDimension = $sheet->getDefaultRowDimension();
         // table.sheetXXXXXX tr { }
         $css['table.sheet' . $hashCode . ' tr'] = '';
         // height is disproportionately large
         $px_height = round(PHPExcel_Shared_Drawing::cellDimensionToPixels($rowDimension->getRowHeight()) / 12);
         $css['table.sheet' . $hashCode . ' tr'] .= 'height: ' . $px_height . 'px; ';
         if ($rowDimension->getVisible() === false) {
             $css['table.sheet' . $hashCode . ' tr'] .= 'display: none; ';
             $css['table.sheet' . $hashCode . ' tr'] .= 'visibility: hidden; ';
         }
         // Calculate row heights
         foreach ($sheet->getRowDimensions() as $rowDimension) {
             // table.sheetXXXXXX tr.rowYYYYYY { }
             $css['table.sheet' . $hashCode . ' tr.row' . ($rowDimension->getRowIndex() - 1)] = '';
             // height is disproportionately large
             $px_height = round(PHPExcel_Shared_Drawing::cellDimensionToPixels($rowDimension->getRowHeight()) / 12);
             $css['table.sheet' . $hashCode . ' tr.row' . ($rowDimension->getRowIndex() - 1)] .= 'height: ' . $px_height . 'px; ';
             if ($rowDimension->getVisible() === false) {
                 $css['table.sheet' . $hashCode . ' tr.row' . ($rowDimension->getRowIndex() - 1)] .= 'display: none; ';
                 $css['table.sheet' . $hashCode . ' tr.row' . ($rowDimension->getRowIndex() - 1)] .= 'visibility: hidden; ';
             }
         }
         // Calculate cell style hashes
         $cellStyleHashes = new PHPExcel_HashTable();
         $aStyles = $sheet->getStyles();
         $cellStyleHashes->addFromSource($aStyles);
         $addedStyles = array();
         foreach ($aStyles as $style) {
             if (isset($addedStyles[$style->getHashIndex()])) {
                 continue;
             }
             $css['style' . $style->getHashIndex()] = $this->_createCSSStyle($style);
             $addedStyles[$style->getHashIndex()] = true;
         }
     }
//.........这里部分代码省略.........
开发者ID:quantrocket,项目名称:planlogiq,代码行数:101,代码来源:HTML.php

示例7: generateStyles

	/**
	 * Generate CSS styles
	 *
	 * @param	boolean	$generateSurroundingHTML	Generate surrounding HTML tags? (<style> and </style>)
	 * @return	string
	 * @throws	Exception
	 */
	public function generateStyles($generateSurroundingHTML = true) {
		// PHPExcel object known?
		if (is_null($this->_phpExcel)) {
			throw new Exception('Internal PHPExcel object not set to an instance of an object.');
		}

		// Construct HTML
		$html = '';

		// Start styles
		if ($generateSurroundingHTML) {
			$html .= '    <style>' . "\r\n";
			$html .= '    <!--' . "\r\n";
			$html .= '      html {' . "\r\n";
			$html .= '        font-family: Calibri, Arial, Helvetica, Sans Serif;' . "\r\n";
			$html .= '        font-size: 10pt;' . "\r\n";
			$html .= '        background-color: white;' . "\r\n";
			$html .= '      }' . "\r\n";
		}

		// Write styles per sheet
		foreach ($this->_phpExcel->getAllSheets() as $sheet) {
			// Calculate hash code
			$hashCode = $sheet->getHashCode();

			// Write styles
			$html .= '      table.sheet' . $hashCode . ', table.sheet' . $hashCode . ' td {' . "\r\n";
			if ($sheet->getShowGridlines()) {
				$html .= '        border: 1px dotted black;' . "\r\n";
			}
			$html .= '        page-break-after: always;' . "\r\n";
			$html .= '      }' . "\r\n";

			// Default column width
			$columnDimension = $sheet->getDefaultColumnDimension();

			$html .= '      table.sheet' . $hashCode . ' td {' . "\r\n";
			$html .= '        width: ' . PHPExcel_Shared_Drawing::cellDimensionToPixels($columnDimension->getWidth()) . 'px;' . "\r\n";
			if ($columnDimension->getVisible() === false) {
				$html .= '        display: none;' . "\r\n";
				$html .= '        visibility: hidden;' . "\r\n";
			}
			$html .= '      }' . "\r\n";

			// Calculate column widths
			$sheet->calculateColumnWidths();
			foreach ($sheet->getColumnDimensions() as $columnDimension) {
				$column = PHPExcel_Cell::columnIndexFromString($columnDimension->getColumnIndex()) - 1;

				$html .= '      table.sheet' . $hashCode . ' td.column' . $column  . ' {' . "\r\n";
				$html .= '        width: ' . PHPExcel_Shared_Drawing::cellDimensionToPixels($columnDimension->getWidth()) . 'px;' . "\r\n";
				if ($columnDimension->getVisible() === false) {
					$html .= '        display: none;' . "\r\n";
					$html .= '        visibility: hidden;' . "\r\n";
				}
				$html .= '      }' . "\r\n";
			}

			// Default row height
			$rowDimension = $sheet->getDefaultRowDimension();

			$html .= '      table.sheet' . $hashCode . ' tr {' . "\r\n";
			// height is disproportionately large
			$px_height = round( PHPExcel_Shared_Drawing::cellDimensionToPixels($rowDimension->getRowHeight()) / 12 );
			$html .= '        height: ' . $px_height . 'px;' . "\r\n";
			if ($rowDimension->getVisible() === false) {
				$html .= '        display: none;' . "\r\n";
				$html .= '        visibility: hidden;' . "\r\n";
			}
			$html .= '      }' . "\r\n";

			// Calculate row heights
			foreach ($sheet->getRowDimensions() as $rowDimension) {
				$html .= '      table.sheet' . $hashCode . ' tr.row' . ($rowDimension->getRowIndex() - 1)  . ' {' . "\r\n";
				// height is disproportionately large
				$px_height = round( PHPExcel_Shared_Drawing::cellDimensionToPixels($rowDimension->getRowHeight()) / 12 );
				$html .= '        height: ' . $px_height . 'px;' . "\r\n";
				if ($rowDimension->getVisible() === false) {
					$html .= '        display: none;' . "\r\n";
					$html .= '        visibility: hidden;' . "\r\n";
				}
				$html .= '      }' . "\r\n";
			}

			// Calculate cell style hashes
			$cellStyleHashes = new PHPExcel_HashTable();
			$cellStyleHashes->addFromSource( $sheet->getStyles() );
			for ($i = 0; $i < $cellStyleHashes->count(); $i++) {
				$html .= $this->_createCSSStyle( $cellStyleHashes->getByIndex($i) );
			}
		}

		// End styles
//.........这里部分代码省略.........
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:101,代码来源:HTML.php

示例8: buildCSS

 /**
  * Build CSS styles
  *
  * @param	boolean	$generateSurroundingHTML	Generate surrounding HTML style? (html { })
  * @return	array
  * @throws	Exception
  */
 public function buildCSS($generateSurroundingHTML = true)
 {
     // PHPExcel object known?
     if (is_null($this->_phpExcel)) {
         throw new Exception('Internal PHPExcel object not set to an instance of an object.');
     }
     // Cached?
     if (!is_null($this->_cssStyles)) {
         return $this->_cssStyles;
     }
     // Construct CSS
     $css = array();
     // Start styles
     if ($generateSurroundingHTML) {
         // html { }
         $css['html'] = 'font-family: Calibri, Arial, Helvetica, sans-serif; ';
         $css['html'] .= 'font-size: 10pt; ';
         $css['html'] .= 'background-color: white; ';
     }
     // 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
         $hashCode = $sheet->getHashCode();
         // Build styles
         // table.sheetXXXXXX { }
         $css['table.sheet' . $hashCode] = '';
         if ($sheet->getShowGridlines()) {
             $css['table.sheet' . $hashCode] .= 'border: 1px dotted black; ';
         }
         $css['table.sheet' . $hashCode] .= 'page-break-after: always; ';
         // table.sheetXXXXXX td { }
         $css['table.sheet' . $hashCode . ' td'] = $css['table.sheet' . $hashCode];
         // Calculate column widths
         $sheet->calculateColumnWidths();
         // col elements, initialize
         $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($sheet->getHighestColumn()) - 1;
         for ($column = 0; $column <= $highestColumnIndex; ++$column) {
             $this->_columnWidths[$hashCode][$column] = 42;
             // approximation
             $css['table.sheet' . $hashCode . ' 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())) >= 0) {
                 $width = PHPExcel_Shared_Drawing::pixelsToPoints($width);
                 $column = PHPExcel_Cell::columnIndexFromString($columnDimension->getColumnIndex()) - 1;
                 $this->_columnWidths[$hashCode][$column] = $width;
                 $css['table.sheet' . $hashCode . ' col.col' . $column] = 'width: ' . $width . 'pt; ';
                 if ($columnDimension->getVisible() === false) {
                     $css['table.sheet' . $hashCode . ' col.col' . $column] .= 'visibility: collapse; ';
                     $css['table.sheet' . $hashCode . ' col.col' . $column] .= '*display: none; ';
                     // target IE6+7
                 }
             }
         }
         // Default row height
         $rowDimension = $sheet->getDefaultRowDimension();
         // table.sheetXXXXXX tr { }
         $css['table.sheet' . $hashCode . ' tr'] = '';
         // height is disproportionately large
         $px_height = round(PHPExcel_Shared_Drawing::cellDimensionToPixels($rowDimension->getRowHeight()) / 12);
         $css['table.sheet' . $hashCode . ' tr'] .= 'height: ' . $px_height . 'px; ';
         if ($rowDimension->getVisible() === false) {
             $css['table.sheet' . $hashCode . ' tr'] .= 'display: none; ';
             $css['table.sheet' . $hashCode . ' tr'] .= 'visibility: hidden; ';
         }
         // Calculate row heights
         foreach ($sheet->getRowDimensions() as $rowDimension) {
             // table.sheetXXXXXX tr.rowYYYYYY { }
             $css['table.sheet' . $hashCode . ' tr.row' . ($rowDimension->getRowIndex() - 1)] = '';
             // height is disproportionately large
             $px_height = round(PHPExcel_Shared_Drawing::cellDimensionToPixels($rowDimension->getRowHeight()) / 12);
             $css['table.sheet' . $hashCode . ' tr.row' . ($rowDimension->getRowIndex() - 1)] .= 'height: ' . $px_height . 'px; ';
             if ($rowDimension->getVisible() === false) {
                 $css['table.sheet' . $hashCode . ' tr.row' . ($rowDimension->getRowIndex() - 1)] .= 'display: none; ';
                 $css['table.sheet' . $hashCode . ' tr.row' . ($rowDimension->getRowIndex() - 1)] .= 'visibility: hidden; ';
             }
         }
         // .b {}
         $css['.b'] = 'text-align: center; ';
         // BOOL
         // .e {}
         $css['.e'] = 'text-align: center; ';
         // ERROR
         // .f {}
         $css['.f'] = 'text-align: right; ';
//.........这里部分代码省略.........
开发者ID:roelvanduijnhoven,项目名称:muzieklijstjes,代码行数:101,代码来源:HTML.php


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