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


PHP PHPExcel::getAllSheets方法代码示例

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


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

示例1: save

 /**
  * Save PHPExcel to file
  *
  * @param 	string 		$pFileName
  * @throws 	Exception
  */
 public function save($pFilename = null)
 {
     if (!is_null($this->_spreadSheet)) {
         // Garbage collect...
         foreach ($this->_spreadSheet->getAllSheets() as $sheet) {
             $sheet->garbageCollect();
         }
         // Create new ZIP file and open it for writing
         $objZip = new ZipArchive();
         // Try opening the ZIP file
         if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) {
             if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) {
                 throw new Exception("Could not open " . $pFilename . " for writing.");
             }
         }
         // Add media
         $sheetCount = $this->_spreadSheet->getSheetCount();
         for ($i = 0; $i < $sheetCount; ++$i) {
             for ($j = 0; $j < $this->_spreadSheet->getSheet($i)->getDrawingCollection()->count(); ++$j) {
                 if ($this->_spreadSheet->getSheet($i)->getDrawingCollection()->offsetGet($j) instanceof PHPExcel_Worksheet_BaseDrawing) {
                     $imgTemp = $this->_spreadSheet->getSheet($i)->getDrawingCollection()->offsetGet($j);
                     $objZip->addFromString('media/' . $imgTemp->getFilename(), file_get_contents($imgTemp->getPath()));
                 }
             }
         }
         // Add phpexcel.xml to the document, which represents a PHP serialized PHPExcel object
         $objZip->addFromString('phpexcel.xml', $this->_writeSerialized($this->_spreadSheet, $pFilename));
         // Close file
         if ($objZip->close() === false) {
             throw new Exception("Could not close zip file {$pFilename}.");
         }
     } else {
         throw new Exception("PHPExcel object unassigned.");
     }
 }
开发者ID:sensorsix,项目名称:app,代码行数:41,代码来源:Serialized.php

示例2: 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

示例3: _buildWorkbookEscher

 /**
  * Build the Escher object corresponding to the MSODRAWINGGROUP record
  */
 private function _buildWorkbookEscher()
 {
     $escher = null;
     // any drawings in this workbook?
     $found = false;
     foreach ($this->_phpExcel->getAllSheets() as $sheet) {
         if (count($sheet->getDrawingCollection()) > 0) {
             $found = true;
             break;
         }
     }
     // nothing to do if there are no drawings
     if (!$found) {
         return;
     }
     // if we reach here, then there are drawings in the workbook
     $escher = new PHPExcel_Shared_Escher();
     // dggContainer
     $dggContainer = new PHPExcel_Shared_Escher_DggContainer();
     $escher->setDggContainer($dggContainer);
     // set IDCLs (identifier clusters)
     $dggContainer->setIDCLs($this->_IDCLs);
     // this loop is for determining maximum shape identifier of all drawing
     $spIdMax = 0;
     $totalCountShapes = 0;
     $countDrawings = 0;
     foreach ($this->_phpExcel->getAllsheets() as $sheet) {
         $sheetCountShapes = 0;
         // count number of shapes (minus group shape), in sheet
         if (count($sheet->getDrawingCollection()) > 0) {
             ++$countDrawings;
             foreach ($sheet->getDrawingCollection() as $drawing) {
                 ++$sheetCountShapes;
                 ++$totalCountShapes;
                 $spId = $sheetCountShapes | $this->_phpExcel->getIndex($sheet) + 1 << 10;
                 $spIdMax = max($spId, $spIdMax);
             }
         }
     }
     $dggContainer->setSpIdMax($spIdMax + 1);
     $dggContainer->setCDgSaved($countDrawings);
     $dggContainer->setCSpSaved($totalCountShapes + $countDrawings);
     // total number of shapes incl. one group shapes per drawing
     // bstoreContainer
     $bstoreContainer = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer();
     $dggContainer->setBstoreContainer($bstoreContainer);
     // the BSE's (all the images)
     foreach ($this->_phpExcel->getAllsheets() as $sheet) {
         foreach ($sheet->getDrawingCollection() as $drawing) {
             if ($drawing instanceof PHPExcel_Worksheet_Drawing) {
                 $filename = $drawing->getPath();
                 list($imagesx, $imagesy, $imageFormat) = getimagesize($filename);
                 switch ($imageFormat) {
                     case 1:
                         // GIF, not supported by BIFF8, we convert to PNG
                         $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
                         ob_start();
                         imagepng(imagecreatefromgif($filename));
                         $blipData = ob_get_contents();
                         ob_end_clean();
                         break;
                     case 2:
                         // JPEG
                         $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG;
                         $blipData = file_get_contents($filename);
                         break;
                     case 3:
                         // PNG
                         $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
                         $blipData = file_get_contents($filename);
                         break;
                     case 6:
                         // Windows DIB (BMP), we convert to PNG
                         $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
                         ob_start();
                         imagepng(PHPExcel_Shared_Drawing::imagecreatefrombmp($filename));
                         $blipData = ob_get_contents();
                         ob_end_clean();
                         break;
                     default:
                         continue 2;
                 }
                 $blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
                 $blip->setData($blipData);
                 $BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE();
                 $BSE->setBlipType($blipType);
                 $BSE->setBlip($blip);
                 $bstoreContainer->addBSE($BSE);
             } else {
                 if ($drawing instanceof PHPExcel_Worksheet_MemoryDrawing) {
                     switch ($drawing->getRenderingFunction()) {
                         case PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG:
                             $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG;
                             $renderingFunction = 'imagejpeg';
                             break;
                         case PHPExcel_Worksheet_MemoryDrawing::RENDERING_GIF:
                         case PHPExcel_Worksheet_MemoryDrawing::RENDERING_PNG:
//.........这里部分代码省略.........
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:101,代码来源:Excel5.php

示例4: close

 /**
  * Close the Moodle Workbook
  */
 public function close()
 {
     global $CFG;
     foreach ($this->objPHPExcel->getAllSheets() as $sheet) {
         $sheet->setSelectedCells('A1');
     }
     $this->objPHPExcel->setActiveSheetIndex(0);
     $filename = preg_replace('/\\.xlsx?$/i', '', $this->filename);
     $mimetype = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
     $filename = $filename . '.xlsx';
     if (is_https()) {
         // HTTPS sites - watch out for IE! KB812935 and KB316431.
         header('Cache-Control: max-age=10');
         header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT');
         header('Pragma: ');
     } else {
         //normal http - prevent caching at all cost
         header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0');
         header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT');
         header('Pragma: no-cache');
     }
     if (core_useragent::is_ie()) {
         $filename = rawurlencode($filename);
     } else {
         $filename = s($filename);
     }
     header('Content-Type: ' . $mimetype);
     header('Content-Disposition: attachment;filename="' . $filename . '"');
     $objWriter = PHPExcel_IOFactory::createWriter($this->objPHPExcel, $this->type);
     $objWriter->save('php://output');
 }
开发者ID:Gavinthisisit,项目名称:Moodle,代码行数:34,代码来源:excellib.class.php

示例5: sheet

 /**
  * @param integer|callable|string $sheetID
  * @param null $callback
  * @return $this
  * @throws \PHPExcel_Exception
  */
 public function sheet($sheetID, $callback = null)
 {
     // Default
     $isCallable = false;
     // Init a new PHPExcel instance without any worksheets
     if (!$this->excel instanceof PHPExcel) {
         $this->original = $this->excel;
         $this->initClonedExcelObject($this->excel);
         // Clone all connected sheets
         foreach ($this->original->getAllSheets() as $sheet) {
             $this->excel->createSheet()->cloneParent($sheet);
         }
     }
     // Copy the callback when needed
     if (is_callable($sheetID)) {
         $callback = $sheetID;
         $isCallable = true;
     } elseif (is_callable($callback)) {
         $isCallable = true;
     }
     // Clone the loaded excel instance
     $this->sheet = $this->getSheetByIdOrName($sheetID);
     // Do the callback
     if ($isCallable) {
         call_user_func($callback, $this->sheet);
     }
     // Return the sheet
     return $this->sheet;
 }
开发者ID:angelgurrolac,项目名称:TastyF,代码行数:35,代码来源:LaravelExcelReader.php

示例6: save

 /**
  * Save PHPExcel to file
  *
  * @param	string		$pFileName
  * @throws	Exception
  */
 public function save($pFilename = null)
 {
     // check mbstring.func_overload
     if (ini_get('mbstring.func_overload') != 0) {
         throw new Exception('Multibyte string function overloading in PHP must be disabled.');
     }
     // garbage collect
     $this->_phpExcel->garbageCollect();
     $saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType();
     PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
     // initialize colors array
     $this->_colors = array();
     // Initialise workbook writer
     $this->_writerWorkbook = new PHPExcel_Writer_Excel5_Workbook($this->_phpExcel, $this->_BIFF_version, $this->_str_total, $this->_str_unique, $this->_str_table, $this->_colors, $this->_parser);
     // Initialise worksheet writers
     $countSheets = count($this->_phpExcel->getAllSheets());
     for ($i = 0; $i < $countSheets; ++$i) {
         $phpSheet = $this->_phpExcel->getSheet($i);
         $writerWorksheet = new PHPExcel_Writer_Excel5_Worksheet($this->_BIFF_version, $this->_str_total, $this->_str_unique, $this->_str_table, $this->_colors, $this->_parser, $this->_preCalculateFormulas, $phpSheet);
         $this->_writerWorksheets[$i] = $writerWorksheet;
     }
     // add 15 identical cell style Xfs
     // for now, we use the first cellXf instead of cellStyleXf
     $cellXfCollection = $this->_phpExcel->getCellXfCollection();
     for ($i = 0; $i < 15; ++$i) {
         $this->_writerWorkbook->addXfWriter($cellXfCollection[0], true);
     }
     // add all the cell Xfs
     foreach ($this->_phpExcel->getCellXfCollection() as $style) {
         $this->_writerWorkbook->addXfWriter($style, false);
     }
     // initialize OLE file
     $workbookStreamName = $this->_BIFF_version == 0x600 ? 'Workbook' : 'Book';
     $OLE = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs($workbookStreamName));
     $OLE->init();
     // Write the worksheet streams before the global workbook stream,
     // because the byte sizes of these are needed in the global workbook stream
     $worksheetSizes = array();
     for ($i = 0; $i < $countSheets; ++$i) {
         $this->_writerWorksheets[$i]->close();
         $worksheetSizes[] = $this->_writerWorksheets[$i]->_datasize;
     }
     // add binary data for global workbook stream
     $OLE->append($this->_writerWorkbook->writeWorkbook($worksheetSizes));
     // add binary data for sheet streams
     for ($i = 0; $i < $countSheets; ++$i) {
         $OLE->append($this->_writerWorksheets[$i]->getData());
     }
     $root = new PHPExcel_Shared_OLE_PPS_Root(time(), time(), array($OLE));
     // save the OLE file
     $res = $root->save($pFilename);
     PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType);
 }
开发者ID:nvidela,项目名称:kimkelen,代码行数:59,代码来源:Excel5.php

示例7: 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

示例8: calcSheetOffsets

 /**
  * Calculate offsets for Worksheet BOF records.
  *
  * @access private
  */
 private function calcSheetOffsets()
 {
     $boundsheet_length = 10;
     // fixed length for a BOUNDSHEET record
     // size of Workbook globals part 1 + 3
     $offset = $this->_datasize;
     // add size of Workbook globals part 2, the length of the SHEET records
     $total_worksheets = count($this->phpExcel->getAllSheets());
     foreach ($this->phpExcel->getWorksheetIterator() as $sheet) {
         $offset += $boundsheet_length + strlen(PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($sheet->getTitle()));
     }
     // add the sizes of each of the Sheet substreams, respectively
     for ($i = 0; $i < $total_worksheets; ++$i) {
         $this->worksheetOffsets[$i] = $offset;
         $offset += $this->worksheetSizes[$i];
     }
     $this->biffSize = $offset;
 }
开发者ID:jaya-project,项目名称:zycms,代码行数:23,代码来源:Workbook.php

示例9: getAllMergedCells

 function getAllMergedCells(PHPExcel $objPHPExcel)
 {
     $i = 0;
     foreach ($objPHPExcel->getAllSheets() as $sheet) {
         $this->arr_merged_allCells[$i] = $sheet->getMergeCells();
         $i++;
     }
 }
开发者ID:ViktorKITP,项目名称:schedule,代码行数:8,代码来源:finder.php

示例10: autosizeColumn

    /**
     * Autosize column for document
     *
     * @return int
     */
    public static function autosizeColumn(\PHPExcel $objPHPExcel)
    {
        foreach ($objPHPExcel->getAllSheets() as $sheet) {
            $toCol = $sheet->getHighestColumn();

            $toCol++;
            for ($i = 'A'; $i !== $toCol; $i++) {
                $sheet->getColumnDimension($i)->setAutoSize(true);
            }

            $sheet->calculateColumnWidths();
        }
    }
开发者ID:hendryguna,项目名称:laravel-basic,代码行数:18,代码来源:HTML_reader.php

示例11: _writeMsoDrawingGroup

 /**
  * Writes the MSODRAWINGGROUP record if needed. Possibly split using CONTINUE records.
  */
 private function _writeMsoDrawingGroup()
 {
     // any drawings in this workbook?
     $found = false;
     foreach ($this->_phpExcel->getAllSheets() as $sheet) {
         if (count($sheet->getDrawingCollection()) > 0) {
             $found = true;
         }
     }
     // if there are drawings, then we need to write MSODRAWINGGROUP record
     if ($found) {
         // create intermediate Escher object
         $escher = new PHPExcel_Shared_Escher();
         // dggContainer
         $dggContainer = new PHPExcel_Shared_Escher_DggContainer();
         $escher->setDggContainer($dggContainer);
         // this loop is for determining maximum shape identifier of all drawing
         $spIdMax = 0;
         $totalCountShapes = 0;
         $countDrawings = 0;
         foreach ($this->_phpExcel->getAllsheets() as $sheet) {
             $sheetCountShapes = 0;
             // count number of shapes (minus group shape), in sheet
             if (count($sheet->getDrawingCollection()) > 0) {
                 ++$countDrawings;
                 foreach ($sheet->getDrawingCollection() as $drawing) {
                     ++$sheetCountShapes;
                     ++$totalCountShapes;
                     $spId = $sheetCountShapes | $this->_phpExcel->getIndex($sheet) + 1 << 10;
                     $spIdMax = max($spId, $spIdMax);
                 }
             }
         }
         $dggContainer->setSpIdMax($spIdMax + 1);
         $dggContainer->setCDgSaved($countDrawings);
         $dggContainer->setCSpSaved($totalCountShapes + $countDrawings);
         // total number of shapes incl. one group shapes per drawing
         // bstoreContainer
         $bstoreContainer = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer();
         $dggContainer->setBstoreContainer($bstoreContainer);
         // the BSE's (all the images)
         foreach ($this->_phpExcel->getAllsheets() as $sheet) {
             foreach ($sheet->getDrawingCollection() as $drawing) {
                 if ($drawing instanceof PHPExcel_Worksheet_Drawing) {
                     $filename = $drawing->getPath();
                     list($imagesx, $imagesy, $imageFormat) = getimagesize($filename);
                     switch ($imageFormat) {
                         case 1:
                             // GIF, not supported by BIFF8, we convert to PNG
                             $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
                             $imageResource = imagecreatefromgif($filename);
                             ob_start();
                             imagepng($imageResource);
                             $blipData = ob_get_contents();
                             ob_end_clean();
                             break;
                         case 2:
                             // JPEG
                             $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG;
                             $blipData = file_get_contents($filename);
                             break;
                         case 3:
                             // PNG
                             $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
                             $blipData = file_get_contents($filename);
                             break;
                         case 6:
                             // Windows DIB (BMP), we convert to PNG
                             $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
                             $imageResource = PHPExcel_Shared_Drawing::imagecreatefrombmp($filename);
                             ob_start();
                             imagepng($imageResource);
                             $blipData = ob_get_contents();
                             ob_end_clean();
                             break;
                         default:
                             continue 2;
                     }
                     $blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
                     $blip->setData($blipData);
                     $BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE();
                     $BSE->setBlipType($blipType);
                     $BSE->setBlip($blip);
                     $bstoreContainer->addBSE($BSE);
                 } else {
                     if ($drawing instanceof PHPExcel_Worksheet_MemoryDrawing) {
                         switch ($drawing->getRenderingFunction()) {
                             case PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG:
                                 $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG;
                                 $renderingFunction = 'imagejpeg';
                                 break;
                             case PHPExcel_Worksheet_MemoryDrawing::RENDERING_GIF:
                             case PHPExcel_Worksheet_MemoryDrawing::RENDERING_PNG:
                             case PHPExcel_Worksheet_MemoryDrawing::RENDERING_DEFAULT:
                                 $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
                                 $renderingFunction = 'imagepng';
                                 break;
//.........这里部分代码省略.........
开发者ID:bshaffer,项目名称:Donate-Nashville,代码行数:101,代码来源:Workbook.php

示例12: 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

示例13: 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

示例14: generateSheetData

 /**
  * Generate sheet data
  *
  * @return    string
  * @throws PHPExcel_Writer_Exception
  */
 public function generateSheetData()
 {
     // PHPExcel object known?
     if (is_null($this->_phpExcel)) {
         throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.');
     }
     // Ensure that Spans have been calculated?
     if (!$this->_spansAreCalculated) {
         $this->_calculateSpans();
     }
     // Fetch sheets
     $sheets = array();
     if (is_null($this->_sheetIndex)) {
         $sheets = $this->_phpExcel->getAllSheets();
     } else {
         $sheets[] = $this->_phpExcel->getSheet($this->_sheetIndex);
     }
     // Construct HTML
     $html = '';
     // Loop all sheets
     $sheetId = 0;
     foreach ($sheets as $sheet) {
         // Write table header
         $html .= $this->_generateTableHeader($sheet);
         // 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;
         // row min,max
         $rowMin = $dimension[0][1];
         $rowMax = $dimension[1][1];
         // calculate start of <tbody>, <thead>
         $tbodyStart = $rowMin;
         $theadStart = $theadEnd = 0;
         // default: no <thead>	no </thead>
         if ($sheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
             $rowsToRepeatAtTop = $sheet->getPageSetup()->getRowsToRepeatAtTop();
             // we can only support repeating rows that start at top row
             if ($rowsToRepeatAtTop[0] == 1) {
                 $theadStart = $rowsToRepeatAtTop[0];
                 $theadEnd = $rowsToRepeatAtTop[1];
                 $tbodyStart = $rowsToRepeatAtTop[1] + 1;
             }
         }
         // Loop through cells
         $row = $rowMin - 1;
         while ($row++ < $rowMax) {
             // <thead> ?
             if ($row == $theadStart) {
                 $html .= '		<thead>' . PHP_EOL;
             }
             // <tbody> ?
             if ($row == $tbodyStart) {
                 $html .= '		<tbody>' . PHP_EOL;
             }
             // Write row if there are HTML table cells in it
             if (!isset($this->_isSpannedRow[$sheet->getParent()->getIndex($sheet)][$row])) {
                 // Start a new rowData
                 $rowData = array();
                 // Loop through columns
                 $column = $dimension[0][0] - 1;
                 while ($column++ < $dimension[1][0]) {
                     // Cell exists?
                     if ($sheet->cellExistsByColumnAndRow($column, $row)) {
                         $rowData[$column] = PHPExcel_Cell::stringFromColumnIndex($column) . $row;
                     } else {
                         $rowData[$column] = '';
                     }
                 }
                 $html .= $this->_generateRow($sheet, $rowData, $row - 1);
             }
             // </thead> ?
             if ($row == $theadEnd) {
                 $html .= '		</thead>' . PHP_EOL;
             }
         }
         $html .= $this->_extendRowsForChartsAndImages($sheet, $row);
         // Close table body.
         $html .= '		</tbody>' . PHP_EOL;
         // Write table footer
         $html .= $this->_generateTableFooter();
         // Writing PDF?
         if ($this->_isPdf) {
             if (is_null($this->_sheetIndex) && $sheetId + 1 < $this->_phpExcel->getSheetCount()) {
                 $html .= '<div style="page-break-before:always" />';
             }
         }
         // Next sheet
         ++$sheetId;
     }
     // Return
     return $html;
//.........这里部分代码省略.........
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:101,代码来源:HTML.php

示例15: componentResults_normal_sheet

 public function componentResults_normal_sheet()
 {
     $this->custom_columns = entities\CustomDatatype::getAll();
     $this->cc = isset($this->cc) ? $this->cc : 0;
     require realpath(THEBUGGENIE_VENDOR_PATH) . DS . 'phpoffice' . DS . 'phpexcel' . DS . 'Classes' . DS . 'PHPExcel.php';
     $phpexcel = new \PHPExcel();
     foreach ($phpexcel->getAllSheets() as $index => $sheet) {
         $phpexcel->removeSheetByIndex($index);
     }
     $this->phpexcel = $phpexcel;
     $this->sheet = $phpexcel->createSheet();
 }
开发者ID:founderio,项目名称:thebuggenie,代码行数:12,代码来源:Components.php


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