本文整理汇总了PHP中PHPExcel_Worksheet_Drawing::setPath方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Worksheet_Drawing::setPath方法的具体用法?PHP PHPExcel_Worksheet_Drawing::setPath怎么用?PHP PHPExcel_Worksheet_Drawing::setPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel_Worksheet_Drawing
的用法示例。
在下文中一共展示了PHPExcel_Worksheet_Drawing::setPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ExportExcelRecord
function ExportExcelRecord($arrdata, $datatype, $numberRow, $objPHPExcel, $pageObj)
{
global $cCharset, $locale_info;
$col = -1;
$objASIndex = $objPHPExcel->setActiveSheetIndex(0);
$objASheet = $objPHPExcel->getActiveSheet();
$rowDim = $objASIndex->getRowDimension($numberRow + 1);
foreach ($arrdata as $field => $data) {
$col++;
$colLetter = PHPExcel_Cell::stringFromColumnIndex($col);
$colDim = $objASIndex->getColumnDimension($colLetter);
if ($datatype[$field] == "binary") {
if (!$data) {
continue;
}
if (!function_exists("imagecreatefromstring")) {
$objASIndex->setCellValueByColumnAndRow($col, $numberRow + 1, "LONG BINARY DATA - CANNOT BE DISPLAYED");
continue;
}
$error_handler = set_error_handler("empty_error_handler");
$gdImage = imagecreatefromstring($data);
if ($error_handler) {
set_error_handler($error_handler);
}
if ($gdImage) {
$objDrawing = new PHPExcel_Worksheet_MemoryDrawing();
$objDrawing->setImageResource($gdImage);
$objDrawing->setCoordinates($colLetter . ($row + 1));
$objDrawing->setWorksheet($objASheet);
$width = $objDrawing->getWidth() * 0.143;
$height = $objDrawing->getHeight() * 0.75;
if ($rowDim->getRowHeight() < $height) {
$rowDim->setRowHeight($height);
}
$colDimSh = $objASheet->getColumnDimension($colLetter);
$colDimSh->setAutoSize(false);
if ($colDim->getWidth() < $width) {
$colDim->setWidth($width);
}
}
} elseif ($datatype[$field] == "file") {
$arr = my_json_decode($row[$field]);
if (count($arr) == 0) {
$data = PHPExcel_Shared_String::ConvertEncoding($data, 'UTF-8', $cCharset);
if ($data == "<img src=\"images/no_image.gif\" />") {
$arr[] = array("name" => "images/no_image.gif");
} else {
if (substr($data, 0, 1) == '=') {
$data = '="' . str_replace('"', '""', $data) . '"';
}
$objASIndex->setCellValueByColumnAndRow($col, $numberRow + 1, $data);
continue;
}
}
$offsetY = 0;
$height = 0;
foreach ($arr as $img) {
if (!file_exists($img["name"]) || !$img["name"]) {
$data = PHPExcel_Shared_String::ConvertEncoding($data, 'UTF-8', $cCharset);
if (substr($data, 0, 1) == '=') {
$data = '="' . str_replace('"', '""', $data) . '"';
}
$objASIndex->setCellValueByColumnAndRow($col, $numberRow + 1, $data);
continue;
}
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setPath($img["name"]);
$objDrawing->setCoordinates($colLetter . ($numberRow + 1));
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
$objDrawing->setOffsetY($offsetY);
$width = $objDrawing->getWidth() * 0.143;
$height = $height + $objDrawing->getHeight() * 0.75;
$offsetY = $offsetY + $objDrawing->getHeight();
if ($rowDim->getRowHeight() < $height) {
$rowDim->setRowHeight($height);
}
$colDimSh = $objASheet->getColumnDimension($colLetter);
$colDimSh->setAutoSize(false);
if ($colDim->getWidth() < $width) {
$colDim->setWidth($width);
}
}
} else {
$data = PHPExcel_Shared_String::ConvertEncoding($data, 'UTF-8', $cCharset);
if (substr($data, 0, 1) == '=') {
$data = '="' . str_replace('"', '""', $data) . '"';
}
$objASIndex->setCellValueByColumnAndRow($col, $numberRow + 1, $data);
if ($datatype[$field] == "date") {
$objStyle = $objASIndex->getStyle($colLetter . ($numberRow + 1));
$objNumFrm = $objStyle->getNumberFormat();
$objNumFrm->setFormatCode($locale_info["LOCALE_SSHORTDATE"] . " hh:mm:ss");
}
}
}
}
示例2: load
//.........这里部分代码省略.........
}
}
if ($vmlRelationship != '') {
// 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) {
示例3: hacerReporte
public function hacerReporte()
{
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
if (PHP_SAPI == 'cli') {
die('This example should only be run from a Web Browser');
}
// Create new PHPExcel object
$objPHPExcel = new PHPExcel();
// Set document properties
$objPHPExcel->getProperties()->setCreator("Inmobiliaria Castilla")->setLastModifiedBy("Inmobiliaria Castilla")->setTitle("Apartados")->setSubject("Apartados ")->setDescription("Apartados ")->setKeywords("office 2007 openxml php")->setCategory("Apartados ");
$objPHPExcel->getActiveSheet()->setTitle('Apartados');
//Imagen
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('imagenCastilla');
$objDrawing->setDescription('Imagen de inmobiliaria Castilla');
$objDrawing->setPath('img/logo.jpg');
$objDrawing->setHeight(35);
$objDrawing->setCoordinates('B2');
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
$objPHPExcel->setActiveSheetIndex()->mergeCells('F2:O2');
for ($columna = 'B'; $columna <= 'O'; $columna++) {
$objPHPExcel->getActiveSheet()->getColumnDimension($columna)->setAutoSize(true);
}
$objPHPExcel->getActiveSheet()->setCellValue('F2', 'Apartados')->setCellValue('N3', 'Fecha de reporte')->setCellValue('O3', date('Y-m-d'));
$objPHPExcel->getActiveSheet()->getStyle('F2:O2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->setCellValue('B6', 'Expediente')->setCellValue('C6', 'Lote')->setCellValue('D6', 'Manzana')->setCellValue('E6', 'Desarrollo')->setCellValue('F6', 'Cliente')->setCellValue('G6', 'Fecha')->setCellValue('H6', 'Enganche estimado')->setCellValue('I6', 'Porcentaje de enganche')->setCellValue('J6', 'Descuento estimado')->setCellValue('K6', 'Porcentaje de descuento')->setCellValue('L6', 'Saldo estimado')->setCellValue('M6', 'Forma de pago')->setCellValue('N6', 'Compromiso de apartado')->setCellValue('O6', 'Monto del apartado')->setCellValue('P6', 'Observaciones');
$renglon = 7;
for ($apartado = 0; $apartado < count($this->apartados); $apartado++) {
if ($this->apartados[$apartado]->tipo == 1) {
$cliente = $this->apartados[$apartado]->nombre . " " . $this->apartados[$apartado]->ape_pate . " " . $this->apartados[$apartado]->ape_mate;
} else {
$cliente = $this->apartados[$apartado]->denominacion;
}
$objPHPExcel->getActiveSheet()->setCellValue('B' . $renglon, $this->apartados[$apartado]->id_expediente)->setCellValue('C' . $renglon, $this->apartados[$apartado]->lote)->setCellValue('D' . $renglon, $this->apartados[$apartado]->num_letra)->setCellValue('E' . $renglon, $this->apartados[$apartado]->nombre)->setCellValue('F' . $renglon, $cliente)->setCellValue('G' . $renglon, $this->apartados[$apartado]->fecha)->setCellValue('H' . $renglon, $this->apartados[$apartado]->enganche_estimado)->setCellValue('I' . $renglon, $this->apartados[$apartado]->porEnganche)->setCellValue('J' . $renglon, $this->apartados[$apartado]->descuentoEstimado)->setCellValue('K' . $renglon, $this->apartados[$apartado]->porDescuento)->setCellValue('L' . $renglon, $this->apartados[$apartado]->saldo_estimado)->setCellValue('M' . $renglon, $this->apartados[$apartado]->forma_pago)->setCellValue('N' . $renglon, $this->apartados[$apartado]->monto_apartado)->setCellValue('O' . $renglon, 0)->setCellValue('P' . $renglon, $this->apartados[$apartado]->observaciones);
$renglon++;
}
// Redirect output to a client’s web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
$hoy = date("m_d_Y");
header('Content-Disposition: attachment; filename="' . $hoy . $cliente . 'apartados.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;
}
示例4: hacerReporte
public function hacerReporte()
{
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
if (PHP_SAPI == 'cli') {
die('This example should only be run from a Web Browser');
}
// Create new PHPExcel object
$objPHPExcel = new PHPExcel();
// Set document properties
$objPHPExcel->getProperties()->setCreator("Inmobiliaria Castilla")->setLastModifiedBy("Inmobiliaria Castilla")->setTitle("Catalogo de Clientes Principales")->setSubject("Catalogo de Clientes Principales")->setDescription("Catalogo de Clientes Principales")->setKeywords("office 2007 openxml php")->setCategory("Catalogo de Clientes Principales");
$objPHPExcel->getActiveSheet()->setTitle('Clientes');
//Imagen
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('imagenCastilla');
$objDrawing->setDescription('Imagen de inmobiliaria Castilla');
$objDrawing->setPath('img/logo.jpg');
$objDrawing->setHeight(35);
$objDrawing->setCoordinates('B2');
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
$objPHPExcel->setActiveSheetIndex()->mergeCells('F2:O2');
for ($columna = 'B'; $columna <= 'O'; $columna++) {
$objPHPExcel->getActiveSheet()->getColumnDimension($columna)->setAutoSize(true);
}
$objPHPExcel->getActiveSheet()->setCellValue('F2', 'Catalogo de Clientes Principales Inmobiliaria Castilla');
$objPHPExcel->getActiveSheet()->getStyle('F2:O2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->setCellValue('F4', 'Fecha del reporte')->setCellValue('G4', date('Y-m-d'))->setCellValue('B6', 'RFC')->setCellValue('C6', 'Denominación')->setCellValue('D6', 'Nombre')->setCellValue('E6', 'Apellido paterno')->setCellValue('F6', 'Apellido materno')->setCellValue('G6', 'Telefono oficina')->setCellValue('H6', 'Email')->setCellValue('I6', 'Contratos activos');
$renglon = 7;
for ($cliente = 0; $cliente < count($this->catalogoCliente); $cliente++) {
$objPHPExcel->getActiveSheet()->setCellValue('A' . $renglon, $cliente + 1)->setCellValue('B' . $renglon, $this->catalogoCliente[$cliente]['cliente']->rfc)->setCellValue('C' . $renglon, $this->catalogoCliente[$cliente]['cliente']->denominacion)->setCellValue('D' . $renglon, $this->catalogoCliente[$cliente]['cliente']->nombre)->setCellValue('E' . $renglon, $this->catalogoCliente[$cliente]['cliente']->ape_pate)->setCellValue('F' . $renglon, $this->catalogoCliente[$cliente]['cliente']->ape_mate)->setCellValue('G' . $renglon, $this->catalogoCliente[$cliente]['cliente']->telefono)->setCellValue('H' . $renglon, $this->catalogoCliente[$cliente]['cliente']->email)->setCellValue('I' . $renglon, $this->catalogoCliente[$cliente]['numero_expedientes']);
$columna = "J";
for ($contrato = 0; $contrato < count($this->catalogoCliente[$cliente]['expedientes']); $contrato++) {
$objPHPExcel->getActiveSheet()->setCellValue($columna . $renglon, $this->catalogoCliente[$cliente]['expedientes'][$contrato]->id_expediente);
$columna++;
}
$renglon++;
}
// Redirect output to a client’s web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;corrida_financiera.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;
}
示例5: attachChart
private function attachChart($img_path)
{
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName($this->title);
$objDrawing->setDescription($this->title . ' graph');
$objDrawing->setPath($img_path);
$objDrawing->setCoordinates($this->cell);
$objDrawing->setWorksheet($this->worksheet);
$getRow = str_replace($this->cell[0], "", $this->cell);
$this->worksheet->getRowDimension($getRow)->setRowHeight($this->height);
}
示例6: 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;
}
示例7: addImage
function addImage($range, $excelAPI, $imageName, $merged, $excelWorksheet)
{
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('DOTC LOGO');
$objDrawing->setDescription('Dotc Logo');
$objDrawing->setPath($imageName);
//$objDrawing->setHeight(36);
$objDrawing->setWorksheet($excelAPI->getActiveSheet());
$objDrawing->setCoordinates(strtoupper($range[0]));
// setImagesRoot('http://www.example.com');
// $excelAPI->insertImage($imageName,$range[0],$range[1],$merged,$excelWorksheet);
}
示例8: 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);
}
示例9: 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;
}
示例10: ponerLogo
public static function ponerLogo($objActSheet, $coordinate)
{
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('IntegrarCT');
$objDrawing->setDescription('Logo IntegrarCT');
$objDrawing->setPath($_SERVER['DOCUMENT_ROOT'] . '/integrarCT/resources/img/logo_reporte.png');
$objDrawing->setHeight(70);
$objDrawing->setCoordinates($coordinate);
//$objDrawing->setOffsetX(10);
//$objDrawing->setRotation(15);
$objDrawing->getShadow()->setVisible(true);
$objDrawing->getShadow()->setDirection(70);
$objDrawing->setWorksheet($objActSheet);
}
示例11: _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;
}
示例12: totalesSum
totalesSum($objPHPExcel, $estiloCabecera, $cell);
//CREAR PESTAÑA PARA AGREGAR GRAFICAS
$objPHPExcel->createSheet(1);
$objPHPExcel->setActiveSheetIndex(1);
//Seleccionar la pestaña deseada
$objPHPExcel->getActiveSheet()->setTitle("Graficas");
//Establecer nombre para la pestaña
//reiniciar cell en la nueva pestaña
$cell = 2;
// objeto PHPExcel_Worksheet_Drawing para agregar la imagen
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName($foto);
$objDrawing->setDescription('Logo');
$logo = $foto;
// Provide path to your logo file
$objDrawing->setPath($logo);
//setOffsetY has no effect
$objDrawing->setCoordinates('B' . $cell);
$objDrawing->setHeight(500);
// logo height
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
$cell = $cell + 14;
// Se activa la hoja 0 de Empresas para mostrar como principal
$objPHPExcel->setActiveSheetIndex(0);
//FIN EXCEL
$writer = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
// This line will force the file to download
$writer->save('php://output');
} else {
echo "no hay data";
}
示例13: date
$objPHPExcel->getActiveSheet()->getTabColor()->setARGB('FF0094FF');
// Set alignments
echo date('H:i:s'), " Set alignments", EOL;
$objPHPExcel->getActiveSheet()->getStyle('A3:A6')->getAlignment()->setWrapText(true);
// Set column widths
echo date('H:i:s'), " Set column widths", EOL;
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(80);
// Set fonts
echo date('H:i:s'), " Set fonts", EOL;
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setName('Candara');
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setSize(20);
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
$objPHPExcel->getActiveSheet()->getStyle('A3:A6')->getFont()->setSize(8);
// Add a drawing to the worksheet
echo date('H:i:s'), " Add a drawing to the worksheet", EOL;
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('Terms and conditions');
$objDrawing->setDescription('Terms and conditions');
$objDrawing->setPath('./images/termsconditions.jpg');
$objDrawing->setCoordinates('B14');
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
// Set page orientation and size
echo date('H:i:s'), " Set page orientation and size", EOL;
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
// Rename second worksheet
echo date('H:i:s'), " Rename second worksheet", EOL;
$objPHPExcel->getActiveSheet()->setTitle('Terms and conditions');
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);
示例14: _convert_array_to_excel
/**
* @author caochunhui@dachuwang.com
* @description 用数组和地址直接生成excel文件
* 每一个数组占一个sheet
*/
private function _convert_array_to_excel($arr = array(), $sheet_titles = array(), $out_name = '', $barcode_arr = array())
{
//下面的代码是抄的。
//set cache
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp;
PHPExcel_Settings::setCacheStorageMethod($cacheMethod);
//open excel file
$write_objPHPExcel = new PHPExcel();
$write_objPHPExcel->getDefaultStyle()->getFont()->setName('simsun')->setSize(10);
//下面要循环了
$sheet_cnt = 0;
foreach ($arr as $item) {
//用订单id.csv来命名每一个sheet
$out_sheet = new PHPExcel_Worksheet($write_objPHPExcel, $sheet_titles[$sheet_cnt]);
//$out_sheet->setTitle($item);
//row index start from 1
$row_index = 0;
foreach ($item as $row) {
$row_index++;
//$cellIterator = $row->getCellIterator();
//$cellIterator->setIterateOnlyExistingCells(false);
//column index start from 0
$column_index = -1;
foreach ($row as $cell) {
$column_index++;
//var_dump($cell);
$out_sheet->setCellValueByColumnAndRow($column_index, $row_index, $cell, PHPExcel_Cell_DataType::TYPE_STRING);
}
}
//如果条码数组不为空,那么说明需要在sheet里插入条码
if (!empty($barcode_arr) && isset($barcode_arr[$sheet_cnt])) {
$barcode_download_res = $this->_download_barcode($barcode_arr[$sheet_cnt]);
if ($barcode_download_res['code'] == 200) {
//no pic you say a jb
$pic_path = $barcode_download_res['file'];
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('barcode');
$objDrawing->setDescription('');
$objDrawing->setPath($pic_path);
$objDrawing->setHeight(50);
$objDrawing->setCoordinates('D26');
//$objDrawing->setOffsetX(10);
//$objDrawing->getShadow()->setVisible(true);
//$objDrawing->getShadow()->setDirection(36);
$objDrawing->setWorksheet($out_sheet);
//no pic you say a jb
}
}
$write_objPHPExcel->addSheet($out_sheet);
$sheet_cnt++;
}
$write_objPHPExcel->removeSheetByIndex(0);
//删除第一个空sheet
//上面要循环了
//上面的代码是抄的
//write excel file
$objWriter = new PHPExcel_Writer_Excel2007($write_objPHPExcel);
$dir_name = dirname($out_name);
if (!is_dir($dir_name)) {
$res = mkdir($dir_name, 0777, TRUE);
}
$objWriter->save($out_name);
}
示例15: postAction
//.........这里部分代码省略.........
// 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);
$objPHPExcel->getActiveSheet()->getStyle('F3')->applyFromArray($styleThinBlackBorderOutline);
$objPHPExcel->getActiveSheet()->getStyle('G3')->applyFromArray($styleThinBlackBorderOutline);
// Set fills
//echo date('H:i:s') , " Set fills" , EOL;
$objPHPExcel->getActiveSheet()->getStyle('A1:G1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$objPHPExcel->getActiveSheet()->getStyle('A1:G1')->getFill()->getStartColor()->setARGB('FFFFFF');
$objPHPExcel->getActiveSheet()->getStyle('A2:G2')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$objPHPExcel->getActiveSheet()->getStyle('A2:G2')->getFill()->getStartColor()->setARGB('FFFFFF');
// Set style for header row using alternative method
//echo date('H:i:s') , " Set style for header row using alternative method" , EOL;
$objPHPExcel->getActiveSheet()->getStyle('A3:G3')->applyFromArray(array('font' => array('bold' => true), 'borders' => array('top' => array('style' => PHPExcel_Style_Border::BORDER_THIN))));
// Add a drawing to the worksheet
//echo date('H:i:s') , " Add a drawing to the worksheet" , EOL;
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('Logo');
$objDrawing->setDescription('Logo');
$objDrawing->setPath('./images/logo.png');
$objDrawing->setHeight(133);
$objDrawing->setWidth(281);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
//$post['id'] = array("1","2","3","4","5");
$products = Mage::getModel('catalog/product')->getCollection();
$products->addAttributeToSelect('*');
$prodIds = $products->getAllIds();
$product = Mage::getModel('catalog/product');
$counter_test = 0;
$i = 4;
foreach ($post['id'] as $productId) {
if (++$counter_test < 30000) {
$product->load($productId);
$style_number = str_replace('"', '', $product->getSku());
$image_link = $product->getImage();
$description = htmlspecialchars(iconv("UTF-8", "UTF-8//IGNORE", $product->getDescription()));
$product->setCustomerGroupId(2);
$wholesale = number_format($product->getPriceModel()->getFinalPrice(1, $product), 2);
$price_temp = round($product->getPrice(), 2);
$price = round($product->getPrice(), 2);
$special_price = number_format($product->getSpecialPrice(), 2);
$qty = $product->getStockItem()->getQty();
$objPHPExcel->getActiveSheet()->getRowDimension($i)->setRowHeight(190);
//Infromation 1
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, $style_number);
$objPHPExcel->getActiveSheet()->getStyle('A' . $i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A' . $i)->getAlignment()->setIndent(9);
$objPHPExcel->getActiveSheet()->getStyle('A' . $i)->getFont()->setName('Arial')->setSize(10)->getColor()->setRGB('000000');
$objPHPExcel->getActiveSheet()->getStyle('A' . $i)->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('A' . $i . ':G' . $i)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$objPHPExcel->getActiveSheet()->getStyle('A' . $i . ':G' . $i)->getFill()->getStartColor()->setARGB('FFFFFF');
$objPHPExcel->getActiveSheet()->getStyle('A' . $i)->applyFromArray($styleThinBlackBorderOutline);