本文整理汇总了PHP中PHPExcel_Worksheet_Drawing::setDescription方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Worksheet_Drawing::setDescription方法的具体用法?PHP PHPExcel_Worksheet_Drawing::setDescription怎么用?PHP PHPExcel_Worksheet_Drawing::setDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel_Worksheet_Drawing
的用法示例。
在下文中一共展示了PHPExcel_Worksheet_Drawing::setDescription方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* Loads PHPExcel from file
*
* @param string $pFilename
* @throws Exception
*/
public function load($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// Initialisations
$excel = new PHPExcel;
$excel->removeSheetByIndex(0);
if (!$this->_readDataOnly) {
$excel->removeCellStyleXfByIndex(0); // remove the default style
$excel->removeCellXfByIndex(0); // remove the default style
}
$zip = new ZipArchive;
$zip->open($pFilename);
$rels = simplexml_load_string($this->_getFromZipArchive($zip, "_rels/.rels")); //~ http://schemas.openxmlformats.org/package/2006/relationships");
foreach ($rels->Relationship as $rel) {
switch ($rel["Type"]) {
case "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties":
$xmlCore = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}"));
if ($xmlCore) {
$xmlCore->registerXPathNamespace("dc", "http://purl.org/dc/elements/1.1/");
$xmlCore->registerXPathNamespace("dcterms", "http://purl.org/dc/terms/");
$xmlCore->registerXPathNamespace("cp", "http://schemas.openxmlformats.org/package/2006/metadata/core-properties");
$docProps = $excel->getProperties();
$docProps->setCreator((string) self::array_item($xmlCore->xpath("dc:creator")));
$docProps->setLastModifiedBy((string) self::array_item($xmlCore->xpath("cp:lastModifiedBy")));
$docProps->setCreated(strtotime(self::array_item($xmlCore->xpath("dcterms:created")))); //! respect xsi:type
$docProps->setModified(strtotime(self::array_item($xmlCore->xpath("dcterms:modified")))); //! respect xsi:type
$docProps->setTitle((string) self::array_item($xmlCore->xpath("dc:title")));
$docProps->setDescription((string) self::array_item($xmlCore->xpath("dc:description")));
$docProps->setSubject((string) self::array_item($xmlCore->xpath("dc:subject")));
$docProps->setKeywords((string) self::array_item($xmlCore->xpath("cp:keywords")));
$docProps->setCategory((string) self::array_item($xmlCore->xpath("cp:category")));
}
break;
case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument":
$dir = dirname($rel["Target"]);
$relsWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/_rels/" . basename($rel["Target"]) . ".rels")); //~ http://schemas.openxmlformats.org/package/2006/relationships");
$relsWorkbook->registerXPathNamespace("rel", "http://schemas.openxmlformats.org/package/2006/relationships");
$sharedStrings = array();
$xpath = self::array_item($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings']"));
$xmlStrings = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/$xpath[Target]")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");
if (isset($xmlStrings) && isset($xmlStrings->si)) {
foreach ($xmlStrings->si as $val) {
if (isset($val->t)) {
$sharedStrings[] = PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $val->t );
} elseif (isset($val->r)) {
$sharedStrings[] = $this->_parseRichText($val);
}
}
}
$worksheets = array();
foreach ($relsWorkbook->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet") {
$worksheets[(string) $ele["Id"]] = $ele["Target"];
}
}
$styles = array();
$cellStyles = array();
$xpath = self::array_item($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles']"));
$xmlStyles = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/$xpath[Target]")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");
$numFmts = null;
if ($xmlStyles && $xmlStyles->numFmts[0]) {
$numFmts = $xmlStyles->numFmts[0];
}
if (isset($numFmts) && !is_null($numFmts)) {
$numFmts->registerXPathNamespace("sml", "http://schemas.openxmlformats.org/spreadsheetml/2006/main");
}
if (!$this->_readDataOnly && $xmlStyles) {
foreach ($xmlStyles->cellXfs->xf as $xf) {
$numFmt = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
if ($xf["numFmtId"]) {
if (isset($numFmts)) {
$tmpNumFmt = self::array_item($numFmts->xpath("sml:numFmt[@numFmtId=$xf[numFmtId]]"));
if (isset($tmpNumFmt["formatCode"])) {
$numFmt = (string) $tmpNumFmt["formatCode"];
}
}
if ((int)$xf["numFmtId"] < 164) {
$numFmt = PHPExcel_Style_NumberFormat::builtInFormatCode((int)$xf["numFmtId"]);
}
}
//$numFmt = str_replace('mm', 'i', $numFmt);
//$numFmt = str_replace('h', 'H', $numFmt);
//.........这里部分代码省略.........
示例2: 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;
}
示例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("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;
}
示例4: 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);
}
示例5: 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);
}
示例6: 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);
}
示例7: 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);
}
示例8: generate
//.........这里部分代码省略.........
echo "<br />Invalid HTML DOM, nothing to Export.";
exit;
}
$dom->preserveWhiteSpace = false;
// remove redundant whitespace
$tables = $dom->getElementsByTagName('table');
if (!is_object($tables)) {
echo "<br />Invalid HTML Table DOM, nothing to Export.";
exit;
}
if ($debug) {
fwrite($handle, "\nTable Count: " . $tables->length);
}
$tbcnt = $tables->length - 1;
// count minus 1 for 0 indexed loop over tables
if ($tbcnt > $limit) {
$tbcnt = $limit;
}
//
//
// Create new PHPExcel object with default attributes
//
require_once 'PHPExcel/PHPExcel.php';
$objPHPExcel = new PHPExcel();
$objPHPExcel->getDefaultStyle()->getFont()->setName('Arial');
$objPHPExcel->getDefaultStyle()->getFont()->setSize(9);
$tm = date(YmdHis);
$pos = strpos($usermail, "@");
$user = substr($usermail, 0, $pos);
$user = str_replace(".", "", $user);
$tfn = $user . "_" . $tm . "_" . $tablevar . ".xlsx";
//$fname = "AuditLog/".$tfn;
$fname = $tfn;
$objPHPExcel->getProperties()->setCreator($username)->setLastModifiedBy($username)->setTitle("Automated Export")->setSubject("Automated Report Generation")->setDescription("Automated report generation.")->setKeywords("Exported File")->setCompany($usercompany)->setCategory("Export");
//
// Loop over tables in DOM to create an array, each table becomes a worksheet
//
for ($z = 0; $z <= $tbcnt; $z++) {
$maxcols = 0;
$totrows = 0;
$headrows = array();
$bodyrows = array();
$r = 0;
$h = 0;
$rows = $tables->item($z)->getElementsByTagName('tr');
$totrows = $rows->length;
if ($debug) {
fwrite($handle, "\nTotal Rows: " . $totrows);
}
foreach ($rows as $row) {
$ths = $row->getElementsByTagName('th');
if (is_object($ths)) {
if ($ths->length > 0) {
$headrows[$h]['colcnt'] = $ths->length;
if ($ths->length > $maxcols) {
$maxcols = $ths->length;
}
$nodes = $ths->length - 1;
for ($x = 0; $x <= $nodes; $x++) {
$thishdg = $ths->item($x)->nodeValue;
$headrows[$h]['th'][] = $thishdg;
$headrows[$h]['bold'][] = $this->findWrapText('b', $this->innerHTML($ths->item($x)));
$headrows[$h]['italic'][] = $this->findWrapText('i', $this->innerHTML($ths->item($x)));
$headrows[$h]['underline'][] = $this->findWrapText('u', $this->innerHTML($ths->item($x)));
if ($ths->item($x)->hasAttribute('style')) {
$style = $ths->item($x)->getAttribute('style');
示例9: receta_generate_xlsx
public function receta_generate_xlsx($params = array(), $save = false)
{
$title = array_key_exists('title', $params) ? $params['title'] : 'IS_XLSX';
$items_recetas = array_key_exists('items_receta', $params) ? $params['items_receta'] : false;
$headers_receta = array_key_exists('headers_receta', $params) ? $params['headers_receta'] : false;
$items_valores = array_key_exists('items_valores', $params) ? $params['items_valores'] : false;
$headers_valores = array_key_exists('headers_valores', $params) ? $params['headers_valores'] : false;
$headers_costo_total = array_key_exists('headers_costo_total', $params) ? $params['headers_costo_total'] : false;
$items_costo_total = array_key_exists('items_costo_total', $params) ? $params['items_costo_total'] : false;
$preparacion = array_key_exists('preparacion', $params) ? $params['preparacion'] : false;
if ($items_recetas && $headers_receta && $items_valores && $headers_valores) {
$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setCreator("IS Intelligent Solution")->setLastModifiedBy("IS Intelligent Solution")->setTitle($title)->setSubject($title)->setDescription($title)->setKeywords("office 2007 openxml");
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('Logo');
$objDrawing->setDescription('Logo');
$objDrawing->setPath('./assets/images/logo.png');
$objDrawing->setHeight(36);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
$countHeadersReceta = count($params['headers_receta']) + 64;
$columnReceta = chr($countHeadersReceta) . '3';
$total_valores = count($params['items_valores']);
$inicio_total = 'D' . (count($params['items_valores']) + 7);
$unidad_total = 'D' . (count($params['items_valores']) + 6);
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setName('Candara');
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setSize(22);
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
$objPHPExcel->getActiveSheet()->getStyle("A1:" . chr($countHeadersReceta) . '1')->applyFromArray($this->defaultStyle_headers());
/*$objPHPExcel->getActiveSheet()->mergeCells('G1:K1')->getStyle("G1:K1")->applyFromArray($this->defaultStyle_aviso());
$objPHPExcel->getActiveSheet()->mergeCells('G2:K2')->getStyle("G2:K2")->applyFromArray($this->defaultStyle_aviso());
$objPHPExcel->getActiveSheet()->mergeCells('G3:K3')->getStyle("G3:K3")->applyFromArray($this->defaultStyle_aviso());
$objPHPExcel->getActiveSheet()->mergeCells('G4:K4')->getStyle("G4:K4")->applyFromArray($this->defaultStyle_aviso());*/
$objPHPExcel->getActiveSheet()->setCellValue('C1', $title);
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->fromArray($params['headers_receta'], null, 'A3');
$objPHPExcel->getActiveSheet()->getStyle("A3:{$columnReceta}")->applyFromArray($this->defaultStyle_headers());
$objPHPExcel->getActiveSheet()->fromArray($params['headers_valores'], null, 'A6');
$objPHPExcel->getActiveSheet()->getStyle("A6:AC6")->applyFromArray($this->defaultStyle_headers());
foreach (range('A', $columnReceta) as $columnID) {
$objPHPExcel->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
}
for ($i = "A"; $i != "AE"; $i++) {
$objPHPExcel->getActiveSheet()->getColumnDimension($i)->setAutoSize(true);
}
foreach (range('A', $columnReceta) as $columnID) {
$objPHPExcel->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
}
$items = $objPHPExcel->getActiveSheet()->fromArray($params['items_receta'], null, 'A4');
$objPHPExcel->setActiveSheetIndex(0);
$items = $objPHPExcel->getActiveSheet()->fromArray($params['items_valores'], null, 'A7');
$objPHPExcel->setActiveSheetIndex(0);
for ($i = 'E'; $i != 'AD'; $i++) {
$objPHPExcel->getActiveSheet()->mergeCells('K' . (count($params['items_valores']) + 9) . ':O' . (count($params['items_valores']) + 9));
$objPHPExcel->getActiveSheet()->setCellValue('E' . (count($params['items_valores']) + 7), 'Costo Total $');
$objPHPExcel->getActiveSheet()->setCellValue('F' . (count($params['items_valores']) + 7), '(g.)');
$objPHPExcel->getActiveSheet()->setCellValue('G' . (count($params['items_valores']) + 7), '(g.)');
$objPHPExcel->getActiveSheet()->setCellValue('H' . (count($params['items_valores']) + 7), '(kcal.)');
$objPHPExcel->getActiveSheet()->setCellValue('I' . (count($params['items_valores']) + 7), '(g.)');
$objPHPExcel->getActiveSheet()->setCellValue('J' . (count($params['items_valores']) + 7), '(g.)');
$objPHPExcel->getActiveSheet()->setCellValue('K' . (count($params['items_valores']) + 7), '(g.)');
$objPHPExcel->getActiveSheet()->setCellValue('L' . (count($params['items_valores']) + 7), '(g.)');
$objPHPExcel->getActiveSheet()->setCellValue('M' . (count($params['items_valores']) + 7), '(µg RE.)');
$objPHPExcel->getActiveSheet()->setCellValue('N' . (count($params['items_valores']) + 7), '(mg.)');
$objPHPExcel->getActiveSheet()->setCellValue('O' . (count($params['items_valores']) + 7), '(mg.)');
$objPHPExcel->getActiveSheet()->setCellValue('P' . (count($params['items_valores']) + 7), '(mg.)');
$objPHPExcel->getActiveSheet()->setCellValue('Q' . (count($params['items_valores']) + 7), '(mg.)');
$objPHPExcel->getActiveSheet()->setCellValue('R' . (count($params['items_valores']) + 7), '(g.)');
$objPHPExcel->getActiveSheet()->setCellValue('S' . (count($params['items_valores']) + 7), '(.)');
$objPHPExcel->getActiveSheet()->setCellValue('T' . (count($params['items_valores']) + 7), '(.)');
$objPHPExcel->getActiveSheet()->setCellValue('U' . (count($params['items_valores']) + 7), '(mg.)');
$objPHPExcel->getActiveSheet()->setCellValue('V' . (count($params['items_valores']) + 7), '(mg.)');
$objPHPExcel->getActiveSheet()->setCellValue('W' . (count($params['items_valores']) + 7), '(mcg.)');
$objPHPExcel->getActiveSheet()->setCellValue('X' . (count($params['items_valores']) + 7), '(mg.)');
$objPHPExcel->getActiveSheet()->setCellValue('Y' . (count($params['items_valores']) + 7), '(mg.)');
$objPHPExcel->getActiveSheet()->setCellValue('Z' . (count($params['items_valores']) + 7), '(g.)');
$objPHPExcel->getActiveSheet()->setCellValue('AA' . (count($params['items_valores']) + 7), '(g.)');
$objPHPExcel->getActiveSheet()->setCellValue('AB' . (count($params['items_valores']) + 7), '(g.)');
$objPHPExcel->getActiveSheet()->setCellValue('AC' . (count($params['items_valores']) + 7), '(g.)');
$objPHPExcel->getActiveSheet()->setCellValue('E' . (count($params['items_valores']) + 9), 'Costo Porción $');
$objPHPExcel->getActiveSheet()->getStyle($i . (count($params['items_valores']) + 8) . ':AC' . (count($params['items_valores']) + 8))->getBorders()->getAllBorders()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
$objPHPExcel->getActiveSheet()->getStyle($i . (count($params['items_valores']) + 10) . ':AC' . (count($params['items_valores']) + 10))->getBorders()->getAllBorders()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
$objPHPExcel->getActiveSheet()->getStyle($i . (count($params['items_valores']) + 7) . ':' . $i . (count($params['items_valores']) + 7))->applyFromArray($this->defaultStyle_headers());
$objPHPExcel->getActiveSheet()->getStyle($i . (count($params['items_valores']) + 9) . ':' . $i . (count($params['items_valores']) + 9))->applyFromArray($this->defaultStyle_headers());
$objPHPExcel->getActiveSheet()->setCellValue($i . (count($params['items_valores']) + 8), '=SUM(' . $i . '7:' . $i . (count($params['items_valores']) + 7) . ')');
$objPHPExcel->getActiveSheet()->setCellValue($i . (count($params['items_valores']) + 10), '=(' . $i . (count($params['items_valores']) + 8) . '/D4)');
$objPHPExcel->setActiveSheetIndex(0);
}
$objPHPExcel->getActiveSheet()->getStyle('A' . (count($params['items_valores']) + 12) . ':O' . (count($params['items_valores']) + 12))->applyFromArray($this->defaultStyle_headers());
$objPHPExcel->getActiveSheet()->mergeCells('A' . (count($params['items_valores']) + 12) . ':O' . (count($params['items_valores']) + 12));
$objPHPExcel->getActiveSheet()->setCellValue('A' . (count($params['items_valores']) + 12), 'PREPARACIÓN');
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->getRowDimension(count($params['items_valores']) + 13)->setRowHeight(40);
$objPHPExcel->getActiveSheet()->getStyle('A' . (count($params['items_valores']) + 13) . ':O' . (count($params['items_valores']) + 13))->getBorders()->getAllBorders()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
$objPHPExcel->getActiveSheet()->mergeCells('A' . (count($params['items_valores']) + 13) . ':O' . (count($params['items_valores']) + 13));
$objPHPExcel->getActiveSheet()->setCellValue('A' . (count($params['items_valores']) + 13), $params['preparacion'][0][0]);
$objPHPExcel->setActiveSheetIndex(0);
if ($save) {
$pathfile = 'assets/docs/' . $title . '.xlsx';
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
//.........这里部分代码省略.........
示例10: 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');
}
示例11:
$techNumber = DB_getItem($_TABLES['nextime_extra_user_data'], "tech_number", "uid={$A['uid']}");
$objPHPExcel->getActiveSheet()->setTitle($A['fullname'] . ' - #' . $techNumber);
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_LEGAL);
$objPHPExcel->getActiveSheet()->getPageSetup()->setFitToHeight(3);
$objPHPExcel->getActiveSheet()->getPageSetup()->setFitToWidth(1);
$objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 9);
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&P of &N');
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setEvenFooter('&L&P of &N');
$tech_number = DB_getItem($_TABLES['nextime_extra_user_data'], 'tech_number', 'uid=' . $A['uid']);
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader("&R&14 {$tech_number}\n{$A['fullname']}");
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setEvenHeader("&R&14 {$tech_number}\n{$A['fullname']}");
//set the top left A1 cell to the logo image
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('Logo');
$objDrawing->setDescription('Logo');
$objDrawing->setPath('./images/logo.png');
$objDrawing->setHeight(36);
$objDrawing->setCoordinates('A1');
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
$objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(27.75);
//end top left image
//generate header of report
$objPHPExcel->getActiveSheet()->setCellValue('Q3', $LANG_NEXTIME_REPORTS['technician_name']);
$objPHPExcel->getActiveSheet()->getStyle('Q3')->getFont()->setName('Arial');
$objPHPExcel->getActiveSheet()->setCellValue('G1', $LANG_NEXTIME_REPORTS['title']);
$objPHPExcel->getActiveSheet()->getStyle('G1')->getFont()->setName('Arial');
$objPHPExcel->getActiveSheet()->getStyle('G1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('G1')->getFont()->setSize(14);
$objPHPExcel->getActiveSheet()->setCellValue('Q2', $LANG_NEXTIME_REPORTS['technician_number']);
$objPHPExcel->getActiveSheet()->getStyle('Q2')->getFont()->setName('Arial');
示例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: PHPExcel
function export_goods_list()
{
$cname = $_GET['cname'];
$list = $_GET['list'];
$w = '';
if (!empty($cname) && $cname != 'all') {
//$cname = str_replace(' ','',trim($cname));
$w = " WHERE goods_cate LIKE '%{$cname}%'";
}
$sql = "SELECT * FROM `{$this->App->prefix()}goods_cache_list` {$w} ORDER BY goods_cate ASC, goods_id DESC LIMIT {$list}";
$rt = $this->App->find($sql);
$iconv = Import::gz_iconv();
require_once SYS_PATH . 'lib/class/PHPExcel.php';
//require_once SYS_PATH.'lib/class/PHPExcel/IOFactory.php';
$objPHPExcel = new PHPExcel();
// 设置基本属性
$objPHPExcel->getProperties()->setCreator("Sun Star Data Center")->setLastModifiedBy("Sun Star Data Center")->setTitle("Microsoft Office Excel Document")->setSubject("Test Data Report -- From Sunstar Data Center")->setDescription("LD Test Data Report, Generate by Sunstar Data Center")->setKeywords("sunstar ld report")->setCategory("Test result file");
//print_r($rt); exit;
// 创建多个工作薄
$sheet1 = $objPHPExcel->createSheet();
//$sheet2 = $objPHPExcel->createSheet();
// 设置第一个工作簿为活动工作簿
//$objPHPExcel->setActiveSheetIndex(0);
// 设置活动工作簿名称
// 如果是中文一定要使用iconv函数转换编码
$objPHPExcel->getActiveSheet()->setTitle(empty($cname) ? '商品导出' : $cname);
// 设置默认字体和大小
$objPHPExcel->getDefaultStyle()->getFont()->setName('宋体');
$objPHPExcel->getDefaultStyle()->getFont()->setSize(10);
// 设置一列的宽度
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(45);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(12);
$objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(12);
$objPHPExcel->getActiveSheet()->getColumnDimension('J')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('K')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('L')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('M')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('N')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('O')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('P')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('Q')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('R')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('S')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('T')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('U')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('V')->setWidth(40);
$objPHPExcel->getActiveSheet()->getColumnDimension('W')->setWidth(30);
// 设置行的高度
// $objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(55);
// 定义一个样式,加粗,居中
//$styleArray1 = array( 'font' => array( 'bold' => true, 'color'=>array( 'argb' => '00000000', ), ), 'alignment' => array( 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, ), );
//$styleArray2 = array( 'font' => array( 'color'=>array( 'argb' => '00000000', ), ), 'alignment' => array( 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, ), );
//居中
$objPHPExcel->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('E')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('F')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('G')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('H')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('I')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('J')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('K')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('L')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('M')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('N')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('O')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('P')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('Q')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('R')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('S')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('T')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('U')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('V')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('W')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//垂直居中
$objPHPExcel->getActiveSheet()->getStyle('A')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('B')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('C')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('D')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('E')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('F')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('G')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('H')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('I')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('J')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('K')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('L')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('M')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('N')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('O')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('P')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('Q')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
//.........这里部分代码省略.........
示例14: 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++;
}
}
//.........这里部分代码省略.........
示例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("Enganches Parciales")->setSubject("Enganches Parciales")->setDescription("Enganches Parciales")->setKeywords("office 2007 openxml php")->setCategory("Enganches Parciales");
$objPHPExcel->getActiveSheet()->setTitle('Enganches');
//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', 'Enganches Parciales Del Desarrollo ' . $this->enganches_parciales['desarrollo'][0]->nombre);
$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('F6', 'Cliente')->setCellValue('G6', 'Expediente')->setCellValue('H6', 'Manzana')->setCellValue('I6', 'Lote')->setCellValue('J6', 'Fecha promesa')->setCellValue('K6', 'Importe prometido')->setCellValue('L6', 'Estado');
$renglon = 7;
for ($enganche = 0; $enganche < count($this->enganches_parciales['enganches']); $enganche++) {
if ($this->enganches_parciales['enganches'][$enganche]->tipo == 1) {
$cliente = $this->enganches_parciales['enganches'][$enganche]->nombre . " " . $this->enganches_parciales['enganches'][$enganche]->ape_pate . " " . $this->enganches_parciales['enganches'][$enganche]->ape_mate;
} else {
$cliente = $this->enganches_parciales['enganches'][$enganche]->denominacion;
}
if ($this->enganches_parciales['enganches'][$enganche]->estado < 2) {
$estado = "Adeudado";
} else {
if ($this->enganches_parciales['enganches'][$enganche]->estado == 2) {
$estado = "Adeudo a moratorios";
} else {
$estado = "Pagado";
}
}
$objPHPExcel->getActiveSheet()->setCellValue('F' . $renglon, $cliente)->setCellValue('G' . $renglon, $this->enganches_parciales['enganches'][$enganche]->id_expediente)->setCellValue('H' . $renglon, $this->enganches_parciales['enganches'][$enganche]->num_letra)->setCellValue('I' . $renglon, $this->enganches_parciales['enganches'][$enganche]->lote)->setCellValue('J' . $renglon, $this->enganches_parciales['enganches'][$enganche]->fecha_promesa)->setCellValue('K' . $renglon, round($this->enganches_parciales['enganches'][$enganche]->importe, 2))->setCellValue('L' . $renglon, $estado);
$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;
}