本文整理汇总了PHP中PHPExcel_Worksheet_Drawing::setOffsetX方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Worksheet_Drawing::setOffsetX方法的具体用法?PHP PHPExcel_Worksheet_Drawing::setOffsetX怎么用?PHP PHPExcel_Worksheet_Drawing::setOffsetX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel_Worksheet_Drawing
的用法示例。
在下文中一共展示了PHPExcel_Worksheet_Drawing::setOffsetX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
//.........这里部分代码省略.........
// Fetch linked images
$relsVML = simplexml_load_string($this->_getFromZipArchive($zip, dirname($vmlRelationship) . '/_rels/' . basename($vmlRelationship) . '.rels' )); //~ http://schemas.openxmlformats.org/package/2006/relationships");
$drawings = array();
foreach ($relsVML->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") {
$drawings[(string) $ele["Id"]] = self::dir_add($vmlRelationship, $ele["Target"]);
}
}
// Fetch VML document
$vmlDrawing = simplexml_load_string($this->_getFromZipArchive($zip, $vmlRelationship));
$vmlDrawing->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml');
$hfImages = array();
$shapes = $vmlDrawing->xpath('//v:shape');
foreach ($shapes as $shape) {
$shape->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml');
$imageData = $shape->xpath('//v:imagedata');
$imageData = $imageData[0];
$imageData = $imageData->attributes('urn:schemas-microsoft-com:office:office');
$style = self::toCSSArray( (string)$shape['style'] );
$hfImages[ (string)$shape['id'] ] = new PHPExcel_Worksheet_HeaderFooterDrawing();
if (isset($imageData['title'])) {
$hfImages[ (string)$shape['id'] ]->setName( (string)$imageData['title'] );
}
$hfImages[ (string)$shape['id'] ]->setPath("zip://$pFilename#" . $drawings[(string)$imageData['relid']], false);
$hfImages[ (string)$shape['id'] ]->setResizeProportional(false);
$hfImages[ (string)$shape['id'] ]->setWidth($style['width']);
$hfImages[ (string)$shape['id'] ]->setHeight($style['height']);
$hfImages[ (string)$shape['id'] ]->setOffsetX($style['margin-left']);
$hfImages[ (string)$shape['id'] ]->setOffsetY($style['margin-top']);
$hfImages[ (string)$shape['id'] ]->setResizeProportional(true);
}
$docSheet->getHeaderFooter()->setImages($hfImages);
}
}
}
}
// ----: Make sure drawings and graph are loaded differently!
if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) {
$relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") ); //~ http://schemas.openxmlformats.org/package/2006/relationships");
$drawings = array();
foreach ($relsWorksheet->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing") {
$drawings[(string) $ele["Id"]] = self::dir_add("$dir/$fileWorksheet", $ele["Target"]);
}
}
if ($xmlSheet->drawing && !$this->_readDataOnly) {
foreach ($xmlSheet->drawing as $drawing) {
$fileDrawing = $drawings[(string) self::array_item($drawing->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")];
$relsDrawing = simplexml_load_string($this->_getFromZipArchive($zip, dirname($fileDrawing) . "/_rels/" . basename($fileDrawing) . ".rels") ); //~ http://schemas.openxmlformats.org/package/2006/relationships");
$images = array();
if ($relsDrawing && $relsDrawing->Relationship) {
foreach ($relsDrawing->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") {
$images[(string) $ele["Id"]] = self::dir_add($fileDrawing, $ele["Target"]);
}
}
示例2: orderexcel
function orderexcel($data, $title)
{
$phpexcel_root = ROOT . '/extends/PHPExcel';
include_once $phpexcel_root . '/PHPExcel.php';
$objPHPExcel = new \PHPExcel();
foreach ($title as $index => $string) {
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index) . '1', $string);
}
foreach ($data as $line => $value) {
$objPHPExcel->getActiveSheet()->getRowDimension($line + 4)->setRowHeight(-3);
$objPHPExcel->getActiveSheet()->getStyle('D' . ($line + 4))->getNumberFormat()->setFormatCode(\PHPExcel_Style_NumberFormat::FORMAT_NUMBER_00);
$objPHPExcel->getActiveSheet()->getStyle('Q' . ($line + 4))->getNumberFormat()->setFormatCode(\PHPExcel_Style_NumberFormat::FORMAT_NUMBER_00);
$objPHPExcel->getActiveSheet()->getStyle('R' . ($line + 4))->getNumberFormat()->setFormatCode(\PHPExcel_Style_NumberFormat::FORMAT_NUMBER);
$objPHPExcel->getActiveSheet()->getStyle('F' . ($line + 4))->getNumberFormat()->setFormatCode(\PHPExcel_Style_NumberFormat::FORMAT_TEXT);
//$objPHPExcel->getActiveSheet()->getRowDimension($line+4)->setHeight(200);
$index = 0;
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index++) . ($line + 4), $value['orderno']);
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index++) . ($line + 4), $value['paytype']);
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index++) . ($line + 4), $value['paynumber']);
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index++) . ($line + 4), $value['ordertotalamount']);
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index++) . ($line + 4), $value['ordertaxamount']);
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index++) . ($line + 4), $value['ordergoodsamount']);
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index++) . ($line + 4), $value['feeamount']);
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index++) . ($line + 4), $value['tradetime']);
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index++) . ($line + 4), $value['totalamount']);
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index++) . ($line + 4), $value['consigneetel']);
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index++) . ($line + 4), $value['consignee']);
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index++) . ($line + 4), $value['zipcode']);
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index++) . ($line + 4), $value['consigneeprovince']);
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index++) . ($line + 4), $value['consigneecity']);
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index++) . ($line + 4), $value['consigneecounty']);
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index++) . ($line + 4), $value['consigneeaddress']);
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index++) . ($line + 4), $value['postmode']);
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index++) . ($line + 4), $value['username']);
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index++) . ($line + 4), $value['sku']);
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index++) . ($line + 4), $value['productname']);
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index++) . ($line + 4), $value['unitprice']);
$objPHPExcel->getActiveSheet()->setCellValue(chr(ord('A') + $index++) . ($line + 4), $value['num']);
if (!empty($value['img'])) {
$objDrawing = new \PHPExcel_Worksheet_Drawing();
$objDrawing->setName($value['productname']);
$objDrawing->setPath($value['img'][0]['thumbnail_path']);
$objDrawing->setCoordinates(chr(ord('A') + $index++) . ($line + 4));
$objDrawing->setResizeProportional(true);
$objDrawing->setWidthAndHeight(100, 100);
$objDrawing->setOffsetX(100);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
}
}
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$filename = time('Y-m-d H:i:s') . '.xls';
$objWriter->save($filename);
return $filename;
}
示例3: 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);
}
示例4: getTeaserImage
private function getTeaserImage(Teasers $teaser)
{
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName($teaser->title);
$path = Yii::app()->params->imageBasePath . DIRECTORY_SEPARATOR . $teaser->picture;
if (!file_exists($path)) {
$path = $path = Yii::app()->params->imageBasePath . DIRECTORY_SEPARATOR . 'notfound.png';
}
$objDrawing->setPath($path);
$objDrawing->setWidthAndHeight(95, 95);
$objDrawing->setOffsetX(10);
$objDrawing->setOffsetY(2);
return $objDrawing;
}
示例5: _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;
}
示例6: setHeaderLogo
/**
* set header logo;
*/
public function setHeaderLogo()
{
$headerLogo = BASEPATH . $this->setup->getSettingValue('config_logo');
switch ($this->driver) {
case 'excel2003':
//drawing
$drawing = new PHPExcel_Worksheet_Drawing();
$drawing->setName('Logo ');
$drawing->setDescription('Logo');
$drawing->setPath($headerLogo);
$drawing->setHeight(90);
$drawing->setCoordinates('A' . $this->currentRow);
$drawing->setOffsetX(90);
$drawing->setRotation(25);
$drawing->getShadow()->setVisible(true);
$drawing->getShadow()->setDirection(45);
$drawing->setWorksheet($this->rpt->getActiveSheet());
break;
case 'excel2007':
//drawing
$drawing = new PHPExcel_Worksheet_Drawing();
$drawing->setName('Logo');
$drawing->setDescription('Logo');
$drawing->setPath($headerLogo);
$drawing->setHeight(90);
$drawing->setCoordinates('A' . $this->currentRow);
$drawing->setOffsetX(10);
$drawing->setRotation(0);
$drawing->getShadow()->setVisible(true);
$drawing->getShadow()->setDirection(45);
$drawing->setWorksheet($this->rpt->getActiveSheet());
break;
}
}
示例7: excel
function excel()
{
//load our new PHPExcel library
$this->load->library('excel');
//activate worksheet number 1
$this->excel->setActiveSheetIndex(0);
//name the worksheet
$this->excel->getActiveSheet()->setTitle('Master Barang');
$this->excel->getActiveSheet()->mergeCells('A1:G6');
//$this->excel->getActiveSheet()->getStyle('C1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('Logo');
$objDrawing->setDescription('Logo');
$objDrawing->setPath('D:/logo-po.jpg');
$objDrawing->setCoordinates('C1');
$objDrawing->setOffsetX(150);
$objDrawing->setHeight(108);
$objDrawing->setWidth(637);
$objDrawing->setWorksheet($this->excel->getActiveSheet());
//$this->excel->getActiveSheet()->setCellValue('C1', 'PT Gramaselindo');
$this->excel->getActiveSheet()->setCellValue('A7', 'No');
$this->excel->getActiveSheet()->setCellValue('B7', 'Kode');
$this->excel->getActiveSheet()->setCellValue('C7', 'Deskripsi');
$this->excel->getActiveSheet()->setCellValue('D7', 'Alias');
$this->excel->getActiveSheet()->setCellValue('E7', 'Jenis Barang');
$this->excel->getActiveSheet()->setCellValue('F7', 'Satuan Dasar');
$this->excel->getActiveSheet()->setCellValue('G7', 'Satuan Laporan');
for ($col = ord('A'); $col <= ord('F'); $col++) {
//set column dimension
$this->excel->getActiveSheet()->getColumnDimension(chr($col))->setAutoSize(false);
//change the font size
$this->excel->getActiveSheet()->getStyle(chr($col))->getFont()->setSize(12);
}
$this->excel->getActiveSheet()->getStyle(chr(ord('A')))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$this->excel->getActiveSheet()->getStyle(chr(ord('B')))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$this->excel->getActiveSheet()->getStyle(chr(ord('C')))->getAlignment()->setWrapText(true);
$this->excel->getActiveSheet()->getStyle(chr(ord('D')))->getAlignment()->setWrapText(true);
$this->excel->getActiveSheet()->getColumnDimension('C')->setWidth(75);
$this->excel->getActiveSheet()->getColumnDimension('D')->setWidth(25);
$this->excel->getActiveSheet()->getColumnDimension('E')->setWidth(20);
$this->excel->getActiveSheet()->getColumnDimension('F')->setWidth(20);
$this->excel->getActiveSheet()->getColumnDimension('G')->setWidth(20);
$rs = $this->barang->get_barang();
//print_//mz($rs);
$exceldata = "";
foreach ($rs as $row) {
$exceldata[] = $row;
}
//Fill data
$this->excel->getActiveSheet()->fromArray($exceldata, null, 'A8');
$this->excel->getActiveSheet()->getStyle('A7')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$this->excel->getActiveSheet()->getStyle('B7')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$this->excel->getActiveSheet()->getStyle('C7')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$this->excel->getActiveSheet()->getStyle('A1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$filename = 'Master Barang.xls';
//save our workbook as this file name
header('Content-Type: application/vnd.ms-excel');
//mime type
header('Content-Disposition: attachment;filename="' . $filename . '"');
//tell browser what's the file name
header('Cache-Control: max-age=0');
//no cache
//save it to Excel5 format (excel 2003 .XLS file), change this to 'Excel2007' (and adjust the filename extension, also the header mime type)
//if you want to save it as .XLSX Excel 2007 format
$objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
//force user to download the Excel file without writing it to server's HD
$objWriter->save('php://output');
}
示例8: generar_reporte_disponibilidad
private function generar_reporte_disponibilidad($mes, $year)
{
if (!$year || $year === '%') {
$year = date("Y");
}
if (!$mes || $mes === '%' || $mes == -1) {
$mes = date("m");
}
$temp = $year . '-' . $mes . '%';
$proveedores = $this->proveedores_disponibilidad($mes, $year);
// Create new PHPExcel object
$this->load->library('phpexcel');
// Set document properties
$this->phpexcel->getProperties()->setCreator("PHPExcel")->setLastModifiedBy("PHPExcel")->setTitle("Office 2007 XLSX Report Document")->setSubject("Office 2007 XLSX Report Document")->setDescription("Report document for Office 2007 XLSX, generated using PHP classes.")->setKeywords("office 2007 openxml php")->setCategory("Report result file");
// Add some data in row 2
$this->phpexcel->getActiveSheet()->setCellValue('B2', 'DIRECCION PROVINCIAL DE ECONOMIA Y PLANIFICACION');
$this->phpexcel->getActiveSheet()->getStyle('B2')->getFont()->setSize(12);
$this->phpexcel->getActiveSheet()->mergeCells('B2:F2');
$this->phpexcel->getActiveSheet()->getColumnDimension('A')->setWidth(2);
$this->phpexcel->getActiveSheet()->getColumnDimension('B')->setWidth(40);
$this->phpexcel->getActiveSheet()->getColumnDimension('D')->setWidth(15);
$this->phpexcel->getActiveSheet()->getColumnDimension('F')->setWidth(30);
$this->phpexcel->getActiveSheet()->getStyle('B2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$this->phpexcel->getActiveSheet()->getStyle('B2')->getFont()->setName('Arial');
$this->phpexcel->getActiveSheet()->getStyle('B2')->getFont()->setItalic(true);
$this->phpexcel->getActiveSheet()->getStyle('B2:F2')->applyFromArray($this->styles('blackStyle'));
// Add some data in row 3
$this->phpexcel->getActiveSheet()->setCellValue('B3', 'CAMAGÜEY');
$this->phpexcel->getActiveSheet()->getStyle('B3')->getFont()->setSize(12);
$this->phpexcel->getActiveSheet()->mergeCells('B3:F3');
$this->phpexcel->getActiveSheet()->getStyle('B3')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$this->phpexcel->getActiveSheet()->getStyle('B3')->getFont()->setName('Arial');
$this->phpexcel->getActiveSheet()->getStyle('B3')->getFont()->setItalic(true);
$this->phpexcel->getActiveSheet()->getStyle('B3:F3')->applyFromArray($this->styles('blackStyle'));
// Add some data in row 4
$this->phpexcel->getActiveSheet()->setCellValue('B4', 'San Pablo # 104 % Martí y Luaces Tel. 295637');
$this->phpexcel->getActiveSheet()->getStyle('B4')->getFont()->setSize(12);
$this->phpexcel->getActiveSheet()->mergeCells('B4:F4');
$this->phpexcel->getActiveSheet()->getStyle('B4')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$this->phpexcel->getActiveSheet()->getStyle('B4')->getFont()->setName('Arial');
$this->phpexcel->getActiveSheet()->getStyle('B4')->getFont()->setItalic(true);
$this->phpexcel->getActiveSheet()->getStyle('B4:F4')->applyFromArray($this->styles('blackStyle'));
// Add some data in row 5
$this->phpexcel->getActiveSheet()->setCellValue('B5', 'Email:boletas@dpepcmg.mep.gov.cu');
$this->phpexcel->getActiveSheet()->getStyle('B5')->getFont()->setSize(12);
$this->phpexcel->getActiveSheet()->mergeCells('B5:F5');
$this->phpexcel->getActiveSheet()->getStyle('B5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$this->phpexcel->getActiveSheet()->getStyle('B5')->getFont()->setName('Arial');
$this->phpexcel->getActiveSheet()->getStyle('B5')->getFont()->setItalic(true);
$this->phpexcel->getActiveSheet()->getStyle('B5:F5')->applyFromArray($this->styles('blackStyle'));
// Add a drawing to the worksheet
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('Paid');
$objDrawing->setDescription('Paid');
$objDrawing->setPath('./web/images/dpep.png');
$objDrawing->setCoordinates('B3');
$objDrawing->setOffsetX(25);
$objDrawing->setRotation(0);
$objDrawing->getShadow()->setVisible(true);
$objDrawing->getShadow()->setDirection(45);
$objDrawing->setWorksheet($this->phpexcel->getActiveSheet());
// Add some data in row 6
$this->phpexcel->getActiveSheet()->setCellValue('B6', PHPExcel_Shared_Date::PHPToExcel(gmmktime(0, 0, 0, date('m'), date('d'), date('Y'))));
$this->phpexcel->getActiveSheet()->getStyle('B6')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15);
$this->phpexcel->getActiveSheet()->getStyle('B6')->getFont()->setSize(12);
$this->phpexcel->getActiveSheet()->mergeCells('B6:F6');
$this->phpexcel->getActiveSheet()->getStyle('B6')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
$this->phpexcel->getActiveSheet()->getStyle('B6')->getFont()->setName('Arial');
$this->phpexcel->getActiveSheet()->getStyle('B6')->getFont()->setItalic(true);
$this->phpexcel->getActiveSheet()->getStyle('B6:F6')->applyFromArray($this->styles('blackStyle'));
// Add some data in row 7
$this->phpexcel->getActiveSheet()->getStyle('B7')->getFont()->setSize(12);
$this->phpexcel->getActiveSheet()->mergeCells('B7:F7');
$this->phpexcel->getActiveSheet()->getStyle('B7')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
$this->phpexcel->getActiveSheet()->getStyle('B7')->getFont()->setName('Arial');
$this->phpexcel->getActiveSheet()->getStyle('B7')->getFont()->setItalic(true);
$this->phpexcel->getActiveSheet()->getStyle('B7:F7')->applyFromArray($this->styles('blackStyle'));
// Add some data in row 8
$this->phpexcel->getActiveSheet()->setCellValue('B8', 'DISPONIBILIDAD DE LA RESERVA DEL CAP');
$this->phpexcel->getActiveSheet()->getStyle('B8')->getFont()->setSize(14);
$this->phpexcel->getActiveSheet()->mergeCells('B8:F8');
$this->phpexcel->getActiveSheet()->getStyle('B8')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$this->phpexcel->getActiveSheet()->getStyle('B8')->getFont()->setName('Arial');
$this->phpexcel->getActiveSheet()->getStyle('B8')->getFont()->setItalic(true);
$this->phpexcel->getActiveSheet()->getStyle('B8:F8')->applyFromArray($this->styles('blackStyle'));
// Add some data in row 9
$this->phpexcel->getActiveSheet()->setCellValue('B9', 'PROVEEDOR / PRODUCTOS');
$this->phpexcel->getActiveSheet()->getStyle('B9')->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_RED);
$this->phpexcel->getActiveSheet()->getStyle('B9')->getFont()->setSize(12);
$this->phpexcel->getActiveSheet()->getStyle('B9')->getFont()->setName('Arial');
$this->phpexcel->getActiveSheet()->getStyle('B9')->getFont()->setItalic(true);
$this->phpexcel->getActiveSheet()->getStyle('B9')->applyFromArray($this->styles('blackStyle'));
$this->phpexcel->getActiveSheet()->getStyle('C9:F9')->getAlignment()->setWrapText(true);
$this->phpexcel->getActiveSheet()->setCellValue('C9', 'U.M.');
$this->phpexcel->getActiveSheet()->getStyle('C9')->getFont()->setSize(12);
$this->phpexcel->getActiveSheet()->getStyle('C9')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$this->phpexcel->getActiveSheet()->getStyle('C9')->getFont()->setName('Arial');
$this->phpexcel->getActiveSheet()->getStyle('C9')->getFont()->setItalic(true);
$this->phpexcel->getActiveSheet()->getStyle('C9')->applyFromArray($this->styles('blackStyle'));
$this->phpexcel->getActiveSheet()->setCellValue('D9', 'Saldo inicial');
//.........这里部分代码省略.........
示例9: load
//.........这里部分代码省略.........
if (isset($hyperlink['tooltip'])) {
$docSheet->getCell($hyperlink['ref'])->getHyperlink()->setTooltip((string) $hyperlink['tooltip']);
}
}
}
}
// Add comments
$comments = array();
if (!$this->_readDataOnly) {
// Locate comment relations
if ($zip->locateName(dirname("{$dir}/{$fileWorksheet}") . "/_rels/" . basename($fileWorksheet) . ".rels")) {
$relsWorksheet = simplexml_load_string($zip->getFromName(dirname("{$dir}/{$fileWorksheet}") . "/_rels/" . basename($fileWorksheet) . ".rels"));
//~ http://schemas.openxmlformats.org/package/2006/relationships");
foreach ($relsWorksheet->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments") {
$comments[(string) $ele["Id"]] = (string) $ele["Target"];
}
}
}
// Loop trough comments
foreach ($comments as $relName => $relPath) {
// Load comments file
$relPath = PHPExcel_Shared_File::realpath(dirname("{$dir}/{$fileWorksheet}") . "/" . $relPath);
$commentsFile = simplexml_load_string($zip->getFromName($relPath));
// Utility variables
$authors = array();
// Loop trough authors
foreach ($commentsFile->authors->author as $author) {
$authors[] = (string) $author;
}
// Loop trough contents
foreach ($commentsFile->commentList->comment as $comment) {
$docSheet->getComment((string) $comment['ref'])->setAuthor($authors[(string) $comment['authorId']]);
$docSheet->getComment((string) $comment['ref'])->setText($this->_parseRichText($comment->text));
}
}
}
// TODO: Make sure drawings and graph are loaded differently!
if ($zip->locateName(dirname("{$dir}/{$fileWorksheet}") . "/_rels/" . basename($fileWorksheet) . ".rels")) {
$relsWorksheet = simplexml_load_string($zip->getFromName(dirname("{$dir}/{$fileWorksheet}") . "/_rels/" . basename($fileWorksheet) . ".rels"));
//~ http://schemas.openxmlformats.org/package/2006/relationships");
$drawings = array();
foreach ($relsWorksheet->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing") {
$drawings[(string) $ele["Id"]] = self::dir_add("{$dir}/{$fileWorksheet}", $ele["Target"]);
}
}
if ($xmlSheet->drawing && !$this->_readDataOnly) {
foreach ($xmlSheet->drawing as $drawing) {
$fileDrawing = $drawings[(string) self::array_item($drawing->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")];
$relsDrawing = simplexml_load_string($zip->getFromName(dirname($fileDrawing) . "/_rels/" . basename($fileDrawing) . ".rels"));
//~ http://schemas.openxmlformats.org/package/2006/relationships");
$images = array();
foreach ($relsDrawing->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") {
$images[(string) $ele["Id"]] = self::dir_add($fileDrawing, $ele["Target"]);
}
}
$xmlDrawing = simplexml_load_string($zip->getFromName($fileDrawing))->children("http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing");
foreach ($xmlDrawing->oneCellAnchor as $oneCellAnchor) {
$blip = $oneCellAnchor->pic->blipFill->children("http://schemas.openxmlformats.org/drawingml/2006/main")->blip;
$xfrm = $oneCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->xfrm;
$outerShdw = $oneCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->effectLst->outerShdw;
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName((string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), "name"));
$objDrawing->setDescription((string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), "descr"));
$objDrawing->setPath("zip://{$pFilename}#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false);
$objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex($oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1));
$objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff));
$objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->rowOff));
$objDrawing->setResizeProportional(false);
$objDrawing->setWidth(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cx")));
$objDrawing->setHeight(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cy")));
if ($xfrm) {
$objDrawing->setRotation(PHPExcel_Shared_Drawing::angleToDegrees(self::array_item($xfrm->attributes(), "rot")));
}
if ($outerShdw) {
$shadow = $objDrawing->getShadow();
$shadow->setVisible(true);
$shadow->setBlurRadius(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(), "blurRad")));
$shadow->setDistance(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(), "dist")));
$shadow->setDirection(PHPExcel_Shared_Drawing::angleToDegrees(self::array_item($outerShdw->attributes(), "dir")));
$shadow->setAlignment((string) self::array_item($outerShdw->attributes(), "algn"));
$shadow->getColor()->setRGB(self::array_item($outerShdw->srgbClr->attributes(), "val"));
$shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes(), "val") / 1000);
}
$objDrawing->setWorksheet($docSheet);
}
}
}
}
}
if (!$this->_readDataOnly) {
$excel->setActiveSheetIndex(intval($xmlWorkbook->bookView->workbookView["activeTab"]));
}
break;
}
}
return $excel;
}
示例10: index
//.........这里部分代码省略.........
$this->myexcel->getActiveSheet()->setCellValue('S' . $rc, '=IF(S' . ($rc - 1) . '<=50,"Buruk",IF(S' . ($rc - 1) . '<=60,"Sedang",IF(S' . ($rc - 1) . '<=75,"Cukup",IF(S' . ($rc - 1) . '<=90.99,"Baik","Sangat Baik"))))');
$this->myexcel->getActiveSheet()->getStyle('S' . $rc)->applyFromArray($styleArray10b);
$rc++;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
$this->myexcel->createSheet(NULL, 2);
$this->myexcel->setActiveSheetIndex(2);
$this->myexcel->getActiveSheet()->setTitle('PENILAIAN');
//$this->myexcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A3);
$this->myexcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_LEGAL);
$this->myexcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
$this->myexcel->getActiveSheet()->getPageSetup()->setScale(75);
$this->myexcel->getActiveSheet()->getPageMargins()->setTop(0.7);
$this->myexcel->getActiveSheet()->getPageMargins()->setRight(0.1);
$this->myexcel->getActiveSheet()->getPageMargins()->setBottom(0.4);
$this->myexcel->getActiveSheet()->getPageMargins()->setLeft(0.4);
$this->myexcel->getActiveSheet()->getColumnDimension("A")->setWidth(3);
$this->myexcel->getActiveSheet()->getColumnDimension("B")->setWidth('3');
$this->myexcel->getActiveSheet()->getColumnDimension("C")->setWidth('20');
$this->myexcel->getActiveSheet()->getColumnDimension("D")->setWidth('14');
$this->myexcel->getActiveSheet()->getColumnDimension("E")->setWidth('14');
$this->myexcel->getActiveSheet()->getColumnDimension("J")->setWidth('4');
$this->myexcel->getActiveSheet()->getColumnDimension("K")->setWidth('4');
$this->myexcel->getActiveSheet()->getColumnDimension("L")->setWidth('3');
$this->myexcel->getActiveSheet()->getColumnDimension("V")->setWidth(3);
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('PHPExcel logo');
$objDrawing->setDescription('PHPExcel logo');
$objDrawing->setPath('assets/images/garuda.gif');
// filesystem reference for the image file
$objDrawing->setHeight(100);
// sets the image height to 36px (overriding the actual image height);
$objDrawing->setCoordinates('P29');
// pins the top-left corner of the image to cell D24
$objDrawing->setOffsetX(35);
// pins the top left corner of the image at an offset of 10 points horizontally to the right of the top-left corner of the cell
$objDrawing->setWorksheet($this->myexcel->getActiveSheet());
$rc = 3;
$this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30);
$this->myexcel->getActiveSheet()->setCellValue('B' . $rc, '4.');
$this->myexcel->getActiveSheet()->getStyle('B' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8aa);
$this->myexcel->getActiveSheet()->setCellValue('C' . $rc, 'UNSUR YANG DINILAI');
$this->myexcel->getActiveSheet()->getStyle('C' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$this->myexcel->getActiveSheet()->getStyle('C' . $rc . ':H' . $rc)->applyFromArray($styleArray8b);
$this->myexcel->getActiveSheet()->mergeCells('C' . $rc . ':H' . $rc);
$this->myexcel->getActiveSheet()->setCellValue('I' . $rc, 'JUMLAH');
$this->myexcel->getActiveSheet()->getStyle('I' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8c);
$this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8h);
$this->myexcel->getActiveSheet()->setCellValue('L' . $rc, '6. TANGGAPAN PEJABAT PENILAI ATAS KEBERATAN');
$this->myexcel->getActiveSheet()->getStyle('L' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8aa);
$this->myexcel->getActiveSheet()->getStyle('M' . $rc . ':T' . $rc)->applyFromArray($styleArray8g);
$this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8h);
$rc++;
$this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8ba);
$this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30);
$this->myexcel->getActiveSheet()->setCellValue('C' . $rc, 'a. Sasaran Kerja Pegawai (SKP)');
$this->myexcel->getActiveSheet()->getStyle('C' . $rc . ':E' . $rc)->applyFromArray($styleArray8c);
$this->myexcel->getActiveSheet()->setCellValue('F' . $rc, '=PENGUKURAN!S' . $r_nilai);
$this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray8c);
$this->myexcel->getActiveSheet()->setCellValue('G' . $rc, 'x');
$this->myexcel->getActiveSheet()->getStyle('G' . $rc)->applyFromArray($styleArray8c);
$this->myexcel->getActiveSheet()->setCellValue('H' . $rc, '60%');
$this->myexcel->getActiveSheet()->getStyle('H' . $rc)->applyFromArray($styleArray8c);
$this->myexcel->getActiveSheet()->setCellValue('I' . $rc, '=F' . $rc . '*H' . $rc);
示例11: 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);
}
}
}
示例12: exportExcel
public function exportExcel($conf = array())
{
$data = $conf['data'];
$name = $conf['filename'] . '-' . date('Y-m-d H-i-s');
$field = explode(',', $conf['field'][0]);
$fieldtitle = explode(',', $conf['field'][1]);
$objPHPExcel = new \PHPExcel();
//以下是一些设置 ,什么作者 标题啊之类的
$objPHPExcel->getProperties()->setCreator("ainiku")->setLastModifiedBy("ainiku")->setTitle("feilv export")->setSubject("feilv export")->setDescription("bakdata")->setKeywords("excel")->setCategory("result file");
//设置表头
$obj = $objPHPExcel->setActiveSheetIndex(0);
$fieldnum = count($fieldtitle);
$j = 65;
foreach ($fieldtitle as $v) {
//
$obj->setCellValue(chr($j++) . '1', ' ' . $v);
}
//Set border colors 设置边框颜色
//$obj->freezePane(chr(65).'1:'.chr($j).'1');
$objPHPExcel->getActiveSheet()->getStyle('D13')->getBorders()->getLeft()->getColor()->setARGB('FF993300');
$objPHPExcel->getActiveSheet()->getStyle('D13')->getBorders()->getTop()->getColor()->setARGB('FF993300');
$objPHPExcel->getActiveSheet()->getStyle('D13')->getBorders()->getBottom()->getColor()->setARGB('FF993300');
$objPHPExcel->getActiveSheet()->getStyle('E13')->getBorders()->getRight()->getColor()->setARGB('FF993300');
//Set border colors 设置背景颜色
//$objPHPExcel->getActiveSheet()->getStyle(chr(65).'1:'.chr($j).'1')->getFill()->setFillType(\PHPExcel_Style_Fill::FILL_SOLID);
//$objPHPExcel->getActiveSheet()->getStyle(chr(65).'1:'.chr($j).'1')->getFill()->getStartColor()->setARGB('FFededed');
//以下就是对处理Excel里的数据, 横着取数据,主要是这一步,其他基本都不要改
// 固定第一行
$obj->freezePane('A1');
$fieldnum = count($field);
foreach ($data as $k => $v) {
$num = $k + 2;
$temfield = $field;
$j = 'A';
$i = 0;
//$obj=$objPHPExcel->setActiveSheetIndex(0);
for ($i; $i < $fieldnum; $i++) {
$temstr = array_shift($temfield);
if (substr($temstr, 0, 1) == "'") {
$temstr = str_replace("'", '', $temstr);
$obj->setCellValue($j . $num, ' ' . $v[$temstr]);
} else {
if (substr($temstr, 0, 5) == "#pic#") {
//插入图片
$temstr = str_replace("#pic#", '', $temstr);
$img = new \PHPExcel_Worksheet_Drawing();
$img->setPath($v[$temstr]);
//写入图片路径
$img->setHeight(100);
//写入图片高度
$img->setWidth(100);
//写入图片宽度
$img->setOffsetX(1);
//写入图片在指定格中的X坐标值
$img->setOffsetY(1);
//写入图片在指定格中的Y坐标值
$img->setRotation(1);
//设置旋转角度
$img->getShadow()->setVisible(true);
//
$img->getShadow()->setDirection(50);
//
$img->setCoordinates($j . $num);
//设置图片所在表格位置
//$objPHPExcel->getColumnDimension("$letter[$i]")->setWidth(20);
$obj->getDefaultRowDimension()->setRowHeight(100);
$img->setWorksheet($obj);
//把图片写到当前的表格中
//$objActSheet->getCell('E26')->getHyperlink()->setUrl( 'http://www.phpexcel.net'); //超链接url地址
//$objActSheet->getCell('E26')->getHyperlink()->setTooltip( 'Navigate to website'); //鼠标移上去连接提示信息
//$obj->setCellValue($j.$num, $img);
} else {
if (substr($temstr, 0, 6) == "#link#") {
$temstr = str_replace("#link#", '', $temstr);
$obj->setCellValue($j . $num, $v[$temstr]);
$obj->getCell($j . $num)->getHyperlink()->setUrl($v[$temstr]);
//超链接url地址
$obj->getCell($j . $num)->getHyperlink()->setTooltip($v[$temstr]);
//鼠标移上去连接提
} else {
$obj->setCellValue($j . $num, $v[$temstr]);
}
}
}
$j++;
}
}
$objPHPExcel->getActiveSheet()->setTitle('User');
$objPHPExcel->setActiveSheetIndex(0);
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="' . $name . '.xls"');
header('Cache-Control: max-age=0');
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
}
示例13: addLogo
private function addLogo($preheader)
{
$objDrawing = new \PHPExcel_Worksheet_Drawing();
$objDrawing->setName($preheader->name);
$objDrawing->setDescription($preheader->desc);
$objDrawing->setPath($preheader->logo);
$objDrawing->setOffsetX($preheader->x);
// setOffsetX works properly
$objDrawing->setOffsetY($preheader->y);
//setOffsetY has no effect
$objDrawing->setCoordinates($preheader->coordinates);
$objDrawing->setHeight($preheader->height);
// logo height
$objDrawing->setWorksheet($this->phpExcelObj->getActiveSheet());
}
示例14: outputExcel
public function outputExcel()
{
//设置PHPExcel类库的include path
App::import('Vendor', 'Classes/PHPExcel');
// 创建一个处理对象实例
$objExcel = new PHPExcel();
// 创建文件格式写入对象实例, uncomment
$objWriter = new PHPExcel_Writer_Excel5($objExcel);
// 用于其他版本格式
//or
//$objWriter = new PHPExcel_Writer_Excel2007($objExcel); // 用于 2007 格式
//$objWriter->setOffice2003Compatibility(true);
//设置文档基本属性
$objProps = $objExcel->getProperties();
$objProps->setCreator("Zeal Li");
$objProps->setLastModifiedBy("Zeal Li");
$objProps->setTitle("Office XLS Test Document");
$objProps->setSubject("Office XLS Test Document, Demo");
$objProps->setDescription("Test document, generated by PHPExcel.");
$objProps->setKeywords("office excel PHPExcel");
$objProps->setCategory("Test");
//设置当前的sheet索引,用于后续的内容操作。
//一般只有在使用多个sheet的时候才需要显示调用。
//缺省情况下,PHPExcel会自动创建第一个sheet被设置SheetIndex=0
$objExcel->setActiveSheetIndex(0);
$objActSheet = $objExcel->getActiveSheet();
//设置当前活动sheet的名称
$objActSheet->setTitle('测试Sheet');
//设置单元格内容 由PHPExcel根据传入内容自动判断单元格内容类型
$objActSheet->setCellValue('A1', '字符串内容');
// 字符串内容
$objActSheet->setCellValue('A2', 26);
// 数值
$objActSheet->setCellValue('A3', true);
// 布尔值
$objActSheet->setCellValue('A4', '=SUM(A2:A2)');
// 公式
//显式指定内容类型
$objActSheet->setCellValueExplicit('A5', '8757584', PHPExcel_Cell_DataType::TYPE_STRING);
//合并单元格
$objActSheet->mergeCells('B1:C22');
//分离单元格
$objActSheet->unmergeCells('B1:C22');
//设置宽度
$objActSheet->getColumnDimension('B')->setAutoSize(true);
$objActSheet->getColumnDimension('A')->setWidth(30);
//设置单元格内容的数字格式。
//如果使用了 PHPExcel_Writer_Excel5 来生成内容的话,
//这里需要注意,在 PHPExcel_Style_NumberFormat 类的 const 变量定义的
//各种自定义格式化方式中,其它类型都可以正常使用,但当setFormatCode
//为 FORMAT_NUMBER 的时候,实际出来的效果被没有把格式设置为"0"。需要
//修改 PHPExcel_Writer_Excel5_Format 类源代码中的 getXf($style) 方法,
//在 if ($this->_BIFF_version == 0x0500) { (第363行附近)前面增加一
//行代码:
//if($ifmt === '0') $ifmt = 1;
//设置格式为PHPExcel_Style_NumberFormat::FORMAT_NUMBER,避免某些大数字
//被使用科学记数方式显示,配合下面的 setAutoSize 方法可以让每一行的内容
//都按原始内容全部显示出来。
$objStyleA5 = $objActSheet->getStyle('A5');
$objStyleA5->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER);
//设置字体
$objFontA5 = $objStyleA5->getFont();
$objFontA5->setName('Courier New');
$objFontA5->setSize(10);
$objFontA5->setBold(true);
$objFontA5->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
$objFontA5->getColor()->setARGB('FFFF0000');
$objFontA5->getColor()->setARGB(PHPExcel_Style_Color::COLOR_WHITE);
// $ objFontA5 ->getFont()->setColor(PHPExcel_Style_Color::COLOR_RED);
//设置对齐方式
$objAlignA5 = $objStyleA5->getAlignment();
$objAlignA5->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$objAlignA5->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
//设置边框
$objBorderA5 = $objStyleA5->getBorders();
$objBorderA5->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
$objBorderA5->getTop()->getColor()->setARGB('FFFF0000');
// 边框color
$objBorderA5->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
$objBorderA5->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
$objBorderA5->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
//设置CELL填充颜色
$objFillA5 = $objStyleA5->getFill();
$objFillA5->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$objFillA5->getStartColor()->setARGB('FFEEEEEE');
//从指定的单元格复制样式信息.
$objActSheet->duplicateStyle($objStyleA5, 'B1:C22');
//添加图片
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('ZealImg');
$objDrawing->setDescription('Image inserted by Zeal');
$objDrawing->setPath('./zeali.net.logo.gif');
$objDrawing->setHeight(36);
$objDrawing->setCoordinates('C23');
$objDrawing->setOffsetX(10);
$objDrawing->setRotation(15);
$objDrawing->getShadow()->setVisible(true);
$objDrawing->getShadow()->setDirection(36);
$objDrawing->setWorksheet($objActSheet);
//添加一个新的worksheet
//.........这里部分代码省略.........
示例15: addLogo
/**
* Добавляет лого на страницу
*
* @param PHPExcel_Worksheet $activeSheet
*/
protected function addLogo(PHPExcel_Worksheet $activeSheet)
{
$logo_path = dirname(Yii::app()->basePath) . DIRECTORY_SEPARATOR . 'htdocs/images' . DIRECTORY_SEPARATOR . 'logo.jpg';
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setWorksheet($activeSheet);
$objDrawing->setName("Лого");
$objDrawing->setPath($logo_path);
$objDrawing->setCoordinates('A1');
$objDrawing->setOffsetX(1);
$objDrawing->setOffsetY(5);
$activeSheet->getRowDimension(3)->setRowHeight(40);
}