本文整理汇总了PHP中PHPExcel_Worksheet_Drawing::setCoordinates方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Worksheet_Drawing::setCoordinates方法的具体用法?PHP PHPExcel_Worksheet_Drawing::setCoordinates怎么用?PHP PHPExcel_Worksheet_Drawing::setCoordinates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel_Worksheet_Drawing
的用法示例。
在下文中一共展示了PHPExcel_Worksheet_Drawing::setCoordinates方法的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 ($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"]);
}
}
}
$xmlDrawing = simplexml_load_string($this->_getFromZipArchive($zip, $fileDrawing))->children("http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing");
if ($xmlDrawing->oneCellAnchor) {
foreach ($xmlDrawing->oneCellAnchor as $oneCellAnchor) {
if ($oneCellAnchor->pic->blipFill) {
$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 ($xmlDrawing->twoCellAnchor) {
foreach ($xmlDrawing->twoCellAnchor as $twoCellAnchor) {
if ($twoCellAnchor->pic->blipFill) {
$blip = $twoCellAnchor->pic->blipFill->children("http://schemas.openxmlformats.org/drawingml/2006/main")->blip;
$xfrm = $twoCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->xfrm;
$outerShdw = $twoCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->effectLst->outerShdw;
$objDrawing = new PHPExcel_Worksheet_Drawing;
$objDrawing->setName((string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), "name"));
$objDrawing->setDescription((string) self::array_item($twoCellAnchor->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);
示例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: 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);
}
示例8: 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);
}
示例9: 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);
}
示例10: _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;
}
示例11:
$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";
}
}
/*
示例12: _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);
}
示例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: date
$objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl('http://www.phpexcel.net');
$objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->setTooltip('Navigate to website');
$objPHPExcel->getActiveSheet()->getStyle('E26')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$objPHPExcel->getActiveSheet()->setCellValue('E27', 'Terms and conditions');
$objPHPExcel->getActiveSheet()->getCell('E27')->getHyperlink()->setUrl("sheet://'Terms and conditions'!A1");
$objPHPExcel->getActiveSheet()->getCell('E27')->getHyperlink()->setTooltip('Review terms and conditions');
$objPHPExcel->getActiveSheet()->getStyle('E27')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);*/
// 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/nextel2.jpg');
$objDrawing->setHeight(50);
$objDrawing->setCoordinates('C3');
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
// 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('Paid');
$objDrawing->setDescription('Paid');
$objDrawing->setPath('./images/paid.png');
$objDrawing->setCoordinates('B15');
$objDrawing->setOffsetX(110);
$objDrawing->setRotation(25);
$objDrawing->getShadow()->setVisible(true);
$objDrawing->getShadow()->setDirection(45);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());*/
// Add a drawing to the worksheet
/*echo date('H:i:s') , " Add a drawing to the worksheet" , EOL;
示例15: 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("Cobranza Proyectada")->setSubject("Cobranza Proyectada")->setDescription("Cobranza Proyectada")->setKeywords("office 2007 openxml php")->setCategory("Cobranza Proyectada");
$objPHPExcel->getActiveSheet()->setTitle('Cobranza');
//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 = 'A'; $columna <= 'D'; $columna++) {
$objPHPExcel->getActiveSheet()->getColumnDimension($columna)->setAutoSize(true);
}
$objPHPExcel->getActiveSheet()->setCellValue('F2', 'Cobranza Proyectada');
$objPHPExcel->getActiveSheet()->getStyle('F2:O2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->setCellValue('F3', 'Fecha de reporte')->setCellValue('G3', date('Y-m-d'));
$columna = 'F';
$objPHPExcel->getActiveSheet()->setCellValue('B6', 'Expediente')->setCellValue('C6', 'Cliente')->setCellValue('D6', 'Mes');
$anio = 0;
$mes = 0;
$meses = array(1 => 'Enero', 2 => 'Febrero', 3 => 'Marzo', 4 => 'Abril', 5 => 'Mayo', 6 => 'Junio', 7 => 'Julio', 8 => 'Agosto', 9 => 'Septiembre', 10 => 'Octubre', 11 => 'Noviembre', 12 => 'Diciembre');
$fecha = $this->cobranza['fechaInicio'];
$num_columnas = 0;
while (strtotime($fecha) <= strtotime($this->cobranza['fechaFinal'])) {
$f = explode('-', $fecha);
$anio = $f[0];
$mes = $f[1];
if ($mes[0] == '0') {
$mes = $mes[1];
}
$objPHPExcel->getActiveSheet()->setCellValue($columna . '6', $meses[$mes] . ' ' . $anio);
$objPHPExcel->getActiveSheet()->getColumnDimension($columna)->setAutoSize(true);
$columna++;
if ($mes == 12) {
$anio++;
$mes = 1;
} else {
$mes++;
}
$fecha = $anio . '-' . $mes . '-1';
// Acumadores para las distintos meses
$acum_meses[$num_columnas] = 0;
$num_columnas++;
}
$ultima_columna = $columna;
$renglon = 8;
$total = 0;
for ($desarrollo = 0; $desarrollo < count($this->cobranza['cobranza']); $desarrollo++) {
$objPHPExcel->setActiveSheetIndex()->mergeCells('F' . $renglon . ':N' . $renglon);
$objPHPExcel->getActiveSheet()->getStyle('F' . $renglon . ':N' . $renglon)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->setCellValue('F' . $renglon, $this->cobranza['cobranza'][$desarrollo]['desarrollo']->nombre);
$renglon += 2;
for ($expediente = 0; $expediente < count($this->cobranza['cobranza'][$desarrollo]['expedientes']); $expediente++) {
if ($this->cobranza['cobranza'][$desarrollo]['expedientes'][$expediente]['cliente']->tipo == 1) {
$cliente = $this->cobranza['cobranza'][$desarrollo]['expedientes'][$expediente]['cliente']->nombre . ' ' . $this->cobranza['cobranza'][$desarrollo]['expedientes'][$expediente]['cliente']->ape_pate . ' ' . $this->cobranza['cobranza'][$desarrollo]['expedientes'][$expediente]['cliente']->ape_mate;
} else {
$cliente = $this->cobranza['cobranza'][$desarrollo]['expedientes'][$expediente]['cliente']->denominacion;
}
$objPHPExcel->getActiveSheet()->setCellValue('B' . $renglon, $this->cobranza['cobranza'][$desarrollo]['expedientes'][$expediente]['expediente']->id_expediente)->setCellValue('C' . $renglon, $cliente);
if ($this->cobranza['cobranza'][$desarrollo]['expedientes'][$expediente]['mensualidades'] != null) {
$fechaInicio = explode('-', $this->cobranza['fechaInicio']);
$f = explode('-', $this->cobranza['cobranza'][$desarrollo]['expedientes'][$expediente]['mensualidades'][0]['fecha_vence']);
$anios = $f[0] - $fechaInicio[0];
$meses = $f[1] - $fechaInicio[1] + 12 * $anios;
$columna = 'F';
$i = 0;
while ($i < $meses) {
$columna++;
$i++;
}
} else {
continue;
}
$cli_total = 0;
for ($mensualidad = 0; $mensualidad < count($this->cobranza['cobranza'][$desarrollo]['expedientes'][$expediente]['mensualidades']); $mensualidad++) {
$t = $this->cobranza['cobranza'][$desarrollo]['expedientes'][$expediente]['mensualidades'][$mensualidad]['capital'] + $this->cobranza['cobranza'][$desarrollo]['expedientes'][$expediente]['mensualidades'][$mensualidad]['actualizacion'] + $this->cobranza['cobranza'][$desarrollo]['expedientes'][$expediente]['mensualidades'][$mensualidad]['admon_cobra'] + $this->cobranza['cobranza'][$desarrollo]['expedientes'][$expediente]['mensualidades'][$mensualidad]['interes'];
$acum_meses[$meses] += $t;
$meses++;
$cli_total += $t;
$objPHPExcel->getActiveSheet()->setCellValue($columna . $renglon, $t);
$columna++;
}
$objPHPExcel->getActiveSheet()->setCellValue($ultima_columna . $renglon, $cli_total);
$total += $cli_total;
$renglon++;
}
}
//.........这里部分代码省略.........