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


PHP PHPExcel_Worksheet类代码示例

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


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

示例1: mockWorkbook

 /**
  * @return \PHPExcel
  */
 protected function mockWorkbook()
 {
     $workbook = new \PHPExcel();
     $workbook->disconnectWorksheets();
     $workbook->getProperties()->setTitle('mocked');
     $sheet = new \PHPExcel_Worksheet($workbook);
     $sheet->fromArray([['test', 'test', 'test'], ['test', 'test', 'test'], ['test', 'test', 'test'], ['test', 'test', 'test']]);
     $workbook->addSheet($sheet);
     $sheet = new \PHPExcel_Worksheet($workbook);
     $sheet->fromArray([['test', 'test', 'test'], ['test', 'test', 'test'], ['test', 'test', 'test'], ['test', 'test', 'test']]);
     $workbook->addSheet($sheet);
     $workbook->setActiveSheetIndex(0);
     return $workbook;
 }
开发者ID:ymnl007,项目名称:Clerk,代码行数:17,代码来源:WorkbookParserTest.php

示例2: mockSheet

 /**
  * @return \PHPExcel_Worksheet
  */
 protected function mockSheet()
 {
     $workbook = new \PHPExcel();
     $workbook->disconnectWorksheets();
     $sheet = new \PHPExcel_Worksheet($workbook);
     $sheet->setTitle('mocked');
     $sheet->fromArray([['a1', 'b1'], ['a2', 'b2']]);
     return $sheet;
 }
开发者ID:ymnl007,项目名称:Clerk,代码行数:12,代码来源:SheetParserTest.php

示例3: mockRow

 /**
  * @return \PHPExcel
  */
 protected function mockRow()
 {
     $workbook = new \PHPExcel();
     $workbook->disconnectWorksheets();
     $sheet = new \PHPExcel_Worksheet($workbook);
     $sheet->fromArray([['a1', 'b1', 'c1']]);
     $row = new \PHPExcel_Worksheet_Row($sheet, 1);
     return $row;
 }
开发者ID:ymnl007,项目名称:Clerk,代码行数:12,代码来源:RowParserTest.php

示例4: sizeRow

 /**
  * Convert the height of a cell from user's units to pixels. By interpolation
  * the relationship is: y = 4/3x. If the height hasn't been set by the user we
  * use the default value. If the row is hidden we use a value of zero.
  *
  * @param PHPExcel_Worksheet $sheet The sheet
  * @param integer $row The row index (1-based)
  * @return integer The width in pixels
  */
 public static function sizeRow($sheet, $row = 1)
 {
     // default font of the workbook
     $font = $sheet->getParent()->getDefaultStyle()->getFont();
     $rowDimensions = $sheet->getRowDimensions();
     // first find the true row height in pixels (uncollapsed and unhidden)
     if (isset($rowDimensions[$row]) and $rowDimensions[$row]->getRowHeight() != -1) {
         // then we have a row dimension
         $rowDimension = $rowDimensions[$row];
         $rowHeight = $rowDimension->getRowHeight();
         $pixelRowHeight = (int) ceil(4 * $rowHeight / 3);
         // here we assume Arial 10
     } elseif ($sheet->getDefaultRowDimension()->getRowHeight() != -1) {
         // then we have a default row dimension with explicit height
         $defaultRowDimension = $sheet->getDefaultRowDimension();
         $rowHeight = $defaultRowDimension->getRowHeight();
         $pixelRowHeight = PHPExcel_Shared_Drawing::pointsToPixels($rowHeight);
     } else {
         // we don't even have any default row dimension. Height depends on default font
         $pointRowHeight = PHPExcel_Shared_Font::getDefaultRowHeightByFont($font);
         $pixelRowHeight = PHPExcel_Shared_Font::fontSizeToPixels($pointRowHeight);
     }
     // now find the effective row height in pixels
     if (isset($rowDimensions[$row]) and !$rowDimensions[$row]->getVisible()) {
         $effectivePixelRowHeight = 0;
     } else {
         $effectivePixelRowHeight = $pixelRowHeight;
     }
     return $effectivePixelRowHeight;
 }
开发者ID:alyayazilim,项目名称:E-Ticaret-2015,代码行数:39,代码来源:Excel5.php

示例5: getCellValue

 protected function getCellValue(\PHPExcel_Worksheet $sheet, $coord)
 {
     $cell = $sheet->getCell($coord);
     if ($cell) {
         return $cell->getValue();
     }
 }
开发者ID:jlaso,项目名称:translations-apibundle,代码行数:7,代码来源:TranslationsExportToExcelCommand.php

示例6: exportAttributeNames

 /**
  * @param \PHPExcel_Worksheet $sheet
  */
 public function exportAttributeNames($sheet)
 {
     $row = 1;
     foreach ($this->_standardAttributes as $name => $standardAttribute) {
         $sheet->setCellValue($standardAttribute->column . $row, $name);
     }
 }
开发者ID:arogachev,项目名称:yii2-excel,代码行数:10,代码来源:StandardModel.php

示例7: writeDrawings

 /**
  * Write drawings to XML format
  *
  * @param 	PHPExcel_Worksheet				$pWorksheet
  * @return 	string 								XML Output
  * @throws 	Exception
  */
 public function writeDrawings(PHPExcel_Worksheet $pWorksheet = null)
 {
     // Create XML writer
     $objWriter = null;
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK);
     } else {
         $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     // xdr:wsDr
     $objWriter->startElement('xdr:wsDr');
     $objWriter->writeAttribute('xmlns:xdr', 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing');
     $objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
     // Loop trough images and write drawings
     $i = 1;
     $iterator = $pWorksheet->getDrawingCollection()->getIterator();
     while ($iterator->valid()) {
         $this->_writeDrawing($objWriter, $iterator->current(), $i);
         $iterator->next();
         $i++;
     }
     $objWriter->endElement();
     // Return
     return $objWriter->getData();
 }
开发者ID:hostellerie,项目名称:nexpro,代码行数:34,代码来源:Drawing.php

示例8: createStringTable

 /**
  * Create worksheet stringtable
  *
  * @param     PHPExcel_Worksheet     $pSheet                Worksheet
  * @param     string[]                 $pExistingTable     Existing table to eventually merge with
  * @return     string[]                 String table for worksheet
  * @throws     PHPExcel_Writer_Exception
  */
 public function createStringTable($pSheet = null, $pExistingTable = null)
 {
     if ($pSheet !== null) {
         // Create string lookup table
         $aStringTable = array();
         $cellCollection = null;
         $aFlippedStringTable = null;
         // For faster lookup
         // Is an existing table given?
         if ($pExistingTable !== null && is_array($pExistingTable)) {
             $aStringTable = $pExistingTable;
         }
         // Fill index array
         $aFlippedStringTable = $this->flipStringTable($aStringTable);
         // Loop through cells
         foreach ($pSheet->getCellCollection() as $cellID) {
             $cell = $pSheet->getCell($cellID);
             $cellValue = $cell->getValue();
             if (!is_object($cellValue) && $cellValue !== null && $cellValue !== '' && !isset($aFlippedStringTable[$cellValue]) && ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_STRING || $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_STRING2 || $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_NULL)) {
                 $aStringTable[] = $cellValue;
                 $aFlippedStringTable[$cellValue] = true;
             } elseif ($cellValue instanceof PHPExcel_RichText && $cellValue !== null && !isset($aFlippedStringTable[$cellValue->getHashCode()])) {
                 $aStringTable[] = $cellValue;
                 $aFlippedStringTable[$cellValue->getHashCode()] = true;
             }
         }
         return $aStringTable;
     } else {
         throw new PHPExcel_Writer_Exception("Invalid PHPExcel_Worksheet object passed.");
     }
 }
开发者ID:alyayazilim,项目名称:E-Ticaret-2015,代码行数:39,代码来源:StringTable.php

示例9: addLine

 /**
  * @param \PHPExcel_Worksheet $sheet
  * @param integer $offset
  * @param array $values
  */
 public function addLine($sheet, $offset, $values)
 {
     $column = 'A';
     foreach ($values as $value) {
         $cellCoordinates = $column++ . (string) $offset;
         $sheet->setCellValue($cellCoordinates, $value);
     }
 }
开发者ID:netis-pl,项目名称:yii2-crud,代码行数:13,代码来源:XlsResponseFormatter.php

示例10: addSheet

 protected function addSheet($name)
 {
     $sheet = new PHPExcel_Worksheet($this->excel, $name);
     $sheet->getSheetView()->setZoomScale(75);
     $this->excel->addSheet($sheet);
     $this->excel->setActiveSheetIndex($this->excel->getSheetCount() - 1);
     $this->sheet = $sheet;
 }
开发者ID:RodrigoBattagliero,项目名称:Cifras,代码行数:8,代码来源:BaseFeed.php

示例11: prepare

 protected function prepare(\PHPExcel_Worksheet $templateSheet)
 {
     $this->output = new \PHPExcel();
     $outputSheet = $this->output->getActiveSheet();
     $outputSheet->setTitle('Report');
     $this->templateSheet = $this->output->addExternalSheet($templateSheet);
     foreach ($this->templateSheet->getColumnDimensions() as $col => $columnDimension) {
         $outputSheet->getColumnDimension($col)->setWidth($columnDimension->getWidth());
     }
 }
开发者ID:mathielen,项目名称:report-write-engine,代码行数:10,代码来源:ExcelCanvasWriter.php

示例12: copyRows

/**
 * 行を完全コピーする
 *
 * http://blog.kotemaru.org/old/2012/04/06.html より
 * @param PHPExcel_Worksheet $sheet
 * @param int $srcRow
 * @param int $dstRow
 * @param int $height
 * @param int $width
 * @throws PHPExcel_Exception
 */
function copyRows(PHPExcel_Worksheet $sheet, $srcRow, $dstRow, $height, $width)
{
    for ($row = 0; $row < $height; $row++) {
        // セルの書式と値の複製
        for ($col = 0; $col < $width; $col++) {
            $cell = $sheet->getCellByColumnAndRow($col, $srcRow + $row);
            $style = $sheet->getStyleByColumnAndRow($col, $srcRow + $row);
            $dstCell = PHPExcel_Cell::stringFromColumnIndex($col) . (string) ($dstRow + $row);
            $sheet->setCellValue($dstCell, $cell->getValue());
            $sheet->duplicateStyle($style, $dstCell);
        }
        // 行の高さ複製。
        $h = $sheet->getRowDimension($srcRow + $row)->getRowHeight();
        $sheet->getRowDimension($dstRow + $row)->setRowHeight($h);
    }
    // セル結合の複製
    // - $mergeCell="AB12:AC15" 複製範囲の物だけ行を加算して復元。
    // - $merge="AB16:AC19"
    foreach ($sheet->getMergeCells() as $mergeCell) {
        $mc = explode(":", $mergeCell);
        $col_s = preg_replace("/[0-9]*/", "", $mc[0]);
        $col_e = preg_replace("/[0-9]*/", "", $mc[1]);
        $row_s = (int) preg_replace("/[A-Z]*/", "", $mc[0]) - $srcRow;
        $row_e = (int) preg_replace("/[A-Z]*/", "", $mc[1]) - $srcRow;
        // 複製先の行範囲なら。
        if (0 <= $row_s && $row_s < $height) {
            $merge = $col_s . (string) ($dstRow + $row_s) . ":" . $col_e . (string) ($dstRow + $row_e);
            $sheet->mergeCells($merge);
        }
    }
}
开发者ID:suin,项目名称:phpexcel-playground,代码行数:42,代码来源:07-output-copy-paste-range.php

示例13: __construct

 public function __construct(\PHPExcel_Worksheet $worksheet, $parent_filename)
 {
     $this->name = $this->genName($parent_filename, $worksheet->getTitle());
     $row_it = $worksheet->getRowIterator();
     $this->header = new \excel2sql\SqlHeader($row_it->current());
     $this->entries = array();
     for ($row_it->next(); $row_it->valid(); $row_it->next()) {
         $rowindex = $row_it->current()->getRowIndex();
         $this->entries[] = new \excel2sql\SqlEntry($rowindex, $this->header, $worksheet);
     }
 }
开发者ID:brandon-garcia,项目名称:statsdashboard,代码行数:11,代码来源:SqlTable.php

示例14: buildFooter

 private function buildFooter()
 {
     $column_index = 0;
     foreach ($this->responseTableView->getFooterData() as $footer) {
         $column_name = Utility::getNameFromNumber($column_index++);
         $this->sheet->setCellValue($column_name . $this->row_index, $footer);
         $this->sheet->getStyle($column_name . $this->row_index)->getFont()->setBold(true);
     }
 }
开发者ID:sensorsix,项目名称:app,代码行数:9,代码来源:ResponseExcelExporter.class.php

示例15: getNextDataset

 public function getNextDataset()
 {
     $dataset = new Dataset();
     for ($col = 0; $col < $this->highestColumnIndex; ++$col) {
         $cell = $this->worksheet->getCellByColumnAndRow($col, $this->rowPointer);
         $dataset->add($this->header[$col], $cell->getValue());
     }
     $this->rowPointer++;
     return $dataset;
 }
开发者ID:r3h6,项目名称:TYPO3.EXT.data_port,代码行数:10,代码来源:ExcelDataProvider.php


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