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


PHP PHPExcel_Worksheet_Drawing::setWidth方法代码示例

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


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

示例1: load


//.........这里部分代码省略.........
							if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->tabColor)) {
								if (isset($xmlSheet->sheetPr->tabColor['rgb'])) {
									$docSheet->getTabColor()->setARGB( (string)$xmlSheet->sheetPr->tabColor['rgb'] );
								}
							}

							if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->outlinePr)) {
								if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) && $xmlSheet->sheetPr->outlinePr['summaryRight'] == false) {
									$docSheet->setShowSummaryRight(false);
								} else {
									$docSheet->setShowSummaryRight(true);
								}

								if (isset($xmlSheet->sheetPr->outlinePr['summaryBelow']) && $xmlSheet->sheetPr->outlinePr['summaryBelow'] == false) {
									$docSheet->setShowSummaryBelow(false);
								} else {
									$docSheet->setShowSummaryBelow(true);
								}
							}

							if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->pageSetUpPr)) {
								if (isset($xmlSheet->sheetPr->pageSetUpPr['fitToPage']) && $xmlSheet->sheetPr->pageSetUpPr['fitToPage'] == false) {
									$docSheet->getPageSetup()->setFitToPage(false);
								} else {
									$docSheet->getPageSetup()->setFitToPage(true);
								}
							}

							if (isset($xmlSheet->sheetFormatPr)) {
								if (isset($xmlSheet->sheetFormatPr['customHeight']) && ((string)$xmlSheet->sheetFormatPr['customHeight'] == '1' || strtolower((string)$xmlSheet->sheetFormatPr['customHeight']) == 'true') && isset($xmlSheet->sheetFormatPr['defaultRowHeight'])) {
									$docSheet->getDefaultRowDimension()->setRowHeight( (float)$xmlSheet->sheetFormatPr['defaultRowHeight'] );
								}
								if (isset($xmlSheet->sheetFormatPr['defaultColWidth'])) {
									$docSheet->getDefaultColumnDimension()->setWidth( (float)$xmlSheet->sheetFormatPr['defaultColWidth'] );
								}
							}

							if (isset($xmlSheet->cols) && !$this->_readDataOnly) {
								foreach ($xmlSheet->cols->col as $col) {
									for ($i = intval($col["min"]) - 1; $i < intval($col["max"]); ++$i) {
										if ($col["style"] && !$this->_readDataOnly) {
											$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setXfIndex(intval($col["style"]));
										}
										if ($col["bestFit"]) {
											//$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setAutoSize(true);
										}
										if ($col["hidden"]) {
											$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setVisible(false);
										}
										if ($col["collapsed"]) {
											$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setCollapsed(true);
										}
										if ($col["outlineLevel"] > 0) {
											$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setOutlineLevel(intval($col["outlineLevel"]));
										}
										$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setWidth(floatval($col["width"]));

										if (intval($col["max"]) == 16384) {
											break;
										}
									}
								}
							}

							if (isset($xmlSheet->printOptions) && !$this->_readDataOnly) {
								if ($xmlSheet->printOptions['gridLinesSet'] == 'true' && $xmlSheet->printOptions['gridLinesSet'] == '1') {
开发者ID:Opmantek,项目名称:open-audit,代码行数:67,代码来源:Excel2007.php

示例2: addImageFooter

function addImageFooter($objPHPExcel, $index)
{
    $objDrawing = new PHPExcel_Worksheet_Drawing();
    $objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
    $objDrawing->setName("name");
    $objDrawing->setDescription("Description");
    $objDrawing->setPath('../img/LogoBSW.png');
    $objDrawing->setCoordinates("A" . $index);
    $objDrawing->setOffsetX(10);
    $objDrawing->setWidth(20);
    $objDrawing->setHeight(20);
}
开发者ID:rafaelurrutia,项目名称:techwizard-nodejs,代码行数:12,代码来源:htmlTableGenerateExcelFile.php

示例3: _excel_add_image

 private function _excel_add_image($sheet, $image, &$i)
 {
     if (!(string) $image) {
         return --$i ? '' : '';
     }
     download_web_file($image->url('350x230p'), $filepath = FCPATH . implode(DIRECTORY_SEPARATOR, array_merge(Cfg::system('orm_uploader', 'uploader', 'temp_directory'), array((string) $image))));
     $objDrawing = new PHPExcel_Worksheet_Drawing();
     $objDrawing->setPath($filepath);
     $j = $j = (ceil($i / 3) - 1) * 7 + 1;
     $objDrawing->setCoordinates(($i % 3 < 2 ? $i % 3 < 1 ? 'G' : 'A' : 'D') . $j);
     $objDrawing->setOffsetX(20);
     $objDrawing->setOffsetY(8);
     $objDrawing->setWidth(175);
     $objDrawing->setWorksheet($sheet);
     return $filepath;
 }
开发者ID:comdan66,项目名称:zeusdesign,代码行数:16,代码来源:invoices.php

示例4: array

// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);
$sharedStyle1 = new PHPExcel_Style();
$sharedStyle2 = new PHPExcel_Style();
$sharedStyle1->applyFromArray(array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'top' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'left' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM))));
$objPHPExcel->getActiveSheet()->setSharedStyle($sharedStyle1, "A12:I{$nox}");
// Set style for header row using alternative method
$objPHPExcel->getActiveSheet()->getStyle('A12:I12')->applyFromArray(array('font' => array('bold' => true), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT), 'borders' => array('top' => array('style' => PHPExcel_Style_Border::BORDER_THIN)), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR, 'rotation' => 90, 'startcolor' => array('argb' => 'FFA0A0A0'), 'endcolor' => array('argb' => 'FFFFFFFF'))));
// Add a drawing to the worksheet
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('Logo');
$objDrawing->setDescription('Logo');
$objDrawing->setPath('images/logo_smk.png');
$objDrawing->setCoordinates('D2');
$objDrawing->setHeight(100);
$objDrawing->setWidth(100);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
//untuk font dan size data
$objPHPExcel->getActiveSheet()->getStyle('A12:I1000')->getFont()->setName('Arial');
$objPHPExcel->getActiveSheet()->getStyle('A12:I1000')->getFont()->setSize(9);
// Mulai Merge cells Judul
$objPHPExcel->getActiveSheet()->mergeCells('D2:I2');
$objPHPExcel->getActiveSheet()->setCellValue('D2', "DAFTAR DATA SISWA");
$objPHPExcel->getActiveSheet()->mergeCells('D3:I3');
$objPHPExcel->getActiveSheet()->setCellValue('D3', "SMK NEGERI 1 PAKONG");
$objPHPExcel->getActiveSheet()->getStyle('D2:I5')->getFont()->setName('Arial');
$objPHPExcel->getActiveSheet()->getStyle('D2:I5')->getFont()->setSize(14);
$objPHPExcel->getActiveSheet()->getStyle('D2:I5')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('D3:I5')->getFont()->setSize(13);
// untuk sub judul
$objPHPExcel->getActiveSheet()->setCellValue('I7', "JUMLAH DATA : {$jumlah}");
开发者ID:holildoank,项目名称:SI-Rumah-Kost-1,代码行数:31,代码来源:laporan-siswa.php

示例5: load


//.........这里部分代码省略.........
                 }
                 $xmlWorkbook = simplexml_load_string($zip->getFromName("{$rel['Target']}"));
                 //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");
                 $sheetId = 0;
                 foreach ($xmlWorkbook->sheets->sheet as $eleSheet) {
                     $docSheet = $excel->createSheet();
                     $docSheet->setTitle((string) $eleSheet["name"]);
                     $fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")];
                     $xmlSheet = simplexml_load_string($zip->getFromName("{$dir}/{$fileWorksheet}"));
                     //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");
                     $sharedFormulas = array();
                     if (isset($xmlSheet->sheetViews) && isset($xmlSheet->sheetViews->sheetView)) {
                         if (isset($xmlSheet->sheetViews->sheetView['showGridLines'])) {
                             $docSheet->setShowGridLines($xmlSheet->sheetViews->sheetView['showGridLines'] ? true : false);
                         }
                     }
                     if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->outlinePr)) {
                         if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) && $xmlSheet->sheetPr->outlinePr['summaryRight'] == false) {
                             $docSheet->setShowSummaryRight(false);
                         } else {
                             $docSheet->setShowSummaryRight(true);
                         }
                         if (isset($xmlSheet->sheetPr->outlinePr['summaryBelow']) && $xmlSheet->sheetPr->outlinePr['summaryBelow'] == false) {
                             $docSheet->setShowSummaryBelow(false);
                         } else {
                             $docSheet->setShowSummaryBelow(true);
                         }
                     }
                     if (isset($xmlSheet->sheetFormatPr)) {
                         if (isset($xmlSheet->sheetFormatPr['customHeight']) && ((string) $xmlSheet->sheetFormatPr['customHeight'] == '1' || strtolower((string) $xmlSheet->sheetFormatPr['customHeight']) == 'true') && isset($xmlSheet->sheetFormatPr['defaultRowHeight'])) {
                             $docSheet->getDefaultRowDimension()->setRowHeight((double) $xmlSheet->sheetFormatPr['defaultRowHeight']);
                         }
                         if (isset($xmlSheet->sheetFormatPr['defaultColWidth'])) {
                             $docSheet->getDefaultColumnDimension()->setWidth((double) $xmlSheet->sheetFormatPr['defaultColWidth']);
                         }
                     }
                     if (isset($xmlSheet->cols) && !$this->_readDataOnly) {
                         foreach ($xmlSheet->cols->col as $col) {
                             for ($i = intval($col["min"]) - 1; $i < intval($col["max"]); $i++) {
                                 if ($col["bestFit"]) {
                                     $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setAutoSize(true);
                                 }
                                 if ($col["hidden"]) {
                                     $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setVisible(false);
                                 }
                                 if ($col["collapsed"]) {
                                     $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setCollapsed(true);
                                 }
                                 if ($col["outlineLevel"] > 0) {
                                     $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setOutlineLevel(intval($col["outlineLevel"]));
                                 }
                                 $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setWidth(floatval($col["width"]));
                                 if (intval($col["max"]) == 16384) {
                                     break;
                                 }
                             }
                         }
                     }
                     if (isset($xmlSheet->printOptions) && !$this->_readDataOnly) {
                         if ($xmlSheet->printOptions['gridLinesSet'] == 'true' && $xmlSheet->printOptions['gridLinesSet'] == '1') {
                             $docSheet->setShowGridlines(true);
                         }
                         if ($xmlSheet->printOptions['gridLines'] == 'true' || $xmlSheet->printOptions['gridLines'] == '1') {
                             $docSheet->setPrintGridlines(true);
                         }
                         if ($xmlSheet->printOptions['horizontalCentered']) {
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:67,代码来源:Excel2007.php

示例6: array

$objPHPExcel->getActiveSheet()->getStyle("C5:C5")->getFont()->setBold(false)->setName('Verdana')->setSize(10);
//////////////////////////
$objPHPExcel->setActiveSheetIndex(0)->setCellValue("G5", 'HASTA:');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('G5:G5');
$objPHPExcel->getActiveSheet()->getStyle("G5:G5")->getFont()->setBold(false)->setName('Verdana')->setSize(10);
//////////////////////////
$objPHPExcel->setActiveSheetIndex(0)->setCellValue("H5", $_GET['fin']);
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('H5:H5');
$objPHPExcel->getActiveSheet()->getStyle("H5:H5")->getFont()->setBold(false)->setName('Verdana')->setSize(10);
//////////////////////////
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('PHPExcel logo');
$objDrawing->setDescription('PHPExcel logo');
$objDrawing->setPath('../images/logo_empresa.jpg');
//
$objDrawing->setWidth(160);
// sets the image
$objDrawing->setHeight(60);
$objDrawing->setCoordinates('L2');
// pins the top-left corner
$objDrawing->setOffsetX(10);
// pins the top left
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
//////////////////////////////////////////////////////////
$styleArray = array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)));
$objPHPExcel->getActiveSheet()->getStyle('B5:L5')->applyFromArray($styleArray);
unset($styleArray);
//////////////////////////////////////////////////////////
$total = 0;
$sub = 0;
$desc = 0;
开发者ID:kailIII,项目名称:catalogo,代码行数:31,代码来源:facturasCompras.php

示例7: load


//.........这里部分代码省略.........
                                     $docSheet->setSelectedCells($sqref);
                                 }
                             }
                         }
                         if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->tabColor)) {
                             if (isset($xmlSheet->sheetPr->tabColor['rgb'])) {
                                 $docSheet->getTabColor()->setARGB((string) $xmlSheet->sheetPr->tabColor['rgb']);
                             }
                         }
                         if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->outlinePr)) {
                             if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) && !self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryRight'])) {
                                 $docSheet->setShowSummaryRight(FALSE);
                             } else {
                                 $docSheet->setShowSummaryRight(TRUE);
                             }
                             if (isset($xmlSheet->sheetPr->outlinePr['summaryBelow']) && !self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryBelow'])) {
                                 $docSheet->setShowSummaryBelow(FALSE);
                             } else {
                                 $docSheet->setShowSummaryBelow(TRUE);
                             }
                         }
                         if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->pageSetUpPr)) {
                             if (isset($xmlSheet->sheetPr->pageSetUpPr['fitToPage']) && !self::boolean((string) $xmlSheet->sheetPr->pageSetUpPr['fitToPage'])) {
                                 $docSheet->getPageSetup()->setFitToPage(FALSE);
                             } else {
                                 $docSheet->getPageSetup()->setFitToPage(TRUE);
                             }
                         }
                         if (isset($xmlSheet->sheetFormatPr)) {
                             if (isset($xmlSheet->sheetFormatPr['customHeight']) && self::boolean((string) $xmlSheet->sheetFormatPr['customHeight']) && isset($xmlSheet->sheetFormatPr['defaultRowHeight'])) {
                                 $docSheet->getDefaultRowDimension()->setRowHeight((double) $xmlSheet->sheetFormatPr['defaultRowHeight']);
                             }
                             if (isset($xmlSheet->sheetFormatPr['defaultColWidth'])) {
                                 $docSheet->getDefaultColumnDimension()->setWidth((double) $xmlSheet->sheetFormatPr['defaultColWidth']);
                             }
                             if (isset($xmlSheet->sheetFormatPr['zeroHeight']) && (string) $xmlSheet->sheetFormatPr['zeroHeight'] == '1') {
                                 $docSheet->getDefaultRowDimension()->setzeroHeight(true);
                             }
                         }
                         if (isset($xmlSheet->cols) && !$this->_readDataOnly) {
                             foreach ($xmlSheet->cols->col as $col) {
                                 for ($i = intval($col["min"]) - 1; $i < intval($col["max"]); ++$i) {
                                     if ($col["style"] && !$this->_readDataOnly) {
                                         $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setXfIndex(intval($col["style"]));
                                     }
                                     if (self::boolean($col["bestFit"])) {
                                         //$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setAutoSize(TRUE);
                                     }
                                     if (self::boolean($col["hidden"])) {
                                         $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setVisible(FALSE);
                                     }
                                     if (self::boolean($col["collapsed"])) {
                                         $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setCollapsed(TRUE);
                                     }
                                     if ($col["outlineLevel"] > 0) {
                                         $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setOutlineLevel(intval($col["outlineLevel"]));
                                     }
                                     $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setWidth(floatval($col["width"]));
                                     if (intval($col["max"]) == 16384) {
                                         break;
                                     }
                                 }
                             }
                         }
                         if (isset($xmlSheet->printOptions) && !$this->_readDataOnly) {
                             if (self::boolean((string) $xmlSheet->printOptions['gridLinesSet'])) {
开发者ID:jimlongo56,项目名称:bhouse,代码行数:67,代码来源:Excel2007.php

示例8: actionPollRating

 public function actionPollRating()
 {
     $orderIds = trim(Yii::app()->request->getParam('orderIds'));
     //获取数据
     $data = PollRating::model()->getExportData($orderIds);
     //获取附件
     $attachments = FileUpload::model()->getFiles($orderIds);
     $pics = array();
     foreach ($attachments as $value) {
         $pics[$value['orderid']][] = $value['file_path'];
     }
     Yii::$enableIncludePath = false;
     //Yii::import('application.extension.PHPExcel', 1);
     $objPHPExcel = new PHPExcel();
     // Add some data
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', '处理日期')->setCellValue('B1', '产品类型')->setCellValue('C1', '开始时间')->setCellValue('D1', '结束时间')->setCellValue('E1', '处理时间')->setCellValue('F1', '账号')->setCellValue('G1', '订单号')->setCellValue('H1', '申请服务')->setCellValue('I1', '具体内容')->setCellValue('J1', '问题描述')->setCellValue('K1', '处理情况')->setCellValue('L1', '备注')->setCellValue('M1', '处理人员')->setCellValue('N1', '附件');
     //最多支持5张附件图片
     $picColumn = array('N', 'O', 'P', 'Q', 'R');
     $i = 2;
     foreach ($data as $value) {
         $endTime = empty($value["updatetime"]) ? time() : strtotime($value["updatetime"]);
         $startTime = empty($value["intitime"]) ? 0 : strtotime($value["intitime"]);
         $subTime = $endTime - $startTime;
         $remark = "";
         $res = unserialize(base64_decode($value['content']));
         $remarkKey = mb_convert_encoding('备注_', 'GBK', 'UTF8');
         if (isset($res[$remarkKey])) {
             $remark = mb_convert_encoding($res[$remarkKey], 'UTF8', 'GBK');
         }
         $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A' . $i, strstr($value["intitime"], ' ', true))->setCellValueExplicit('B' . $i, mb_convert_encoding($value['game_name'], 'UTF8', 'GBK'), PHPExcel_Cell_DataType::TYPE_STRING)->setCellValue('C' . $i, trim(strstr($value["intitime"], ' ')))->setCellValueExplicit('D' . $i, $value['updatetime'], PHPExcel_Cell_DataType::TYPE_STRING)->setCellValueExplicit('E' . $i, $subTime, PHPExcel_Cell_DataType::TYPE_STRING)->setCellValue('F' . $i, $value['consumeraccount'])->setCellValueExplicit('G' . $i, $value['ordernum'], PHPExcel_Cell_DataType::TYPE_STRING)->setCellValue('H' . $i, $value['typename'])->setCellValue('I' . $i, $value['typedetail'])->setCellValueExplicit('J' . $i, $remark, PHPExcel_Cell_DataType::TYPE_STRING)->setCellValue('K' . $i, mb_convert_encoding($value['status'], 'UTF8', 'GBK'))->setCellValue('L' . $i, mb_convert_encoding($value['remark'], 'UTF-8', 'GBK'))->setCellValue('M' . $i, mb_convert_encoding($value['username'], 'UTF8', 'GBK'));
         //图片
         if (isset($pics[$value['orderid']])) {
             foreach ($pics[$value['orderid']] as $key => $pic) {
                 $objDrawing = new PHPExcel_Worksheet_Drawing();
                 $objDrawing->setPath(_PATH_UPLOAD . DIRECTORY_SEPARATOR . $pic);
                 $objDrawing->setCoordinates($picColumn[$key] . $i);
                 $objDrawing->setName($pic);
                 $objDrawing->setHeight(60);
                 $objDrawing->setWidth(60);
                 $objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
             }
         }
         //设置行高
         $objPHPExcel->getActiveSheet()->getRowDimension($i)->setRowHeight(30);
         $i++;
     }
     $filename = mb_convert_encoding('所有接待日志', 'GBK', 'UTF8') . date('YmdHis');
     header('Content-Type: application/vnd.ms-excel');
     header('Content-Disposition: attachment;filename="' . $filename . '.xls"');
     header('Cache-Control: max-age=0');
     // If you're serving to IE 9, then the following may be needed
     header('Cache-Control: max-age=1');
     // If you're serving to IE over SSL, then the following may be needed
     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     // Date in the past
     header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     // always modified
     header('Cache-Control: cache, must-revalidate');
     // HTTP/1.1
     header('Pragma: public');
     // HTTP/1.0
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
     $objWriter->save('php://output');
     exit;
 }
开发者ID:jy02511876,项目名称:extjs,代码行数:65,代码来源:ExportController.php

示例9: postAction


//.........这里部分代码省略.........
         // Create new PHPExcel object
         //echo date('H:i:s') , " Create new PHPExcel object" , EOL;
         $objPHPExcel = new PHPExcel();
         ini_set('display_errors', TRUE);
         ini_set('display_startup_errors', TRUE);
         define('EOL', PHP_SAPI == 'cli' ? PHP_EOL : '<br />');
         date_default_timezone_set('Europe/London');
         /** Include PHPExcel_IOFactory */
         require_once 'Classes/PHPExcel/IOFactory.php';
         $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
         //********* CUSTOM CODE ****************************
         // Create a first sheet, representing sales data
         //echo date('H:i:s') , " Add some data" , EOL;
         $objPHPExcel->setActiveSheetIndex(0);
         $objPHPExcel->getActiveSheet()->getCell('B1')->setValue("500 Sauve West\nMontreal, Quebec\nCanada\nH3L 1Z8");
         $objPHPExcel->getActiveSheet()->getStyle('B1')->getAlignment()->setWrapText(true);
         $objPHPExcel->getActiveSheet()->getCell('C1')->setValue("info@italgemjewellers.com\nTel   (514) 388-5777\nFax  (514) 384-5777");
         $objPHPExcel->getActiveSheet()->getStyle('C1')->getAlignment()->setWrapText(true);
         // Merge cells
         //echo date('H:i:s') , " Merge cells" , EOL;
         $objPHPExcel->getActiveSheet()->mergeCells('F1:G1');
         $objPHPExcel->getActiveSheet()->getCell('F1')->setValue("Quotation preparred for \nClientABCD");
         $objPHPExcel->getActiveSheet()->getStyle('F1')->getAlignment()->setWrapText(true);
         $objPHPExcel->getActiveSheet()->setCellValue('A3', 'STYLE CODE #');
         $objPHPExcel->getActiveSheet()->setCellValue('B3', 'PICTURE');
         $objPHPExcel->getActiveSheet()->setCellValue('C3', 'DESCRIPTION');
         $objPHPExcel->getActiveSheet()->setCellValue('D3', 'RETAIL');
         $objPHPExcel->getActiveSheet()->setCellValue('E3', 'WHOLE SALE PRICE');
         $objPHPExcel->getActiveSheet()->setCellValue('F3', 'YOUR PRICE');
         $objPHPExcel->getActiveSheet()->setCellValue('G3', 'Quanity ');
         // Set column widths
         //echo date('H:i:s') , " Set column widths" , EOL;
         $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(98);
         $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(40);
         $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(50);
         $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(80);
         $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(20);
         $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20);
         $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(20);
         $objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(20);
         // Set fonts
         //echo date('H:i:s') , " Set fonts" , EOL;
         $objPHPExcel->getActiveSheet()->getStyle("B1")->getFont()->setName('Times New Roman')->setSize(15)->getColor()->setRGB('000000');
         $objPHPExcel->getActiveSheet()->getStyle("C1")->getFont()->setName('Times New Roman')->setSize(15)->getColor()->setRGB('000000');
         $objPHPExcel->getActiveSheet()->getStyle("F1")->getFont()->setBold(true)->setName('Times New Roman')->setSize(18)->getColor()->setRGB('000000');
         $objPHPExcel->getActiveSheet()->getStyle('B1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
         $objPHPExcel->getActiveSheet()->getStyle('C1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
         $objPHPExcel->getActiveSheet()->getStyle('F1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
         $objPHPExcel->getActiveSheet()->getStyle('F1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
         // Set thin black border outline around column
         //echo date('H:i:s') , " Set thin black border outline around column" , EOL;
         $styleThinBlackBorderOutline = array('borders' => array('outline' => array('style' => PHPExcel_Style_Border::BORDER_THIN, 'color' => array('argb' => 'FF000000'))));
         $objPHPExcel->getActiveSheet()->getStyle('A1:D1')->applyFromArray($styleThinBlackBorderOutline);
         $objPHPExcel->getActiveSheet()->getStyle('G1')->applyFromArray($styleThinBlackBorderOutline);
         $objPHPExcel->getActiveSheet()->getStyle('A2')->applyFromArray($styleThinBlackBorderOutline);
         $objPHPExcel->getActiveSheet()->getStyle('B2')->applyFromArray($styleThinBlackBorderOutline);
         $objPHPExcel->getActiveSheet()->getStyle('C2')->applyFromArray($styleThinBlackBorderOutline);
         $objPHPExcel->getActiveSheet()->getStyle('D2')->applyFromArray($styleThinBlackBorderOutline);
         $objPHPExcel->getActiveSheet()->getStyle('E2')->applyFromArray($styleThinBlackBorderOutline);
         $objPHPExcel->getActiveSheet()->getStyle('F2')->applyFromArray($styleThinBlackBorderOutline);
         $objPHPExcel->getActiveSheet()->getStyle('G2')->applyFromArray($styleThinBlackBorderOutline);
         $objPHPExcel->getActiveSheet()->getStyle('A3')->applyFromArray($styleThinBlackBorderOutline);
         $objPHPExcel->getActiveSheet()->getStyle('B3')->applyFromArray($styleThinBlackBorderOutline);
         $objPHPExcel->getActiveSheet()->getStyle('C3')->applyFromArray($styleThinBlackBorderOutline);
         $objPHPExcel->getActiveSheet()->getStyle('D3')->applyFromArray($styleThinBlackBorderOutline);
         $objPHPExcel->getActiveSheet()->getStyle('E3')->applyFromArray($styleThinBlackBorderOutline);
开发者ID:planetwebsolution,项目名称:Magento-Sample-Code,代码行数:67,代码来源:MyformController.php

示例10: write

 function write($content, $char = "A1", $ispic = false, $align = "", $isnum = false)
 {
     //如果是图片
     if ($ispic && is_file($content) && file_exists($content)) {
         $w_h = explode(":", $ispic);
         $pic_width = intval($w_h[0]) > 0 ? intval($w_h[0]) : 100;
         $pic_height = intval($w_h[1]) > 0 ? intval($w_h[1]) : 100;
         $XLS_D = new PHPExcel_Worksheet_Drawing();
         //画图片
         $XLS_D->setPath($content);
         $XLS_D->setOffsetX(6);
         $XLS_D->setOffsetY(3);
         $XLS_D->setHeight($pic_width);
         $XLS_D->setWidth($pic_height);
         $XLS_D->setCoordinates($char);
         $XLS_D->getShadow()->setVisible(true);
         $XLS_D->setWorksheet($this->phpexcel->getActiveSheet());
     } else {
         //居中和居右设置
         if ($align == "center") {
             $this->phpexcel->getActiveSheet()->getStyle($char)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
         } elseif ($align == "right") {
             $this->phpexcel->getActiveSheet()->getStyle($char)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
         }
         //垂直居中
         $this->phpexcel->getActiveSheet()->getStyle($char)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
         $this->phpexcel->getActiveSheet()->getStyle($char)->getAlignment()->setWrapText(true);
         if (!$isnum) {
             $this->phpexcel->getActiveSheet()->setCellValueExplicit($char, $content, PHPExcel_Cell_DataType::TYPE_STRING);
         } else {
             $this->phpexcel->getActiveSheet()->setCellValue($char, $content);
         }
     }
 }
开发者ID:norain2050,项目名称:hkgbf,代码行数:34,代码来源:excel_out.php

示例11: setDataIntoSheet

 private function setDataIntoSheet($spaces, &$objWorksheet, &$imageNeedDelete = array())
 {
     $alignCenter = array('alignment' => array('vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER));
     $first = 6;
     $i = 1;
     App::import('Vendor', 'PHPExcel', array('file' => 'PHPExcel/PHPExcel.php'));
     Configure::load('appconfig');
     $typeSpace = Configure::read('TypeSpace');
     $typeLease = Configure::read('TypeLease');
     $objWorksheet->setCellValue('E3', date('m/d/Y'));
     foreach ($spaces as $value) {
         //fill alignment
         $row = $first + $i;
         $objWorksheet->setCellValue('A' . $row, $i);
         $objWorksheet->setCellValue('B' . $row, $value['Space']['address'] . ', ' . $value['City']['name'] . ', ' . $value['City']['State']['name']);
         $objWorksheet->setCellValue('C' . $row, $value['Space']['zip_code']);
         $objWorksheet->setCellValue('D' . $row, $value['Space']['floor']);
         $objWorksheet->setCellValue('E' . $row, $value['Space']['square_footage']);
         $objWorksheet->setCellValue('F' . $row, $value['Space']['availability']);
         $objWorksheet->setCellValue('G' . $row, $typeSpace[$value['Space']['space']]);
         $objWorksheet->setCellValue('H' . $row, $value['Space']['price_monthly']);
         $objWorksheet->setCellValue('I' . $row, $value['Space']['price_year']);
         $totalYear = 0;
         $totalMonth = 0;
         if (!empty($value['Space']['price_monthly'])) {
             $totalMonth = $value['Space']['price_monthly'] * $value['Space']['square_footage'];
         }
         if (!empty($value['Space']['price_year'])) {
             $totalYear = $value['Space']['price_year'] / 12 * $value['Space']['square_footage'];
         }
         $objWorksheet->setCellValue('J' . $row, round($totalMonth, 2));
         $objWorksheet->setCellValue('K' . $row, round($totalYear, 2));
         $objWorksheet->setCellValue('L' . $row, $typeLease[$value['Space']['type_lease']]);
         $objWorksheet->setCellValue('M' . $row, $value['Space']['rating']);
         $objWorksheet->setCellValue('N' . $row, $value['Space']['general_space_note']);
         $listNote = $value['SpaceNote'];
         $str = '';
         foreach ($listNote as $item) {
             $str .= $item['SpaceNoteTemplate']['question'];
             if (isset($item['answer']) && $item['answer'] == 1) {
                 $str .= " (True)\r\n";
             } else {
                 $str .= " (False)\r\n";
             }
         }
         $objWorksheet->setCellValue('O' . $row, $str);
         $objWorksheet->getStyle('O' . $row)->getAlignment()->setWrapText(true);
         //Image
         if (!empty($value['Media'])) {
             $strVideo = '';
             $isImage = false;
             $col = 'Q';
             foreach ($value['Media'] as $item) {
                 if ($item['type'] == MEDIA_IMAGE) {
                     $objDrawing = new PHPExcel_Worksheet_Drawing();
                     $linkThumb = substr_replace($item['link'], '_thumb', strrpos($item['link'], '.'), 0);
                     if (Utils::smart_resize_image($item['link'], $linkThumb, EXCEL_WIDTH_IMAGE, EXCEL_HEIGHT_IMAGE, false, 'file', false)) {
                         $objDrawing->setPath($linkThumb);
                         $objDrawing->setCoordinates($col . $row);
                         $objDrawing->setHeight(EXCEL_HEIGHT_IMAGE);
                         $objDrawing->setWidth(EXCEL_WIDTH_IMAGE);
                         $objWorksheet->getColumnDimension($col)->setWidth(EXCEL_WIDTH_IMAGE / 6);
                         $objDrawing->setWorksheet($objWorksheet);
                         array_push($imageNeedDelete, $linkThumb);
                         $col = Utils::increase($col);
                         $isImage = true;
                     }
                 } else {
                     $strVideo .= $item['link'] . "\r\n";
                 }
             }
             if (!empty($strVideo)) {
                 $objWorksheet->setCellValue('P' . $row, $strVideo);
             }
             if ($isImage) {
                 $objWorksheet->getRowDimension($row)->setRowHeight(EXCEL_HEIGHT_IMAGE - 30);
                 $objWorksheet->duplicateStyleArray($alignCenter, 'A' . $row . ':P' . $row);
             }
         }
         $i++;
     }
     $this->setDefaultStyle($objWorksheet, $first, $first + $i - 1);
 }
开发者ID:hoanglannet,项目名称:copar,代码行数:83,代码来源:downloads.php

示例12: _exportData2Excel


//.........这里部分代码省略.........
     $activeSheet->setCellValue('A1', $device['target_type'] . '轨迹数据')->setCellValue('A2', '定位对象:' . $device['target_name'])->setCellValue('A3', '所属分组:' . $device['department_name'])->setCellValue('C2', '从:' . $_REQUEST['startTime']);
     if (!empty($_REQUEST['endTime'])) {
         $activeSheet->setCellValue('C3', '到:' . $_REQUEST['endTime']);
     }
     $Location = M('Location');
     check_error($Location);
     R('File/setfilepercent', array($filename, '正在查询数据库...'));
     $locations = $Location->join('`device` on `device`.`id`=`location`.`device_id`')->join('`department` on `department`.`id`=`device`.`department_id`')->field(array('`location`.`id`', '`device`.`department_id`', '`department`.`name`' => 'department', '`location`.`device_id`', '`device`.`type`', '`device`.`label`', '`device`.`target_type`', '`device`.`target_id`', '`device`.`target_name`', '`location`.`time`', 'state', 'online', '`location`.`address`', 'baidu_lat', 'baidu_lng', 'speed', 'direction', 'mcc', 'mnc', 'lac', 'cellid', '`location`.`range`'))->where($condition)->order('`time` ASC')->select();
     check_error($Location);
     if (empty($locations)) {
         $activeSheet->setCellValue('A6', '没有定位数据');
     } else {
         $center = $this->_request('center');
         $width = $this->_request('width') + 0;
         $height = $this->_request('height') + 0;
         $zoom = $this->_request('zoom') + 0;
         if (empty($center) || empty($width) || empty($height) || empty($zoom)) {
             $activeSheet->setCellValue('A6', '地图参数不正确,无法创建地图');
         } else {
             $mapparams = array('center' => $center, 'width' => $width, 'height' => $height, 'zoom' => $zoom);
         }
     }
     $total = count($locations);
     R('File/setfilepercent', array($filename, '正在处理数据库查询结果...', $total, 0));
     $lastTime = time();
     $baseRow = 9;
     $startMarker = null;
     $endMarker = null;
     $paths = array();
     foreach ($locations as $r => $dataRow) {
         $row = $baseRow + $r;
         if ($r) {
             $activeSheet->insertNewRowBefore($row, 1);
         }
         if (!empty($dataRow['baidu_lat']) && !empty($dataRow['baidu_lng'])) {
             $endMarker = $p = $dataRow['baidu_lng'] . "," . $dataRow['baidu_lat'];
             if (empty($startMarker)) {
                 $startMarker = $p;
             }
             $paths[] = $p;
         }
         $activeSheet->setCellValue('A' . $row, $dataRow['time'])->setCellValue('B' . $row, $dataRow['address'])->setCellValue('C' . $row, $dataRow['speed'])->setCellValue('D' . $row, $dataRow['direction'])->setCellValue('E' . $row, $dataRow['state']);
         $activeSheet->getRowDimension($row)->setRowHeight(-1);
         if (time() - $lastTime) {
             //过了1秒
             $lastTime = time();
             R('File/setfilepercent', array($filename, '正在处理数据库查询结果...', $total, $r + 1));
         }
     }
     if (!empty($mapparams)) {
         R('File/setfilepercent', array($filename, '正在准备地图...'));
         if (!empty($startMarker)) {
             $mapparams['markers'] = $startMarker;
             $mapparams['markerStyles'] = 'm,A';
         }
         if (!empty($endMarker) && !empty($mapparams['markers'])) {
             $mapparams['markers'] .= '|' . $endMarker;
             $mapparams['markerStyles'] = '|m,B';
         }
         if (!empty($paths)) {
             $mapparams['paths'] = implode(";", $paths);
             $mapparams['pathStyles'] = '0xff0000,3,1';
         }
         $img = R('File/getbaidumapstaticimage', array($mapparams));
         if ($img) {
             $objDrawing = new PHPExcel_Worksheet_Drawing();
             $objDrawing->setName('map');
             $objDrawing->setDescription('Map');
             $objDrawing->setPath($img);
             $objDrawing->setCoordinates('A6');
             $objDrawing->getShadow()->setVisible(true);
             $objDrawing->getShadow()->setDirection(45);
             //调整图片大小,使之适应实际大小
             $widthPT = $activeSheet->getColumnDimension('A')->getWidth() + $activeSheet->getColumnDimension('B')->getWidth() + $activeSheet->getColumnDimension('C')->getWidth() + $activeSheet->getColumnDimension('D')->getWidth() + $activeSheet->getColumnDimension('E')->getWidth();
             //根据经验调整$widthPT
             if ($target == 'PDF') {
                 $widthPT *= 4.7499;
             } else {
                 if ($target == 'Excel5') {
                     $widthPT *= 5.251282;
                 } else {
                     $widthPT *= 6;
                 }
             }
             //经验:导出成Excel2007
             $widthPX = round($widthPT * 4 / 3);
             $scale = $objDrawing->getWidth() / $widthPX;
             $heightPX = round($objDrawing->getHeight() / $scale);
             $heightPT = $heightPX * 0.75;
             $objDrawing->setWidth($widthPX);
             $objDrawing->setHeight($heightPX);
             $activeSheet->getRowDimension('6')->setRowHeight($heightPT);
             $objDrawing->setWorksheet($activeSheet);
             R('File/setfilepercent', array($filename, '地图就绪...'));
         } else {
             R('File/setfilepercent', array($filename, '地图准备失败...'));
         }
     }
     return $objPHPExcel;
 }
开发者ID:jumboluo,项目名称:tracking,代码行数:101,代码来源:TrackingAction.class.php

示例13: addHeader

 protected function addHeader($from, $to)
 {
     $this->_row = 1;
     $structure = Doctrine::getTable('Structure')->createQuery('a')->fetchOne();
     PHPExcel_Cell::setValueBinder(new PHPExcel_Cell_AdvancedValueBinder());
     $active_sheet = $this->getDocument()->getActiveSheet();
     //Add the logo of the structure at the top left of the page:
     $logo = new PHPExcel_Worksheet_Drawing();
     $logo->setName('Logo');
     $logo->setDescription('Logo');
     $logo->setPath('./uploads/images/logo.png');
     $logo->setHeight(60);
     $logo->setWidth(129);
     $logo->setCoordinates('A' . $this->_row);
     $logo->setWorksheet($active_sheet);
     //Merge the cells at the top right of the page:
     $active_sheet->mergeCells('B' . $this->_row . ':D' . $this->_row);
     //and put inside the informations about the structure:
     $active_sheet->getCell('B' . $this->_row)->setValue($structure->getName() . "\n" . $structure->getAddress()->getStreet() . "\n" . $structure->getAddress()->getAddressCity()->getPostalCode() . " " . $structure->getAddress()->getAddressCity()->getName() . "\n" . "Tel: " . $structure->getTelephoneNumber() . "\n" . "Tel2: " . $structure->getAddress()->getTelephoneNumber() . "\n" . "e-mail: " . $structure->getEmail() . "\n" . "site: " . $structure->getWebsite() . "\n");
     $active_sheet->getStyle('B' . $this->_row)->getFont()->setBold(true);
     $this->nextLine();
     //Write the chosen period at the date of document generation:
     $active_sheet->getCell('A' . $this->_row)->setValue($this->_translate("Period") . ":\n" . $this->_translate("From") . " " . date($this->_translate('m/d/y'), strtotime($from)) . " " . $this->_translate("to") . " " . date($this->_translate('m/d/y'), strtotime($to)));
     $active_sheet->getCell('B' . $this->_row)->setValue($this->_translate("Generated") . ":\n" . date($this->_translate('m/d/y')) . " " . $this->_translate("at") . " " . date('H:i:s'));
     $active_sheet->getStyle('A' . $this->_row . ':B' . $this->_row)->getFont()->setSize(8);
     //General specifications of the page:
     //Footer:
     $active_sheet->getHeaderFooter()->setOddFooter('&L&D&RPage &P/&N');
     $this->nextLine(2);
 }
开发者ID:xmasclaux,项目名称:OpenGenepi,代码行数:30,代码来源:ExportDocument.class.php

示例14: load


//.........这里部分代码省略.........
                 foreach ($xmlWorkbook->sheets->sheet as $eleSheet) {
                     $docSheet = $excel->createSheet();
                     $docSheet->setTitle((string) $eleSheet["name"]);
                     $fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")];
                     $xmlSheet = simplexml_load_string($zip->getFromName("{$dir}/{$fileWorksheet}"));
                     //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");
                     if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->outlinePr)) {
                         if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) && $xmlSheet->sheetPr->outlinePr['summaryRight'] == false) {
                             $docSheet->setShowSummaryRight(false);
                         } else {
                             $docSheet->setShowSummaryRight(true);
                         }
                         if (isset($xmlSheet->sheetPr->outlinePr['summaryBelow']) && $xmlSheet->sheetPr->outlinePr['summaryBelow'] == false) {
                             $docSheet->setShowSummaryBelow(false);
                         } else {
                             $docSheet->setShowSummaryBelow(true);
                         }
                     }
                     if (isset($xmlSheet->cols) && !$this->_readDataOnly) {
                         foreach ($xmlSheet->cols->col as $col) {
                             for ($i = intval($col["min"]) - 1; $i < intval($col["max"]) && $i < 256; $i++) {
                                 if ($col["bestFit"]) {
                                     $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setAutoSize(true);
                                 }
                                 if ($col["hidden"]) {
                                     $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setVisible(false);
                                 }
                                 if ($col["collapsed"]) {
                                     $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setCollapsed(true);
                                 }
                                 if ($col["outlineLevel"] > 0) {
                                     $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setOutlineLevel(intval($col["outlineLevel"]));
                                 }
                                 $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setWidth(floatval($col["width"]));
                             }
                         }
                     }
                     if (isset($xmlSheet->printOptions) && !$this->_readDataOnly) {
                         if ($xmlSheet->printOptions['gridLines'] && $xmlSheet->printOptions['gridLinesSet']) {
                             $docSheet->setShowGridlines(true);
                         }
                     }
                     foreach ($xmlSheet->sheetData->row as $row) {
                         if ($row["ht"] && !$this->_readDataOnly) {
                             $docSheet->getRowDimension(intval($row["r"]))->setRowHeight(floatval($row["ht"]));
                         }
                         if ($row["hidden"] && !$this->_readDataOnly) {
                             $docSheet->getRowDimension(intval($row["r"]))->setVisible(false);
                         }
                         if ($row["collapsed"]) {
                             $docSheet->getRowDimension(intval($row["r"]))->setCollapsed(true);
                         }
                         if ($row["outlineLevel"] > 0) {
                             $docSheet->getRowDimension(intval($row["r"]))->setOutlineLevel(intval($row["outlineLevel"]));
                         }
                         foreach ($row->c as $c) {
                             $r = (string) $c["r"];
                             switch ($c["t"]) {
                                 case "s":
                                     $value = $sharedStrings[intval($c->v)];
                                     if ($value instanceof PHPExcel_RichText) {
                                         $value = clone $value;
                                     }
                                     break;
                                 case "b":
                                     $value = (bool) $c->v;
开发者ID:hostellerie,项目名称:nexpro,代码行数:67,代码来源:Excel2007.php

示例15: actionExcel

 public function actionExcel()
 {
     /*
         Проверка на доступ пользователя к странице
     */
     $permissions_report_task_search = \app\models\Permissions::find()->where('(SUBJECT_TYPE = :subject_type and SUBJECT_ID = :user_id and DEL_TRACT_ID = :del_tract and PERM_LEVEL != :perm_level and ACTION_ID = :action) or
                                     (SUBJECT_TYPE = :subject_type_dolg and SUBJECT_ID = :dolg_id and DEL_TRACT_ID = :del_tract and PERM_LEVEL != :perm_level and ACTION_ID = :action)', ['subject_type_dolg' => 1, 'dolg_id' => \Yii::$app->session->get('user.user_iddolg'), 'action' => 82, 'subject_type' => 2, 'user_id' => \Yii::$app->user->id, 'del_tract' => 0, 'perm_level' => 0])->one();
     if ($permissions_report_task_search) {
         /*
             Проверяем получены ли идентификаторы заданий для формирования отчета
         */
         if (Yii::$app->request->get('ids')) {
             $issues_ids = Yii::$app->request->get('ids');
             $issues_ids = explode(',', $issues_ids);
             /*
                 Делаем выборку необходимых заданий
             */
             $model = \app\models\Tasks::find()->where(['ID' => $issues_ids])->all();
             if ($model) {
                 // Создаем объект класса PHPExcel
                 $xls = new \PHPExcel();
                 // Устанавливаем индекс активного листа
                 $xls->setActiveSheetIndex(0);
                 // Получаем активный лист
                 $sheet = $xls->getActiveSheet();
                 // Подписываем лист
                 $sheet->setTitle('Отчет по отобранным заданиям');
                 $sheet->getStyle('A1')->getFont()->setBold(true);
                 // Вставляем текст в ячейку A1
                 $sheet->setCellValue("A1", 'Отчет по отобранным заданиям');
                 $sheet->getStyle('A1')->getFill()->setFillType(\PHPExcel_Style_Fill::FILL_SOLID);
                 $sheet->getStyle('A1')->getFill()->getStartColor()->setRGB('EEEEEE');
                 // Объединяем ячейки
                 $sheet->mergeCells('A1:I1');
                 // Выравнивание текста
                 $sheet->getStyle('A1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
                 // Формируем шапку
                 $sheet->setCellValue("A2", 'Заказ ПЭО');
                 $sheet->setCellValue("B2", 'Номер заказа');
                 $sheet->setCellValue("C2", 'Проект/Тема');
                 $sheet->setCellValue("D2", 'Обозначение');
                 $sheet->setCellValue("E2", 'Наименование');
                 $sheet->setCellValue("F2", 'Срок выполнения');
                 $sheet->setCellValue("G2", 'Статус');
                 $sheet->setCellValue("H2", 'Ф.И.О. и Дата');
                 $sheet->setCellValue("I2", 'Форматов А4');
                 /* устанавливаем ширину колонок и стили*/
                 $sheet->getStyle('A2:I2')->getFont()->setBold(true);
                 $sheet->getColumnDimension('A')->setAutoSize(true);
                 $sheet->getColumnDimension('B')->setAutoSize(true);
                 $sheet->getColumnDimension('C')->setAutoSize(true);
                 $sheet->getColumnDimension('D')->setAutoSize(true);
                 $sheet->getColumnDimension('E')->setAutoSize(true);
                 $sheet->getColumnDimension('F')->setAutoSize(true);
                 $sheet->getColumnDimension('G')->setWidth(20);
                 $sheet->getColumnDimension('H')->setAutoSize(true);
                 $sheet->getColumnDimension('I')->setAutoSize(true);
                 $row_number = 3;
                 foreach ($model as $task) {
                     $sheet->setCellValue("A" . $row_number, $task->PEOORDERNUM);
                     $sheet->setCellValue("B" . $row_number, $task->ORDERNUM);
                     $sheet->setCellValue("C" . $row_number, '');
                     $sheet->setCellValue("D" . $row_number, $task->TASK_NUMBER);
                     $sheet->setCellValue("E" . $row_number, 'Задание');
                     $sheet->setCellValue("F" . $row_number, \Yii::$app->formatter->asDate($task->DEADLINE, 'php:d-m-Y'));
                     //вставляем информацию по статусам
                     $task_states = \app\models\TaskStates::find()->where(['TASK_ID' => $task->ID])->orderBy('STATE_ID ASC')->all();
                     if ($task_states) {
                         foreach ($task_states as $state) {
                             $state_date = $state->getStateDate();
                             $logo = new \PHPExcel_Worksheet_Drawing();
                             $logo->setPath(Yii::getAlias('@webroot') . '/images/items_status/' . $state->getStateColour() . '.png');
                             $logo->setCoordinates("G" . $row_number);
                             $logo->setOffsetX(5);
                             $logo->setOffsetY(2);
                             $logo->setResizeProportional(true);
                             $logo->setWidth(16);
                             $logo->setWorksheet($sheet);
                             $sheet->setCellValue("G" . $row_number, '        ' . $state->getStateName());
                             $pers_tasks = \app\models\PersTasks::findOne($state->PERS_TASKS_ID);
                             $query = new \yii\db\Query();
                             $query->select('*')->from('STIGIT.V_F_PERS')->where('TN = \'' . $pers_tasks->TN . '\'');
                             $command = $query->createCommand();
                             $data = $command->queryOne();
                             $sheet->setCellValue("H" . $row_number, $data['FIO'] . ' ' . $state_date);
                             $task_docs = \app\models\TaskDocs::find()->where(['PERS_TASKS_ID' => $state->PERS_TASKS_ID])->one();
                             if ($task_docs) {
                                 $quantity = $task_docs->FORMAT_QUANTITY;
                             } else {
                                 $quantity = 0;
                             }
                             $sheet->setCellValue("I" . $row_number, $quantity);
                             $row_number++;
                         }
                     }
                     $row_number++;
                 }
                 //стили для рамки таблицы
                 $styleArray = array('borders' => array('allborders' => array('style' => \PHPExcel_Style_Border::BORDER_THIN)));
                 $total_rows = $row_number - 1;
//.........这里部分代码省略.........
开发者ID:alaevka,项目名称:stigit.basalt,代码行数:101,代码来源:ReportsController.php


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