/** * 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); $style = (object) array( "numFmt" => $numFmt, "font" => $xmlStyles->fonts->font[intval($xf["fontId"])], "fill" => $xmlStyles->fills->fill[intval($xf["fillId"])], "border" => $xmlStyles->borders->border[intval($xf["borderId"])], "alignment" => $xf->alignment, "protection" => $xf->protection, ); $styles[] = $style; // add style to cellXf collection $objStyle = new PHPExcel_Style; $this->_readStyle($objStyle, $style); $excel->addCellXf($objStyle); } foreach ($xmlStyles->cellStyleXfs->xf as $xf) { $numFmt = PHPExcel_Style_NumberFormat::FORMAT_GENERAL; if ($numFmts && $xf["numFmtId"]) { $tmpNumFmt = self::array_item($numFmts->xpath("sml:numFmt[@numFmtId=$xf[numFmtId]]")); if (isset($tmpNumFmt["formatCode"])) { $numFmt = (string) $tmpNumFmt["formatCode"]; } else if ((int)$xf["numFmtId"] < 165) { $numFmt = PHPExcel_Style_NumberFormat::builtInFormatCode((int)$xf["numFmtId"]); } } $cellStyle = (object) array( "numFmt" => $numFmt, "font" => $xmlStyles->fonts->font[intval($xf["fontId"])], "fill" => $xmlStyles->fills->fill[intval($xf["fillId"])], "border" => $xmlStyles->borders->border[intval($xf["borderId"])], "alignment" => $xf->alignment, "protection" => $xf->protection, ); $cellStyles[] = $cellStyle; // add style to cellStyleXf collection $objStyle = new PHPExcel_Style; $this->_readStyle($objStyle, $cellStyle); $excel->addCellStyleXf($objStyle); } } $dxfs = array(); if (!$this->_readDataOnly && $xmlStyles) { if ($xmlStyles->dxfs) { foreach ($xmlStyles->dxfs->dxf as $dxf) { $style = new PHPExcel_Style; $this->_readStyle($style, $dxf); $dxfs[] = $style; } } if ($xmlStyles->cellStyles) { foreach ($xmlStyles->cellStyles->cellStyle as $cellStyle) { if (intval($cellStyle['builtinId']) == 0) { if (isset($cellStyles[intval($cellStyle['xfId'])])) { // Set default style $style = new PHPExcel_Style; $this->_readStyle($style, $cellStyles[intval($cellStyle['xfId'])]); // normal style, currently not using it for anything } } } } } $xmlWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); // Set base date if ($xmlWorkbook->workbookPr) { PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900); if (isset($xmlWorkbook->workbookPr['date1904'])) { $date1904 = (string)$xmlWorkbook->workbookPr['date1904']; if ($date1904 == "true" || $date1904 == "1") { PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_MAC_1904); } } } $sheetId = 0; // keep track of new sheet id in final workbook $oldSheetId = -1; // keep track of old sheet id in final workbook $countSkippedSheets = 0; // keep track of number of skipped sheets $mapSheetId = array(); // mapping of sheet ids from old to new if ($xmlWorkbook->sheets) { foreach ($xmlWorkbook->sheets->sheet as $eleSheet) { ++$oldSheetId; // Check if sheet should be skipped if (isset($this->_loadSheetsOnly) && !in_array((string) $eleSheet["name"], $this->_loadSheetsOnly)) { ++$countSkippedSheets; $mapSheetId[$oldSheetId] = null; continue; } // Map old sheet id in original workbook to new sheet id. // They will differ if loadSheetsOnly() is being used $mapSheetId[$oldSheetId] = $oldSheetId - $countSkippedSheets; // Load sheet $docSheet = $excel->createSheet(); $docSheet->setTitle((string) $eleSheet["name"]); $fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")]; $xmlSheet = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/$fileWorksheet")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); $sharedFormulas = array(); if (isset($eleSheet["state"]) && (string) $eleSheet["state"] != '') { $docSheet->setSheetState( (string) $eleSheet["state"] ); } if (isset($xmlSheet->sheetViews) && isset($xmlSheet->sheetViews->sheetView)) { if (isset($xmlSheet->sheetViews->sheetView['zoomScale'])) { $docSheet->getSheetView()->setZoomScale( intval($xmlSheet->sheetViews->sheetView['zoomScale']) ); } if (isset($xmlSheet->sheetViews->sheetView['zoomScaleNormal'])) { $docSheet->getSheetView()->setZoomScaleNormal( intval($xmlSheet->sheetViews->sheetView['zoomScaleNormal']) ); } if (isset($xmlSheet->sheetViews->sheetView['showGridLines'])) { $docSheet->setShowGridLines((string)$xmlSheet->sheetViews->sheetView['showGridLines'] ? true : false); } if (isset($xmlSheet->sheetViews->sheetView['showRowColHeaders'])) { $docSheet->setShowRowColHeaders((string)$xmlSheet->sheetViews->sheetView['showRowColHeaders'] ? true : false); } if (isset($xmlSheet->sheetViews->sheetView['rightToLeft'])) { $docSheet->setRightToLeft((string)$xmlSheet->sheetViews->sheetView['rightToLeft'] ? true : false); } if (isset($xmlSheet->sheetViews->sheetView->pane)) { if (isset($xmlSheet->sheetViews->sheetView->pane['topLeftCell'])) { $docSheet->freezePane( (string)$xmlSheet->sheetViews->sheetView->pane['topLeftCell'] ); } else { $xSplit = 0; $ySplit = 0; if (isset($xmlSheet->sheetViews->sheetView->pane['xSplit'])) { $xSplit = 1 + intval($xmlSheet->sheetViews->sheetView->pane['xSplit']); } if (isset($xmlSheet->sheetViews->sheetView->pane['ySplit'])) { $ySplit = 1 + intval($xmlSheet->sheetViews->sheetView->pane['ySplit']); } $docSheet->freezePaneByColumnAndRow($xSplit, $ySplit); } } if (isset($xmlSheet->sheetViews->sheetView->selection)) { if (isset($xmlSheet->sheetViews->sheetView->selection['sqref'])) { $sqref = (string)$xmlSheet->sheetViews->sheetView->selection['sqref']; $sqref = explode(' ', $sqref); $sqref = $sqref[0]; $docSheet->setSelectedCells($sqref); } } } if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->tabColor)) { if (isset($xmlSheet->sheetPr->tabColor['rgb'])) { $docSheet->getTabColor()->setARGB( (string)$xmlSheet->sheetPr->tabColor['rgb'] ); } } if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->outlinePr)) { if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) && $xmlSheet->sheetPr->outlinePr['summaryRight'] == false) { $docSheet->setShowSummaryRight(false); } else { $docSheet->setShowSummaryRight(true); } if (isset($xmlSheet->sheetPr->outlinePr['summaryBelow']) && $xmlSheet->sheetPr->outlinePr['summaryBelow'] == false) { $docSheet->setShowSummaryBelow(false); } else { $docSheet->setShowSummaryBelow(true); } } if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->pageSetUpPr)) { if (isset($xmlSheet->sheetPr->pageSetUpPr['fitToPage']) && $xmlSheet->sheetPr->pageSetUpPr['fitToPage'] == false) { $docSheet->getPageSetup()->setFitToPage(false); } else { $docSheet->getPageSetup()->setFitToPage(true); } } if (isset($xmlSheet->sheetFormatPr)) { if (isset($xmlSheet->sheetFormatPr['customHeight']) && ((string)$xmlSheet->sheetFormatPr['customHeight'] == '1' || strtolower((string)$xmlSheet->sheetFormatPr['customHeight']) == 'true') && isset($xmlSheet->sheetFormatPr['defaultRowHeight'])) { $docSheet->getDefaultRowDimension()->setRowHeight( (float)$xmlSheet->sheetFormatPr['defaultRowHeight'] ); } if (isset($xmlSheet->sheetFormatPr['defaultColWidth'])) { $docSheet->getDefaultColumnDimension()->setWidth( (float)$xmlSheet->sheetFormatPr['defaultColWidth'] ); } } if (isset($xmlSheet->cols) && !$this->_readDataOnly) { foreach ($xmlSheet->cols->col as $col) { for ($i = intval($col["min"]) - 1; $i < intval($col["max"]); ++$i) { if ($col["style"] && !$this->_readDataOnly) { $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setXfIndex(intval($col["style"])); } if ($col["bestFit"]) { //$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setAutoSize(true); } if ($col["hidden"]) { $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setVisible(false); } if ($col["collapsed"]) { $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setCollapsed(true); } if ($col["outlineLevel"] > 0) { $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setOutlineLevel(intval($col["outlineLevel"])); } $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setWidth(floatval($col["width"])); if (intval($col["max"]) == 16384) { break; } } } } if (isset($xmlSheet->printOptions) && !$this->_readDataOnly) { if ($xmlSheet->printOptions['gridLinesSet'] == 'true' && $xmlSheet->printOptions['gridLinesSet'] == '1') { $docSheet->setShowGridlines(true); } if ($xmlSheet->printOptions['gridLines'] == 'true' || $xmlSheet->printOptions['gridLines'] == '1') { $docSheet->setPrintGridlines(true); } if ($xmlSheet->printOptions['horizontalCentered']) { $docSheet->getPageSetup()->setHorizontalCentered(true); } if ($xmlSheet->printOptions['verticalCentered']) { $docSheet->getPageSetup()->setVerticalCentered(true); } } if ($xmlSheet && $xmlSheet->sheetData && $xmlSheet->sheetData->row) { foreach ($xmlSheet->sheetData->row as $row) { if ($row["ht"] && !$this->_readDataOnly) { $docSheet->getRowDimension(intval($row["r"]))->setRowHeight(floatval($row["ht"])); } if ($row["hidden"] && !$this->_readDataOnly) { $docSheet->getRowDimension(intval($row["r"]))->setVisible(false); } if ($row["collapsed"]) { $docSheet->getRowDimension(intval($row["r"]))->setCollapsed(true); } if ($row["outlineLevel"] > 0) { $docSheet->getRowDimension(intval($row["r"]))->setOutlineLevel(intval($row["outlineLevel"])); } if ($row["s"] && !$this->_readDataOnly) { $docSheet->getRowDimension(intval($row["r"]))->setXfIndex(intval($row["s"])); } foreach ($row->c as $c) { $r = (string) $c["r"]; $cellDataType = (string) $c["t"]; $value = null; $calculatedValue = null; // Read cell? if (!is_null($this->getReadFilter())) { $coordinates = PHPExcel_Cell::coordinateFromString($r); if (!$this->getReadFilter()->readCell($coordinates[0], $coordinates[1], $docSheet->getTitle())) { continue; } } // echo '<b>Reading cell '.$coordinates[0].$coordinates[1].'</b><br />'; // print_r($c); // echo '<br />'; // echo 'Cell Data Type is '.$cellDataType.': '; // // Read cell! switch ($cellDataType) { case "s": // echo 'String<br />'; if ((string)$c->v != '') { $value = $sharedStrings[intval($c->v)]; if ($value instanceof PHPExcel_RichText) { $value = clone $value; } } else { $value = ''; } break; case "b": // echo 'Boolean<br />'; if (!isset($c->f)) { $value = $this->_castToBool($c); } else { // Formula $this->_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,'_castToBool'); // echo '$calculatedValue = '.$calculatedValue.'<br />'; } break; case "inlineStr": // echo 'Inline String<br />'; $value = $this->_parseRichText($c->is); break; case "e": // echo 'Error<br />'; if (!isset($c->f)) { $value = $this->_castToError($c); } else { // Formula $this->_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,'_castToError'); // echo '$calculatedValue = '.$calculatedValue.'<br />'; } break; default: // echo 'Default<br />'; if (!isset($c->f)) { // echo 'Not a Formula<br />'; $value = $this->_castToString($c); } else { // echo 'Treat as Formula<br />'; // Formula $this->_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,'_castToString'); // echo '$calculatedValue = '.$calculatedValue.'<br />'; } break; } // echo 'Value is '.$value.'<br />'; // Check for numeric values if (is_numeric($value) && $cellDataType != 's') { if ($value == (int)$value) $value = (int)$value; elseif ($value == (float)$value) $value = (float)$value; elseif ($value == (double)$value) $value = (double)$value; } // Rich text? if ($value instanceof PHPExcel_RichText && $this->_readDataOnly) { $value = $value->getPlainText(); } $cell = $docSheet->getCell($r); // Assign value if ($cellDataType != '') { $cell->setValueExplicit($value, $cellDataType); } else { $cell->setValue($value); } if (!is_null($calculatedValue)) { $cell->setCalculatedValue($calculatedValue); } // Style information? if ($c["s"] && !$this->_readDataOnly) { // no style index means 0, it seems $cell->setXfIndex(isset($styles[intval($c["s"])]) ? intval($c["s"]) : 0); } } } } $conditionals = array(); if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->conditionalFormatting) { foreach ($xmlSheet->conditionalFormatting as $conditional) { foreach ($conditional->cfRule as $cfRule) { if ( ( (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_NONE || (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CELLIS || (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT || (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_EXPRESSION ) && isset($dxfs[intval($cfRule["dxfId"])]) ) { $conditionals[(string) $conditional["sqref"]][intval($cfRule["priority"])] = $cfRule; } } } foreach ($conditionals as $ref => $cfRules) { ksort($cfRules); $conditionalStyles = array(); foreach ($cfRules as $cfRule) { $objConditional = new PHPExcel_Style_Conditional(); $objConditional->setConditionType((string)$cfRule["type"]); $objConditional->setOperatorType((string)$cfRule["operator"]); if ((string)$cfRule["text"] != '') { $objConditional->setText((string)$cfRule["text"]); } if (count($cfRule->formula) > 1) { foreach ($cfRule->formula as $formula) { $objConditional->addCondition((string)$formula); } } else { $objConditional->addCondition((string)$cfRule->formula); } $objConditional->setStyle(clone $dxfs[intval($cfRule["dxfId"])]); $conditionalStyles[] = $objConditional; } // Extract all cell references in $ref $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($ref); foreach ($aReferences as $reference) { $docSheet->getStyle($reference)->setConditionalStyles($conditionalStyles); } } } $aKeys = array("sheet", "objects", "scenarios", "formatCells", "formatColumns", "formatRows", "insertColumns", "insertRows", "insertHyperlinks", "deleteColumns", "deleteRows", "selectLockedCells", "sort", "autoFilter", "pivotTables", "selectUnlockedCells"); if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) { foreach ($aKeys as $key) { $method = "set" . ucfirst($key); $docSheet->getProtection()->$method($xmlSheet->sheetProtection[$key] == "true"); } } if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) { $docSheet->getProtection()->setPassword((string) $xmlSheet->sheetProtection["password"], true); if ($xmlSheet->protectedRanges->protectedRange) { foreach ($xmlSheet->protectedRanges->protectedRange as $protectedRange) { $docSheet->protectCells((string) $protectedRange["sqref"], (string) $protectedRange["password"], true); } } } if ($xmlSheet && $xmlSheet->autoFilter && !$this->_readDataOnly) { $docSheet->setAutoFilter((string) $xmlSheet->autoFilter["ref"]); } if ($xmlSheet && $xmlSheet->mergeCells && $xmlSheet->mergeCells->mergeCell && !$this->_readDataOnly) { foreach ($xmlSheet->mergeCells->mergeCell as $mergeCell) { $docSheet->mergeCells((string) $mergeCell["ref"]); } } if ($xmlSheet && $xmlSheet->pageMargins && !$this->_readDataOnly) { $docPageMargins = $docSheet->getPageMargins(); $docPageMargins->setLeft(floatval($xmlSheet->pageMargins["left"])); $docPageMargins->setRight(floatval($xmlSheet->pageMargins["right"])); $docPageMargins->setTop(floatval($xmlSheet->pageMargins["top"])); $docPageMargins->setBottom(floatval($xmlSheet->pageMargins["bottom"])); $docPageMargins->setHeader(floatval($xmlSheet->pageMargins["header"])); $docPageMargins->setFooter(floatval($xmlSheet->pageMargins["footer"])); } if ($xmlSheet && $xmlSheet->pageSetup && !$this->_readDataOnly) { $docPageSetup = $docSheet->getPageSetup(); if (isset($xmlSheet->pageSetup["orientation"])) { $docPageSetup->setOrientation((string) $xmlSheet->pageSetup["orientation"]); } if (isset($xmlSheet->pageSetup["paperSize"])) { $docPageSetup->setPaperSize(intval($xmlSheet->pageSetup["paperSize"])); } if (isset($xmlSheet->pageSetup["scale"])) { $docPageSetup->setScale(intval($xmlSheet->pageSetup["scale"]), false); } if (isset($xmlSheet->pageSetup["fitToHeight"]) && intval($xmlSheet->pageSetup["fitToHeight"]) >= 0) { $docPageSetup->setFitToHeight(intval($xmlSheet->pageSetup["fitToHeight"]), false); } if (isset($xmlSheet->pageSetup["fitToWidth"]) && intval($xmlSheet->pageSetup["fitToWidth"]) >= 0) { $docPageSetup->setFitToWidth(intval($xmlSheet->pageSetup["fitToWidth"]), false); } if (isset($xmlSheet->pageSetup["firstPageNumber"]) && isset($xmlSheet->pageSetup["useFirstPageNumber"]) && ((string)$xmlSheet->pageSetup["useFirstPageNumber"] == 'true' || (string)$xmlSheet->pageSetup["useFirstPageNumber"] == '1')) { $docPageSetup->setFirstPageNumber(intval($xmlSheet->pageSetup["firstPageNumber"])); } } if ($xmlSheet && $xmlSheet->headerFooter && !$this->_readDataOnly) { $docHeaderFooter = $docSheet->getHeaderFooter(); if (isset($xmlSheet->headerFooter["differentOddEven"]) && ((string)$xmlSheet->headerFooter["differentOddEven"] == 'true' || (string)$xmlSheet->headerFooter["differentOddEven"] == '1')) { $docHeaderFooter->setDifferentOddEven(true); } else { $docHeaderFooter->setDifferentOddEven(false); } if (isset($xmlSheet->headerFooter["differentFirst"]) && ((string)$xmlSheet->headerFooter["differentFirst"] == 'true' || (string)$xmlSheet->headerFooter["differentFirst"] == '1')) { $docHeaderFooter->setDifferentFirst(true); } else { $docHeaderFooter->setDifferentFirst(false); } if (isset($xmlSheet->headerFooter["scaleWithDoc"]) && ((string)$xmlSheet->headerFooter["scaleWithDoc"] == 'false' || (string)$xmlSheet->headerFooter["scaleWithDoc"] == '0')) { $docHeaderFooter->setScaleWithDocument(false); } else { $docHeaderFooter->setScaleWithDocument(true); } if (isset($xmlSheet->headerFooter["alignWithMargins"]) && ((string)$xmlSheet->headerFooter["alignWithMargins"] == 'false' || (string)$xmlSheet->headerFooter["alignWithMargins"] == '0')) { $docHeaderFooter->setAlignWithMargins(false); } else { $docHeaderFooter->setAlignWithMargins(true); } $docHeaderFooter->setOddHeader((string) $xmlSheet->headerFooter->oddHeader); $docHeaderFooter->setOddFooter((string) $xmlSheet->headerFooter->oddFooter); $docHeaderFooter->setEvenHeader((string) $xmlSheet->headerFooter->evenHeader); $docHeaderFooter->setEvenFooter((string) $xmlSheet->headerFooter->evenFooter); $docHeaderFooter->setFirstHeader((string) $xmlSheet->headerFooter->firstHeader); $docHeaderFooter->setFirstFooter((string) $xmlSheet->headerFooter->firstFooter); } if ($xmlSheet && $xmlSheet->rowBreaks && $xmlSheet->rowBreaks->brk && !$this->_readDataOnly) { foreach ($xmlSheet->rowBreaks->brk as $brk) { if ($brk["man"]) { $docSheet->setBreak("A$brk[id]", PHPExcel_Worksheet::BREAK_ROW); } } } if ($xmlSheet && $xmlSheet->colBreaks && $xmlSheet->colBreaks->brk && !$this->_readDataOnly) { foreach ($xmlSheet->colBreaks->brk as $brk) { if ($brk["man"]) { $docSheet->setBreak(PHPExcel_Cell::stringFromColumnIndex($brk["id"]) . "1", PHPExcel_Worksheet::BREAK_COLUMN); } } } if ($xmlSheet && $xmlSheet->dataValidations && !$this->_readDataOnly) { foreach ($xmlSheet->dataValidations->dataValidation as $dataValidation) { // Uppercase coordinate $range = strtoupper($dataValidation["sqref"]); $rangeSet = explode(' ',$range); foreach($rangeSet as $range) { $stRange = $docSheet->shrinkRangeToFit($range); // Extract all cell references in $range $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($stRange); foreach ($aReferences as $reference) { // Create validation $docValidation = $docSheet->getCell($reference)->getDataValidation(); $docValidation->setType((string) $dataValidation["type"]); $docValidation->setErrorStyle((string) $dataValidation["errorStyle"]); $docValidation->setOperator((string) $dataValidation["operator"]); $docValidation->setAllowBlank($dataValidation["allowBlank"] != 0); $docValidation->setShowDropDown($dataValidation["showDropDown"] == 0); $docValidation->setShowInputMessage($dataValidation["showInputMessage"] != 0); $docValidation->setShowErrorMessage($dataValidation["showErrorMessage"] != 0); $docValidation->setErrorTitle((string) $dataValidation["errorTitle"]); $docValidation->setError((string) $dataValidation["error"]); $docValidation->setPromptTitle((string) $dataValidation["promptTitle"]); $docValidation->setPrompt((string) $dataValidation["prompt"]); $docValidation->setFormula1((string) $dataValidation->formula1); $docValidation->setFormula2((string) $dataValidation->formula2); } } } } // Add hyperlinks $hyperlinks = array(); if (!$this->_readDataOnly) { // Locate hyperlink relations 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"); foreach ($relsWorksheet->Relationship as $ele) { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink") { $hyperlinks[(string)$ele["Id"]] = (string)$ele["Target"]; } } } // Loop through hyperlinks if ($xmlSheet && $xmlSheet->hyperlinks) { foreach ($xmlSheet->hyperlinks->hyperlink as $hyperlink) { // Link url $linkRel = $hyperlink->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'); foreach (PHPExcel_Cell::extractAllCellReferencesInRange($hyperlink['ref']) as $cellReference) { $cell = $docSheet->getCell( $cellReference ); if (isset($linkRel['id'])) { $cell->getHyperlink()->setUrl( $hyperlinks[ (string)$linkRel['id'] ] ); } if (isset($hyperlink['location'])) { $cell->getHyperlink()->setUrl( 'sheet://' . (string)$hyperlink['location'] ); } // Tooltip if (isset($hyperlink['tooltip'])) { $cell->getHyperlink()->setTooltip( (string)$hyperlink['tooltip'] ); } } } } } // Add comments $comments = array(); $vmlComments = array(); if (!$this->_readDataOnly) { // Locate comment relations 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"); foreach ($relsWorksheet->Relationship as $ele) { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments") { $comments[(string)$ele["Id"]] = (string)$ele["Target"]; } if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing") { $vmlComments[(string)$ele["Id"]] = (string)$ele["Target"]; } } } // Loop through comments foreach ($comments as $relName => $relPath) { // Load comments file $relPath = PHPExcel_Shared_File::realpath(dirname("$dir/$fileWorksheet") . "/" . $relPath); $commentsFile = simplexml_load_string($this->_getFromZipArchive($zip, $relPath) ); // Utility variables $authors = array(); // Loop through authors foreach ($commentsFile->authors->author as $author) { $authors[] = (string)$author; } // Loop through contents foreach ($commentsFile->commentList->comment as $comment) { $docSheet->getComment( (string)$comment['ref'] )->setAuthor( $authors[(string)$comment['authorId']] ); $docSheet->getComment( (string)$comment['ref'] )->setText( $this->_parseRichText($comment->text) ); } } // Loop through VML comments foreach ($vmlComments as $relName => $relPath) { // Load VML comments file $relPath = PHPExcel_Shared_File::realpath(dirname("$dir/$fileWorksheet") . "/" . $relPath); $vmlCommentsFile = simplexml_load_string( $this->_getFromZipArchive($zip, $relPath) ); $vmlCommentsFile->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); $shapes = $vmlCommentsFile->xpath('//v:shape'); foreach ($shapes as $shape) { $shape->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); if (isset($shape['style'])) { $style = (string)$shape['style']; $fillColor = strtoupper( substr( (string)$shape['fillcolor'], 1 ) ); $column = null; $row = null; $clientData = $shape->xpath('.//x:ClientData'); if (is_array($clientData) && count($clientData) > 0) { $clientData = $clientData[0]; if ( isset($clientData['ObjectType']) && (string)$clientData['ObjectType'] == 'Note' ) { $temp = $clientData->xpath('.//x:Row'); if (is_array($temp)) $row = $temp[0]; $temp = $clientData->xpath('.//x:Column'); if (is_array($temp)) $column = $temp[0]; } } if (!is_null($column) && !is_null($row)) { // Set comment properties $comment = $docSheet->getCommentByColumnAndRow($column, $row + 1); $comment->getFillColor()->setRGB( $fillColor ); // Parse style $styleArray = explode(';', str_replace(' ', '', $style)); foreach ($styleArray as $stylePair) { $stylePair = explode(':', $stylePair); if ($stylePair[0] == 'margin-left') $comment->setMarginLeft($stylePair[1]); if ($stylePair[0] == 'margin-top') $comment->setMarginTop($stylePair[1]); if ($stylePair[0] == 'width') $comment->setWidth($stylePair[1]); if ($stylePair[0] == 'height') $comment->setHeight($stylePair[1]); if ($stylePair[0] == 'visibility') $comment->setVisible( $stylePair[1] == 'visible' ); } } } } } // Header/footer images if ($xmlSheet && $xmlSheet->legacyDrawingHF && !$this->_readDataOnly) { 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"); $vmlRelationship = ''; foreach ($relsWorksheet->Relationship as $ele) { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing") { $vmlRelationship = self::dir_add("$dir/$fileWorksheet", $ele["Target"]); } } 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) { 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); $objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex($twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1)); $objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff)); $objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff)); $objDrawing->setResizeProportional(false); $objDrawing->setWidth(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($xfrm->ext->attributes(), "cx"))); $objDrawing->setHeight(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($xfrm->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); } } } } } } // Loop through definedNames if ($xmlWorkbook->definedNames) { foreach ($xmlWorkbook->definedNames->definedName as $definedName) { // Extract range $extractedRange = (string)$definedName; $extractedRange = preg_replace('/\'(\w+)\'\!/', '', $extractedRange); $extractedRange = str_replace('$', '', $extractedRange); // Valid range? if (stripos((string)$definedName, '#REF!') !== false || $extractedRange == '') { continue; } // Some definedNames are only applicable if we are on the same sheet... if ((string)$definedName['localSheetId'] != '' && (string)$definedName['localSheetId'] == $sheetId) { // Switch on type switch ((string)$definedName['name']) { case '_xlnm._FilterDatabase': $docSheet->setAutoFilter($extractedRange); break; case '_xlnm.Print_Titles': // Split $extractedRange $extractedRange = explode(',', $extractedRange); // Set print titles foreach ($extractedRange as $range) { $matches = array(); // check for repeating columns, e g. 'A:A' or 'A:D' if (preg_match('/^([A-Z]+)\:([A-Z]+)$/', $range, $matches)) { $docSheet->getPageSetup()->setColumnsToRepeatAtLeft(array($matches[1], $matches[2])); } // check for repeating rows, e.g. '1:1' or '1:5' elseif (preg_match('/^(\d+)\:(\d+)$/', $range, $matches)) { $docSheet->getPageSetup()->setRowsToRepeatAtTop(array($matches[1], $matches[2])); } } break; case '_xlnm.Print_Area': $range = explode('!', $extractedRange); $extractedRange = isset($range[1]) ? $range[1] : $range[0]; $docSheet->getPageSetup()->setPrintArea($extractedRange); break; default: break; } } } } // Next sheet id ++$sheetId; } // Loop through definedNames if ($xmlWorkbook->definedNames) { foreach ($xmlWorkbook->definedNames->definedName as $definedName) { // Extract range $extractedRange = (string)$definedName; $extractedRange = preg_replace('/\'(\w+)\'\!/', '', $extractedRange); $extractedRange = str_replace('$', '', $extractedRange); // Valid range? if (stripos((string)$definedName, '#REF!') !== false || $extractedRange == '') { continue; } // Some definedNames are only applicable if we are on the same sheet... if ((string)$definedName['localSheetId'] != '') { // Local defined name // Switch on type switch ((string)$definedName['name']) { case '_xlnm._FilterDatabase': case '_xlnm.Print_Titles': case '_xlnm.Print_Area': break; default: $range = explode('!', (string)$definedName); if (count($range) == 2) { $range[0] = str_replace("''", "'", $range[0]); $range[0] = str_replace("'", "", $range[0]); if ($worksheet = $docSheet->getParent()->getSheetByName($range[0])) { $extractedRange = str_replace('$', '', $range[1]); $scope = $docSheet->getParent()->getSheet((string)$definedName['localSheetId']); $excel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $worksheet, $extractedRange, true, $scope) ); } } break; } } else if (!isset($definedName['localSheetId'])) { // "Global" definedNames $locatedSheet = null; $extractedSheetName = ''; if (strpos( (string)$definedName, '!' ) !== false) { // Extract sheet name $extractedSheetName = PHPExcel_Worksheet::extractSheetTitle( (string)$definedName, true ); $extractedSheetName = $extractedSheetName[0]; // Locate sheet $locatedSheet = $excel->getSheetByName($extractedSheetName); // Modify range $range = explode('!', $extractedRange); $extractedRange = isset($range[1]) ? $range[1] : $range[0]; } if (!is_null($locatedSheet)) { $excel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $locatedSheet, $extractedRange, false) ); } } } } } if (!$this->_readDataOnly) { // active sheet index $activeTab = intval($xmlWorkbook->bookViews->workbookView["activeTab"]); // refers to old sheet index // keep active sheet index if sheet is still loaded, else first sheet is set as the active if (isset($mapSheetId[$activeTab]) && $mapSheetId[$activeTab] !== null) { $excel->setActiveSheetIndex($mapSheetId[$activeTab]); } else { if ($excel->getSheetCount() == 0) { $excel->createSheet(); } $excel->setActiveSheetIndex(0); } } break; } } return $excel; }
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; }
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; }
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); }
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); }
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); }
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); }
function generate($tbl) { session_start(); $_SESSION['zprofile'] = 'yes'; $_SESSION['zprofile']['username'] = '******'; $_SESSION['zprofile']['useremail'] = '*****@*****.**'; $_SESSION['zprofile']['usercompany'] = 'hehehahhaha'; $_GET['var'] = 'tbl_tes'; $_SESSION['tbl_tes'] = $tbl; /* $_SESSION['tbl_tes'] = ' <table border="1"> <thead> <tr bgcolor="yellow"> <th>no</th> <th>col1</th> <th>col2</th> <th>col3</th> <th>col4</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>B2</td> <td>C2</td> <td rowspan="2">D2</td> <td>E3</td> </tr> <tr> <td>2</td> <td colspan="2">B3</td> <td>C3</td> </tr> <tr> <td>3</td> <td>B4</td> <td colspan="2" rowspan="2">C4</td> <td>D4</td> </tr> <tr> <td>4</td> <td> B5<img src="././assets/img/ecsi.png" name="gambar tes" title="hehehe coba titlenya" width="100" height="100"> <td><b>C5</b></td> </tr> </tbody> </table> '; */ //echo $_SESSION['tbl_tes'];exit(); ini_set("memory_limit", "-1"); ini_set("set_time_limit", "0"); set_time_limit(0); if (isset($_SESSION['zprofile'])) { $username = $_SESSION['zprofile']['username']; // user's name $usermail = $_SESSION['zprofile']['useremail']; // user's emailid $usercompany = $_SESSION['zprofile']['usercompany']; // user's company } else { header('Location: index.php?e=0'); } if (!isset($_GET['var'])) { echo "<br />No Table Variable Present, nothing to Export."; exit; } else { $tablevar = $_GET['var']; } if (!isset($_GET['limit'])) { $limit = 12; } else { $limit = $_GET['limit']; } if (!isset($_GET['debug'])) { $debug = false; } else { $debug = true; $handle = fopen("Auditlog/exportlog.txt", "w"); fwrite($handle, "\nDebugging On..."); } if (!isset($_SESSION[$tablevar]) or $_SESSION[$tablevar] == '') { echo "<br />Empty HTML Table, nothing to Export."; exit; } else { $htmltable = $_SESSION[$tablevar]; } if (strlen($htmltable) == strlen(strip_tags($htmltable))) { echo "<br />Invalid HTML Table after Stripping Tags, nothing to Export."; exit; } $htmltable = strip_tags($htmltable, "<table><tr><th><thead><tbody><tfoot><td><br><br /><b><span><img><img />"); $htmltable = str_replace("<br />", "\n", $htmltable); $htmltable = str_replace("<br/>", "\n", $htmltable); $htmltable = str_replace("<br>", "\n", $htmltable); $htmltable = str_replace(" ", " ", $htmltable); $htmltable = str_replace("\n\n", "\n", $htmltable); // // Extract HTML table contents to array // $dom = new domDocument(); $dom->loadHTML($htmltable); if (!$dom) { 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'); $stylecolor = $this->findStyleCSS('color', $style); if ($stylecolor == '') { $headrows[$h]['color'][] = $this->findSpanColor($this->innerHTML($ths->item($x))); } else { $headrows[$h]['color'][] = $stylecolor; } $headrows[$h]['font_name'][] = $this->findStyleCSS('font-family', $style); $headrows[$h]['font_size'][] = $this->findStyleCSS('font-size', $style); $headrows[$h]['border_top'][] = $this->findStyleCSS('border-top', $style); $headrows[$h]['border_bottom'][] = $this->findStyleCSS('border-bottom', $style); $headrows[$h]['border_left'][] = $this->findStyleCSS('border-left', $style); $headrows[$h]['border_right'][] = $this->findStyleCSS('border-right', $style); } else { $headrows[$h]['color'][] = $this->findSpanColor($this->innerHTML($ths->item($x))); } if ($ths->item($x)->hasAttribute('colspan')) { $headrows[$h]['colspan'][] = $ths->item($x)->getAttribute('colspan'); } else { $headrows[$h]['colspan'][] = 1; } if ($ths->item($x)->hasAttribute('rowspan')) { $headrows[$h]['rowspan'][] = $ths->item($x)->getAttribute('rowspan'); } else { $headrows[$h]['rowspan'][] = 1; } if ($ths->item($x)->hasAttribute('align')) { $headrows[$h]['align'][] = $ths->item($x)->getAttribute('align'); } else { $headrows[$h]['align'][] = 'left'; } if ($ths->item($x)->hasAttribute('valign')) { $headrows[$h]['valign'][] = $ths->item($x)->getAttribute('valign'); } else { $headrows[$h]['valign'][] = 'top'; } if ($ths->item($x)->hasAttribute('bgcolor')) { $headrows[$h]['bgcolor'][] = str_replace("#", "", $ths->item($x)->getAttribute('bgcolor')); } else { $headrows[$h]['bgcolor'][] = 'FFFFFF'; } } $h++; } } } $iRow = 0; $fillCell = array(); foreach ($rows as $row) { $iRow++; $tds = $row->getElementsByTagName('td'); if (is_object($tds)) { if ($tds->length > 0) { $bodyrows[$r]['colcnt'] = $tds->length; if ($tds->length > $maxcols) { $maxcols = $tds->length; } $nodes = $tds->length - 1; $iCol = 'A'; for ($x = 0; $x <= $nodes; $x++) { $thistxt = $tds->item($x)->nodeValue; $bodyrows[$r]['td'][] = $thistxt; $bodyrows[$r]['img'][] = $this->collecImg($tds->item($x)->getElementsByTagName('img')); $bodyrows[$r]['bold'][] = $this->findWrapText('b', $this->innerHTML($tds->item($x))); $bodyrows[$r]['italic'][] = $this->findWrapText('i', $this->innerHTML($tds->item($x))); $bodyrows[$r]['underline'][] = $this->findWrapText('u', $this->innerHTML($tds->item($x))); if ($tds->item($x)->hasAttribute('style')) { $style = $tds->item($x)->getAttribute('style'); $stylecolor = $this->findStyleCSS('color', $style); if ($stylecolor == '') { $bodyrows[$r]['color'][] = $this->findSpanColor($this->innerHTML($tds->item($x))); } else { $bodyrows[$r]['color'][] = $stylecolor; } $bodyrows[$h]['font_name'][] = $this->findStyleCSS('font-family', $style); $bodyrows[$h]['font_size'][] = $this->findStyleCSS('font-size', $style); $bodyrows[$h]['border_top'][] = $this->findStyleCSS('border-top', $style); $bodyrows[$h]['border_bottom'][] = $this->findStyleCSS('border-bottom', $style); $bodyrows[$h]['border_left'][] = $this->findStyleCSS('border-left', $style); $bodyrows[$h]['border_right'][] = $this->findStyleCSS('border-right', $style); } else { $bodyrows[$r]['color'][] = $this->findSpanColor($this->innerHTML($tds->item($x))); } if ($tds->item($x)->hasAttribute('colspan')) { $icolspan = $tds->item($x)->getAttribute('colspan'); $bodyrows[$r]['colspan'][] = $tds->item($x)->getAttribute('colspan'); } else { $icolspan = 1; $bodyrows[$r]['colspan'][] = 1; } if ($tds->item($x)->hasAttribute('rowspan')) { $irowspan = $tds->item($x)->getAttribute('rowspan'); $bodyrows[$r]['rowspan'][] = $irowspan; } else { $irowspan = 1; $bodyrows[$r]['rowspan'][] = 1; } if ($tds->item($x)->hasAttribute('align')) { $bodyrows[$r]['align'][] = $tds->item($x)->getAttribute('align'); } else { $bodyrows[$r]['align'][] = 'left'; } if ($tds->item($x)->hasAttribute('valign')) { $bodyrows[$r]['valign'][] = $tds->item($x)->getAttribute('valign'); } else { $bodyrows[$r]['valign'][] = 'top'; } if ($tds->item($x)->hasAttribute('bgcolor')) { $bodyrows[$r]['bgcolor'][] = str_replace("#", "", $tds->item($x)->getAttribute('bgcolor')); } else { $bodyrows[$r]['bgcolor'][] = 'FFFFFF'; } $lastIcol = $iCol; $lastIrow = $iRow; for ($ic = 1; $ic < $icolspan; $ic++) { $lastIcol++; $fillCell[$lastIcol . ':' . $lastIrow] = true; } $lastIcol = $iCol; $lastIrow = $iRow; for ($ir = 1; $ir < $irowspan; $ir++) { $lastIrow++; $fillCell[$lastIcol . ':' . $lastIrow] = true; } $lastIcol = $iCol; $lastIrow = $iRow; for ($ic = 1; $ic < $icolspan; $ic++) { for ($ir = 1; $ir < $irowspan; $ir++) { $lastIrow++; $fillCell[$lastIcol . ':' . $lastIrow] = true; } $lastIcol++; $fillCell[$lastIcol . ':' . $lastIrow] = true; } $iCol++; } $r++; } } } //echo '<pre>';print_r($fillCell); //exit(); if ($z > 0) { $objPHPExcel->createSheet($z); } $suf = $z + 1; $tableid = $tablevar . $suf; $wksheetname = ucfirst($tableid); $objPHPExcel->setActiveSheetIndex($z); // each sheet corresponds to a table in html $objPHPExcel->getActiveSheet()->setTitle($wksheetname); // tab name $worksheet = $objPHPExcel->getActiveSheet(); // set worksheet we're working on $style_overlay = array('font' => array('color' => array('rgb' => '000000'), 'bold' => false), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'CCCCFF')), 'alignment' => array('wrap' => true, 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_TOP), 'borders' => array('top' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'left' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'right' => array('style' => PHPExcel_Style_Border::BORDER_THIN))); $xcol = ''; $xrow = 1; $usedhdrows = 0; $heightvars = array(1 => '42', 2 => '42', 3 => '48', 4 => '52', 5 => '58', 6 => '64', 7 => '68', 8 => '76', 9 => '82'); for ($h = 0; $h < count($headrows); $h++) { $th = $headrows[$h]['th']; $colspans = $headrows[$h]['colspan']; $rowspans = $headrows[$h]['rowspan']; $aligns = $headrows[$h]['align']; $valigns = $headrows[$h]['valign']; $bgcolors = $headrows[$h]['bgcolor']; $colcnt = $headrows[$h]['colcnt']; $colors = $headrows[$h]['color']; $bolds = $headrows[$h]['bold']; $italics = $headrows[$h]['italic']; $underlines = $headrows[$h]['underline']; $font_sizes = $headrows[$h]['font_size']; $font_names = $headrows[$h]['font_name']; $border_tops = $headrows[$h]['border_top']; $border_bottoms = $headrows[$h]['border_bottom']; $border_lefts = $headrows[$h]['border_left']; $border_rights = $headrows[$h]['border_right']; $usedhdrows++; $mergedcells = false; for ($t = 0; $t < count($th); $t++) { if ($xcol == '') { $xcol = 'A'; } else { $xcol++; } $thishdg = $th[$t]; $thisalign = $aligns[$t]; $thisvalign = $valigns[$t]; $thiscolspan = (int) $colspans[$t]; $thisrowspan = (int) $rowspans[$t]; $thiscolor = $colors[$t]; $thisbg = $bgcolors[$t]; $thisbold = $bolds[$t]; $thisitalic = $italics[$t]; $thisunderline = $underlines[$t]; $thissize = (double) str_replace(array('pt', 'PT', 'px', 'PX'), '', $font_sizes[$t]); $thissize = $thissize > 0 ? $thissize : 9; $thisname = $font_names[$t]; $thisname = $thisname ? $thisname : 'Arial'; $thisbordertop = str_replace(array('px', 'PX'), '', $border_tops) > 0 && !empty($border_tops) ? PHPExcel_Style_Border::BORDER_THIN : PHPExcel_Style_Border::BORDER_NONE; $thisborderbottom = str_replace(array('px', 'PX'), '', $border_bottoms) > 0 && !empty($border_bottoms) ? PHPExcel_Style_Border::BORDER_THIN : PHPExcel_Style_Border::BORDER_NONE; $thisborderleft = str_replace(array('px', 'PX'), '', $border_lefts) > 0 && !empty($border_lefts) ? PHPExcel_Style_Border::BORDER_THIN : PHPExcel_Style_Border::BORDER_NONE; $thisborderright = str_replace(array('px', 'PX'), '', $border_rights) > 0 && !empty($border_rights) ? PHPExcel_Style_Border::BORDER_THIN : PHPExcel_Style_Border::BORDER_NONE; $strbordertop = str_replace(array('px', 'PX'), '', $border_tops) > 0 ? 'true' : 'false'; $strborderbottom = str_replace(array('px', 'PX'), '', $border_bottoms) > 0 ? 'true' : 'false'; $strborderleft = str_replace(array('px', 'PX'), '', $border_lefts) > 0 ? 'true' : 'false'; $strborderright = str_replace(array('px', 'PX'), '', $border_rights) > 0 ? 'true' : 'false'; $strbold = $thisbold == true ? 'true' : 'false'; $stritalic = $thisitalic == true ? 'true' : 'false'; $strunderline = $thisunderline == true ? 'true' : 'false'; if ($thisbg == 'FFFFFF') { $style_overlay['fill']['type'] = PHPExcel_Style_Fill::FILL_NONE; } else { $style_overlay['fill']['type'] = PHPExcel_Style_Fill::FILL_SOLID; } $style_overlay['alignment']['vertical'] = $thisvalign; // set styles for cell $style_overlay['alignment']['horizontal'] = $thisalign; $style_overlay['font']['color']['rgb'] = $thiscolor; $style_overlay['font']['bold'] = $thisbold; $style_overlay['font']['italic'] = $thisitalic; $style_overlay['font']['underline'] = $thisunderline == true ? PHPExcel_Style_Font::UNDERLINE_SINGLE : PHPExcel_Style_Font::UNDERLINE_NONE; $style_overlay['font']['size'] = $thissize; $style_overlay['font']['name'] = $thisname; $style_overlay['borders']['top']['style'] = $thisbordertop; $style_overlay['borders']['bottom']['style'] = $thisborderbottom; $style_overlay['borders']['left']['style'] = $thisborderleft; $style_overlay['borders']['right']['style'] = $thisborderright; $style_overlay['fill']['color']['rgb'] = $thisbg; $worksheet->setCellValue($xcol . $xrow, $thishdg); $worksheet->getStyle($xcol . $xrow)->applyFromArray($style_overlay); if ($debug) { fwrite($handle, "\n" . $xcol . ":" . $xrow . " Rowspan:" . $thisrowspan . " ColSpan:" . $thiscolspan . " Color:" . $thiscolor . " Align:" . $thisalign . " VAlign:" . $thisvalign . " BGColor:" . $thisbg . " Bold:" . $strbold . " Italic:" . $stritalic . " Underline:" . $strunderline . " Font-name:" . $thisname . " Font-size:" . $thissize . " Border-top: " . $strbordertop . " Border-bottom" . $strborderbottom . " Border-left:" . $strborderleft . " Border-right:" . $strborderright . " cellValue: " . $thishdg); } if ($thiscolspan > 1 && $thisrowspan < 1) { // spans more than 1 column $mergedcells = true; $lastxcol = $xcol; for ($j = 1; $j < $thiscolspan; $j++) { $lastxcol++; $worksheet->setCellValue($lastxcol . $xrow, ''); $worksheet->getStyle($lastxcol . $xrow)->applyFromArray($style_overlay); } $cellRange = $xcol . $xrow . ':' . $lastxcol . $xrow; if ($debug) { fwrite($handle, "\nmergeCells: " . $xcol . ":" . $xrow . " " . $lastxcol . ":" . $xrow); } $worksheet->mergeCells($cellRange); $worksheet->getStyle($cellRange)->applyFromArray($style_overlay); $num_newlines = substr_count($thishdg, "\n"); // count number of newline chars if ($num_newlines > 1) { $rowheight = $heightvars[1]; // default to 35 if (array_key_exists($num_newlines, $heightvars)) { $rowheight = $heightvars[$num_newlines]; } else { $rowheight = 75; } $worksheet->getRowDimension($xrow)->setRowHeight($rowheight); // adjust heading row height } $xcol = $lastxcol; } } $xrow++; $xcol = ''; } //Put an auto filter on last row of heading only if last row was not merged if (!$mergedcells) { $worksheet->setAutoFilter("A{$usedhdrows}:" . $worksheet->getHighestColumn() . $worksheet->getHighestRow()); } if ($debug) { fwrite($handle, "\nautoFilter: A" . $usedhdrows . ":" . $worksheet->getHighestColumn() . $worksheet->getHighestRow()); } // Freeze heading lines starting after heading lines $usedhdrows++; $worksheet->freezePane("A{$usedhdrows}"); if ($debug) { fwrite($handle, "\nfreezePane: A" . $usedhdrows); } // // Loop thru data rows and write them out // $xcol = ''; $xrow = $usedhdrows; for ($b = 0; $b < count($bodyrows); $b++) { $td = $bodyrows[$b]['td']; $img = $bodyrows[$b]['img']; $colcnt = $bodyrows[$b]['colcnt']; $colspans = $bodyrows[$b]['colspan']; $rowspans = $bodyrows[$b]['rowspan']; $aligns = $bodyrows[$b]['align']; $valigns = $bodyrows[$b]['valign']; $bgcolors = $bodyrows[$b]['bgcolor']; $colors = $bodyrows[$b]['color']; $bolds = $bodyrows[$b]['bold']; $italics = $bodyrows[$h]['italic']; $underlines = $bodyrows[$h]['underline']; $font_sizes = $bodyrows[$h]['font_size']; $font_names = $bodyrows[$h]['font_name']; $border_tops = $bodyrows[$h]['border_top']; $border_bottoms = $bodyrows[$h]['border_bottom']; $border_lefts = $bodyrows[$h]['border_left']; $border_rights = $bodyrows[$h]['border_right']; for ($t = 0; $t < count($td); $t++) { if ($xcol == '') { $xcol = 'A'; } else { $xcol++; } if (isset($fillCell[$xcol . ':' . $xrow])) { $xcol = $this->nextCol($xcol, $xrow); } $thistext = $td[$t]; $thisimg = $img[$t]; $thisalign = $aligns[$t]; $thisvalign = $valigns[$t]; $thiscolspan = (int) $colspans[$t]; $thisrowspan = (int) $rowspans[$t]; $thiscolor = $colors[$t]; $thisbg = $bgcolors[$t]; $thisbold = $bolds[$t]; $strbold = $thisbold == true ? 'true' : 'false'; $thisbold = $bolds[$t]; $thisitalic = $italics[$t]; $thisunderline = $underlines[$t]; $thissize = (double) str_replace(array('pt', 'PT', 'px', 'PX'), '', $font_sizes[$t]); $thissize = $thissize > 0 ? $thissize : 9; $thisname = $font_names[$t]; $thisname = $thisname ? $thisname : 'Arial'; $thisbordertop = str_replace(array('px', 'PX'), '', $border_tops) > 0 && !empty($border_tops) ? PHPExcel_Style_Border::BORDER_THIN : PHPExcel_Style_Border::BORDER_NONE; $thisborderbottom = str_replace(array('px', 'PX'), '', $border_bottoms) > 0 && !empty($border_bottoms) ? PHPExcel_Style_Border::BORDER_THIN : PHPExcel_Style_Border::BORDER_NONE; $thisborderleft = str_replace(array('px', 'PX'), '', $border_lefts) > 0 && !empty($border_lefts) ? PHPExcel_Style_Border::BORDER_THIN : PHPExcel_Style_Border::BORDER_NONE; $thisborderright = str_replace(array('px', 'PX'), '', $border_rights) > 0 && !empty($border_rights) ? PHPExcel_Style_Border::BORDER_THIN : PHPExcel_Style_Border::BORDER_NONE; $strbold = $thisbold == true ? 'true' : 'false'; $stritalic = $thisitalic == true ? 'true' : 'false'; $strunderline = $thisunderline == true ? 'true' : 'false'; $strbordertop = str_replace(array('px', 'PX'), '', $border_tops) > 0 ? 'true' : 'false'; $strborderbottom = str_replace(array('px', 'PX'), '', $border_bottoms) > 0 ? 'true' : 'false'; $strborderleft = str_replace(array('px', 'PX'), '', $border_lefts) > 0 ? 'true' : 'false'; $strborderright = str_replace(array('px', 'PX'), '', $border_rights) > 0 ? 'true' : 'false'; if ($thisbg == 'FFFFFF') { $style_overlay['fill']['type'] = PHPExcel_Style_Fill::FILL_NONE; } else { $style_overlay['fill']['type'] = PHPExcel_Style_Fill::FILL_SOLID; } $style_overlay['alignment']['vertical'] = $thisvalign; // set styles for cell $style_overlay['alignment']['horizontal'] = $thisalign; $style_overlay['font']['color']['rgb'] = $thiscolor; $style_overlay['font']['bold'] = $thisbold; $style_overlay['font']['italic'] = $thisitalic; $style_overlay['font']['underline'] = $thisunderline == true ? PHPExcel_Style_Font::UNDERLINE_SINGLE : PHPExcel_Style_Font::UNDERLINE_NONE; $style_overlay['font']['size'] = $thissize; $style_overlay['font']['name'] = $thisname; $style_overlay['borders']['top']['style'] = $thisbordertop; $style_overlay['borders']['bottom']['style'] = $thisborderbottom; $style_overlay['borders']['left']['style'] = $thisborderleft; $style_overlay['borders']['right']['style'] = $thisborderright; $style_overlay['fill']['color']['rgb'] = $thisbg; if ($thiscolspan == 1) { $worksheet->getColumnDimension($xcol)->setWidth(25); } $worksheet->setCellValue($xcol . $xrow, $thistext); if (is_array($thisimg) && count($thisimg) > 0) { $thisCellWidth = $worksheet->getColumnDimension($xcol)->getWidth(); $thisCellHeight = 0; $offsetY = 5; foreach ($thisimg as $Vimg) { $objDrawing = new PHPExcel_Worksheet_Drawing(); $objDrawing->setWorksheet($worksheet); $objDrawing->setName($Vimg['name']); $objDrawing->setDescription($Vimg['title']); $objDrawing->setPath($Vimg['src']); $objDrawing->setCoordinates($xcol . $xrow); $objDrawing->setOffsetX(1); $objDrawing->setOffsetY($offsetY); $objDrawing->setWidth($Vimg['width']); $objDrawing->setHeight($Vimg['height']); $thisCellHeight += $Vimg['height']; if ($Vimg['width'] > $thisCellWidth) { $worksheet->getColumnDimension($xcol)->setWidth($Vimg['width'] / 5); } if ($Vimg['height'] > 0) { $worksheet->getRowDimension($xrow)->setRowHeight($thisCellHeight); } if ($debug) { fwrite($handle, "\n Insert Image on " . $xcol . ":" . $xrow . ' src:' . $Vimg['src'] . ' Width:' . $Vimg['width'] . ' Height:' . $Vimg['height'] . ' Offset:' . $offsetY); } $offsetY += $Vimg['height'] + 10; } } if ($debug) { fwrite($handle, "\n" . $xcol . ":" . $xrow . " Rowspan:" . $thisrowspan . " ColSpan:" . $thiscolspan . " Color:" . $thiscolor . " Align:" . $thisalign . " VAlign:" . $thisvalign . " BGColor:" . $thisbg . " Bold:" . $strbold . " Italic:" . $stritalic . " Underline:" . $strunderline . " Font-name:" . $thisname . " Font-size:" . $thissize . " Border-top: " . $strbordertop . " Border-bottom" . $strborderbottom . " Border-left:" . $strborderleft . " Border-right:" . $strborderright . " cellValue: " . $thistext); } $worksheet->getStyle($xcol . $xrow)->applyFromArray($style_overlay); if ($thiscolspan > 1 && $thisrowspan == 1) { // spans more than 1 column $lastxcol = $xcol; for ($j = 1; $j < $thiscolspan; $j++) { $lastxcol++; } $cellRange = $xcol . $xrow . ':' . $lastxcol . $xrow; if ($debug) { fwrite($handle, "\nmergeCells: " . $xcol . ":" . $xrow . " " . $lastxcol . ":" . $xrow); } $worksheet->mergeCells($cellRange); $worksheet->getStyle($cellRange)->applyFromArray($style_overlay); $xcol = $lastxcol; } elseif ($thiscolspan == 1 && $thisrowspan > 1) { // spans more than 1 column $lastxrow = $xrow; for ($j = 1; $j < $thisrowspan; $j++) { $lastxrow++; //$fillCell[$xcol.':'.$lastxrow] = true; } $cellRange = $xcol . $xrow . ':' . $xcol . $lastxrow; if ($debug) { fwrite($handle, "\nmergeCells: " . $xcol . ":" . $xrow . " " . $xcol . ":" . $lastxrow); } $worksheet->mergeCells($cellRange); $worksheet->getStyle($cellRange)->applyFromArray($style_overlay); //$xrow = $lastxrow; } elseif ($thiscolspan > 1 && $thisrowspan > 1) { // spans more than 1 column $lastxcol = $xcol; $lastxrow = $xrow; for ($j = 1; $j < $thiscolspan; $j++) { $lastxcol++; for ($k = 1; $k < $thisrowspan; $k++) { $lastxrow++; //$fillCell[$lastxcol.':'.$lastxrow] = true; } } $cellRange = $xcol . $xrow . ':' . $lastxcol . $lastxrow; if ($debug) { fwrite($handle, "\nmergeCells: " . $xcol . ":" . $xrow . " " . $lastxcol . ":" . $lastxrow); } $worksheet->mergeCells($cellRange); $worksheet->getStyle($cellRange)->applyFromArray($style_overlay); $xcol = $lastxcol; //$xrow = $lastxrow; } } $xrow++; $xcol = ''; } // autosize columns to fit data $azcol = 'A'; for ($x = 1; $x == $maxcols; $x++) { $worksheet->getColumnDimension($azcol)->setAutoSize(true); $azcol++; } if ($debug) { fwrite($handle, "\nHEADROWS: " . print_r($headrows, true)); fwrite($handle, "\nBODYROWS: " . print_r($bodyrows, true)); fwrite($handle, "\nFILLCELL: " . print_r($fillCell, true)); } } // end for over tables $objPHPExcel->setActiveSheetIndex(0); // set to first worksheet before close // // Write to Browser // if ($debug) { fclose($handle); } header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header("Content-Disposition: attachment;filename={$fname}"); header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); //$objWriter->save($fname); $objWriter->save('php://output'); exit; }
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'); $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); rename(APPPATH . 'libraries/excel.xlsx', $pathfile); return $pathfile; } else { header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="' . $title . '.xlsx"'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save('php://output'); exit; } } else { redirect('override_404'); } }
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'); }
$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');
/** * @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); }
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); $objPHPExcel->getActiveSheet()->getStyle('R')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('S')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('T')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('U')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('V')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('W')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); // 将样式应用于A1单元格 /* $objPHPExcel->getActiveSheet()->getStyle('A1')->applyFromArray($styleArray1); $objPHPExcel->getActiveSheet()->getStyle('B1')->applyFromArray($styleArray1); $objPHPExcel->getActiveSheet()->getStyle('C1')->applyFromArray($styleArray1); $objPHPExcel->getActiveSheet()->getStyle('D1')->applyFromArray($styleArray1); $objPHPExcel->getActiveSheet()->getStyle('E1')->applyFromArray($styleArray1); $objPHPExcel->getActiveSheet()->getStyle('F1')->applyFromArray($styleArray1); $objPHPExcel->getActiveSheet()->getStyle('G1')->applyFromArray($styleArray1); */ // 给特定单元格中写入内容 $objPHPExcel->getActiveSheet()->setCellValue('A1', '图片'); $objPHPExcel->getActiveSheet()->setCellValue('B1', '商品编号'); $objPHPExcel->getActiveSheet()->setCellValue('C1', '商品条形码'); $objPHPExcel->getActiveSheet()->setCellValue('D1', '商品名称'); $objPHPExcel->getActiveSheet()->setCellValue('E1', '商品分类'); $objPHPExcel->getActiveSheet()->setCellValue('F1', '商品品牌'); $objPHPExcel->getActiveSheet()->setCellValue('G1', '商品规格'); $objPHPExcel->getActiveSheet()->setCellValue('H1', '商品重量'); $objPHPExcel->getActiveSheet()->setCellValue('I1', '产地'); $objPHPExcel->getActiveSheet()->setCellValue('J1', '生产商'); $objPHPExcel->getActiveSheet()->setCellValue('K1', '保质期'); $objPHPExcel->getActiveSheet()->setCellValue('L1', '商品单位'); $objPHPExcel->getActiveSheet()->setCellValue('M1', '供应价'); $objPHPExcel->getActiveSheet()->setCellValue('N1', '批发价'); $objPHPExcel->getActiveSheet()->setCellValue('O1', '零售价'); $objPHPExcel->getActiveSheet()->setCellValue('P1', '商品库存'); $objPHPExcel->getActiveSheet()->setCellValue('Q1', '库存警告数量'); $objPHPExcel->getActiveSheet()->setCellValue('R1', 'meta关键字'); $objPHPExcel->getActiveSheet()->setCellValue('S1', 'meta描述'); $objPHPExcel->getActiveSheet()->setCellValue('T1', '商品赠送'); $objPHPExcel->getActiveSheet()->setCellValue('U1', '供应商帐号'); $objPHPExcel->getActiveSheet()->setCellValue('V1', '商品图片路径'); $objPHPExcel->getActiveSheet()->setCellValue('W1', '商品相册[多个用|分隔]'); //循环 $k = 1; if (!empty($rt)) { foreach ($rt as $row) { ++$k; //居中 /* $objPHPExcel->getActiveSheet()->getStyle('A'.$k)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('B'.$k)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('C'.$k)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); // $objPHPExcel->getActiveSheet()->getStyle('D'.$k)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('E'.$k)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('F'.$k)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('G'.$k)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); //垂直居中 $objPHPExcel->getActiveSheet()->getStyle('A'.$k)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('B'.$k)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('C'.$k)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('D'.$k)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('E'.$k)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('F'.$k)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('G'.$k)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);*/ // 设置行的高度 $objPHPExcel->getActiveSheet()->getRowDimension($k)->setRowHeight(50); //赋值 // $objPHPExcel->getActiveSheet()->getStyle('A'.$k)->applyFromArray($styleArray1); //$objPHPExcel->getActiveSheet()->setCellValue('B'.$k, '图片'); // 给单元格中放入图片, 将数据图片放在J1单元格内 $objDrawing = new PHPExcel_Worksheet_Drawing(); $objDrawing->setName('Logo'); $objDrawing->setDescription('Logo'); $objDrawing->setPath(!empty($row['goods_thumb']) && file_exists(SYS_PATH . $row['goods_thumb']) ? '../' . $row['goods_thumb'] : './images/no_picture.gif'); // 图片路径,只能是相对路径 //$objDrawing->setWidth(60); // 图片宽度 $objDrawing->setHeight(50); // 图片高度 $objDrawing->setCoordinates('A' . $k); $objDrawing->setWorksheet($objPHPExcel->getActiveSheet()); $objPHPExcel->getActiveSheet()->setCellValue('B' . $k, $row['goods_bianhao']); $objPHPExcel->getActiveSheet()->setCellValue('C' . $k, $row['goods_sn']); $objPHPExcel->getActiveSheet()->setCellValue('D' . $k, $row['goods_name']); $objPHPExcel->getActiveSheet()->setCellValue('E' . $k, empty($row['goods_cate_sub']) ? $row['goods_cate'] : $row['goods_cate_sub']); $brand_name = !empty($row['brand_name']) ? trim(stripcslashes(strip_tags(nl2br($row['brand_name'])))) : '---'; $objPHPExcel->getActiveSheet()->setCellValue('F' . $k, $brand_name); $objPHPExcel->getActiveSheet()->setCellValue('G' . $k, $row['goods_brief']); $objPHPExcel->getActiveSheet()->setCellValue('H' . $k, $row['goods_weight']); $objPHPExcel->getActiveSheet()->setCellValue('I' . $k, ''); $objPHPExcel->getActiveSheet()->setCellValue('J' . $k, ''); $objPHPExcel->getActiveSheet()->setCellValue('K' . $k, ''); $objPHPExcel->getActiveSheet()->setCellValue('L' . $k, $row['goods_unit']); $objPHPExcel->getActiveSheet()->setCellValue('M' . $k, $row['market_price']); $objPHPExcel->getActiveSheet()->setCellValue('N' . $k, $row['pifa_price']); $objPHPExcel->getActiveSheet()->setCellValue('O' . $k, $row['shop_price']); $objPHPExcel->getActiveSheet()->setCellValue('P' . $k, $row['goods_number']); $objPHPExcel->getActiveSheet()->setCellValue('Q' . $k, $row['warn_number']); $objPHPExcel->getActiveSheet()->setCellValue('R' . $k, $row['meta_keys']); $objPHPExcel->getActiveSheet()->setCellValue('S' . $k, $row['meta_desc']); $objPHPExcel->getActiveSheet()->setCellValue('T' . $k, ''); $objPHPExcel->getActiveSheet()->setCellValue('U' . $k, ''); $objPHPExcel->getActiveSheet()->setCellValue('V' . $k, $row['original_img']); $objPHPExcel->getActiveSheet()->setCellValue('W' . $k, ''); } } $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $m_strOutputExcelFileName = (empty($cname) ? '商品列表' : $cname) . date('Y-m-j_H_i_s') . ".xls"; // 输出EXCEL文件名 header("Pragma: public"); header("Expires: 0"); header("Cache-Control:must-revalidate, post-check=0, pre-check=0"); header("Content-Type:application/force-download"); header("Content-Type: application/vnd.ms-excel;"); header("Content-Type:application/octet-stream"); header("Content-Type:application/download"); header("Content-Disposition:attachment;filename=" . $m_strOutputExcelFileName); header("Content-Transfer-Encoding:binary"); $objWriter->save("php://output"); }
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++; } } $renglon++; $objPHPExcel->getActiveSheet()->setCellValue('E' . $renglon, 'Total'); $columna = 'F'; $m = 0; while ($m < $num_columnas) { $objPHPExcel->getActiveSheet()->setCellValue($columna . $renglon, $acum_meses[$m]); $m++; $columna++; } // 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; }
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; }
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("cartera ")->setSubject("cartera ")->setDescription("cartera ")->setKeywords("office 2007 openxml php")->setCategory("cartera "); $objPHPExcel->getActiveSheet()->setTitle('cartera'); //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', 'Cartera Vencida Desarrollo ' . $this->cartera['desarrollo']->nombre . ' (Moratorios)'); $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')); $capital = 0; $actualizacion = 0; $intereses = 0; $gas_admon_cob = 0; $moratorios = 0; $enga = 0; $objPHPExcel->getActiveSheet()->setCellValue('F6', 'Cliente')->setCellValue('G6', 'Expediente')->setCellValue('H6', 'Manzana')->setCellValue('I6', 'Lote')->setCellValue('J6', 'Mensualidad')->setCellValue('K6', 'Fecha de vencimiento')->setCellValue('L6', 'Moratorios'); $renglon = 7; $total = 0; for ($expediente = 0; $expediente < count($this->cartera['cartera_vencida']); $expediente++) { if ($this->cartera['cartera_vencida'][$expediente]['cliente']->tipo == 1) { $cliente = $this->cartera['cartera_vencida'][$expediente]['cliente']->nombre . " " . $this->cartera['cartera_vencida'][$expediente]['cliente']->ape_pate . " " . $this->cartera['cartera_vencida'][$expediente]['cliente']->ape_mate; } else { $cliente = $this->cartera['cartera_vencida'][$expediente]['cliente']->denominacion; } $objPHPExcel->getActiveSheet()->setCellValue('F' . $renglon, $cliente)->setCellValue('G' . $renglon, $this->cartera['cartera_vencida'][$expediente]['expediente']->id_expediente)->setCellValue('H' . $renglon, $this->cartera['cartera_vencida'][$expediente]['expediente']->num_letra)->setCellValue('I' . $renglon, $this->cartera['cartera_vencida'][$expediente]['expediente']->lote); $cli_total = 0; $renglon++; for ($mensualidad = 0; $mensualidad < count($this->cartera['cartera_vencida'][$expediente]['mensualidades']); $mensualidad++) { $objPHPExcel->getActiveSheet()->setCellValue('J' . $renglon, $this->cartera['cartera_vencida'][$expediente]['mensualidades'][$mensualidad]['mensualidad'])->setCellValue('K' . $renglon, $this->cartera['cartera_vencida'][$expediente]['mensualidades'][$mensualidad]['fecha_vence'])->setCellValue('L' . $renglon, $this->cartera['cartera_vencida'][$expediente]['mensualidades'][$mensualidad]['total']); $cli_total += $this->cartera['cartera_vencida'][$expediente]['mensualidades'][$mensualidad]['total']; $total += $this->cartera['cartera_vencida'][$expediente]['mensualidades'][$mensualidad]['total']; $renglon++; } $objPHPExcel->getActiveSheet()->setCellValue('K' . $renglon, 'Totales')->setCellValue('L' . $renglon, $cli_total); } $renglon += 4; $objPHPExcel->getActiveSheet()->setCellValue('K' . $renglon, 'Total en el desarrollo')->setCellValue('L' . $renglon, $total); // 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 . '-cartera_vencida_moratorios.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; }
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("Cancelaciones")->setSubject("Cancelaciones")->setDescription("Cancelaciones")->setKeywords("office 2007 openxml php")->setCategory("Cancelaciones"); //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->getActiveSheet()->setTitle('Cancelaciones ' . $this->cancelaciones['desarrollo']->id_desarrollo); $objPHPExcel->setActiveSheetIndex()->mergeCells('F2:O2'); for ($columna = 'B'; $columna <= 'O'; $columna++) { $objPHPExcel->getActiveSheet()->getColumnDimension($columna)->setAutoSize(true); } $objPHPExcel->getActiveSheet()->setCellValue('F2', 'Cancelaciones del Desarrollo ' . $this->cancelaciones['desarrollo']->nombre); $objPHPExcel->getActiveSheet()->getStyle('F2:O2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $renglon = 6; for ($cancelacion = 0; $cancelacion < count($this->cancelaciones['cancelaciones']); $cancelacion++) { $lote = DB::table('solicitud')->where('fk_expediente', $this->cancelaciones['cancelaciones'][$cancelacion]->id_expediente)->join('lote', 'lote.id_lote', '=', 'solicitud.fk_lote')->join('manzana', 'manzana.id_manzana', '=', 'lote.fk_manzana')->get()[0]; if ($this->cancelaciones['cancelaciones'][$cancelacion]->abonado_capital - $this->cancelaciones['cancelaciones'][$cancelacion]->pena_capital > 0) { $devuelto = $this->cancelaciones['cancelaciones'][$cancelacion]->abonado_capital - $this->cancelaciones['cancelaciones'][$cancelacion]->pena_capital; } else { $devuelto = 0; } if ($this->cancelaciones['cancelaciones'][$cancelacion]->denominacion != '_') { $cliente = $this->cancelaciones['cancelaciones'][$cancelacion]->denominacion; } else { $cliente = $this->cancelaciones['cancelaciones'][$cancelacion]->nombre . ' ' . $this->cancelaciones['cancelaciones'][$cancelacion]->ape_pate . $this->cancelaciones['cancelaciones'][$cancelacion]->ape_mate; } $objPHPExcel->getActiveSheet()->setCellValue('B' . ($renglon - 1), 'Cancelacion')->setCellValue('C' . ($renglon - 1), $this->cancelaciones['cancelaciones'][$cancelacion]->id_cancelacion)->setCellValue('D' . ($renglon - 1), 'Cliente')->setCellValue('E' . ($renglon - 1), $cliente)->setCellValue('F' . ($renglon - 1), 'RFC')->setCellValue('G' . ($renglon - 1), $this->cancelaciones['cancelaciones'][$cancelacion]->rfc)->setCellValue('D' . $renglon, 'Lote')->setCellValue('D' . ($renglon + 1), $lote->lote)->setCellValue('E' . $renglon, 'Manzana')->setCellValue('E' . ($renglon + 1), $lote->num_letra)->setCellValue('F' . $renglon, 'Fecha')->setCellValue('F' . ($renglon + 1), $this->cancelaciones['cancelaciones'][$cancelacion]->fecha)->setCellValue('G' . $renglon, 'Penalización a Capital')->setCellValue('G' . ($renglon + 1), '$' . $this->cancelaciones['cancelaciones'][$cancelacion]->pena_capital)->setCellValue('H' . $renglon, 'Abonado a Capital')->setCellValue('H' . ($renglon + 1), '$' . $this->cancelaciones['cancelaciones'][$cancelacion]->abonado_capital)->setCellValue('I' . $renglon, 'Devuelto al cliente')->setCellValue('I' . ($renglon + 1), '$' . $devuelto); $renglon += 2; } // 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 . '-cancelacion_contrato.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; }
public function exportFlightTaskToXls($xls, $firstSheet, $row, $progressBar) { foreach ($firstSheet->getRowDimensions() as $rd) { $rd->setRowHeight(-1); } $xls->getProperties()->setCreator(Kwf_Config::getValue('application.name')); $xls->getProperties()->setLastModifiedBy(Kwf_Config::getValue('application.name')); $xls->getProperties()->setTitle("Полетное Задание"); $xls->getProperties()->setSubject("Полетное Задание"); $xls->getProperties()->setDescription("Полетное Задание на сегодня"); $xls->getProperties()->setKeywords(""); $xls->getProperties()->setCategory(""); $firstSheet->getPageSetup()->setFitToPage(true); $firstSheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE); $firstSheet->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4); $firstSheet->setTitle('Титульный лист'); $pageMargins = $firstSheet->getPageMargins(); $margin = 0.42; $pageMargins->setTop($margin * 2); $pageMargins->setBottom($margin); $pageMargins->setLeft($margin); $pageMargins->setRight($margin); $styleThinBlackBorderOutline = array('borders' => array('outline' => array('style' => PHPExcel_Style_Border::BORDER_THIN, 'color' => array('argb' => 'FF000000')))); $totalLeftColumns = 28; for ($i = 0; $i <= $totalLeftColumns - 1; $i++) { $firstSheet->getColumnDimension($this->_getColumnLetterByIndex($i))->setWidth('2.0pt'); } $tableColumn = $this->_getColumnLetterByIndex($totalLeftColumns - 1); $tableHeaderColumnt = $this->_getColumnLetterByIndex($totalLeftColumns); $firstSheet->getColumnDimension($this->_getColumnLetterByIndex($totalLeftColumns + 1))->setWidth('10pt'); $firstSheet->mergeCells($this->_getColumnLetterByIndex($totalLeftColumns + 1) . '1:' . $this->_getColumnLetterByIndex($totalLeftColumns + 1) . '39'); $firstSheet->getStyle('A1:' . $tableColumn . '13')->applyFromArray($styleThinBlackBorderOutline); $firstSheet->mergeCells('A1:' . $tableColumn . '13'); $firstSheet->getStyle($tableHeaderColumnt . '1:' . $tableHeaderColumnt . '13')->applyFromArray($styleThinBlackBorderOutline); $firstSheet->mergeCells($tableHeaderColumnt . '1:' . $tableHeaderColumnt . '13'); $firstSheet->setCellValue($tableHeaderColumnt . '1', 'Предполётный медосмотр'); $firstSheet->getStyle($tableHeaderColumnt . '1')->getAlignment()->setWrapText(true); $firstSheet->getStyle($tableHeaderColumnt . '1')->getFont()->setBold(true); $firstSheet->getStyle($tableHeaderColumnt . '1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $firstSheet->getStyle($tableHeaderColumnt . '1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $firstSheet->getStyle($tableHeaderColumnt . '1')->getAlignment()->setTextRotation(-90); $firstSheet->getStyle('A14:' . $tableColumn . '26')->applyFromArray($styleThinBlackBorderOutline); $firstSheet->mergeCells('A14:' . $tableColumn . '26'); $firstSheet->getStyle($tableHeaderColumnt . '14:' . $tableHeaderColumnt . '26')->applyFromArray($styleThinBlackBorderOutline); $firstSheet->mergeCells($tableHeaderColumnt . '14:' . $tableHeaderColumnt . '26'); $firstSheet->setCellValue($tableHeaderColumnt . '14', 'Спецконроль в аэропортах'); $firstSheet->getStyle($tableHeaderColumnt . '14')->getAlignment()->setWrapText(true); $firstSheet->getStyle($tableHeaderColumnt . '14')->getFont()->setBold(true); $firstSheet->getStyle($tableHeaderColumnt . '14')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $firstSheet->getStyle($tableHeaderColumnt . '14')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $firstSheet->getStyle($tableHeaderColumnt . '14')->getAlignment()->setTextRotation(-90); $firstSheet->getStyle('A27:' . $tableColumn . '39')->applyFromArray($styleThinBlackBorderOutline); $firstSheet->mergeCells('A27:B39'); $firstSheet->getStyle($tableHeaderColumnt . '27:' . $tableHeaderColumnt . '39')->applyFromArray($styleThinBlackBorderOutline); $firstSheet->mergeCells($tableHeaderColumnt . '27:' . $tableHeaderColumnt . '39'); $firstSheet->setCellValue($tableHeaderColumnt . '27', 'Результаты послеполётного разбора'); $firstSheet->getStyle($tableHeaderColumnt . '27')->getFont()->setBold(true); $firstSheet->getStyle($tableHeaderColumnt . '27')->getAlignment()->setWrapText(true); $firstSheet->getStyle($tableHeaderColumnt . '27')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $firstSheet->getStyle($tableHeaderColumnt . '27')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $firstSheet->getStyle($tableHeaderColumnt . '27')->getAlignment()->setTextRotation(-90); $progressBar->update(10); for ($i = 2; $i <= $totalLeftColumns - 1; $i++) { $col = $this->_getColumnLetterByIndex($i); $firstSheet->mergeCells($col . '27:' . $col . '39'); } $rightColumn = $totalLeftColumns + 2; $rowNumber = 1; $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); $rowNumber += 1; $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn) . $rowNumber)->getFont()->setSize(10); $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn) . $rowNumber, trlKwf('Дальневосточное межрегиональное территориальное управление')); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn) . $rowNumber)->getFont()->setBold(true); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn) . $rowNumber)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $rowNumber += 1; $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn) . $rowNumber)->getFont()->setSize(10); $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn) . $rowNumber, trlKwf('воздушного транспорта ФАВТ')); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn) . $rowNumber)->getFont()->setBold(true); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn) . $rowNumber)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $rowNumber += 1; $firstSheet->getColumnDimension($this->_getColumnLetterByIndex($rightColumn))->setWidth('15pt'); $firstSheet->getColumnDimension($this->_getColumnLetterByIndex($rightColumn + 1))->setWidth('15pt'); $firstSheet->getColumnDimension($this->_getColumnLetterByIndex($rightColumn + 2))->setWidth('10pt'); $firstSheet->getColumnDimension($this->_getColumnLetterByIndex($rightColumn + 3))->setWidth('10pt'); $firstSheet->getColumnDimension($this->_getColumnLetterByIndex($rightColumn + 4))->setWidth('15pt'); $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); $rowNumber += 1; $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . ($rowNumber + 3)); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn) . $rowNumber)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objDrawing = new PHPExcel_Worksheet_Drawing(); $objDrawing->setName('Logo'); $objDrawing->setDescription('Logo'); $objDrawing->setPath('./images/doc_logo.png'); $objDrawing->setCoordinates($this->_getColumnLetterByIndex($rightColumn) . $rowNumber); $objDrawing->setWidth('360px'); $objDrawing->setOffsetX(50); $objDrawing->setWorksheet($firstSheet); $rowNumber += 4; $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); $rowNumber += 1; $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 2) . $rowNumber); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn) . $rowNumber)->getFont()->setBold(true); $flightsModel = Kwf_Model_Abstract::getInstance('Flights'); $flightsSelect = $flightsModel->select()->whereEquals('planId', $row->planId)->order(array('subCompanyId', 'flightStartTime')); $flights = $flightsModel->getRows($flightsSelect); $flightSequenceNumber = 1; $lastSubcompanyId = 0; foreach ($flights as $flight) { if ($lastSubcompanyId != $flight->subCompanyId) { $flightSequenceNumber = 0; } $lastSubcompanyId = $flight->subCompanyId; $flightSequenceNumber += 1; if ($flight->id == $row->id) { break; } } $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn) . $rowNumber, trlKwf('ЗАДАНИЕ НА ПОЛЁТ №') . $row->number); #$firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn + 2) . $rowNumber, $flightSequenceNumber . ' / ' . $row->flightStartDate); #$firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn + 1) . $rowNumber, $row->number); #$firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn + 1) . $rowNumber)->getFont()->setBold(true); $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn + 3) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn + 3) . $rowNumber, 'ЮШ ' . $row->requestNumber); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn + 3) . $rowNumber)->getFont()->setBold(true); $rowNumber += 1; $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); $rowNumber += 1; $planesModel = Kwf_Model_Abstract::getInstance('Airplanes'); $planesSelect = $planesModel->select()->whereEquals('id', $row->planeId); $plane = $planesModel->getRow($planesSelect); $typeModel = Kwf_Model_Abstract::getInstance('Wstypes'); $typeSelect = $typeModel->select()->whereEquals('id', $plane->twsId); $planeType = $typeModel->getRow($typeSelect); $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn) . $rowNumber, 'Экипажу вертолёта:'); $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn + 2) . $rowNumber, $planeType->Name); $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber, $row->planeName); $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn + 2) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 3) . $rowNumber); $rowNumber += 1; $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); $rowNumber += 1; $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn) . $rowNumber, 'СОСТАВ ЭКИПАЖА'); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn) . $rowNumber)->getFont()->setBold(true); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn) . $rowNumber)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $rowNumber += 1; $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn + 1) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn) . $rowNumber, 'Должность'); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn) . $rowNumber)->getFont()->setBold(true); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn) . $rowNumber)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn + 1) . $rowNumber, 'ФИО'); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn + 1) . $rowNumber)->getFont()->setBold(true); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn + 1) . $rowNumber)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $flightGroupsModel = Kwf_Model_Abstract::getInstance('Flightgroups'); $flightGroupsSelect = $flightGroupsModel->select()->whereEquals('flightId', $row->id)->whereEquals('mainCrew', TRUE)->order('id'); $flightMembers = $flightGroupsModel->getRows($flightGroupsSelect); $rowNumber += 1; $employeesModel = Kwf_Model_Abstract::getInstance('Employees'); $subSpecModel = Kwf_Model_Abstract::getInstance('Linkdata'); $kwsId = 0; $progressBar->update(50); foreach ($flightMembers as $flightMember) { $employeesSelect = $employeesModel->select()->whereEquals('id', $flightMember->employeeId); $employeeRow = $employeesModel->getRow($employeesSelect); if ($employeeRow == NULL) { continue; } $subSpecSelect = $subSpecModel->select()->whereEquals('id', $employeeRow->positionId); $subSpecRow = $subSpecModel->getRow($subSpecSelect); $position = $flightMember->positionName; if ($position == 'КВС') { $kwsId = $flightMember->employeeId; } $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn) . $rowNumber, $position); $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn + 1) . $rowNumber, (string) $employeeRow); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn + 1) . $rowNumber)->getFont()->setBold(true); $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn + 1) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); $rowNumber += 1; } $progressBar->update(60); $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); $rowNumber += 1; $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn) . $rowNumber, 'Дата вылета: '); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn) . $rowNumber)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn + 1) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 2) . $rowNumber); $flightDate = new DateTime($row->flightStartDate); $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn + 1) . $rowNumber, $this->russianDate($flightDate->format('d-m-Y'))); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn + 1) . $rowNumber)->getFont()->setBold(true); $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn + 3) . $rowNumber, 'Время: '); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn + 3) . $rowNumber)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $flightStartTime = new DateTime($row->flightStartTime); $flightStartTime = $flightStartTime->format("H:i"); $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber, $flightStartTime); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber)->getFont()->setBold(true); $rowNumber += 1; $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); // $rowNumber += 1; // $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn) . ($rowNumber + 1)); // // $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn) . $rowNumber, 'Маршрут полёта'); // $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn) . $rowNumber)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); // // $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn + 1) . $rowNumber, $row->routeName); // $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn + 1) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); // $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn + 1) . ($rowNumber + 1) . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . ($rowNumber + 1)); $rowNumber += 1; $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn) . ($rowNumber + 1)); $objectiveModel = Kwf_Model_Abstract::getInstance('Linkdata'); $objectiveSelect = $objectiveModel->select()->whereEquals('id', $row->objectiveId); $objective = $objectiveModel->getRow($objectiveSelect); $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn) . $rowNumber, 'Цель полёта'); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn) . $rowNumber)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn + 1) . $rowNumber, $objective->desc); $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn + 1) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn + 1) . ($rowNumber + 1) . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . ($rowNumber + 1)); $rowNumber += 2; $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn) . ($rowNumber + 1)); $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn) . $rowNumber, 'Пункты посадки'); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn) . $rowNumber)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn + 1) . $rowNumber, $row->routeName); $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn + 1) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn + 1) . ($rowNumber + 1) . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . ($rowNumber + 1)); $rowNumber += 2; $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); $rowNumber += 1; $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn) . $rowNumber, 'В ПОЛЕТНОЕ ЗАДАНИЕ ВКЛЮЧИТЬ'); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn) . $rowNumber)->getFont()->setBold(true); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn) . $rowNumber)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $rowNumber += 1; $flightGroupsModel = Kwf_Model_Abstract::getInstance('Flightgroups'); $flightGroupsSelect = $flightGroupsModel->select()->whereEquals('flightId', $row->id)->whereEquals('mainCrew', FALSE)->order('id'); $flightMembers = $flightGroupsModel->getRows($flightGroupsSelect); $employeesModel = Kwf_Model_Abstract::getInstance('Employees'); $subSpecModel = Kwf_Model_Abstract::getInstance('Linkdata'); $progressBar->update(70); foreach ($flightMembers as $flightMember) { $employeesSelect = $employeesModel->select()->whereEquals('id', $flightMember->employeeId); $employeeRow = $employeesModel->getRow($employeesSelect); $position = $flightMember->positionName; if ($position == 'По специальности') { if ($employeeRow->positionId == NULL) { $position = ''; } else { $subSpecSelect = $subSpecModel->select()->whereEquals('id', $employeeRow->positionId); $subSpecRow = $subSpecModel->getRow($subSpecSelect); $position = $subSpecRow->value; } } if ($employeeRow != NULL) { $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn) . $rowNumber, $position); $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn + 1) . $rowNumber, (string) $employeeRow); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn + 1) . $rowNumber)->getFont()->setBold(true); $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn + 1) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); $rowNumber += 1; } } $progressBar->update(80); $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); $rowNumber += 1; $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn) . $rowNumber, 'ЭКИПАЖ ДОПУЩЕН ПО МЕТЕОМИНИМУМУ'); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn) . $rowNumber)->getFont()->setBold(true); $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn) . $rowNumber)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $rowNumber += 1; $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); $rowNumber += 1; $accessesModel = Kwf_Model_Abstract::getInstance('Flightaccesses'); $accessesSelect = $accessesModel->select()->where(new Kwf_Model_Select_Expr_Sql("`employeeId` = " . $kwsId . " AND `wsTypeId` = " . $planeType->id)); $accesses = $accessesModel->getRows($accessesSelect); foreach ($accesses as $access) { $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); $firstSheet->setCellValue($this->_getColumnLetterByIndex($rightColumn) . $rowNumber, $access->accessName); $rowNumber += 1; } $firstSheet->mergeCells($this->_getColumnLetterByIndex($rightColumn) . $rowNumber . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . $rowNumber); $rowNumber += 1; $firstSheet->getStyle($this->_getColumnLetterByIndex($rightColumn) . 1 . ':' . $this->_getColumnLetterByIndex($rightColumn + 4) . 39)->applyFromArray($styleThinBlackBorderOutline); # Second page $xls->setActiveSheetIndex(1); $secondSheet = $xls->getActiveSheet(); $secondSheet->getPageSetup()->setFitToPage(true); $secondSheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE); $secondSheet->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4); $secondSheet->setTitle('Отчет о полете'); $pageMargins = $secondSheet->getPageMargins(); $margin = 0.2; $pageMargins->setTop($margin); $pageMargins->setBottom($margin); $pageMargins->setLeft($margin); $pageMargins->setRight($margin); for ($column = 0; $column < 70; $column++) { $secondSheet->getColumnDimension($this->_getColumnLetterByIndex($column))->setWidth('2.5pt'); } $secondSheet->getPageSetup()->setFitToPage(true); $xls->setActiveSheetIndex(0); $progressBar->update(100); }
/** * set header logo; */ public function setHeaderLogo() { $headerLogo = BASEPATH . $this->setup->getSettingValue('config_logo'); switch ($this->driver) { case 'excel2003': //drawing $drawing = new PHPExcel_Worksheet_Drawing(); $drawing->setName('Logo '); $drawing->setDescription('Logo'); $drawing->setPath($headerLogo); $drawing->setHeight(90); $drawing->setCoordinates('A' . $this->currentRow); $drawing->setOffsetX(90); $drawing->setRotation(25); $drawing->getShadow()->setVisible(true); $drawing->getShadow()->setDirection(45); $drawing->setWorksheet($this->rpt->getActiveSheet()); break; case 'excel2007': //drawing $drawing = new PHPExcel_Worksheet_Drawing(); $drawing->setName('Logo'); $drawing->setDescription('Logo'); $drawing->setPath($headerLogo); $drawing->setHeight(90); $drawing->setCoordinates('A' . $this->currentRow); $drawing->setOffsetX(10); $drawing->setRotation(0); $drawing->getShadow()->setVisible(true); $drawing->getShadow()->setDirection(45); $drawing->setWorksheet($this->rpt->getActiveSheet()); break; } }
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 Del Día")->setSubject("Cobranza ")->setDescription("Cobranza ")->setKeywords("office 2007 openxml php")->setCategory("Cobranza "); $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 = 'B'; $columna <= 'O'; $columna++) { $objPHPExcel->getActiveSheet()->getColumnDimension($columna)->setAutoSize(true); } $objPHPExcel->getActiveSheet()->setCellValue('F2', 'Cobranza Del Día ' . $this->cobranza['desde'] . ' Hasta ' . $this->cobranza['hasta']); $objPHPExcel->getActiveSheet()->getStyle('F2:O2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex()->mergeCells('F5:N5'); $objPHPExcel->getActiveSheet()->getStyle('F5:N5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->getActiveSheet()->setCellValue('F3', 'Fecha de reporte')->setCellValue('G3', date('Y-m-d'))->setCellValue('F5', 'Abonos a mensualidad'); $capital = 0; $actualizacion = 0; $intereses = 0; $gas_admon_cob = 0; $moratorios = 0; $renglon = 6; for ($abono = 0; $abono < count($this->cobranza['abonos_mensualidad']); $abono++) { if ($this->cobranza['abonos_mensualidad'][$abono]['mensualidad']->tipo == 1) { $cliente = $this->cobranza['abonos_mensualidad'][$abono]['mensualidad']->nombre . ' ' . $this->cobranza['abonos_mensualidad'][$abono]['mensualidad']->ape_pate . ' ' . $this->cobranza['abonos_mensualidad'][$abono]['mensualidad']->ape_mate; } else { $cliente = $this->cobranza['abonos_mensualidad'][$abono]['mensualidad']->denominacion; } if ($this->cobranza['abonos_mensualidad'][$abono]['mensualidad']->estado == 1) { if ($this->cobranza['abonos_mensualidad'][$abono]['mensualidad']->moratorios != 0) { $estado = "Adeudo a accesorios y a moratorios"; } else { $estado = "Adeudo a accesorios"; } } else { if ($this->cobranza['abonos_mensualidad'][$abono]['mensualidad']->estado == 2) { $estado = "Adeuda solo a moratorios"; } else { $estado = "Pagada"; } } $objPHPExcel->getActiveSheet()->setCellValue('F' . $renglon, 'Expediente')->setCellValue('F' . ($renglon + 1), $this->cobranza['abonos_mensualidad'][$abono]['mensualidad']->id_expediente)->setCellValue('G' . $renglon, 'Cliente')->setCellValue('G' . ($renglon + 1), $cliente)->setCellValue('H' . $renglon, 'Mensualidad')->setCellValue('I' . $renglon, $this->cobranza['abonos_mensualidad'][$abono]['mensualidad']->numero . '/' . $this->cobranza['abonos_mensualidad'][$abono]['mensualidad']->plazo)->setCellValue('H' . ($renglon + 1), 'Fecha de vencimiento')->setCellValue('I' . ($renglon + 1), $this->cobranza['abonos_mensualidad'][$abono]['mensualidad']->fecha_vence)->setCellValue('H' . ($renglon + 2), 'Capital')->setCellValue('I' . ($renglon + 2), $this->cobranza['abonos_mensualidad'][$abono]['mensualidad']->capital)->setCellValue('H' . ($renglon + 3), 'Gastos de administración y cobranza')->setCellValue('I' . ($renglon + 3), $this->cobranza['abonos_mensualidad'][$abono]['mensualidad']->gas_admon_cob)->setCellValue('H' . ($renglon + 4), 'Intereses')->setCellValue('I' . ($renglon + 4), $this->cobranza['abonos_mensualidad'][$abono]['mensualidad']->interes_aplicable)->setCellValue('H' . ($renglon + 5), 'Actualización')->setCellValue('I' . ($renglon + 5), $this->cobranza['abonos_mensualidad'][$abono]['mensualidad']->actualizacion)->setCellValue('H' . ($renglon + 6), 'Moratorios')->setCellValue('I' . ($renglon + 6), $this->cobranza['abonos_mensualidad'][$abono]['mensualidad']->moratorios)->setCellValue('H' . ($renglon + 7), 'Estado')->setCellValue('I' . ($renglon + 7), $estado)->setCellValue('L' . $renglon, 'Folio')->setCellValue('K' . $renglon, $this->cobranza['abonos_mensualidad'][$abono]['abono']->fk_operacion)->setCellValue('L' . ($renglon + 1), 'Fecha de abono')->setCellValue('M' . $renglon, 'Forma de pago')->setCellValue('M' . ($renglon + 1), '')->setCellValue('K' . ($renglon + 1), $this->cobranza['abonos_mensualidad'][$abono]['abono']->fecha)->setCellValue('K' . ($renglon + 2), $this->cobranza['abonos_mensualidad'][$abono]['abono']->pago_capital)->setCellValue('K' . ($renglon + 3), $this->cobranza['abonos_mensualidad'][$abono]['abono']->gas_admon_cob)->setCellValue('K' . ($renglon + 4), $this->cobranza['abonos_mensualidad'][$abono]['abono']->interes_aplicable)->setCellValue('K' . ($renglon + 5), $this->cobranza['abonos_mensualidad'][$abono]['abono']->actualizacion)->setCellValue('K' . ($renglon + 6), $this->cobranza['abonos_mensualidad'][$abono]['abono']->moratorios); $capital += $this->cobranza['abonos_mensualidad'][$abono]['abono']->pago_capital; $actualizacion += $this->cobranza['abonos_mensualidad'][$abono]['abono']->actualizacion; $intereses += $this->cobranza['abonos_mensualidad'][$abono]['abono']->interes_aplicable; $gas_admon_cob += $this->cobranza['abonos_mensualidad'][$abono]['abono']->gas_admon_cob; $moratorios += $this->cobranza['abonos_mensualidad'][$abono]['abono']->moratorios; $renglon += 10; } $objPHPExcel->getActiveSheet()->setCellValue('F' . ($renglon - 1), 'Abonado por concepto')->setCellValue('F' . $renglon, 'Capital')->setCellValue('G' . $renglon, $capital)->setCellValue('F' . ($renglon + 1), 'Actualizacion')->setCellValue('G' . ($renglon + 1), $actualizacion)->setCellValue('F' . ($renglon + 2), 'Intereses')->setCellValue('G' . ($renglon + 2), $intereses)->setCellValue('F' . ($renglon + 3), 'Gastos de admisnitración y cobranza')->setCellValue('G' . ($renglon + 3), $gas_admon_cob)->setCellValue('F' . ($renglon + 4), 'Moratorios')->setCellValue('G' . ($renglon + 4), $moratorios)->setCellValue('H' . $renglon, 'Total abonado a mensualidades')->setCellValue('I' . $renglon, $capital + $actualizacion + $intereses + $gas_admon_cob + $moratorios); $renglon += 8; $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, 'Abonos a enganches'); $renglon++; $abonos_enganche = 0; $amora_enganche = 0; for ($abono = 0; $abono < count($this->cobranza['abonos_enganche']); $abono++) { if ($this->cobranza['abonos_enganche'][$abono]['enganche']->tipo == 1) { $cliente = $this->cobranza['abonos_enganche'][$abono]['enganche']->nombre . ' ' . $this->cobranza['abonos_enganche'][$abono]['enganche']->ape_pate . ' ' . $this->cobranza['abonos_mensualidad'][$abono]['mensualidad']->ape_mate; } else { $cliente = $this->cobranza['abonos_enganche'][$abono]['enganche']->denominacion; } if ($this->cobranza['abonos_enganche'][$abono]['enganche']->estado == 1) { if ($this->cobranza['abonos_enganche'][$abono]['enganche']->moratorios != 0) { $estado = "Adeudo a accesorios y a moratorios"; } else { $estado = "Adeudo a complemento"; } } else { if ($this->cobranza['abonos_enganche'][$abono]['enganche']->estado == 2) { $estado = "Adeuda solo a moratorios"; } else { $estado = "Pagada"; } } $objPHPExcel->getActiveSheet()->setCellValue('F' . $renglon, 'Expediente')->setCellValue('G' . $renglon, $this->cobranza['abonos_enganche'][$abono]['enganche']->id_expediente)->setCellValue('F' . ($renglon + 1), 'Cliente')->setCellValue('G' . ($renglon + 1), $cliente)->setCellValue('H' . ($renglon + 1), 'Fecha promesa')->setCellValue('I' . ($renglon + 1), $this->cobranza['abonos_enganche'][$abono]['enganche']->fecha_promesa)->setCellValue('H' . ($renglon + 2), 'Importe')->setCellValue('I' . ($renglon + 2), $this->cobranza['abonos_enganche'][$abono]['enganche']->importe)->setCellValue('H' . ($renglon + 3), 'Moratorios')->setCellValue('I' . ($renglon + 3), $this->cobranza['abonos_enganche'][$abono]['enganche']->moratorios)->setCellValue('H' . ($renglon + 4), 'Estado')->setCellValue('I' . ($renglon + 4), $estado)->setCellValue('L' . $renglon, 'Folio')->setCellValue('K' . $renglon, $this->cobranza['abonos_enganche'][$abono]['abono']->fk_folio)->setCellValue('L' . ($renglon + 1), 'Fecha de abono')->setCellValue('K' . ($renglon + 1), $this->cobranza['abonos_enganche'][$abono]['abono']->fecha)->setCellValue('L' . ($renglon + 2), 'Importe')->setCellValue('K' . ($renglon + 2), $this->cobranza['abonos_enganche'][$abono]['abono']->importe)->setCellValue('L' . ($renglon + 3), 'Abono a Moratorios')->setCellValue('K' . ($renglon + 3), $this->cobranza['abonos_enganche'][$abono]['abono']->moratorios); $abonos_enganche += $this->cobranza['abonos_enganche'][$abono]['abono']->importe; $amora_enganche += $this->cobranza['abonos_enganche'][$abono]['abono']->moratorios; $renglon += 5; } $objPHPExcel->getActiveSheet()->setCellValue('F' . $renglon, 'Abonado a enganches')->setCellValue('G' . $renglon, $abonos_enganche)->setCellValue('F' . ($renglon + 1), 'Abonado a moratorios enganche')->setCellValue('G' . ($renglon + 1), $amora_enganche)->setCellValue('F' . ($renglon + 2), 'Total')->setCellValue('G' . ($renglon + 2), $abonos_enganche + $amora_enganche); $renglon += 4; $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, 'Abonos a capital'); $renglon++; $abonos_capital = 0; for ($abono = 0; $abono < count($this->cobranza['abonos_capital']); $abono++) { $objPHPExcel->getActiveSheet()->setCellValue('F' . $renglon, 'Expediente')->setCellValue('G' . $renglon, $this->cobranza['abonos_capital'][$abono]->id_expediente)->setCellValue('F' . ($renglon + 1), 'Cliente')->setCellValue('G' . ($renglon + 1), $cliente)->setCellValue('F' . ($renglon + 2), 'Folio')->setCellValue('G' . ($renglon + 2), $this->cobranza['abonos_capital'][$abono]->fk_folio)->setCellValue('F' . ($renglon + 3), 'Fecha')->setCellValue('G' . ($renglon + 3), $this->cobranza['abonos_capital'][$abono]->fecha)->setCellValue('F' . ($renglon + 4), 'Importe')->setCellValue('G' . ($renglon + 4), $this->cobranza['abonos_capital'][$abono]->monto); $abonos_capital += $this->cobranza['abonos_capital'][$abono]->monto; $renglon += 5; } $renglon += 2; $objPHPExcel->getActiveSheet()->setCellValue('F' . $renglon, 'Total abonado en abonos a capital')->setCellValue('G' . $renglon, $abonos_capital); $renglon += 5; $objPHPExcel->getActiveSheet()->setCellValue('F' . $renglon, 'Gran total')->setCellValue('G' . $renglon, $abonos_capital + $abonos_enganche + $amora_enganche + $capital + $actualizacion + $intereses + $gas_admon_cob + $moratorios); // 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; }
function index() { $this->load->library('myexcel'); $styleArray2 = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'top' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_DOUBLE)), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER), 'font' => array('bold' => true), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array('rgb' => 'CCCCCC'))); $styleArray3 = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'top' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_DOUBLE)), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER), 'font' => array('bold' => true), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array('rgb' => 'CCCCCC'))); $styleArray3a = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'top' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN)), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER), 'font' => array('bold' => true), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array('rgb' => 'CCCCCC'))); $styleArray3b = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'top' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_DOUBLE)), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER), 'font' => array('bold' => true), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array('rgb' => 'CCCCCC'))); $styleArray3c = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'top' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_DOUBLE)), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER), 'font' => array('bold' => true), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array('rgb' => 'CCCCCC'))); $styleArray4 = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'top' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_DOUBLE)), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER), 'font' => array('name' => 'Arial', 'bold' => true), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array('rgb' => 'CCCCCC'))); $styleArray4b = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'top' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN)), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER), 'font' => array('name' => 'Arial', 'bold' => true), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array('rgb' => 'CCCCCC'))); $styleArray4c = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'top' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_DOUBLE)), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER), 'font' => array('name' => 'Arial', 'bold' => true), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array('rgb' => 'CCCCCC'))); $styleArray5 = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_HAIR)), 'alignment' => array('vertical' => PHPExcel_Style_Alignment::VERTICAL_TOP)); $styleArray5a = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_THIN))); $styleArray6 = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_HAIR))); $styleArray6a = array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_HAIR))); $styleArray7 = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_HAIR))); $styleArray7a = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'top' => array('style' => PHPExcel_Style_Border::BORDER_THIN))); $styleArray7b = array('borders' => array('right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'top' => array('style' => PHPExcel_Style_Border::BORDER_HAIR))); $styleArray8 = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'top' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM))); $styleArray8a = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'top' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN))); $styleArray8aa = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'top' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM))); $styleArray8b = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'top' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN))); $styleArray8ba = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN))); $styleArray8c = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN))); $styleArray8d = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM))); $styleArray8e = array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM))); $styleArray8f = array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'left' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM))); $styleArray8g = array('borders' => array('top' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM))); $styleArray8h = array('borders' => array('right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'top' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM))); $styleArray8i = array('borders' => array('right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM))); $styleArray8j = array('borders' => array('right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM))); $styleArray9 = array('borders' => array('top' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER), 'font' => array('name' => 'Arial', 'bold' => true)); $styleArray10 = array('borders' => array('right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'top' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM))); $styleArray10b = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'top' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM))); ////////////////////////////////////////// $id_pegawai = $this->session->userdata('pegawai_info'); $tahun = $this->session->userdata('tahun_skp'); $bulan = $this->dropdowns->bulan(); $data['skp_tahun'] = $this->m_penilaian->get_skp_tahun($id_pegawai, $tahun); ////////////////////////////////////////// $this->myexcel->setActiveSheetIndex(0); $this->myexcel->getActiveSheet()->setTitle('SKP'); $this->myexcel->getActiveSheet()->getPageSetup()->setScale(85); $this->myexcel->getActiveSheet()->getPageMargins()->setLeft(0.4); $this->myexcel->getActiveSheet()->getPageMargins()->setRight(0.2); $this->myexcel->getActiveSheet()->getColumnDimension("A")->setWidth(2); $this->myexcel->getActiveSheet()->getColumnDimension("B")->setWidth(6); $this->myexcel->getActiveSheet()->getColumnDimension("C")->setWidth(20); $this->myexcel->getActiveSheet()->getColumnDimension("E")->setWidth(20); $this->myexcel->getActiveSheet()->getColumnDimension("G")->setWidth(6); $this->myexcel->getActiveSheet()->getColumnDimension("H")->setWidth(11); $this->myexcel->getActiveSheet()->getColumnDimension("I")->setWidth(6); $this->myexcel->getActiveSheet()->getColumnDimension("J")->setWidth(6); $rc = 1; foreach ($data['skp_tahun'] as $key => $val) { $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, 'FORMULIR SASARAN KERJA'); $this->myexcel->getActiveSheet()->setCellValue('B' . ($rc + 1), 'Pegawai Negeri Sipil'); $this->myexcel->getActiveSheet()->getStyle('B' . $rc . ':B' . ($rc + 1))->getFont()->setSize(16); $this->myexcel->getActiveSheet()->getStyle('B' . $rc . ':B' . ($rc + 1))->getFont()->setBold(true); $this->myexcel->getActiveSheet()->mergeCells('B' . $rc . ':L' . $rc); $this->myexcel->getActiveSheet()->mergeCells('B' . ($rc + 1) . ':L' . ($rc + 1)); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('B' . ($rc + 1))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $rc++; $rc++; $rc++; $bulan = $this->dropdowns->bulan(); $bulan_mulai = $bulan[$val->bulan_mulai]; $bulan_selesai = $bulan[$val->bulan_selesai]; $periode = "PERIODE : " . $bulan_mulai . " s.d. " . $bulan_selesai; $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, $periode); $rc++; $r_perilaku = $rc; $perilaku = $this->m_skp->get_perilaku($val->id_skp); if (!empty($perilaku)) { $pelayanan = $perilaku->pelayanan; $integritas = $perilaku->integritas; $komitmen = $perilaku->komitmen; $disiplin = $perilaku->disiplin; $kerjasama = $perilaku->kerjasama; $kepemimpinan = $perilaku->kepemimpinan; } else { $pelayanan = 0; $integritas = 0; $komitmen = 0; $disiplin = 0; $kerjasama = 0; $kepemimpinan = 0; } $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, 'No.'); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray2); $this->myexcel->getActiveSheet()->setCellValue('C' . $rc, 'I. PEJABAT PENILAI'); $this->myexcel->getActiveSheet()->mergeCells('C' . $rc . ':E' . $rc); $this->myexcel->getActiveSheet()->setCellValue('F' . $rc, 'No.'); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray3); $this->myexcel->getActiveSheet()->setCellValue('G' . $rc, 'II. PEGAWAI NEGERI SIPIL YANG DINILAI'); $this->myexcel->getActiveSheet()->getStyle('C' . $rc . ':K' . $rc)->applyFromArray($styleArray3); $this->myexcel->getActiveSheet()->setCellValue('L' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray4); $this->myexcel->getActiveSheet()->mergeCells('G' . $rc . ':L' . $rc); $this->myexcel->getActiveSheet()->setCellValue('O' . $rc, 'PELAYANAN'); $this->myexcel->getActiveSheet()->setCellValue('O' . ($rc + 1), $pelayanan); $this->myexcel->getActiveSheet()->setCellValue('P' . $rc, 'INTEGRITAS'); $this->myexcel->getActiveSheet()->setCellValue('P' . ($rc + 1), $integritas); $this->myexcel->getActiveSheet()->setCellValue('Q' . $rc, 'KOMITMEN'); $this->myexcel->getActiveSheet()->setCellValue('Q' . ($rc + 1), $komitmen); $this->myexcel->getActiveSheet()->setCellValue('R' . $rc, 'DISIPLIN'); $this->myexcel->getActiveSheet()->setCellValue('R' . ($rc + 1), $disiplin); $this->myexcel->getActiveSheet()->setCellValue('S' . $rc, 'KERJASAMA'); $this->myexcel->getActiveSheet()->setCellValue('S' . ($rc + 1), $kerjasama); $this->myexcel->getActiveSheet()->setCellValue('T' . $rc, 'KEPEMIMPINAN'); $this->myexcel->getActiveSheet()->setCellValue('T' . ($rc + 1), $kepemimpinan); $rc++; $nama_pegawai = (trim($val->gelar_depan) != '-' ? trim($val->gelar_depan) . ' ' : '') . $val->nama_pegawai . (trim($val->gelar_belakang) != '-' ? ', ' . trim($val->gelar_belakang) : ''); $nama_penilai = (trim($val->penilai_gelar_depan) != '-' ? trim($val->penilai_gelar_depan) . ' ' : '') . $val->penilai_nama_pegawai . (trim($val->penilai_gelar_belakang) != '-' ? ', ' . trim($val->penilai_gelar_belakang) : ''); $r_nama = $rc; $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, 1); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray5); $this->myexcel->getActiveSheet()->setCellValue('C' . $rc, 'Nama'); $this->myexcel->getActiveSheet()->setCellValue('D' . $rc, $nama_penilai); $this->myexcel->getActiveSheet()->getStyle('C' . $rc . ':E' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('F' . $rc, 1); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('G' . $rc, 'Nama'); $this->myexcel->getActiveSheet()->setCellValue('I' . $rc, $nama_pegawai); $this->myexcel->getActiveSheet()->getStyle('G' . $rc . ':K' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray7b); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, " "); $rc++; $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, 2); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray5); $this->myexcel->getActiveSheet()->setCellValue('C' . $rc, 'NIP'); $this->myexcel->getActiveSheet()->setCellValue('D' . $rc, " " . $val->penilai_nip_baru); $this->myexcel->getActiveSheet()->getStyle('C' . $rc . ':E' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('F' . $rc, 2); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('G' . $rc, 'NIP'); $this->myexcel->getActiveSheet()->setCellValue('I' . $rc, " " . $val->nip_baru); $this->myexcel->getActiveSheet()->getStyle('G' . $rc . ':K' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray7b); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, " "); $rc++; $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, 3); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray5); $this->myexcel->getActiveSheet()->setCellValue('C' . $rc, 'Pangkat / Gol.Ruang'); $this->myexcel->getActiveSheet()->setCellValue('D' . $rc, $val->penilai_nama_golongan . " / " . $val->penilai_nama_pangkat); $this->myexcel->getActiveSheet()->getStyle('C' . $rc . ':E' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('F' . $rc, 3); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('G' . $rc, 'Pangkat / Gol.Ruang'); $this->myexcel->getActiveSheet()->setCellValue('I' . $rc, $val->nama_golongan . " / " . $val->nama_pangkat); $this->myexcel->getActiveSheet()->getStyle('G' . $rc . ':K' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray7b); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, " "); $rc++; $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, 4); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray5); $this->myexcel->getActiveSheet()->setCellValue('C' . $rc, 'Jabatan'); $this->myexcel->getActiveSheet()->setCellValue('D' . $rc, $val->penilai_nomenklatur_jabatan); $this->myexcel->getActiveSheet()->getStyle('D' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->mergeCells('D' . $rc . ':E' . $rc); $this->myexcel->getActiveSheet()->getStyle('C' . $rc . ':E' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('F' . $rc, 4); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('G' . $rc, 'Jabatan'); $this->myexcel->getActiveSheet()->setCellValue('I' . $rc, $val->nomenklatur_jabatan); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->mergeCells('I' . $rc . ':L' . $rc); $this->myexcel->getActiveSheet()->getStyle('G' . $rc . ':K' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray7b); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, " "); $this->myexcel->getActiveSheet()->getStyle('C' . $rc . ':L' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP); $rc++; $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, 5); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray5); $this->myexcel->getActiveSheet()->getStyle('C' . $rc . ':E' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('C' . $rc, 'Unit Kerja'); $this->myexcel->getActiveSheet()->setCellValue('D' . $rc, $val->penilai_nomenklatur_pada); $this->myexcel->getActiveSheet()->getStyle('D' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->mergeCells('D' . $rc . ':E' . $rc); $this->myexcel->getActiveSheet()->setCellValue('F' . $rc, 5); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('G' . $rc, 'Unit Kerja'); $this->myexcel->getActiveSheet()->setCellValue('I' . $rc, $val->nomenklatur_pada); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->mergeCells('I' . $rc . ':L' . $rc); $this->myexcel->getActiveSheet()->getStyle('G' . $rc . ':K' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray7b); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, " "); $this->myexcel->getActiveSheet()->getStyle('C' . $rc . ':L' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP); $rc++; $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, 'No.'); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray2); $this->myexcel->getActiveSheet()->setCellValue('C' . $rc, 'III. KEGIATAN TUGAS JABATAN'); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray3); $this->myexcel->getActiveSheet()->getStyle('C' . $rc . ':E' . $rc)->applyFromArray($styleArray3); $this->myexcel->getActiveSheet()->setCellValue('F' . $rc, 'TARGET'); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray3a); $this->myexcel->getActiveSheet()->setCellValue('G' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('G' . $rc)->applyFromArray($styleArray3a); $this->myexcel->getActiveSheet()->setCellValue('H' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->applyFromArray($styleArray3a); $this->myexcel->getActiveSheet()->setCellValue('I' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray3a); $this->myexcel->getActiveSheet()->setCellValue('J' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('J' . $rc)->applyFromArray($styleArray3a); $this->myexcel->getActiveSheet()->setCellValue('K' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('K' . $rc)->applyFromArray($styleArray3a); $this->myexcel->getActiveSheet()->setCellValue('L' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray4b); $this->myexcel->getActiveSheet()->mergeCells('F' . $rc . ':L' . $rc); $rc++; $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray2); $this->myexcel->getActiveSheet()->mergeCells('B' . ($rc - 1) . ':B' . $rc); $this->myexcel->getActiveSheet()->setCellValue('C' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray3); $this->myexcel->getActiveSheet()->getStyle('C' . $rc . ':E' . $rc)->applyFromArray($styleArray3); $this->myexcel->getActiveSheet()->mergeCells('C' . ($rc - 1) . ':E' . $rc); $this->myexcel->getActiveSheet()->setCellValue('F' . $rc, 'AK'); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray3b); $this->myexcel->getActiveSheet()->setCellValue('G' . $rc, 'KUANTITAS'); $this->myexcel->getActiveSheet()->getStyle('G' . $rc)->applyFromArray($styleArray3b); $this->myexcel->getActiveSheet()->setCellValue('H' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->applyFromArray($styleArray3b); $this->myexcel->getActiveSheet()->mergeCells('G' . $rc . ':H' . $rc); $this->myexcel->getActiveSheet()->setCellValue('I' . $rc, 'KUAL.'); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray3b); $this->myexcel->getActiveSheet()->setCellValue('J' . $rc, 'WAKTU'); $this->myexcel->getActiveSheet()->getStyle('J' . $rc)->applyFromArray($styleArray3b); $this->myexcel->getActiveSheet()->setCellValue('K' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('K' . $rc)->applyFromArray($styleArray3b); $this->myexcel->getActiveSheet()->mergeCells('J' . $rc . ':K' . $rc); $this->myexcel->getActiveSheet()->setCellValue('L' . $rc, 'BIAYA'); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray4c); $target = $this->m_penilaian->get_skp_tahun_target($val->id_skp); $i = 1; foreach ($target as $ky => $vl) { $rc++; $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, $i); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray5); $this->myexcel->getActiveSheet()->setCellValue('C' . $rc, $vl->pekerjaan); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('D' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('D' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('E' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->mergeCells('C' . $rc . ':E' . $rc); $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP); $this->myexcel->getActiveSheet()->setCellValue('F' . $rc, $vl->ak); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('G' . $rc, $vl->volume); $this->myexcel->getActiveSheet()->getStyle('G' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('H' . $rc, $vl->satuan); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->applyFromArray($styleArray6a); $this->myexcel->getActiveSheet()->setCellValue('I' . $rc, $vl->kualitas); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('J' . $rc, $vl->waktu_lama); $this->myexcel->getActiveSheet()->getStyle('J' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('K' . $rc, $vl->waktu_satuan); $this->myexcel->getActiveSheet()->getStyle('K' . $rc)->applyFromArray($styleArray6a); $this->myexcel->getActiveSheet()->setCellValue('L' . $rc, $vl->biaya); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->getNumberFormat()->setFormatCode('_-* #,##0.00'); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray7); $i++; } $rc++; $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8); $this->myexcel->getActiveSheet()->getStyle('C' . $rc . ':K' . $rc)->applyFromArray($styleArray9); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray10); $rc++; $rc++; $this->myexcel->getActiveSheet()->setCellValue('H' . $rc, 'Tangerang, Januari ' . $val->tahun); $rc++; $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, 'Pejabat Penilai'); $this->myexcel->getActiveSheet()->mergeCells('B' . $rc . ':D' . $rc); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $this->myexcel->getActiveSheet()->setCellValue('H' . $rc, 'Pegawai Negeri Sipil Yang Dinilai'); $this->myexcel->getActiveSheet()->mergeCells('H' . $rc . ':L' . $rc); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $rc++; $rc++; $rc++; $rc++; $rc++; $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, $nama_penilai); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->getFont()->setUnderline(true); $this->myexcel->getActiveSheet()->mergeCells('B' . $rc . ':D' . $rc); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $this->myexcel->getActiveSheet()->setCellValue('H' . $rc, $nama_pegawai); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->getFont()->setUnderline(true); $this->myexcel->getActiveSheet()->mergeCells('H' . $rc . ':L' . $rc); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $rc++; $nip_penilai = $val->penilai_nip_baru; $nip_baru = $val->nip_baru; $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, "NIP. " . $nip_penilai); $this->myexcel->getActiveSheet()->mergeCells('B' . $rc . ':D' . $rc); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $this->myexcel->getActiveSheet()->setCellValue('H' . $rc, "NIP. " . $nip_baru); $this->myexcel->getActiveSheet()->mergeCells('H' . $rc . ':L' . $rc); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $rc = $rc + 3; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// $this->myexcel->createSheet(NULL, 1); $this->myexcel->setActiveSheetIndex(1); $this->myexcel->getActiveSheet()->setTitle('PENGUKURAN'); $this->myexcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_LEGAL); $this->myexcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE); $this->myexcel->getActiveSheet()->getPageMargins()->setLeft(0.2); $this->myexcel->getActiveSheet()->getPageMargins()->setRight(0.2); $this->myexcel->getActiveSheet()->getColumnDimension("A")->setWidth(3); $this->myexcel->getActiveSheet()->getColumnDimension("B")->setWidth(6); $this->myexcel->getActiveSheet()->getColumnDimension("C")->setWidth(40); $this->myexcel->getActiveSheet()->getColumnDimension("D")->setWidth(10); $this->myexcel->getActiveSheet()->getColumnDimension("E")->setAutoSize(true); $this->myexcel->getActiveSheet()->getColumnDimension("F")->setAutoSize(true); $this->myexcel->getActiveSheet()->getColumnDimension("H")->setAutoSize(true); $this->myexcel->getActiveSheet()->getColumnDimension("I")->setAutoSize(true); $this->myexcel->getActiveSheet()->getColumnDimension("L")->setAutoSize(true); $this->myexcel->getActiveSheet()->getColumnDimension("M")->setAutoSize(true); $this->myexcel->getActiveSheet()->getColumnDimension("O")->setAutoSize(true); $this->myexcel->getActiveSheet()->getColumnDimension("P")->setAutoSize(true); $rc = 2; foreach ($data['skp_tahun'] as $key => $val) { $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, 'Penilaian Capaian Sasaran Kerja'); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->getFont()->setSize(20); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->getFont()->setBold(true); $this->myexcel->getActiveSheet()->mergeCells('B' . $rc . ':S' . $rc); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $rc++; $rc++; $bulan_mulai = $bulan[$val->bulan_mulai]; $bulan_selesai = $bulan[$val->bulan_selesai]; $periode = "PERIODE : " . $bulan_mulai . " s.d. " . $bulan_selesai; $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, $periode); $rc++; $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, 'No.'); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray2); $this->myexcel->getActiveSheet()->setCellValue('C' . $rc, 'I. KEGIATAN TUGAS JABATAN'); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray3); $this->myexcel->getActiveSheet()->setCellValue('D' . $rc, 'TARGET'); $this->myexcel->getActiveSheet()->getStyle('D' . $rc)->applyFromArray($styleArray3a); $this->myexcel->getActiveSheet()->setCellValue('E' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->applyFromArray($styleArray3a); $this->myexcel->getActiveSheet()->setCellValue('F' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray3a); $this->myexcel->getActiveSheet()->setCellValue('G' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('G' . $rc)->applyFromArray($styleArray3a); $this->myexcel->getActiveSheet()->setCellValue('H' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->applyFromArray($styleArray3a); $this->myexcel->getActiveSheet()->setCellValue('I' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray3a); $this->myexcel->getActiveSheet()->setCellValue('J' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('J' . $rc)->applyFromArray($styleArray3a); $this->myexcel->getActiveSheet()->mergeCells('D' . $rc . ':J' . $rc); $this->myexcel->getActiveSheet()->setCellValue('K' . $rc, 'REALISASI'); $this->myexcel->getActiveSheet()->getStyle('K' . $rc)->applyFromArray($styleArray3a); $this->myexcel->getActiveSheet()->setCellValue('L' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray3a); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('M' . $rc)->applyFromArray($styleArray3a); $this->myexcel->getActiveSheet()->setCellValue('N' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('N' . $rc)->applyFromArray($styleArray3a); $this->myexcel->getActiveSheet()->setCellValue('O' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('O' . $rc)->applyFromArray($styleArray3a); $this->myexcel->getActiveSheet()->setCellValue('P' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('P' . $rc)->applyFromArray($styleArray3a); $this->myexcel->getActiveSheet()->setCellValue('Q' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc)->applyFromArray($styleArray3a); $this->myexcel->getActiveSheet()->mergeCells('K' . $rc . ':Q' . $rc); $this->myexcel->getActiveSheet()->setCellValue('R' . $rc, 'PERHITUNGAN'); $this->myexcel->getActiveSheet()->getStyle('R' . $rc)->applyFromArray($styleArray3); $this->myexcel->getActiveSheet()->getStyle('R' . $rc)->getFont()->setSize(8); $this->myexcel->getActiveSheet()->setCellValue('S' . $rc, 'CAPAIAN'); $this->myexcel->getActiveSheet()->getStyle('S' . $rc)->applyFromArray($styleArray4); $rc++; $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray2); $this->myexcel->getActiveSheet()->mergeCells('B' . ($rc - 1) . ':B' . $rc); $this->myexcel->getActiveSheet()->setCellValue('C' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray3); $this->myexcel->getActiveSheet()->mergeCells('C' . ($rc - 1) . ':C' . $rc); $this->myexcel->getActiveSheet()->setCellValue('D' . $rc, 'AK'); $this->myexcel->getActiveSheet()->getStyle('D' . $rc)->applyFromArray($styleArray3b); $this->myexcel->getActiveSheet()->setCellValue('E' . $rc, 'KUANTITAS'); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->applyFromArray($styleArray3b); $this->myexcel->getActiveSheet()->setCellValue('F' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray3b); $this->myexcel->getActiveSheet()->mergeCells('E' . $rc . ':F' . $rc); $this->myexcel->getActiveSheet()->setCellValue('G' . $rc, 'KUAL.'); $this->myexcel->getActiveSheet()->getStyle('G' . $rc)->applyFromArray($styleArray3b); $this->myexcel->getActiveSheet()->setCellValue('H' . $rc, 'WAKTU'); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->applyFromArray($styleArray3b); $this->myexcel->getActiveSheet()->setCellValue('I' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray3b); $this->myexcel->getActiveSheet()->mergeCells('H' . $rc . ':I' . $rc); $this->myexcel->getActiveSheet()->setCellValue('J' . $rc, 'BIAYA'); $this->myexcel->getActiveSheet()->getStyle('J' . $rc)->applyFromArray($styleArray3b); $this->myexcel->getActiveSheet()->setCellValue('K' . $rc, 'AK'); $this->myexcel->getActiveSheet()->getStyle('K' . $rc)->applyFromArray($styleArray3b); $this->myexcel->getActiveSheet()->setCellValue('L' . $rc, 'KUANTITAS'); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray3b); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('M' . $rc)->applyFromArray($styleArray3b); $this->myexcel->getActiveSheet()->mergeCells('L' . $rc . ':M' . $rc); $this->myexcel->getActiveSheet()->setCellValue('N' . $rc, 'KUAL.'); $this->myexcel->getActiveSheet()->getStyle('N' . $rc)->applyFromArray($styleArray3b); $this->myexcel->getActiveSheet()->setCellValue('O' . $rc, 'WAKTU'); $this->myexcel->getActiveSheet()->getStyle('O' . $rc)->applyFromArray($styleArray3b); $this->myexcel->getActiveSheet()->setCellValue('P' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('P' . $rc)->applyFromArray($styleArray3b); $this->myexcel->getActiveSheet()->mergeCells('O' . $rc . ':P' . $rc); $this->myexcel->getActiveSheet()->setCellValue('Q' . $rc, 'BIAYA'); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc)->applyFromArray($styleArray3b); $this->myexcel->getActiveSheet()->setCellValue('R' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('R' . $rc)->applyFromArray($styleArray3); $this->myexcel->getActiveSheet()->mergeCells('R' . ($rc - 1) . ':R' . $rc); $this->myexcel->getActiveSheet()->setCellValue('S' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('S' . $rc)->applyFromArray($styleArray4); $this->myexcel->getActiveSheet()->mergeCells('S' . ($rc - 1) . ':S' . $rc); $rc++; $i = 1; $target = $this->m_penilaian->get_skp_tahun_target($val->id_skp); $data['skp_tahun'][$key]->target = $this->m_penilaian->get_skp_tahun_target($val->id_skp); $mulai = $rc; foreach ($target as $ky => $vl) { $realisasi = $this->m_penilaian->get_skp_tahun_realisasi($vl->id_target); if (!empty($realisasi)) { if ($vl->volume != 0) { $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, $i); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray5); $this->myexcel->getActiveSheet()->setCellValue('C' . $rc, $vl->pekerjaan); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->setCellValue('D' . $rc, $vl->ak); $this->myexcel->getActiveSheet()->getStyle('D' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('E' . $rc, $vl->volume); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('F' . $rc, $vl->satuan); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray6a); $this->myexcel->getActiveSheet()->setCellValue('G' . $rc, $vl->kualitas); $this->myexcel->getActiveSheet()->getStyle('G' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('H' . $rc, $vl->waktu_lama); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('I' . $rc, $vl->waktu_satuan); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray6a); $this->myexcel->getActiveSheet()->setCellValue('J' . $rc, $vl->biaya); $this->myexcel->getActiveSheet()->getStyle('J' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->getStyle('J' . $rc)->getNumberFormat()->setFormatCode('_-* #,##0.00'); $this->myexcel->getActiveSheet()->setCellValue('K' . $rc, $realisasi->ak); $this->myexcel->getActiveSheet()->getStyle('K' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('L' . $rc, $realisasi->volume); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, $vl->satuan); $this->myexcel->getActiveSheet()->getStyle('M' . $rc)->applyFromArray($styleArray6a); $this->myexcel->getActiveSheet()->setCellValue('N' . $rc, $realisasi->kualitas); $this->myexcel->getActiveSheet()->getStyle('N' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('O' . $rc, $realisasi->waktu_lama); $this->myexcel->getActiveSheet()->getStyle('O' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('P' . $rc, $vl->waktu_satuan); $this->myexcel->getActiveSheet()->getStyle('P' . $rc)->applyFromArray($styleArray6a); $this->myexcel->getActiveSheet()->setCellValue('Q' . $rc, $realisasi->biaya); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc)->getNumberFormat()->setFormatCode('_-* #,##0.00'); $this->myexcel->getActiveSheet()->setCellValue('R' . $rc, '=AG' . $rc); $this->myexcel->getActiveSheet()->getStyle('R' . $rc)->applyFromArray($styleArray6); if ($vl->biaya != 0 && $realisasi->biaya != 0) { $this->myexcel->getActiveSheet()->setCellValue('S' . $rc, '=IF(J' . $rc . '="-",IF(Q' . $rc . '="-",R' . $rc . '/4,R' . $rc . '/4),R' . $rc . '/4)'); } else { $this->myexcel->getActiveSheet()->setCellValue('S' . $rc, '=IF(J' . $rc . '="-",IF(Q' . $rc . '="-",R' . $rc . '/3,R' . $rc . '/3),R' . $rc . '/3)'); } $this->myexcel->getActiveSheet()->getStyle('S' . $rc)->applyFromArray($styleArray7); $this->myexcel->getActiveSheet()->setCellValue('U' . $rc, '=IF(E' . $rc . '>0,1,0)'); $this->myexcel->getActiveSheet()->setCellValue('V' . $rc, '=S' . $rc); $this->myexcel->getActiveSheet()->setCellValue('W' . $rc, '=100-(O' . $rc . '/H' . $rc . '*100)'); $this->myexcel->getActiveSheet()->setCellValue('X' . $rc, '=100-(Q' . $rc . '/J' . $rc . '*100)'); $this->myexcel->getActiveSheet()->setCellValue('Y' . $rc, '=L' . $rc . '/E' . $rc . '*100'); $this->myexcel->getActiveSheet()->setCellValue('Z' . $rc, '=N' . $rc . '/G' . $rc . '*100'); $this->myexcel->getActiveSheet()->setCellValue('AA' . $rc, '=IF(W' . $rc . '>24,AD' . $rc . ',AC' . $rc . ')'); $this->myexcel->getActiveSheet()->setCellValue('AB' . $rc, '=IF(X' . $rc . '>24,AF' . $rc . ',AE' . $rc . ')'); $this->myexcel->getActiveSheet()->setCellValue('AC' . $rc, '=((1.76*H' . $rc . '-O' . $rc . ')/H' . $rc . ')*100'); $this->myexcel->getActiveSheet()->setCellValue('AD' . $rc, '=76-((((1.76*H' . $rc . '-O' . $rc . ')/H' . $rc . ')*100)-100)'); $this->myexcel->getActiveSheet()->setCellValue('AE' . $rc, '=((1.76*J' . $rc . '-Q' . $rc . ')/J' . $rc . ')*100'); $this->myexcel->getActiveSheet()->setCellValue('AF' . $rc, '=76-((((1.76*J' . $rc . '-Q' . $rc . ')/J' . $rc . ')*100)-100)'); if ($vl->biaya != 0 && $realisasi->biaya != 0) { $this->myexcel->getActiveSheet()->setCellValue('AG' . $rc, '=SUM(Y' . $rc . ':AB' . $rc . ')'); } else { $this->myexcel->getActiveSheet()->setCellValue('AG' . $rc, '=SUM(Y' . $rc . ':AA' . $rc . ')'); } $i++; $rc++; } //end if=>volume } //end if=>realisasi } //end foreach=>target $akhir = $rc; $this->myexcel->getActiveSheet()->setCellValue('U' . $rc, '=SUM(U' . $mulai . ':U' . ($rc - 1) . ')'); $this->myexcel->getActiveSheet()->setCellValue('V' . $rc, '=SUM(V' . $mulai . ':V' . ($rc - 1) . ')'); $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, ""); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray2); $this->myexcel->getActiveSheet()->setCellValue('C' . $rc, "II. TUGAS TAMBAHAN"); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray3c); $this->myexcel->getActiveSheet()->setCellValue('D' . $rc, "PEJABAT PEMBERI PERINTAH"); $this->myexcel->getActiveSheet()->getStyle('D' . $rc . ':R' . $rc)->applyFromArray($styleArray3c); $this->myexcel->getActiveSheet()->mergeCells('D' . $rc . ':J' . $rc); $this->myexcel->getActiveSheet()->setCellValue('K' . $rc, "No. / TANGGAL SURAT PERINTAH"); $this->myexcel->getActiveSheet()->getStyle('K' . $rc . ':Q' . $rc)->applyFromArray($styleArray3c); $this->myexcel->getActiveSheet()->mergeCells('K' . $rc . ':Q' . $rc); $this->myexcel->getActiveSheet()->getStyle('R' . $rc)->applyFromArray($styleArray3c); $this->myexcel->getActiveSheet()->setCellValue('S' . $rc, ""); $this->myexcel->getActiveSheet()->getStyle('S' . $rc)->applyFromArray($styleArray4); $rc++; $awal_tt = $rc; $tt = $this->m_skp->get_tugas_tambahan($val->id_skp); $nott = 0; foreach ($tt as $ktt => $vtt) { $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, $nott + 1); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray5); $this->myexcel->getActiveSheet()->setCellValue('C' . $rc, $vtt->pekerjaan); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->getStyle('D' . $rc . ':J' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->mergeCells('D' . $rc . ':J' . $rc); $this->myexcel->getActiveSheet()->getStyle('K' . $rc . ':Q' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->mergeCells('K' . $rc . ':Q' . $rc); $this->myexcel->getActiveSheet()->getStyle('R' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->getStyle('S' . $rc)->applyFromArray($styleArray7); $rc++; $nott++; } if ($nott == 0) { $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray5); $this->myexcel->getActiveSheet()->setCellValue('C' . $rc, ' - '); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->getStyle('D' . $rc . ':J' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->mergeCells('D' . $rc . ':J' . $rc); $this->myexcel->getActiveSheet()->getStyle('K' . $rc . ':Q' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->mergeCells('K' . $rc . ':Q' . $rc); $this->myexcel->getActiveSheet()->getStyle('R' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->getStyle('S' . $rc)->applyFromArray($styleArray7); $rc++; } if ($nott > 0) { if ($nott < 3) { $nilai_tt = 1; } elseif ($nott >= 3 && $nott <= 6) { $nilai_tt = 2; } elseif ($nott > 6) { $nilai_tt = 3; } $this->myexcel->getActiveSheet()->setCellValue('S' . $awal_tt, $nilai_tt); $this->myexcel->getActiveSheet()->mergeCells('S' . $awal_tt . ':S' . ($rc - 1)); $this->myexcel->getActiveSheet()->getStyle('S' . $awal_tt)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP); } $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, ""); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray2); $this->myexcel->getActiveSheet()->setCellValue('C' . $rc, "III. KREATIFITAS"); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray3c); $this->myexcel->getActiveSheet()->setCellValue('D' . $rc, "PENANDATANGAN SURAT KEPUTUSAN"); $this->myexcel->getActiveSheet()->getStyle('D' . $rc . ':R' . $rc)->applyFromArray($styleArray3c); $this->myexcel->getActiveSheet()->mergeCells('D' . $rc . ':J' . $rc); $this->myexcel->getActiveSheet()->setCellValue('K' . $rc, "No. / TANGGAL SURAT KEPUTUSAN"); $this->myexcel->getActiveSheet()->getStyle('K' . $rc . ':Q' . $rc)->applyFromArray($styleArray3c); $this->myexcel->getActiveSheet()->mergeCells('K' . $rc . ':Q' . $rc); $this->myexcel->getActiveSheet()->getStyle('R' . $rc)->applyFromArray($styleArray3c); $this->myexcel->getActiveSheet()->setCellValue('S' . $rc, ""); $this->myexcel->getActiveSheet()->getStyle('S' . $rc)->applyFromArray($styleArray4); $rc++; $awal_kr = $rc; $kr = $this->m_skp->get_kreatifitas($val->id_skp); $nokr = 0; foreach ($kr as $kkr => $vkr) { $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, $nokr + 1); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray5); $this->myexcel->getActiveSheet()->setCellValue('C' . $rc, $vkr->kreatifitas); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->getStyle('D' . $rc . ':J' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->mergeCells('D' . $rc . ':J' . $rc); $this->myexcel->getActiveSheet()->getStyle('K' . $rc . ':Q' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->mergeCells('K' . $rc . ':Q' . $rc); $this->myexcel->getActiveSheet()->getStyle('R' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->getStyle('S' . $rc)->applyFromArray($styleArray7); $rc++; $nokr++; } if ($nokr == 0) { $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray5); $this->myexcel->getActiveSheet()->setCellValue('C' . $rc, ' - '); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->getStyle('D' . $rc . ':J' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->mergeCells('D' . $rc . ':J' . $rc); $this->myexcel->getActiveSheet()->getStyle('K' . $rc . ':Q' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->mergeCells('K' . $rc . ':Q' . $rc); $this->myexcel->getActiveSheet()->getStyle('R' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->getStyle('S' . $rc)->applyFromArray($styleArray7); $rc++; } if ($nokr > 0) { if ($nokr < 3) { $nilai_kr = 1; } elseif ($nokr >= 3 && $nokr <= 6) { $nilai_kr = 2; } elseif ($nokr > 6) { $nilai_kr = 3; } $this->myexcel->getActiveSheet()->setCellValue('S' . $awal_kr, $nilai_kr); $this->myexcel->getActiveSheet()->mergeCells('S' . $awal_kr . ':S' . ($rc - 1)); $this->myexcel->getActiveSheet()->getStyle('S' . $awal_kr)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP); } $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, 'NILAI CAPAIAN SKP'); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8); $this->myexcel->getActiveSheet()->getStyle('B' . $rc . ':R' . $rc)->applyFromArray($styleArray9); $this->myexcel->getActiveSheet()->setCellValue('S' . $rc, '=(V' . $akhir . '/' . 'U' . $akhir . ')+S' . $awal_tt . '+S' . $awal_kr); $this->myexcel->getActiveSheet()->getStyle('S' . $rc)->applyFromArray($styleArray7a); $this->myexcel->getActiveSheet()->setCellValue('AH' . $rc, '1'); $this->myexcel->getActiveSheet()->setCellValue('AI' . $rc, '=S' . $rc); $rc++; $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8); $this->myexcel->getActiveSheet()->getStyle('B' . $rc . ':R' . $rc)->applyFromArray($styleArray9); $this->myexcel->getActiveSheet()->mergeCells('B' . ($rc - 1) . ':R' . $rc); $this->myexcel->getActiveSheet()->setCellValue('S' . $rc, '=IF(S' . ($rc - 1) . '<=50,"Buruk",IF(S' . ($rc - 1) . '<=60,"Sedang",IF(S' . ($rc - 1) . '<=75,"Cukup",IF(S' . ($rc - 1) . '<=90.99,"Baik","Sangat Baik"))))'); $this->myexcel->getActiveSheet()->getStyle('S' . $rc)->applyFromArray($styleArray10b); $rc++; $rc++; $this->myexcel->getActiveSheet()->setCellValue('N' . $rc, 'Tangerang, .....'); $rc++; $this->myexcel->getActiveSheet()->setCellValue('N' . $rc, 'PEJABAT PENILAI'); $this->myexcel->getActiveSheet()->mergeCells('N' . $rc . ':S' . $rc); $this->myexcel->getActiveSheet()->getStyle('N' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $rc++; $rc++; $rc++; $rc++; $nama_penilai = (trim($val->penilai_gelar_depan) != '-' ? trim($val->penilai_gelar_depan) . ' ' : '') . $val->penilai_nama_pegawai . (trim($val->penilai_gelar_belakang) != '-' ? ', ' . trim($val->penilai_gelar_belakang) : ''); $this->myexcel->getActiveSheet()->setCellValue('N' . $rc, $nama_penilai); $this->myexcel->getActiveSheet()->getStyle('N' . $rc)->getFont()->setUnderline(true); $this->myexcel->getActiveSheet()->mergeCells('N' . $rc . ':S' . $rc); $this->myexcel->getActiveSheet()->getStyle('N' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $rc++; $this->myexcel->getActiveSheet()->setCellValue('N' . $rc, 'NIP. ' . $val->penilai_nip_baru); $this->myexcel->getActiveSheet()->mergeCells('N' . $rc . ':S' . $rc); $this->myexcel->getActiveSheet()->getStyle('N' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $rc++; $rc++; } //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// //if($item_n!=0){ //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// $rc++; $rc++; $rc++; $r_nilai = $rc; $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, 'NILAI AKHIR SKP'); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8); $this->myexcel->getActiveSheet()->getStyle('B' . $rc . ':R' . $rc)->applyFromArray($styleArray9); $this->myexcel->getActiveSheet()->setCellValue('AH' . $rc, '=SUM(AH1:AH' . ($rc - 4) . ')'); $this->myexcel->getActiveSheet()->setCellValue('AI' . $rc, '=SUM(AI1:AI' . ($rc - 4) . ')'); $this->myexcel->getActiveSheet()->setCellValue('S' . $rc, '=AI' . $rc . '/AH' . $rc); $this->myexcel->getActiveSheet()->getStyle('S' . $rc)->applyFromArray($styleArray7a); $this->myexcel->getActiveSheet()->getStyle('B' . $rc . ':S' . $rc)->applyFromArray(array('borders' => array('top' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)))); $rc++; $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8); $this->myexcel->getActiveSheet()->getStyle('B' . $rc . ':R' . $rc)->applyFromArray($styleArray9); $this->myexcel->getActiveSheet()->mergeCells('B' . ($rc - 1) . ':R' . $rc); $this->myexcel->getActiveSheet()->setCellValue('S' . $rc, '=IF(S' . ($rc - 1) . '<=50,"Buruk",IF(S' . ($rc - 1) . '<=60,"Sedang",IF(S' . ($rc - 1) . '<=75,"Cukup",IF(S' . ($rc - 1) . '<=90.99,"Baik","Sangat Baik"))))'); $this->myexcel->getActiveSheet()->getStyle('S' . $rc)->applyFromArray($styleArray10b); $rc++; /////////////////////////////////////////////////////////////////////////////////////////////////////////////// $this->myexcel->createSheet(NULL, 2); $this->myexcel->setActiveSheetIndex(2); $this->myexcel->getActiveSheet()->setTitle('PENILAIAN'); //$this->myexcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A3); $this->myexcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_LEGAL); $this->myexcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE); $this->myexcel->getActiveSheet()->getPageSetup()->setScale(75); $this->myexcel->getActiveSheet()->getPageMargins()->setTop(0.7); $this->myexcel->getActiveSheet()->getPageMargins()->setRight(0.1); $this->myexcel->getActiveSheet()->getPageMargins()->setBottom(0.4); $this->myexcel->getActiveSheet()->getPageMargins()->setLeft(0.4); $this->myexcel->getActiveSheet()->getColumnDimension("A")->setWidth(3); $this->myexcel->getActiveSheet()->getColumnDimension("B")->setWidth('3'); $this->myexcel->getActiveSheet()->getColumnDimension("C")->setWidth('20'); $this->myexcel->getActiveSheet()->getColumnDimension("D")->setWidth('14'); $this->myexcel->getActiveSheet()->getColumnDimension("E")->setWidth('14'); $this->myexcel->getActiveSheet()->getColumnDimension("J")->setWidth('4'); $this->myexcel->getActiveSheet()->getColumnDimension("K")->setWidth('4'); $this->myexcel->getActiveSheet()->getColumnDimension("L")->setWidth('3'); $this->myexcel->getActiveSheet()->getColumnDimension("V")->setWidth(3); $objDrawing = new PHPExcel_Worksheet_Drawing(); $objDrawing->setName('PHPExcel logo'); $objDrawing->setDescription('PHPExcel logo'); $objDrawing->setPath('assets/images/garuda.gif'); // filesystem reference for the image file $objDrawing->setHeight(100); // sets the image height to 36px (overriding the actual image height); $objDrawing->setCoordinates('P29'); // pins the top-left corner of the image to cell D24 $objDrawing->setOffsetX(35); // pins the top left corner of the image at an offset of 10 points horizontally to the right of the top-left corner of the cell $objDrawing->setWorksheet($this->myexcel->getActiveSheet()); $rc = 3; $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, '4.'); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8aa); $this->myexcel->getActiveSheet()->setCellValue('C' . $rc, 'UNSUR YANG DINILAI'); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('C' . $rc . ':H' . $rc)->applyFromArray($styleArray8b); $this->myexcel->getActiveSheet()->mergeCells('C' . $rc . ':H' . $rc); $this->myexcel->getActiveSheet()->setCellValue('I' . $rc, 'JUMLAH'); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8h); $this->myexcel->getActiveSheet()->setCellValue('L' . $rc, '6. TANGGAPAN PEJABAT PENILAI ATAS KEBERATAN'); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8aa); $this->myexcel->getActiveSheet()->getStyle('M' . $rc . ':T' . $rc)->applyFromArray($styleArray8g); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8h); $rc++; $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8ba); $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->setCellValue('C' . $rc, 'a. Sasaran Kerja Pegawai (SKP)'); $this->myexcel->getActiveSheet()->getStyle('C' . $rc . ':E' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->setCellValue('F' . $rc, '=PENGUKURAN!S' . $r_nilai); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->setCellValue('G' . $rc, 'x'); $this->myexcel->getActiveSheet()->getStyle('G' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->setCellValue('H' . $rc, '60%'); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->setCellValue('I' . $rc, '=F' . $rc . '*H' . $rc); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->mergeCells('C' . $rc . ':E' . $rc); $this->myexcel->getActiveSheet()->getStyle('C' . $rc . ':I' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('G' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8a); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray(array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_THIN)))); $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->setCellValue('C' . $rc, 'b. Perilaku Kerja'); $this->myexcel->getActiveSheet()->getStyle('C' . $rc . ':I' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->setCellValue('D' . $rc, '1. Orientasi Pelayanan'); $this->myexcel->getActiveSheet()->getStyle('D' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->setCellValue('F' . $rc, '=SKP!O' . ($r_perilaku + 1)); $this->myexcel->getActiveSheet()->setCellValue('G' . $rc, ''); $this->myexcel->getActiveSheet()->setCellValue('H' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray8c); $sebut = '=IF(F' . $rc . '<=50,"Buruk",IF(F' . $rc . '<=60,"Sedang",IF(F' . $rc . '<=75,"Cukup",IF(F' . $rc . '<=90.99,"Baik","Sangat Baik"))))'; $this->myexcel->getActiveSheet()->setCellValue('G' . $rc, $sebut); $this->myexcel->getActiveSheet()->getStyle('G' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->mergeCells('D' . $rc . ':E' . $rc); $this->myexcel->getActiveSheet()->mergeCells('G' . $rc . ':H' . $rc); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8a); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->setCellValue('D' . $rc, '2. Integritas'); $this->myexcel->getActiveSheet()->getStyle('D' . $rc . ':I' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('D' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->setCellValue('F' . $rc, '=SKP!P' . ($r_perilaku + 1)); $this->myexcel->getActiveSheet()->setCellValue('G' . $rc, ''); $this->myexcel->getActiveSheet()->setCellValue('H' . $rc, ''); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray8c); $sebut = '=IF(F' . $rc . '<=50,"Buruk",IF(F' . $rc . '<=60,"Sedang",IF(F' . $rc . '<=75,"Cukup",IF(F' . $rc . '<=90.99,"Baik","Sangat Baik"))))'; $this->myexcel->getActiveSheet()->setCellValue('G' . $rc, $sebut); $this->myexcel->getActiveSheet()->getStyle('G' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->mergeCells('D' . $rc . ':E' . $rc); $this->myexcel->getActiveSheet()->mergeCells('G' . $rc . ':H' . $rc); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8a); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->setCellValue('D' . $rc, '3. Komitmen'); $this->myexcel->getActiveSheet()->getStyle('D' . $rc . ':I' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('D' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->setCellValue('F' . $rc, '=SKP!Q' . ($r_perilaku + 1)); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray8c); $sebut = '=IF(F' . $rc . '<=50,"Buruk",IF(F' . $rc . '<=60,"Sedang",IF(F' . $rc . '<=75,"Cukup",IF(F' . $rc . '<=90.99,"Baik","Sangat Baik"))))'; $this->myexcel->getActiveSheet()->setCellValue('G' . $rc, $sebut); $this->myexcel->getActiveSheet()->getStyle('G' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->mergeCells('D' . $rc . ':E' . $rc); $this->myexcel->getActiveSheet()->mergeCells('G' . $rc . ':H' . $rc); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8a); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->setCellValue('D' . $rc, '4. Disiplin'); $this->myexcel->getActiveSheet()->getStyle('D' . $rc . ':I' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('D' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->setCellValue('F' . $rc, '=SKP!R' . ($r_perilaku + 1)); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray8c); $sebut = '=IF(F' . $rc . '<=50,"Buruk",IF(F' . $rc . '<=60,"Sedang",IF(F' . $rc . '<=75,"Cukup",IF(F' . $rc . '<=90.99,"Baik","Sangat Baik"))))'; $this->myexcel->getActiveSheet()->setCellValue('G' . $rc, $sebut); $this->myexcel->getActiveSheet()->getStyle('G' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->mergeCells('D' . $rc . ':E' . $rc); $this->myexcel->getActiveSheet()->mergeCells('G' . $rc . ':H' . $rc); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8a); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->setCellValue('D' . $rc, '5. Kerjasama'); $this->myexcel->getActiveSheet()->getStyle('D' . $rc . ':I' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('D' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->setCellValue('F' . $rc, '=SKP!S' . ($r_perilaku + 1)); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray8c); $sebut = '=IF(F' . $rc . '<=50,"Buruk",IF(F' . $rc . '<=60,"Sedang",IF(F' . $rc . '<=75,"Cukup",IF(F' . $rc . '<=90.99,"Baik","Sangat Baik"))))'; $this->myexcel->getActiveSheet()->setCellValue('G' . $rc, $sebut); $this->myexcel->getActiveSheet()->getStyle('G' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->mergeCells('D' . $rc . ':E' . $rc); $this->myexcel->getActiveSheet()->mergeCells('G' . $rc . ':H' . $rc); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8a); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->setCellValue('D' . $rc, '6. Kepemimpinan'); $this->myexcel->getActiveSheet()->getStyle('D' . $rc . ':I' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('D' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->applyFromArray($styleArray8c); $isi_kepemimpinan = $kepemimpinan == 0 ? ' - ' : '=SKP!T' . ($r_perilaku + 1); $this->myexcel->getActiveSheet()->setCellValue('F' . $rc, $isi_kepemimpinan); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray8c); $sebut = $kepemimpinan == 0 ? ' - ' : '=IF(F' . $rc . '<=50,"Buruk",IF(F' . $rc . '<=60,"Sedang",IF(F' . $rc . '<=75,"Cukup",IF(F' . $rc . '<=90.99,"Baik","Sangat Baik"))))'; $this->myexcel->getActiveSheet()->setCellValue('G' . $rc, $sebut); $this->myexcel->getActiveSheet()->getStyle('G' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->mergeCells('D' . $rc . ':E' . $rc); $this->myexcel->getActiveSheet()->mergeCells('G' . $rc . ':H' . $rc); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8a); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->setCellValue('D' . $rc, '7. Jumlah'); $this->myexcel->getActiveSheet()->getStyle('D' . $rc . ':I' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('D' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->applyFromArray($styleArray8c); $isi_kepemimpinan = $kepemimpinan == 0 ? '=SUM(F5:F9)' : '=SUM(F5:F10)'; $this->myexcel->getActiveSheet()->setCellValue('F' . $rc, $isi_kepemimpinan); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('G' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->mergeCells('D' . $rc . ':E' . $rc); $this->myexcel->getActiveSheet()->mergeCells('G' . $rc . ':H' . $rc); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8a); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->setCellValue('D' . $rc, '8. Nilai Rata-rata'); $this->myexcel->getActiveSheet()->getStyle('D' . $rc . ':I' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('D' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->applyFromArray($styleArray8c); $isi_kepemimpinan = $kepemimpinan == 0 ? '=F11/5' : '=F11/6'; $this->myexcel->getActiveSheet()->setCellValue('F' . $rc, $isi_kepemimpinan); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('G' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->mergeCells('D' . $rc . ':E' . $rc); $this->myexcel->getActiveSheet()->mergeCells('G' . $rc . ':H' . $rc); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8a); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->setCellValue('D' . $rc, '9. Nilai Perilaku Kerja'); $this->myexcel->getActiveSheet()->getStyle('D' . $rc . ':I' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('D' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->setCellValue('F' . $rc, '=F' . ($rc - 1)); $this->myexcel->getActiveSheet()->setCellValue('G' . $rc, 'x'); $this->myexcel->getActiveSheet()->getStyle('G' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $this->myexcel->getActiveSheet()->setCellValue('H' . $rc, '40%'); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('G' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->setCellValue('I' . $rc, '=F' . $rc . '*H' . $rc); $this->myexcel->getActiveSheet()->mergeCells('D' . $rc . ':E' . $rc); $this->myexcel->getActiveSheet()->mergeCells('B4:B' . $rc); $this->myexcel->getActiveSheet()->mergeCells('C6:C' . $rc); $this->myexcel->getActiveSheet()->setCellValue('L' . $rc, '7. KEPUTUSAN ATASAN PEJABAT PENILAI ATAS KEBERATAN'); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8aa); $this->myexcel->getActiveSheet()->getStyle('M' . $rc . ':T' . $rc)->applyFromArray($styleArray8g); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8h); $rc++; $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, 'NILAI PRESTASI KERJA'); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8a); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray8a); $this->myexcel->getActiveSheet()->getStyle('D' . $rc)->applyFromArray($styleArray8a); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->applyFromArray($styleArray8a); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray8a); $this->myexcel->getActiveSheet()->getStyle('G' . $rc)->applyFromArray($styleArray8a); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->applyFromArray($styleArray8a); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8h); $this->myexcel->getActiveSheet()->setCellValue('I' . $rc, '=I4+I13'); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray9); $this->myexcel->getActiveSheet()->getStyle('D' . $rc)->applyFromArray($styleArray9); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->applyFromArray($styleArray9); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray9); $this->myexcel->getActiveSheet()->getStyle('G' . $rc)->applyFromArray($styleArray9); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->applyFromArray($styleArray9); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->setCellValue('I' . $rc, '=IF(I14<=50,"Buruk",IF(I14<=60,"Sedang",IF(I14<=75,"Cukup",IF(I14<=90.99,"Baik","Sangat Baik"))))'); $this->myexcel->getActiveSheet()->mergeCells('B' . ($rc - 1) . ':H' . $rc); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, '5. KEBERATAN DARI PEGAWAI NEGERI SIPIL YANG DINILAI (APABILA ADA)'); $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->mergeCells('B' . $rc . ':I' . $rc); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8aa); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8h); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->mergeCells('B' . $rc . ':I' . $rc); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->mergeCells('B' . $rc . ':I' . $rc); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->mergeCells('B' . $rc . ':I' . $rc); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->mergeCells('B' . $rc . ':I' . $rc); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->mergeCells('B' . $rc . ':I' . $rc); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->mergeCells('B' . $rc . ':I' . $rc); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->mergeCells('B' . $rc . ':I' . $rc); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->mergeCells('B' . $rc . ':I' . $rc); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8i); $rc++; //$this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->mergeCells('B' . $rc . ':I' . $rc); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->mergeCells('B' . $rc . ':I' . $rc); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8f); $this->myexcel->getActiveSheet()->getStyle('C' . $rc)->applyFromArray($styleArray8e); $this->myexcel->getActiveSheet()->getStyle('D' . $rc)->applyFromArray($styleArray8e); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->applyFromArray($styleArray8e); $this->myexcel->getActiveSheet()->getStyle('F' . $rc)->applyFromArray($styleArray8e); $this->myexcel->getActiveSheet()->getStyle('G' . $rc)->applyFromArray($styleArray8e); $this->myexcel->getActiveSheet()->getStyle('H' . $rc)->applyFromArray($styleArray8e); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8j); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8f); $this->myexcel->getActiveSheet()->getStyle('M' . $rc . ':T' . $rc)->applyFromArray($styleArray8e); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8j); $rc++; $rc++; $rc++; $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8aa); $this->myexcel->getActiveSheet()->getStyle('B' . $rc . ':H' . $rc)->applyFromArray($styleArray8g); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8h); $rc++; $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, '8. REKOMENDASI'); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->setCellValue('L' . $rc, 'PENILAIAN PRESTASI KERJA'); $this->myexcel->getActiveSheet()->mergeCells('L' . $rc . ':U' . $rc); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->getFont()->setSize(16); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->getFont()->setBold(true); $rc++; $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->setCellValue('L' . $rc, 'PEGAWAI NEGERI SIPIL'); $this->myexcel->getActiveSheet()->mergeCells('L' . $rc . ':U' . $rc); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->getFont()->setSize(16); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->getFont()->setBold(true); $rc++; $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $rc++; $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->setCellValue('L' . $rc, 'BKPP'); $this->myexcel->getActiveSheet()->setCellValue('R' . $rc, 'JANGKA WAKTU PENILAIAN'); $rc++; $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->setCellValue('L' . $rc, 'KOTA TANGERANG'); $this->myexcel->getActiveSheet()->setCellValue('R' . $rc, 'BULAN'); $rc++; $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->setCellValue('L' . $rc, '1'); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8aa); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, 'YANG DINILAI'); $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->getStyle('L' . $rc . ':M' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->mergeCells('M' . $rc . ':U' . $rc); $this->myexcel->getActiveSheet()->getStyle('M' . $rc . ':U' . $rc)->applyFromArray($styleArray8b); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8h); $rc++; $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, 'a. Nama'); $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->mergeCells('M' . $rc . ':P' . $rc); $this->myexcel->getActiveSheet()->getStyle('M' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('M' . $rc . ':T' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('Q' . $rc, '=SKP!I' . $r_nama); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->applyFromArray($styleArray7); $this->myexcel->getActiveSheet()->mergeCells('Q' . $rc . ':U' . $rc); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $rc++; $this->myexcel->getActiveSheet()->setCellValue('E' . $rc, '9. Dibuat tanggal: ... Januari ....'); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8aa); $this->myexcel->getActiveSheet()->getStyle('C' . $rc . ':H' . $rc)->applyFromArray($styleArray8g); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8h); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, 'b. NIP'); $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->mergeCells('M' . $rc . ':P' . $rc); $this->myexcel->getActiveSheet()->getStyle('M' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('M' . $rc . ':T' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('Q' . $rc, '=SKP!I' . ($r_nama + 1)); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->applyFromArray($styleArray7); $this->myexcel->getActiveSheet()->mergeCells('Q' . $rc . ':U' . $rc); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $rc++; $this->myexcel->getActiveSheet()->setCellValue('E' . $rc, 'PEJABAT PENILAI'); $this->myexcel->getActiveSheet()->mergeCells('E' . $rc . ':I' . $rc); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, 'c. Pangkat / Gol.Ruang / TMT'); $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->mergeCells('M' . $rc . ':P' . $rc); $this->myexcel->getActiveSheet()->getStyle('M' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('M' . $rc . ':T' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('Q' . $rc, '=SKP!I' . ($r_nama + 2)); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->applyFromArray($styleArray7); $this->myexcel->getActiveSheet()->mergeCells('Q' . $rc . ':U' . $rc); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $rc++; $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, 'd. Jabatan / Pekerjaan'); $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->mergeCells('M' . $rc . ':P' . $rc); $this->myexcel->getActiveSheet()->getStyle('M' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('M' . $rc . ':T' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('Q' . $rc, '=SKP!I' . ($r_nama + 3)); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->applyFromArray($styleArray7); $this->myexcel->getActiveSheet()->mergeCells('Q' . $rc . ':U' . $rc); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $rc++; $this->myexcel->getActiveSheet()->setCellValue('E' . $rc, '=Q46'); $this->myexcel->getActiveSheet()->mergeCells('E' . $rc . ':I' . $rc); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->getFont()->setUnderline(true); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, 'e. Unit Kerja'); $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->mergeCells('M' . $rc . ':P' . $rc); $this->myexcel->getActiveSheet()->getStyle('M' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('M' . $rc . ':T' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('Q' . $rc, '=SKP!I' . ($r_nama + 4)); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->applyFromArray($styleArray7); $this->myexcel->getActiveSheet()->mergeCells('Q' . $rc . ':U' . $rc); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $rc++; $this->myexcel->getActiveSheet()->setCellValue('E' . $rc, 'NIP. ' . $nip_penilai); $this->myexcel->getActiveSheet()->mergeCells('E' . $rc . ':I' . $rc); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->setCellValue('L' . $rc, '2'); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8aa); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, 'PEJABAT PENILAI'); $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->getStyle('L' . $rc . ':M' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->mergeCells('M' . $rc . ':U' . $rc); $this->myexcel->getActiveSheet()->getStyle('M' . $rc . ':U' . $rc)->applyFromArray($styleArray8b); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8h); $rc++; $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, '10. Diterima tanggal: .. Januari ....'); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, 'a. Nama'); $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->mergeCells('M' . $rc . ':P' . $rc); $this->myexcel->getActiveSheet()->getStyle('M' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('M' . $rc . ':T' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('Q' . $rc, '=SKP!D' . $r_nama); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->applyFromArray($styleArray7); $this->myexcel->getActiveSheet()->mergeCells('Q' . $rc . ':U' . $rc); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $rc++; $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, 'Pegawai Negeri Sipil Yang Dinilai'); $this->myexcel->getActiveSheet()->mergeCells('B' . $rc . ':E' . $rc); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, 'b. NIP'); $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->mergeCells('M' . $rc . ':P' . $rc); $this->myexcel->getActiveSheet()->getStyle('M' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('M' . $rc . ':T' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('Q' . $rc, '=SKP!D' . ($r_nama + 1)); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->applyFromArray($styleArray7); $this->myexcel->getActiveSheet()->mergeCells('Q' . $rc . ':U' . $rc); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $rc++; $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, 'c. Pangkat / Gol.Ruang / TMT'); $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->mergeCells('M' . $rc . ':P' . $rc); $this->myexcel->getActiveSheet()->getStyle('M' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('M' . $rc . ':T' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('Q' . $rc, '=SKP!D' . ($r_nama + 2)); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->applyFromArray($styleArray7); $this->myexcel->getActiveSheet()->mergeCells('Q' . $rc . ':U' . $rc); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $rc++; $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, '=Q40'); $this->myexcel->getActiveSheet()->mergeCells('B' . $rc . ':E' . $rc); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->getFont()->setUnderline(true); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, 'd. Jabatan / Pekerjaan'); $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->mergeCells('M' . $rc . ':P' . $rc); $this->myexcel->getActiveSheet()->getStyle('M' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('M' . $rc . ':T' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('Q' . $rc, '=SKP!D' . ($r_nama + 3)); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->applyFromArray($styleArray7); $this->myexcel->getActiveSheet()->mergeCells('Q' . $rc . ':U' . $rc); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $rc++; $this->myexcel->getActiveSheet()->setCellValue('B' . $rc, 'NIP. ' . $nip_baru); $this->myexcel->getActiveSheet()->mergeCells('B' . $rc . ':E' . $rc); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, 'e. Unit Kerja'); $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->mergeCells('M' . $rc . ':P' . $rc); $this->myexcel->getActiveSheet()->getStyle('M' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('M' . $rc . ':T' . $rc)->applyFromArray($styleArray6); $this->myexcel->getActiveSheet()->setCellValue('Q' . $rc, '=SKP!D' . ($r_nama + 4)); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->applyFromArray($styleArray7); $this->myexcel->getActiveSheet()->mergeCells('Q' . $rc . ':U' . $rc); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $rc++; $this->myexcel->getActiveSheet()->setCellValue('E' . $rc, '11. Diterima tanggal .. Januari ....'); $this->myexcel->getActiveSheet()->mergeCells('E' . $rc . ':I' . $rc); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->setCellValue('L' . $rc, '3'); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8aa); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, 'ATASAN PEJABAT PENILAI'); $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->getStyle('L' . $rc . ':M' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->mergeCells('M' . $rc . ':U' . $rc); $this->myexcel->getActiveSheet()->getStyle('M' . $rc . ':U' . $rc)->applyFromArray($styleArray8b); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8h); $rc++; $this->myexcel->getActiveSheet()->setCellValue('E' . $rc, 'ATASAN PEJABAT PENILAI'); $this->myexcel->getActiveSheet()->mergeCells('E' . $rc . ':I' . $rc); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, 'a. Nama'); $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->mergeCells('M' . $rc . ':P' . $rc); $this->myexcel->getActiveSheet()->getStyle('M' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('M' . $rc . ':T' . $rc)->applyFromArray($styleArray6); $nama_atasan = $this->session->userdata('nama_atasan_penilai'); $this->myexcel->getActiveSheet()->setCellValue('Q' . $rc, $nama_atasan); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->applyFromArray($styleArray7); $this->myexcel->getActiveSheet()->mergeCells('Q' . $rc . ':U' . $rc); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $rc++; $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, 'b. NIP'); $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->mergeCells('M' . $rc . ':P' . $rc); $this->myexcel->getActiveSheet()->getStyle('M' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('M' . $rc . ':T' . $rc)->applyFromArray($styleArray6); $nip_atasan = $this->session->userdata('nip_atasan_penilai'); $this->myexcel->getActiveSheet()->setCellValue('Q' . $rc, ' ' . $nip_atasan); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->applyFromArray($styleArray7); $this->myexcel->getActiveSheet()->mergeCells('Q' . $rc . ':U' . $rc); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $rc++; $this->myexcel->getActiveSheet()->setCellValue('E' . $rc, '=Q52'); $this->myexcel->getActiveSheet()->mergeCells('E' . $rc . ':I' . $rc); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->getFont()->setUnderline(true); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, 'c. Pangkat / Gol.Ruang / TMT'); $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->mergeCells('M' . $rc . ':P' . $rc); $this->myexcel->getActiveSheet()->getStyle('M' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('M' . $rc . ':T' . $rc)->applyFromArray($styleArray6); $pangkat_atasan = $this->session->userdata('pangkat_atasan_penilai'); $this->myexcel->getActiveSheet()->setCellValue('Q' . $rc, $pangkat_atasan); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->applyFromArray($styleArray7); $this->myexcel->getActiveSheet()->mergeCells('Q' . $rc . ':U' . $rc); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $rc++; $this->myexcel->getActiveSheet()->setCellValue('E' . $rc, 'NIP. ' . $nip_atasan); $this->myexcel->getActiveSheet()->mergeCells('E' . $rc . ':I' . $rc); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('E' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP); $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8i); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8d); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, 'd. Jabatan / Pekerjaan'); $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->mergeCells('M' . $rc . ':P' . $rc); $this->myexcel->getActiveSheet()->getStyle('M' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('M' . $rc . ':T' . $rc)->applyFromArray($styleArray6); $jabatan_atasan = $this->session->userdata('jabatan_atasan_penilai'); $this->myexcel->getActiveSheet()->setCellValue('Q' . $rc, $jabatan_atasan); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->applyFromArray($styleArray7); $this->myexcel->getActiveSheet()->mergeCells('Q' . $rc . ':U' . $rc); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $rc++; $this->myexcel->getActiveSheet()->getStyle('B' . $rc)->applyFromArray($styleArray8f); $this->myexcel->getActiveSheet()->getStyle('C' . $rc . ':H' . $rc)->applyFromArray($styleArray8e); $this->myexcel->getActiveSheet()->getStyle('I' . $rc)->applyFromArray($styleArray8j); $this->myexcel->getActiveSheet()->getStyle('L' . $rc)->applyFromArray($styleArray8f); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc)->applyFromArray($styleArray6); $unor_atasan = $this->session->userdata('unor_atasan_penilai'); $this->myexcel->getActiveSheet()->setCellValue('Q' . $rc, $unor_atasan); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->applyFromArray($styleArray7); $this->myexcel->getActiveSheet()->mergeCells('Q' . $rc . ':U' . $rc); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setWrapText(true); $this->myexcel->getActiveSheet()->getStyle('Q' . $rc . ':U' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->setCellValue('M' . $rc, 'e. Unit Kerja'); $this->myexcel->getActiveSheet()->getRowDimension($rc)->setRowHeight(30); $this->myexcel->getActiveSheet()->mergeCells('M' . $rc . ':P' . $rc); $this->myexcel->getActiveSheet()->getStyle('M' . $rc)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $this->myexcel->getActiveSheet()->getStyle('M' . $rc)->applyFromArray($styleArray8c); $this->myexcel->getActiveSheet()->getStyle('M' . $rc . ':T' . $rc)->applyFromArray($styleArray8e); $this->myexcel->getActiveSheet()->getStyle('U' . $rc)->applyFromArray($styleArray8j); /////////////////////////////////////////////////////////////////////////// $filename = 'skp_realisasi.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->myexcel, 'Excel5'); //force user to download the Excel file without writing it to server's HD $objWriter->save('php://output'); }
function write($fileName) { $dataSourceProcesoCompra = $this->getDataSource(); $objectPHPExcel = new PHPExcel(); $objectActiveSheet = $objectPHPExcel->getActiveSheet(); $objectActiveSheet->getHeaderFooter()->setOddHeader('&L&H&6&BORIGINAL'); $objectActiveSheet->getHeaderFooter()->setOddFooter('&L&8' . "&8Usuario: \n&8Sistema: " . '&C&8Page &8&P of &8&N' . "&R&8Fecha: &8&D\n&8Hora: &8&T"); $objDrawing = new PHPExcel_Worksheet_Drawing(); $objDrawing->setName('Logo'); $objDrawing->setDescription('Logo'); $objDrawing->setPath(dirname(__FILE__) . '/boa-airline-logo.jpg'); $objDrawing->setHeight(60); $objDrawing->setCoordinates('H1'); $objDrawing->setWorksheet($objectPHPExcel->getActiveSheet()); $styleArrayTitle = array('font' => array('bold' => true, 'size' => 15)); $styleArraySubTitle = array('font' => array('bold' => false, 'size' => 8)); $objectActiveSheet->getStyle('C2')->applyFromArray($styleArrayTitle); $objectActiveSheet->setCellValue('C2', 'CUADRO COMPARATIVO DE OFERTAS'); $objectActiveSheet->setCellValue('E3', 'Expresado en Bolivianos')->getStyle('E3')->applyFromArray($styleArraySubTitle); $objectActiveSheet->setCellValue('E4', 'Formato: Compacto')->getStyle('E4')->applyFromArray($styleArraySubTitle); $objectActiveSheet->setCellValue('A5', 'Nº Proceso: ' . $dataSourceProcesoCompra->getParameter('id_proceso_compra'))->getStyle('A5')->applyFromArray($styleArraySubTitle); $objectActiveSheet->setCellValue('C5', 'Codigo Proceso: ' . $dataSourceProcesoCompra->getParameter('codigo_proceso'))->getStyle('C5')->applyFromArray($styleArraySubTitle); $objectActiveSheet->setCellValue('H5', 'Solicitud: ' . $dataSourceProcesoCompra->getParameter('desc_solicitud'))->getStyle('H5')->applyFromArray($styleArraySubTitle); $styleArrayCell = array('font' => array('name' => 'Arial', 'size' => '8'), 'borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'right' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'top' => array('style' => PHPExcel_Style_Border::BORDER_THIN))); $objectActiveSheet->getColumnDimension('B')->setWidth(20); $objectActiveSheet->mergeCells('A7:A8')->getStyle('A7:A8')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objectActiveSheet->mergeCells('B7:B8')->getStyle('B7:B8')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objectActiveSheet->mergeCells('C7:C8')->getStyle('C7:C8')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objectActiveSheet->setCellValue('A7', 'Nro')->getStyle('A7:A8')->applyFromArray($styleArrayCell); $objectActiveSheet->setCellValue('B7', 'Descripcion del item')->getStyle('B7:B8')->applyFromArray($styleArrayCell); $objectActiveSheet->setCellValue('C7', 'Cantidad')->getStyle('C7:C8')->applyFromArray($styleArrayCell); $datasetItems = $dataSourceProcesoCompra->getParameter('detalleSolicitudDataSource')->getDataset(); for ($i = 0; $i < count($datasetItems); $i++) { $celda = $i + 9; $objectActiveSheet->setCellValue('A' . $celda, $i + 1)->getStyle('A' . $celda)->applyFromArray($styleArrayCell); $objectActiveSheet->setCellValue('B' . $celda, $datasetItems[$i]['desc_concepto_ingas'])->getStyle('B' . $celda)->applyFromArray($styleArrayCell); $objectActiveSheet->setCellValue('C' . $celda, $datasetItems[$i]['cantidad'])->getStyle('C' . $celda)->applyFromArray($styleArrayCell); } $datasetCotizaciones = $dataSourceProcesoCompra->getParameter('cotizacionDataSource')->getDataset(); $column = 3; $file = 7; $lastFile = 0; foreach ($datasetCotizaciones as $provider) { $objectActiveSheet->mergeCellsByColumnAndRow($column, $file, $column + 2, $file); $objectActiveSheet->setCellValueByColumnAndRow($column, $file, $provider['desc_proveedor']); $objectActiveSheet->getStyleByColumnAndRow($column, $file)->applyFromArray($styleArrayCell); $objectActiveSheet->getStyleByColumnAndRow($column + 1, $file)->applyFromArray($styleArrayCell); $objectActiveSheet->getStyleByColumnAndRow($column + 2, $file)->applyFromArray($styleArrayCell); $objectActiveSheet->setCellValueByColumnAndRow($column, $file + 1, 'Cant. Cot.'); $objectActiveSheet->getStyleByColumnAndRow($column, $file + 1)->applyFromArray($styleArrayCell); $objectActiveSheet->setCellValueByColumnAndRow($column + 1, $file + 1, 'Precio U.'); $objectActiveSheet->getStyleByColumnAndRow($column + 1, $file + 1)->applyFromArray($styleArrayCell); $objectActiveSheet->setCellValueByColumnAndRow($column + 2, $file + 1, 'Precio T.'); $objectActiveSheet->getStyleByColumnAndRow($column + 2, $file + 1)->applyFromArray($styleArrayCell); $itemsCotizadosPorProveedor = $provider['dataset']->getDataset(); $fileItemCotizado = $file + 2; for ($i = 0; $i < count($itemsCotizadosPorProveedor); $i++) { if ($datasetItems[$i]['desc_concepto_ingas'] == $itemsCotizadosPorProveedor[$i]['desc_solicitud_det']) { $objectActiveSheet->setCellValueByColumnAndRow($column, $fileItemCotizado, $itemsCotizadosPorProveedor[$i]['cantidad_coti']); $objectActiveSheet->getStyleByColumnAndRow($column, $fileItemCotizado)->applyFromArray($styleArrayCell); $objectActiveSheet->setCellValueByColumnAndRow($column + 1, $fileItemCotizado, $itemsCotizadosPorProveedor[$i]['precio_unitario']); $objectActiveSheet->getStyleByColumnAndRow($column + 1, $fileItemCotizado)->applyFromArray($styleArrayCell); $objectActiveSheet->setCellValueByColumnAndRow($column + 2, $fileItemCotizado, $itemsCotizadosPorProveedor[$i]['cantidad_coti'] * $itemCotizado['precio_unitario']); $objectActiveSheet->getStyleByColumnAndRow($column + 2, $fileItemCotizado)->applyFromArray($styleArrayCell); } $fileItemCotizado = $fileItemCotizado + 1; } $objectActiveSheet->setCellValueByColumnAndRow(0, $fileItemCotizado, 'Plazo de Entrega'); $objectActiveSheet->getStyleByColumnAndRow(0, $fileItemCotizado)->applyFromArray($styleArrayCell); $objectActiveSheet->getStyleByColumnAndRow(1, $fileItemCotizado)->applyFromArray($styleArrayCell); $objectActiveSheet->getStyleByColumnAndRow(2, $fileItemCotizado)->applyFromArray($styleArrayCell); $objectActiveSheet->mergeCellsByColumnAndRow(0, $fileItemCotizado, 2, $fileItemCotizado); $objectActiveSheet->setCellValueByColumnAndRow($column, $fileItemCotizado, $provider['fecha_entrega']); $objectActiveSheet->getStyleByColumnAndRow($column, $fileItemCotizado)->applyFromArray($styleArrayCell); $objectActiveSheet->getStyleByColumnAndRow($column + 1, $fileItemCotizado)->applyFromArray($styleArrayCell); $objectActiveSheet->getStyleByColumnAndRow($column + 2, $fileItemCotizado)->applyFromArray($styleArrayCell); $objectActiveSheet->mergeCellsByColumnAndRow($column, $fileItemCotizado, $column + 2, $fileItemCotizado); $objectActiveSheet->setCellValueByColumnAndRow(0, $fileItemCotizado + 1, 'Lugar de Entrega'); $objectActiveSheet->getStyleByColumnAndRow(0, $fileItemCotizado + 1)->applyFromArray($styleArrayCell); $objectActiveSheet->getStyleByColumnAndRow(1, $fileItemCotizado + 1)->applyFromArray($styleArrayCell); $objectActiveSheet->getStyleByColumnAndRow(2, $fileItemCotizado + 1)->applyFromArray($styleArrayCell); $objectActiveSheet->mergeCellsByColumnAndRow(0, $fileItemCotizado + 1, 2, $fileItemCotizado + 1); $objectActiveSheet->setCellValueByColumnAndRow($column, $fileItemCotizado + 1, $provider['lugar_entrega']); $objectActiveSheet->getStyleByColumnAndRow($column, $fileItemCotizado + 1)->applyFromArray($styleArrayCell); $objectActiveSheet->getStyleByColumnAndRow($column + 1, $fileItemCotizado + 1)->applyFromArray($styleArrayCell); $objectActiveSheet->getStyleByColumnAndRow($column + 2, $fileItemCotizado + 1)->applyFromArray($styleArrayCell); $objectActiveSheet->mergeCellsByColumnAndRow($column, $fileItemCotizado + 1, $column + 2, $fileItemCotizado + 1); $objectActiveSheet->setCellValueByColumnAndRow(0, $fileItemCotizado + 2, 'Validez de la oferta'); $objectActiveSheet->getStyleByColumnAndRow(0, $fileItemCotizado + 2)->applyFromArray($styleArrayCell); $objectActiveSheet->getStyleByColumnAndRow(1, $fileItemCotizado + 2)->applyFromArray($styleArrayCell); $objectActiveSheet->getStyleByColumnAndRow(2, $fileItemCotizado + 2)->applyFromArray($styleArrayCell); $objectActiveSheet->setCellValueByColumnAndRow($column, $fileItemCotizado + 2, $provider['fecha_venc']); $objectActiveSheet->getStyleByColumnAndRow($column, $fileItemCotizado + 2)->applyFromArray($styleArrayCell); $objectActiveSheet->getStyleByColumnAndRow($column + 1, $fileItemCotizado + 2)->applyFromArray($styleArrayCell); $objectActiveSheet->getStyleByColumnAndRow($column + 2, $fileItemCotizado + 2)->applyFromArray($styleArrayCell); $objectActiveSheet->mergeCellsByColumnAndRow($column, $fileItemCotizado + 2, $column + 2, $fileItemCotizado + 2); $objectActiveSheet->mergeCellsByColumnAndRow(0, $fileItemCotizado + 2, 2, $fileItemCotizado + 2); $column = $column + 3; $lastFile = $fileItemCotizado + 5; } $objWriter = PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel5'); $objWriter->save($fileName); }
public function create_excel($cart, $data) { /** Error reporting */ error_reporting(E_ALL); //define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); date_default_timezone_set('Europe/London'); /** Include PHPExcel */ require_once dirname(__FILE__) . '/excel/PHPExcel.php'; // Create new PHPExcel object //echo date('H:i:s') , " Create new PHPExcel object" , EOL; $objPHPExcel = new PHPExcel(); // Set document properties //echo date('H:i:s') , " Set document properties" , EOL; $objPHPExcel->getProperties()->setCreator("Margina Radu")->setLastModifiedBy("Margina Radu")->setTitle("Office 2007 XLSX Test Document")->setSubject("Office 2007 XLSX Test Document")->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")->setKeywords("office 2007 openxml php")->setCategory("Test result file"); // Create a first sheet, representing sales data //echo date('H:i:s') , " Add some data" , EOL; $objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->getActiveSheet()->setCellValue('B1', 'Corden: Invoice'); $objPHPExcel->getActiveSheet()->setCellValue('F1', PHPExcel_Shared_Date::PHPToExcel(gmmktime(0, 0, 0, date('m'), date('d'), date('Y')))); $objPHPExcel->getActiveSheet()->getStyle('F1')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15); //$objPHPExcel->getActiveSheet()->setCellValue('E1', '#12566'); $objPHPExcel->getActiveSheet()->setCellValue('A12', 'ID'); $objPHPExcel->getActiveSheet()->setCellValue('B12', 'Simbol'); $objPHPExcel->getActiveSheet()->setCellValue('C12', 'Denumire'); $objPHPExcel->getActiveSheet()->setCellValue('D12', 'Cantitatea'); $objPHPExcel->getActiveSheet()->setCellValue('E12', 'Pret'); $objPHPExcel->getActiveSheet()->setCellValue('F12', 'Subtotal'); $index = 13; $start_index = 13; foreach ($cart as $item) { $objPHPExcel->getActiveSheet()->setCellValue('A' . $index, $item['id']); $objPHPExcel->getActiveSheet()->setCellValue('B' . $index, $item['simbol']); $objPHPExcel->getActiveSheet()->setCellValue('C' . $index, $item['name']); $objPHPExcel->getActiveSheet()->setCellValue('D' . $index, $item['qty']); $objPHPExcel->getActiveSheet()->setCellValue('E' . $index, $item['price']); $objPHPExcel->getActiveSheet()->setCellValue('F' . $index, $item['subtotal']); $index++; } $end_index = $index - 1; $total_index = $index + 1; $objPHPExcel->getActiveSheet()->setCellValue('E' . $total_index, 'Pret Total:'); $objPHPExcel->getActiveSheet()->setCellValue('F' . $total_index, '=SUM(F13:F' . $end_index . ')'); // Add comment //echo date('H:i:s') , " Add comments" , EOL; $objPHPExcel->getActiveSheet()->getComment('F' . $total_index)->setAuthor('PHPExcel'); $objCommentRichText = $objPHPExcel->getActiveSheet()->getComment('F' . $total_index)->getText()->createTextRun('PHPExcel:'); $objCommentRichText->getFont()->setBold(true); $objPHPExcel->getActiveSheet()->getComment('F' . $total_index)->getText()->createTextRun("\r\n"); $objPHPExcel->getActiveSheet()->getComment('F' . $total_index)->getText()->createTextRun('Total amount on the current invoice, including VAT.'); $objPHPExcel->getActiveSheet()->getComment('F' . $total_index)->setWidth('100pt'); $objPHPExcel->getActiveSheet()->getComment('F' . $total_index)->setHeight('100pt'); $objPHPExcel->getActiveSheet()->getComment('F' . $total_index)->setMarginLeft('150pt'); $objPHPExcel->getActiveSheet()->getComment('F' . $total_index)->getFillColor()->setRGB('EEEEEE'); // Add rich-text string //echo date('H:i:s') , " Add rich-text string" , EOL; $objRichText = new PHPExcel_RichText(); $objRichText->createText("Nume: "); $objPayable = $objRichText->createTextRun($data['nume'] . " " . $data['prenume']); $objPayable->getFont()->setBold(true); $objPayable->getFont()->setItalic(true); $objPayable->getFont()->setColor(new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_DARKGREEN)); $objRichText->createText("\nEmail : "); $objPayable = $objRichText->createTextRun($data['email']); $objPayable->getFont()->setBold(true); $objPayable->getFont()->setItalic(true); $objPayable->getFont()->setColor(new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_DARKGREEN)); $objRichText->createText("\nTelefon : "); $objPayable = $objRichText->createTextRun($data['telefon']); $objPayable->getFont()->setBold(true); $objPayable->getFont()->setItalic(true); $objPayable->getFont()->setColor(new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_DARKGREEN)); $objRichText->createText("\nAdresa : "); $objPayable = $objRichText->createTextRun($data['adresa']['orasul'] . "," . $data['adresa']['localitatea'] . ", str. " . $data['adresa']['strada'] . " " . $data['adresa']['numarul'] . ", ap. " . $data['adresa']['apartament']); $objPayable->getFont()->setBold(true); $objPayable->getFont()->setItalic(true); $objPayable->getFont()->setColor(new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_DARKGREEN)); $objRichText->createText("\nMetoda de plata : "); $objPayable = $objRichText->createTextRun($data['payment']); $objPayable->getFont()->setBold(true); $objPayable->getFont()->setItalic(true); $objPayable->getFont()->setColor(new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_DARKGREEN)); $objRichText->createText("\nSunet de confirmare : "); $objPayable = $objRichText->createTextRun(isset($data['call_after']) ? $data['call_after'] : 'nu'); $objPayable->getFont()->setBold(true); $objPayable->getFont()->setItalic(true); $objPayable->getFont()->setColor(new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_DARKGREEN)); $objPHPExcel->getActiveSheet()->getCell('A3')->setValue($objRichText); // Merge cells //echo date('H:i:s') , " Merge cells" , EOL; $objPHPExcel->getActiveSheet()->mergeCells('A3:F10'); // Just to test... // Protect cells //echo date('H:i:s') , " Protect cells" , EOL; // $objPHPExcel->getActiveSheet()->getProtection()->setSheet(true); // Needs to be set to true in order to enable any worksheet protection! //$objPHPExcel->getActiveSheet()->protectCells('A3:F13', 'PHPExcel'); // Set cell number formats //echo date('H:i:s') , " Set cell number formats" , EOL; //$objPHPExcel->getActiveSheet()->getStyle('E4:F13')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE); // Set column widths //echo date('H:i:s') , " Set column widths" , EOL; $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(20); $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(20); $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(12); $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(12); $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(12); // Set fonts //echo date('H:i:s') , " Set fonts" , EOL; $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setName('Candara'); $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setSize(20); $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setBold(true); $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE); $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_WHITE); $objPHPExcel->getActiveSheet()->getStyle('D1')->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_WHITE); $objPHPExcel->getActiveSheet()->getStyle('E1')->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_WHITE); $objPHPExcel->getActiveSheet()->getStyle('F1')->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_WHITE); $objPHPExcel->getActiveSheet()->getStyle('E' . $total_index)->getFont()->setBold(true); $objPHPExcel->getActiveSheet()->getStyle('F' . $total_index)->getFont()->setBold(true); // Set alignments //echo date('H:i:s') , " Set alignments" , EOL; $objPHPExcel->getActiveSheet()->getStyle('F' . $total_index)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->getStyle('A3')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY); $objPHPExcel->getActiveSheet()->getStyle('A3')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('B13')->getAlignment()->setShrinkToFit(true); // 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('A13:F' . $end_index)->applyFromArray($styleThinBlackBorderOutline); // Set thick brown border outline around "Total" //echo date('H:i:s') , " Set thick brown border outline around Total" , EOL; $styleThickBrownBorderOutline = array('borders' => array('outline' => array('style' => PHPExcel_Style_Border::BORDER_THICK, 'color' => array('argb' => 'FF993300')))); $objPHPExcel->getActiveSheet()->getStyle('E' . $total_index . ':F' . $total_index . '')->applyFromArray($styleThickBrownBorderOutline); // Set fills //echo date('H:i:s') , " Set fills" , EOL; $objPHPExcel->getActiveSheet()->getStyle('A1:F1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID); $objPHPExcel->getActiveSheet()->getStyle('A1:F1')->getFill()->getStartColor()->setARGB('FF808080'); $objPHPExcel->getActiveSheet()->getStyle('A1')->getFill()->getStartColor()->setARGB('80FFFFFF'); // 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('A12:F12')->applyFromArray(array('font' => array('bold' => true), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_RIGHT), 'borders' => array('top' => array('style' => PHPExcel_Style_Border::BORDER_THIN)), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR, 'rotation' => 90, 'startcolor' => array('argb' => 'FFA0A0A0'), 'endcolor' => array('argb' => 'FFFFFFFF')))); $objPHPExcel->getActiveSheet()->getStyle('A12')->applyFromArray(array('alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT), 'borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_THIN)))); $objPHPExcel->getActiveSheet()->getStyle('B12')->applyFromArray(array('alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT))); $objPHPExcel->getActiveSheet()->getStyle('F12')->applyFromArray(array('borders' => array('right' => array('style' => PHPExcel_Style_Border::BORDER_THIN)))); // Unprotect a cell //echo date('H:i:s') , " Unprotect a cell" , EOL; $objPHPExcel->getActiveSheet()->getStyle('B1')->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED); // 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($_SERVER['DOCUMENT_ROOT'] . '/assets/img/images/logo.jpg'); $objDrawing->setHeight(36); $objDrawing->setWorksheet($objPHPExcel->getActiveSheet()); // Set header and footer. When no different headers for odd/even are used, odd header is assumed. //echo date('H:i:s') , " Set header/footer" , EOL; $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&L&BInvoice&RPrinted on &D'); $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . $objPHPExcel->getProperties()->getTitle() . '&RPage &P of &N'); // Set page orientation and size //echo date('H:i:s') , " Set page orientation and size" , EOL; $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT); $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4); // Rename first worksheet //echo date('H:i:s') , " Rename first worksheet" , EOL; $objPHPExcel->getActiveSheet()->setTitle('Invoice'); // Set active sheet index to the first sheet, so Excel opens this as the first sheet $objPHPExcel->setActiveSheetIndex(0); /** Include PHPExcel_IOFactory */ require_once dirname(__FILE__) . '/excel/PHPExcel/IOFactory.php'; // Save Excel 2007 file //echo date('H:i:s') , " Write to Excel2007 format" , EOL; $callStartTime = microtime(true); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save(str_replace('.php', '.xlsx', 'invoice.xlsx')); //echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; //echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; // Echo memory usage //echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; // Echo done //echo date('H:i:s') , " Done writing files" , EOL; //echo 'Files have been created in ' , getcwd() , EOL; }
/** * Loads PHPExcel from file * * @param string $pFilename * @throws PHPExcel_Reader_Exception */ public function load($pFilename) { // Check if file exists if (!file_exists($pFilename)) { throw new PHPExcel_Reader_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); // Read the theme first, because we need the colour scheme when reading the styles $wbRels = simplexml_load_string($this->_getFromZipArchive($zip, "xl/_rels/workbook.xml.rels")); //~ http://schemas.openxmlformats.org/package/2006/relationships"); foreach ($wbRels->Relationship as $rel) { switch ($rel["Type"]) { case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme": $themeOrderArray = array('lt1', 'dk1', 'lt2', 'dk2'); $themeOrderAdditional = count($themeOrderArray); $xmlTheme = simplexml_load_string($this->_getFromZipArchive($zip, "xl/{$rel['Target']}")); if (is_object($xmlTheme)) { $xmlThemeName = $xmlTheme->attributes(); $xmlTheme = $xmlTheme->children("http://schemas.openxmlformats.org/drawingml/2006/main"); $themeName = (string) $xmlThemeName['name']; $colourScheme = $xmlTheme->themeElements->clrScheme->attributes(); $colourSchemeName = (string) $colourScheme['name']; $colourScheme = $xmlTheme->themeElements->clrScheme->children("http://schemas.openxmlformats.org/drawingml/2006/main"); $themeColours = array(); foreach ($colourScheme as $k => $xmlColour) { $themePos = array_search($k, $themeOrderArray); if ($themePos === false) { $themePos = $themeOrderAdditional++; } if (isset($xmlColour->sysClr)) { $xmlColourData = $xmlColour->sysClr->attributes(); $themeColours[$themePos] = $xmlColourData['lastClr']; } elseif (isset($xmlColour->srgbClr)) { $xmlColourData = $xmlColour->srgbClr->attributes(); $themeColours[$themePos] = $xmlColourData['val']; } } self::$_theme = new PHPExcel_Reader_Excel2007_Theme($themeName, $colourSchemeName, $themeColours); } break; } } $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 (is_object($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/extended-properties": $xmlCore = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}")); if (is_object($xmlCore)) { $docProps = $excel->getProperties(); if (isset($xmlCore->Company)) { $docProps->setCompany((string) $xmlCore->Company); } if (isset($xmlCore->Manager)) { $docProps->setManager((string) $xmlCore->Manager); } } break; case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties": $xmlCore = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}")); if (is_object($xmlCore)) { $docProps = $excel->getProperties(); foreach ($xmlCore as $xmlProperty) { $cellDataOfficeAttributes = $xmlProperty->attributes(); if (isset($cellDataOfficeAttributes['name'])) { $propertyName = (string) $cellDataOfficeAttributes['name']; $cellDataOfficeChildren = $xmlProperty->children('http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); $attributeType = $cellDataOfficeChildren->getName(); $attributeValue = (string) $cellDataOfficeChildren->{$attributeType}; $attributeValue = PHPExcel_DocumentProperties::convertProperty($attributeValue, $attributeType); $attributeType = PHPExcel_DocumentProperties::convertPropertyType($attributeType); $docProps->setCustomProperty($propertyName, $attributeValue, $attributeType); } } } 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) && $numFmts !== NULL) { $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); $style = (object) array("numFmt" => $numFmt, "font" => $xmlStyles->fonts->font[intval($xf["fontId"])], "fill" => $xmlStyles->fills->fill[intval($xf["fillId"])], "border" => $xmlStyles->borders->border[intval($xf["borderId"])], "alignment" => $xf->alignment, "protection" => $xf->protection); $styles[] = $style; // add style to cellXf collection $objStyle = new PHPExcel_Style(); self::_readStyle($objStyle, $style); $excel->addCellXf($objStyle); } foreach ($xmlStyles->cellStyleXfs->xf as $xf) { $numFmt = PHPExcel_Style_NumberFormat::FORMAT_GENERAL; if ($numFmts && $xf["numFmtId"]) { $tmpNumFmt = self::array_item($numFmts->xpath("sml:numFmt[@numFmtId={$xf['numFmtId']}]")); if (isset($tmpNumFmt["formatCode"])) { $numFmt = (string) $tmpNumFmt["formatCode"]; } else { if ((int) $xf["numFmtId"] < 165) { $numFmt = PHPExcel_Style_NumberFormat::builtInFormatCode((int) $xf["numFmtId"]); } } } $cellStyle = (object) array("numFmt" => $numFmt, "font" => $xmlStyles->fonts->font[intval($xf["fontId"])], "fill" => $xmlStyles->fills->fill[intval($xf["fillId"])], "border" => $xmlStyles->borders->border[intval($xf["borderId"])], "alignment" => $xf->alignment, "protection" => $xf->protection); $cellStyles[] = $cellStyle; // add style to cellStyleXf collection $objStyle = new PHPExcel_Style(); self::_readStyle($objStyle, $cellStyle); $excel->addCellStyleXf($objStyle); } } $dxfs = array(); if (!$this->_readDataOnly && $xmlStyles) { // Conditional Styles if ($xmlStyles->dxfs) { foreach ($xmlStyles->dxfs->dxf as $dxf) { $style = new PHPExcel_Style(FALSE, TRUE); self::_readStyle($style, $dxf); $dxfs[] = $style; } } // Cell Styles if ($xmlStyles->cellStyles) { foreach ($xmlStyles->cellStyles->cellStyle as $cellStyle) { if (intval($cellStyle['builtinId']) == 0) { if (isset($cellStyles[intval($cellStyle['xfId'])])) { // Set default style $style = new PHPExcel_Style(); self::_readStyle($style, $cellStyles[intval($cellStyle['xfId'])]); // normal style, currently not using it for anything } } } } } $xmlWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); // Set base date if ($xmlWorkbook->workbookPr) { PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900); if (isset($xmlWorkbook->workbookPr['date1904'])) { if (self::boolean((string) $xmlWorkbook->workbookPr['date1904'])) { PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_MAC_1904); } } } $sheetId = 0; // keep track of new sheet id in final workbook $oldSheetId = -1; // keep track of old sheet id in final workbook $countSkippedSheets = 0; // keep track of number of skipped sheets $mapSheetId = array(); // mapping of sheet ids from old to new $charts = $chartDetails = array(); if ($xmlWorkbook->sheets) { foreach ($xmlWorkbook->sheets->sheet as $eleSheet) { ++$oldSheetId; // Check if sheet should be skipped if (isset($this->_loadSheetsOnly) && !in_array((string) $eleSheet["name"], $this->_loadSheetsOnly)) { ++$countSkippedSheets; $mapSheetId[$oldSheetId] = null; continue; } // Map old sheet id in original workbook to new sheet id. // They will differ if loadSheetsOnly() is being used $mapSheetId[$oldSheetId] = $oldSheetId - $countSkippedSheets; // Load sheet $docSheet = $excel->createSheet(); // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet // references in formula cells... during the load, all formulae should be correct, // and we're simply bringing the worksheet name in line with the formula, not the // reverse $docSheet->setTitle((string) $eleSheet["name"], false); $fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")]; $xmlSheet = simplexml_load_string($this->_getFromZipArchive($zip, "{$dir}/{$fileWorksheet}")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); $sharedFormulas = array(); if (isset($eleSheet["state"]) && (string) $eleSheet["state"] != '') { $docSheet->setSheetState((string) $eleSheet["state"]); } if (isset($xmlSheet->sheetViews) && isset($xmlSheet->sheetViews->sheetView)) { if (isset($xmlSheet->sheetViews->sheetView['zoomScale'])) { $docSheet->getSheetView()->setZoomScale(intval($xmlSheet->sheetViews->sheetView['zoomScale'])); } if (isset($xmlSheet->sheetViews->sheetView['zoomScaleNormal'])) { $docSheet->getSheetView()->setZoomScaleNormal(intval($xmlSheet->sheetViews->sheetView['zoomScaleNormal'])); } if (isset($xmlSheet->sheetViews->sheetView['view'])) { $docSheet->getSheetView()->setView((string) $xmlSheet->sheetViews->sheetView['view']); } if (isset($xmlSheet->sheetViews->sheetView['showGridLines'])) { $docSheet->setShowGridLines(self::boolean((string) $xmlSheet->sheetViews->sheetView['showGridLines'])); } if (isset($xmlSheet->sheetViews->sheetView['showRowColHeaders'])) { $docSheet->setShowRowColHeaders(self::boolean((string) $xmlSheet->sheetViews->sheetView['showRowColHeaders'])); } if (isset($xmlSheet->sheetViews->sheetView['rightToLeft'])) { $docSheet->setRightToLeft(self::boolean((string) $xmlSheet->sheetViews->sheetView['rightToLeft'])); } if (isset($xmlSheet->sheetViews->sheetView->pane)) { if (isset($xmlSheet->sheetViews->sheetView->pane['topLeftCell'])) { $docSheet->freezePane((string) $xmlSheet->sheetViews->sheetView->pane['topLeftCell']); } else { $xSplit = 0; $ySplit = 0; if (isset($xmlSheet->sheetViews->sheetView->pane['xSplit'])) { $xSplit = 1 + intval($xmlSheet->sheetViews->sheetView->pane['xSplit']); } if (isset($xmlSheet->sheetViews->sheetView->pane['ySplit'])) { $ySplit = 1 + intval($xmlSheet->sheetViews->sheetView->pane['ySplit']); } $docSheet->freezePaneByColumnAndRow($xSplit, $ySplit); } } if (isset($xmlSheet->sheetViews->sheetView->selection)) { if (isset($xmlSheet->sheetViews->sheetView->selection['sqref'])) { $sqref = (string) $xmlSheet->sheetViews->sheetView->selection['sqref']; $sqref = explode(' ', $sqref); $sqref = $sqref[0]; $docSheet->setSelectedCells($sqref); } } } if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->tabColor)) { if (isset($xmlSheet->sheetPr->tabColor['rgb'])) { $docSheet->getTabColor()->setARGB((string) $xmlSheet->sheetPr->tabColor['rgb']); } } if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->outlinePr)) { if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) && !self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryRight'])) { $docSheet->setShowSummaryRight(FALSE); } else { $docSheet->setShowSummaryRight(TRUE); } if (isset($xmlSheet->sheetPr->outlinePr['summaryBelow']) && !self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryBelow'])) { $docSheet->setShowSummaryBelow(FALSE); } else { $docSheet->setShowSummaryBelow(TRUE); } } if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->pageSetUpPr)) { if (isset($xmlSheet->sheetPr->pageSetUpPr['fitToPage']) && !self::boolean((string) $xmlSheet->sheetPr->pageSetUpPr['fitToPage'])) { $docSheet->getPageSetup()->setFitToPage(FALSE); } else { $docSheet->getPageSetup()->setFitToPage(TRUE); } } if (isset($xmlSheet->sheetFormatPr)) { if (isset($xmlSheet->sheetFormatPr['customHeight']) && self::boolean((string) $xmlSheet->sheetFormatPr['customHeight']) && isset($xmlSheet->sheetFormatPr['defaultRowHeight'])) { $docSheet->getDefaultRowDimension()->setRowHeight((double) $xmlSheet->sheetFormatPr['defaultRowHeight']); } if (isset($xmlSheet->sheetFormatPr['defaultColWidth'])) { $docSheet->getDefaultColumnDimension()->setWidth((double) $xmlSheet->sheetFormatPr['defaultColWidth']); } if (isset($xmlSheet->sheetFormatPr['zeroHeight']) && (string) $xmlSheet->sheetFormatPr['zeroHeight'] == '1') { $docSheet->getDefaultRowDimension()->setzeroHeight(true); } } if (isset($xmlSheet->cols) && !$this->_readDataOnly) { foreach ($xmlSheet->cols->col as $col) { for ($i = intval($col["min"]) - 1; $i < intval($col["max"]); ++$i) { if ($col["style"] && !$this->_readDataOnly) { $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setXfIndex(intval($col["style"])); } if (self::boolean($col["bestFit"])) { //$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setAutoSize(TRUE); } if (self::boolean($col["hidden"])) { $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setVisible(FALSE); } if (self::boolean($col["collapsed"])) { $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setCollapsed(TRUE); } if ($col["outlineLevel"] > 0) { $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setOutlineLevel(intval($col["outlineLevel"])); } $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setWidth(floatval($col["width"])); if (intval($col["max"]) == 16384) { break; } } } } if (isset($xmlSheet->printOptions) && !$this->_readDataOnly) { if (self::boolean((string) $xmlSheet->printOptions['gridLinesSet'])) { $docSheet->setShowGridlines(TRUE); } if (self::boolean((string) $xmlSheet->printOptions['gridLines'])) { $docSheet->setPrintGridlines(TRUE); } if (self::boolean((string) $xmlSheet->printOptions['horizontalCentered'])) { $docSheet->getPageSetup()->setHorizontalCentered(TRUE); } if (self::boolean((string) $xmlSheet->printOptions['verticalCentered'])) { $docSheet->getPageSetup()->setVerticalCentered(TRUE); } } if ($xmlSheet && $xmlSheet->sheetData && $xmlSheet->sheetData->row) { foreach ($xmlSheet->sheetData->row as $row) { if ($row["ht"] && !$this->_readDataOnly) { $docSheet->getRowDimension(intval($row["r"]))->setRowHeight(floatval($row["ht"])); } if (self::boolean($row["hidden"]) && !$this->_readDataOnly) { $docSheet->getRowDimension(intval($row["r"]))->setVisible(FALSE); } if (self::boolean($row["collapsed"])) { $docSheet->getRowDimension(intval($row["r"]))->setCollapsed(TRUE); } if ($row["outlineLevel"] > 0) { $docSheet->getRowDimension(intval($row["r"]))->setOutlineLevel(intval($row["outlineLevel"])); } if ($row["s"] && !$this->_readDataOnly) { $docSheet->getRowDimension(intval($row["r"]))->setXfIndex(intval($row["s"])); } foreach ($row->c as $c) { $r = (string) $c["r"]; $cellDataType = (string) $c["t"]; $value = null; $calculatedValue = null; // Read cell? if ($this->getReadFilter() !== NULL) { $coordinates = PHPExcel_Cell::coordinateFromString($r); if (!$this->getReadFilter()->readCell($coordinates[0], $coordinates[1], $docSheet->getTitle())) { continue; } } // echo '<b>Reading cell '.$coordinates[0].$coordinates[1].'</b><br />'; // print_r($c); // echo '<br />'; // echo 'Cell Data Type is '.$cellDataType.': '; // // Read cell! switch ($cellDataType) { case "s": // echo 'String<br />'; if ((string) $c->v != '') { $value = $sharedStrings[intval($c->v)]; if ($value instanceof PHPExcel_RichText) { $value = clone $value; } } else { $value = ''; } break; case "b": // echo 'Boolean<br />'; if (!isset($c->f)) { $value = self::_castToBool($c); } else { // Formula $this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, '_castToBool'); if (isset($c->f['t'])) { $att = array(); $att = $c->f; $docSheet->getCell($r)->setFormulaAttributes($att); } // echo '$calculatedValue = '.$calculatedValue.'<br />'; } break; case "inlineStr": // echo 'Inline String<br />'; $value = $this->_parseRichText($c->is); break; case "e": // echo 'Error<br />'; if (!isset($c->f)) { $value = self::_castToError($c); } else { // Formula $this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, '_castToError'); // echo '$calculatedValue = '.$calculatedValue.'<br />'; } break; default: // echo 'Default<br />'; if (!isset($c->f)) { // echo 'Not a Formula<br />'; $value = self::_castToString($c); } else { // echo 'Treat as Formula<br />'; // Formula $this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, '_castToString'); // echo '$calculatedValue = '.$calculatedValue.'<br />'; } break; } // echo 'Value is '.$value.'<br />'; // Check for numeric values if (is_numeric($value) && $cellDataType != 's') { if ($value == (int) $value) { $value = (int) $value; } elseif ($value == (double) $value) { $value = (double) $value; } elseif ($value == (double) $value) { $value = (double) $value; } } // Rich text? if ($value instanceof PHPExcel_RichText && $this->_readDataOnly) { $value = $value->getPlainText(); } $cell = $docSheet->getCell($r); // Assign value if ($cellDataType != '') { $cell->setValueExplicit($value, $cellDataType); } else { $cell->setValue($value); } if ($calculatedValue !== NULL) { $cell->setCalculatedValue($calculatedValue); } // Style information? if ($c["s"] && !$this->_readDataOnly) { // no style index means 0, it seems $cell->setXfIndex(isset($styles[intval($c["s"])]) ? intval($c["s"]) : 0); } } } } $conditionals = array(); if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->conditionalFormatting) { foreach ($xmlSheet->conditionalFormatting as $conditional) { foreach ($conditional->cfRule as $cfRule) { if (((string) $cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_NONE || (string) $cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CELLIS || (string) $cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT || (string) $cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_EXPRESSION) && isset($dxfs[intval($cfRule["dxfId"])])) { $conditionals[(string) $conditional["sqref"]][intval($cfRule["priority"])] = $cfRule; } } } foreach ($conditionals as $ref => $cfRules) { ksort($cfRules); $conditionalStyles = array(); foreach ($cfRules as $cfRule) { $objConditional = new PHPExcel_Style_Conditional(); $objConditional->setConditionType((string) $cfRule["type"]); $objConditional->setOperatorType((string) $cfRule["operator"]); if ((string) $cfRule["text"] != '') { $objConditional->setText((string) $cfRule["text"]); } if (count($cfRule->formula) > 1) { foreach ($cfRule->formula as $formula) { $objConditional->addCondition((string) $formula); } } else { $objConditional->addCondition((string) $cfRule->formula); } $objConditional->setStyle(clone $dxfs[intval($cfRule["dxfId"])]); $conditionalStyles[] = $objConditional; } // Extract all cell references in $ref $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($ref); foreach ($aReferences as $reference) { $docSheet->getStyle($reference)->setConditionalStyles($conditionalStyles); } } } $aKeys = array("sheet", "objects", "scenarios", "formatCells", "formatColumns", "formatRows", "insertColumns", "insertRows", "insertHyperlinks", "deleteColumns", "deleteRows", "selectLockedCells", "sort", "autoFilter", "pivotTables", "selectUnlockedCells"); if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) { foreach ($aKeys as $key) { $method = "set" . ucfirst($key); $docSheet->getProtection()->{$method}(self::boolean((string) $xmlSheet->sheetProtection[$key])); } } if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) { $docSheet->getProtection()->setPassword((string) $xmlSheet->sheetProtection["password"], TRUE); if ($xmlSheet->protectedRanges->protectedRange) { foreach ($xmlSheet->protectedRanges->protectedRange as $protectedRange) { $docSheet->protectCells((string) $protectedRange["sqref"], (string) $protectedRange["password"], true); } } } if ($xmlSheet && $xmlSheet->autoFilter && !$this->_readDataOnly) { $autoFilter = $docSheet->getAutoFilter(); $autoFilter->setRange((string) $xmlSheet->autoFilter["ref"]); foreach ($xmlSheet->autoFilter->filterColumn as $filterColumn) { $column = $autoFilter->getColumnByOffset((int) $filterColumn["colId"]); // Check for standard filters if ($filterColumn->filters) { $column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER); $filters = $filterColumn->filters; if (isset($filters["blank"]) && $filters["blank"] == 1) { $column->createRule()->setRule(NULL, '')->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER); } // Standard filters are always an OR join, so no join rule needs to be set // Entries can be either filter elements foreach ($filters->filter as $filterRule) { $column->createRule()->setRule(NULL, (string) $filterRule["val"])->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER); } // Or Date Group elements foreach ($filters->dateGroupItem as $dateGroupItem) { $column->createRule()->setRule(NULL, array('year' => (string) $dateGroupItem["year"], 'month' => (string) $dateGroupItem["month"], 'day' => (string) $dateGroupItem["day"], 'hour' => (string) $dateGroupItem["hour"], 'minute' => (string) $dateGroupItem["minute"], 'second' => (string) $dateGroupItem["second"]), (string) $dateGroupItem["dateTimeGrouping"])->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP); } } // Check for custom filters if ($filterColumn->customFilters) { $column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER); $customFilters = $filterColumn->customFilters; // Custom filters can an AND or an OR join; // and there should only ever be one or two entries if (isset($customFilters["and"]) && $customFilters["and"] == 1) { $column->setJoin(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND); } foreach ($customFilters->customFilter as $filterRule) { $column->createRule()->setRule((string) $filterRule["operator"], (string) $filterRule["val"])->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); } } // Check for dynamic filters if ($filterColumn->dynamicFilter) { $column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER); // We should only ever have one dynamic filter foreach ($filterColumn->dynamicFilter as $filterRule) { $column->createRule()->setRule(NULL, (string) $filterRule["val"], (string) $filterRule["type"])->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER); if (isset($filterRule["val"])) { $column->setAttribute('val', (string) $filterRule["val"]); } if (isset($filterRule["maxVal"])) { $column->setAttribute('maxVal', (string) $filterRule["maxVal"]); } } } // Check for dynamic filters if ($filterColumn->top10) { $column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER); // We should only ever have one top10 filter foreach ($filterColumn->top10 as $filterRule) { $column->createRule()->setRule(isset($filterRule["percent"]) && $filterRule["percent"] == 1 ? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT : PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE, (string) $filterRule["val"], isset($filterRule["top"]) && $filterRule["top"] == 1 ? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP : PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM)->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_TOPTENFILTER); } } } } if ($xmlSheet && $xmlSheet->mergeCells && $xmlSheet->mergeCells->mergeCell && !$this->_readDataOnly) { foreach ($xmlSheet->mergeCells->mergeCell as $mergeCell) { $mergeRef = (string) $mergeCell["ref"]; if (strpos($mergeRef, ':') !== FALSE) { $docSheet->mergeCells((string) $mergeCell["ref"]); } } } if ($xmlSheet && $xmlSheet->pageMargins && !$this->_readDataOnly) { $docPageMargins = $docSheet->getPageMargins(); $docPageMargins->setLeft(floatval($xmlSheet->pageMargins["left"])); $docPageMargins->setRight(floatval($xmlSheet->pageMargins["right"])); $docPageMargins->setTop(floatval($xmlSheet->pageMargins["top"])); $docPageMargins->setBottom(floatval($xmlSheet->pageMargins["bottom"])); $docPageMargins->setHeader(floatval($xmlSheet->pageMargins["header"])); $docPageMargins->setFooter(floatval($xmlSheet->pageMargins["footer"])); } if ($xmlSheet && $xmlSheet->pageSetup && !$this->_readDataOnly) { $docPageSetup = $docSheet->getPageSetup(); if (isset($xmlSheet->pageSetup["orientation"])) { $docPageSetup->setOrientation((string) $xmlSheet->pageSetup["orientation"]); } if (isset($xmlSheet->pageSetup["paperSize"])) { $docPageSetup->setPaperSize(intval($xmlSheet->pageSetup["paperSize"])); } if (isset($xmlSheet->pageSetup["scale"])) { $docPageSetup->setScale(intval($xmlSheet->pageSetup["scale"]), FALSE); } if (isset($xmlSheet->pageSetup["fitToHeight"]) && intval($xmlSheet->pageSetup["fitToHeight"]) >= 0) { $docPageSetup->setFitToHeight(intval($xmlSheet->pageSetup["fitToHeight"]), FALSE); } if (isset($xmlSheet->pageSetup["fitToWidth"]) && intval($xmlSheet->pageSetup["fitToWidth"]) >= 0) { $docPageSetup->setFitToWidth(intval($xmlSheet->pageSetup["fitToWidth"]), FALSE); } if (isset($xmlSheet->pageSetup["firstPageNumber"]) && isset($xmlSheet->pageSetup["useFirstPageNumber"]) && self::boolean((string) $xmlSheet->pageSetup["useFirstPageNumber"])) { $docPageSetup->setFirstPageNumber(intval($xmlSheet->pageSetup["firstPageNumber"])); } } if ($xmlSheet && $xmlSheet->headerFooter && !$this->_readDataOnly) { $docHeaderFooter = $docSheet->getHeaderFooter(); if (isset($xmlSheet->headerFooter["differentOddEven"]) && self::boolean((string) $xmlSheet->headerFooter["differentOddEven"])) { $docHeaderFooter->setDifferentOddEven(TRUE); } else { $docHeaderFooter->setDifferentOddEven(FALSE); } if (isset($xmlSheet->headerFooter["differentFirst"]) && self::boolean((string) $xmlSheet->headerFooter["differentFirst"])) { $docHeaderFooter->setDifferentFirst(TRUE); } else { $docHeaderFooter->setDifferentFirst(FALSE); } if (isset($xmlSheet->headerFooter["scaleWithDoc"]) && !self::boolean((string) $xmlSheet->headerFooter["scaleWithDoc"])) { $docHeaderFooter->setScaleWithDocument(FALSE); } else { $docHeaderFooter->setScaleWithDocument(TRUE); } if (isset($xmlSheet->headerFooter["alignWithMargins"]) && !self::boolean((string) $xmlSheet->headerFooter["alignWithMargins"])) { $docHeaderFooter->setAlignWithMargins(FALSE); } else { $docHeaderFooter->setAlignWithMargins(TRUE); } $docHeaderFooter->setOddHeader((string) $xmlSheet->headerFooter->oddHeader); $docHeaderFooter->setOddFooter((string) $xmlSheet->headerFooter->oddFooter); $docHeaderFooter->setEvenHeader((string) $xmlSheet->headerFooter->evenHeader); $docHeaderFooter->setEvenFooter((string) $xmlSheet->headerFooter->evenFooter); $docHeaderFooter->setFirstHeader((string) $xmlSheet->headerFooter->firstHeader); $docHeaderFooter->setFirstFooter((string) $xmlSheet->headerFooter->firstFooter); } if ($xmlSheet && $xmlSheet->rowBreaks && $xmlSheet->rowBreaks->brk && !$this->_readDataOnly) { foreach ($xmlSheet->rowBreaks->brk as $brk) { if ($brk["man"]) { $docSheet->setBreak("A{$brk['id']}", PHPExcel_Worksheet::BREAK_ROW); } } } if ($xmlSheet && $xmlSheet->colBreaks && $xmlSheet->colBreaks->brk && !$this->_readDataOnly) { foreach ($xmlSheet->colBreaks->brk as $brk) { if ($brk["man"]) { $docSheet->setBreak(PHPExcel_Cell::stringFromColumnIndex((string) $brk["id"]) . "1", PHPExcel_Worksheet::BREAK_COLUMN); } } } if ($xmlSheet && $xmlSheet->dataValidations && !$this->_readDataOnly) { foreach ($xmlSheet->dataValidations->dataValidation as $dataValidation) { // Uppercase coordinate $range = strtoupper($dataValidation["sqref"]); $rangeSet = explode(' ', $range); foreach ($rangeSet as $range) { $stRange = $docSheet->shrinkRangeToFit($range); // Extract all cell references in $range $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($stRange); foreach ($aReferences as $reference) { // Create validation $docValidation = $docSheet->getCell($reference)->getDataValidation(); $docValidation->setType((string) $dataValidation["type"]); $docValidation->setErrorStyle((string) $dataValidation["errorStyle"]); $docValidation->setOperator((string) $dataValidation["operator"]); $docValidation->setAllowBlank($dataValidation["allowBlank"] != 0); $docValidation->setShowDropDown($dataValidation["showDropDown"] == 0); $docValidation->setShowInputMessage($dataValidation["showInputMessage"] != 0); $docValidation->setShowErrorMessage($dataValidation["showErrorMessage"] != 0); $docValidation->setErrorTitle((string) $dataValidation["errorTitle"]); $docValidation->setError((string) $dataValidation["error"]); $docValidation->setPromptTitle((string) $dataValidation["promptTitle"]); $docValidation->setPrompt((string) $dataValidation["prompt"]); $docValidation->setFormula1((string) $dataValidation->formula1); $docValidation->setFormula2((string) $dataValidation->formula2); } } } } // Add hyperlinks $hyperlinks = array(); if (!$this->_readDataOnly) { // Locate hyperlink relations 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"); foreach ($relsWorksheet->Relationship as $ele) { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink") { $hyperlinks[(string) $ele["Id"]] = (string) $ele["Target"]; } } } // Loop through hyperlinks if ($xmlSheet && $xmlSheet->hyperlinks) { foreach ($xmlSheet->hyperlinks->hyperlink as $hyperlink) { // Link url $linkRel = $hyperlink->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'); foreach (PHPExcel_Cell::extractAllCellReferencesInRange($hyperlink['ref']) as $cellReference) { $cell = $docSheet->getCell($cellReference); if (isset($linkRel['id'])) { $hyperlinkUrl = $hyperlinks[(string) $linkRel['id']]; if (isset($hyperlink['location'])) { $hyperlinkUrl .= '#' . (string) $hyperlink['location']; } $cell->getHyperlink()->setUrl($hyperlinkUrl); } elseif (isset($hyperlink['location'])) { $cell->getHyperlink()->setUrl('sheet://' . (string) $hyperlink['location']); } // Tooltip if (isset($hyperlink['tooltip'])) { $cell->getHyperlink()->setTooltip((string) $hyperlink['tooltip']); } } } } } // Add comments $comments = array(); $vmlComments = array(); if (!$this->_readDataOnly) { // Locate comment relations 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"); foreach ($relsWorksheet->Relationship as $ele) { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments") { $comments[(string) $ele["Id"]] = (string) $ele["Target"]; } if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing") { $vmlComments[(string) $ele["Id"]] = (string) $ele["Target"]; } } } // Loop through comments foreach ($comments as $relName => $relPath) { // Load comments file $relPath = PHPExcel_Shared_File::realpath(dirname("{$dir}/{$fileWorksheet}") . "/" . $relPath); $commentsFile = simplexml_load_string($this->_getFromZipArchive($zip, $relPath)); // Utility variables $authors = array(); // Loop through authors foreach ($commentsFile->authors->author as $author) { $authors[] = (string) $author; } // Loop through contents foreach ($commentsFile->commentList->comment as $comment) { $docSheet->getComment((string) $comment['ref'])->setAuthor($authors[(string) $comment['authorId']]); $docSheet->getComment((string) $comment['ref'])->setText($this->_parseRichText($comment->text)); } } // Loop through VML comments foreach ($vmlComments as $relName => $relPath) { // Load VML comments file $relPath = PHPExcel_Shared_File::realpath(dirname("{$dir}/{$fileWorksheet}") . "/" . $relPath); $vmlCommentsFile = simplexml_load_string($this->_getFromZipArchive($zip, $relPath)); $vmlCommentsFile->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); $shapes = $vmlCommentsFile->xpath('//v:shape'); foreach ($shapes as $shape) { $shape->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); if (isset($shape['style'])) { $style = (string) $shape['style']; $fillColor = strtoupper(substr((string) $shape['fillcolor'], 1)); $column = null; $row = null; $clientData = $shape->xpath('.//x:ClientData'); if (is_array($clientData) && !empty($clientData)) { $clientData = $clientData[0]; if (isset($clientData['ObjectType']) && (string) $clientData['ObjectType'] == 'Note') { $temp = $clientData->xpath('.//x:Row'); if (is_array($temp)) { $row = $temp[0]; } $temp = $clientData->xpath('.//x:Column'); if (is_array($temp)) { $column = $temp[0]; } } } if ($column !== NULL && $row !== NULL) { // Set comment properties $comment = $docSheet->getCommentByColumnAndRow((string) $column, $row + 1); $comment->getFillColor()->setRGB($fillColor); // Parse style $styleArray = explode(';', str_replace(' ', '', $style)); foreach ($styleArray as $stylePair) { $stylePair = explode(':', $stylePair); if ($stylePair[0] == 'margin-left') { $comment->setMarginLeft($stylePair[1]); } if ($stylePair[0] == 'margin-top') { $comment->setMarginTop($stylePair[1]); } if ($stylePair[0] == 'width') { $comment->setWidth($stylePair[1]); } if ($stylePair[0] == 'height') { $comment->setHeight($stylePair[1]); } if ($stylePair[0] == 'visibility') { $comment->setVisible($stylePair[1] == 'visible'); } } } } } } // Header/footer images if ($xmlSheet && $xmlSheet->legacyDrawingHF && !$this->_readDataOnly) { 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"); $vmlRelationship = ''; foreach ($relsWorksheet->Relationship as $ele) { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing") { $vmlRelationship = self::dir_add("{$dir}/{$fileWorksheet}", $ele["Target"]); } } 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://" . PHPExcel_Shared_File::realpath($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); } } } } // TODO: Autoshapes from twoCellAnchors! 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"]); } elseif ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart") { if ($this->_includeCharts) { $charts[self::dir_add($fileDrawing, $ele["Target"])] = array('id' => (string) $ele["Id"], 'sheet' => $docSheet->getTitle()); } } } } $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://" . PHPExcel_Shared_File::realpath($pFilename) . "#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false); $objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex((string) $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); } else { // ? Can charts be positioned with a oneCellAnchor ? $coordinates = PHPExcel_Cell::stringFromColumnIndex((string) $oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1); $offsetX = PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff); $offsetY = PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->rowOff); $width = PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cx")); $height = PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cy")); } } } 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://" . PHPExcel_Shared_File::realpath($pFilename) . "#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false); $objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1)); $objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff)); $objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff)); $objDrawing->setResizeProportional(false); $objDrawing->setWidth(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($xfrm->ext->attributes(), "cx"))); $objDrawing->setHeight(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($xfrm->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); } elseif ($this->_includeCharts && $twoCellAnchor->graphicFrame) { $fromCoordinate = PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1); $fromOffsetX = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff); $fromOffsetY = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff); $toCoordinate = PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->to->col) . ($twoCellAnchor->to->row + 1); $toOffsetX = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->to->colOff); $toOffsetY = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->to->rowOff); $graphic = $twoCellAnchor->graphicFrame->children("http://schemas.openxmlformats.org/drawingml/2006/main")->graphic; $chartRef = $graphic->graphicData->children("http://schemas.openxmlformats.org/drawingml/2006/chart")->chart; $thisChart = (string) $chartRef->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"); $chartDetails[$docSheet->getTitle() . '!' . $thisChart] = array('fromCoordinate' => $fromCoordinate, 'fromOffsetX' => $fromOffsetX, 'fromOffsetY' => $fromOffsetY, 'toCoordinate' => $toCoordinate, 'toOffsetX' => $toOffsetX, 'toOffsetY' => $toOffsetY, 'worksheetTitle' => $docSheet->getTitle()); } } } } } } // Loop through definedNames if ($xmlWorkbook->definedNames) { foreach ($xmlWorkbook->definedNames->definedName as $definedName) { // Extract range $extractedRange = (string) $definedName; $extractedRange = preg_replace('/\'(\\w+)\'\\!/', '', $extractedRange); if (($spos = strpos($extractedRange, '!')) !== false) { $extractedRange = substr($extractedRange, 0, $spos) . str_replace('$', '', substr($extractedRange, $spos)); } else { $extractedRange = str_replace('$', '', $extractedRange); } // Valid range? if (stripos((string) $definedName, '#REF!') !== FALSE || $extractedRange == '') { continue; } // Some definedNames are only applicable if we are on the same sheet... if ((string) $definedName['localSheetId'] != '' && (string) $definedName['localSheetId'] == $sheetId) { // Switch on type switch ((string) $definedName['name']) { case '_xlnm._FilterDatabase': if ((string) $definedName['hidden'] !== '1') { $docSheet->getAutoFilter()->setRange($extractedRange); } break; case '_xlnm.Print_Titles': // Split $extractedRange $extractedRange = explode(',', $extractedRange); // Set print titles foreach ($extractedRange as $range) { $matches = array(); // check for repeating columns, e g. 'A:A' or 'A:D' if (preg_match('/^([A-Z]+)\\:([A-Z]+)$/', $range, $matches)) { $docSheet->getPageSetup()->setColumnsToRepeatAtLeft(array($matches[1], $matches[2])); } elseif (preg_match('/^(\\d+)\\:(\\d+)$/', $range, $matches)) { $docSheet->getPageSetup()->setRowsToRepeatAtTop(array($matches[1], $matches[2])); } } break; case '_xlnm.Print_Area': $rangeSets = explode(',', $extractedRange); // FIXME: what if sheetname contains comma? $newRangeSets = array(); foreach ($rangeSets as $rangeSet) { $range = explode('!', $rangeSet); // FIXME: what if sheetname contains exclamation mark? $rangeSet = isset($range[1]) ? $range[1] : $range[0]; if (strpos($rangeSet, ':') === FALSE) { $rangeSet = $rangeSet . ':' . $rangeSet; } $newRangeSets[] = str_replace('$', '', $rangeSet); } $docSheet->getPageSetup()->setPrintArea(implode(',', $newRangeSets)); break; default: break; } } } } // Next sheet id ++$sheetId; } // Loop through definedNames if ($xmlWorkbook->definedNames) { foreach ($xmlWorkbook->definedNames->definedName as $definedName) { // Extract range $extractedRange = (string) $definedName; $extractedRange = preg_replace('/\'(\\w+)\'\\!/', '', $extractedRange); if (($spos = strpos($extractedRange, '!')) !== false) { $extractedRange = substr($extractedRange, 0, $spos) . str_replace('$', '', substr($extractedRange, $spos)); } else { $extractedRange = str_replace('$', '', $extractedRange); } // Valid range? if (stripos((string) $definedName, '#REF!') !== false || $extractedRange == '') { continue; } // Some definedNames are only applicable if we are on the same sheet... if ((string) $definedName['localSheetId'] != '') { // Local defined name // Switch on type switch ((string) $definedName['name']) { case '_xlnm._FilterDatabase': case '_xlnm.Print_Titles': case '_xlnm.Print_Area': break; default: if ($mapSheetId[(int) $definedName['localSheetId']] !== null) { $range = explode('!', (string) $definedName); if (count($range) == 2) { $range[0] = str_replace("''", "'", $range[0]); $range[0] = str_replace("'", "", $range[0]); if ($worksheet = $docSheet->getParent()->getSheetByName($range[0])) { $extractedRange = str_replace('$', '', $range[1]); $scope = $docSheet->getParent()->getSheet($mapSheetId[(int) $definedName['localSheetId']]); $excel->addNamedRange(new PHPExcel_NamedRange((string) $definedName['name'], $worksheet, $extractedRange, true, $scope)); } } } break; } } else { if (!isset($definedName['localSheetId'])) { // "Global" definedNames $locatedSheet = null; $extractedSheetName = ''; if (strpos((string) $definedName, '!') !== false) { // Extract sheet name $extractedSheetName = PHPExcel_Worksheet::extractSheetTitle((string) $definedName, true); $extractedSheetName = $extractedSheetName[0]; // Locate sheet $locatedSheet = $excel->getSheetByName($extractedSheetName); // Modify range $range = explode('!', $extractedRange); $extractedRange = isset($range[1]) ? $range[1] : $range[0]; } if ($locatedSheet !== NULL) { $excel->addNamedRange(new PHPExcel_NamedRange((string) $definedName['name'], $locatedSheet, $extractedRange, false)); } } } } } } if (!$this->_readDataOnly || !empty($this->_loadSheetsOnly)) { // active sheet index $activeTab = intval($xmlWorkbook->bookViews->workbookView["activeTab"]); // refers to old sheet index // keep active sheet index if sheet is still loaded, else first sheet is set as the active if (isset($mapSheetId[$activeTab]) && $mapSheetId[$activeTab] !== null) { $excel->setActiveSheetIndex($mapSheetId[$activeTab]); } else { if ($excel->getSheetCount() == 0) { $excel->createSheet(); } $excel->setActiveSheetIndex(0); } } break; } } if (!$this->_readDataOnly) { $contentTypes = simplexml_load_string($this->_getFromZipArchive($zip, "[Content_Types].xml")); foreach ($contentTypes->Override as $contentType) { switch ($contentType["ContentType"]) { case "application/vnd.openxmlformats-officedocument.drawingml.chart+xml": if ($this->_includeCharts) { $chartEntryRef = ltrim($contentType['PartName'], '/'); $chartElements = simplexml_load_string($this->_getFromZipArchive($zip, $chartEntryRef)); $objChart = PHPExcel_Reader_Excel2007_Chart::readChart($chartElements, basename($chartEntryRef, '.xml')); // echo 'Chart ',$chartEntryRef,'<br />'; // var_dump($charts[$chartEntryRef]); // if (isset($charts[$chartEntryRef])) { $chartPositionRef = $charts[$chartEntryRef]['sheet'] . '!' . $charts[$chartEntryRef]['id']; // echo 'Position Ref ',$chartPositionRef,'<br />'; if (isset($chartDetails[$chartPositionRef])) { // var_dump($chartDetails[$chartPositionRef]); $excel->getSheetByName($charts[$chartEntryRef]['sheet'])->addChart($objChart); $objChart->setWorksheet($excel->getSheetByName($charts[$chartEntryRef]['sheet'])); $objChart->setTopLeftPosition($chartDetails[$chartPositionRef]['fromCoordinate'], $chartDetails[$chartPositionRef]['fromOffsetX'], $chartDetails[$chartPositionRef]['fromOffsetY']); $objChart->setBottomRightPosition($chartDetails[$chartPositionRef]['toCoordinate'], $chartDetails[$chartPositionRef]['toOffsetX'], $chartDetails[$chartPositionRef]['toOffsetY']); } } } } } } $zip->close(); return $excel; }
$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);
public function almacenes_xlsx($params = array(), $save = false) { //print_debug($params['headers']); $headers_pasillos = array_key_exists('headers_pasillos', $params) ? $params['headers_pasillos'] : false; $items_pasillo = array_key_exists('items_pasillo', $params) ? $params['items_pasillo'] : false; $headers_gabetas = array_key_exists('headers_gabetas', $params) ? $params['headers_gabetas'] : false; $items_gabeta = array_key_exists('items_gabeta', $params) ? $params['items_gabeta'] : false; $title = array_key_exists('title', $params) ? $params['title'] : 'IS_XLSX'; $headers = array_key_exists('headers', $params) ? $params['headers'] : false; $items = array_key_exists('items', $params) ? $params['items'] : false; //print_debug($headers); if ($headers && $items) { $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()); $countHeaders = count($params['headers']) + 66; $column = chr($countHeaders) . '3'; $countHeadersPasillo = count($params['headers_pasillos']) + 64; $columnPasillo = chr($countHeadersPasillo) . '6'; $countHeadersGabeta = count($params['headers_gabetas']) + 68; $columnGabeta = chr($countHeadersGabeta) . '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:G1")->applyFromArray($this->defaultStyle_headers()); $objPHPExcel->getActiveSheet()->setCellValue('E1', $title); $objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->getActiveSheet()->fromArray($params['headers'], null, 'A3'); $objPHPExcel->getActiveSheet()->getStyle("A3:E3")->applyFromArray($this->defaultStyle_headers()); $objPHPExcel->getActiveSheet()->fromArray($params['headers_pasillos'], null, 'A6'); $objPHPExcel->getActiveSheet()->getStyle("A6:{$columnPasillo}")->applyFromArray($this->defaultStyle_headers()); $objPHPExcel->getActiveSheet()->fromArray($params['headers_gabetas'], null, 'E6'); $objPHPExcel->getActiveSheet()->getStyle("E6:{$columnGabeta}")->applyFromArray($this->defaultStyle_headers()); foreach (range('A', $column) as $columnID) { $objPHPExcel->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true); } foreach (range('A', $columnPasillo) as $columnID) { $objPHPExcel->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true); } foreach (range('E', $columnPasillo) as $columnID) { $objPHPExcel->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true); } $items = $objPHPExcel->getActiveSheet()->fromArray($params['items'], null, 'A4'); $objPHPExcel->setActiveSheetIndex(0); $items_pasillo = $objPHPExcel->getActiveSheet()->fromArray($params['items_pasillo'], null, 'A7'); $objPHPExcel->setActiveSheetIndex(0); $items_pasillo = $objPHPExcel->getActiveSheet()->fromArray($params['items_gabeta'], null, 'E7'); $objPHPExcel->setActiveSheetIndex(0); if ($save) { $pathfile = 'assets/docs/' . $title . '.xlsx'; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); rename(APPPATH . 'libraries/excel.xlsx', $pathfile); return $pathfile; } else { header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="' . $title . '.xlsx"'); ob_end_clean(); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save('php://output'); exit; } } else { redirect('override_404'); } }
$vs_column = reset($va_a_to_z); $va_supercol_a_to_z = range('A', 'Z'); $vs_supercol = ''; // default to automatic row height. works pretty well in Excel but not so much in LibreOffice/OOo :-( $o_sheet->getRowDimension($vn_line)->setRowHeight(-1); foreach ($va_display_list as $vn_placement_id => $va_info) { if (strpos($va_info['bundle_name'], 'ca_object_representations.media') !== false && $va_info['settings']['display_mode'] == 'media') { $vs_version = str_replace("ca_object_representations.media.", "", $va_info['bundle_name']); $va_info = $vo_result->getMediaInfo('ca_object_representations.media', $vs_version); if ($va_info['MIMETYPE'] == 'image/jpeg') { // don't try to insert anything non-jpeg into an Excel file if (is_file($vs_path = $vo_result->getMediaPath('ca_object_representations.media', $vs_version))) { $image = "image" . $vs_supercol . $vs_column . $vn_line; $drawing = new PHPExcel_Worksheet_Drawing(); $drawing->setName($image); $drawing->setDescription($image); $drawing->setPath($vs_path); $drawing->setCoordinates($vs_supercol . $vs_column . $vn_line); $drawing->setWorksheet($o_sheet); $drawing->setOffsetX(10); $drawing->setOffsetY(10); } $vn_width = floor(intval($va_info['PROPERTIES']['width']) * $vn_ratio_pixels_to_excel_width); $vn_height = floor(intval($va_info['PROPERTIES']['height']) * $vn_ratio_pixels_to_excel_height); // set the calculated withs for the current row and column, // but make sure we don't make either smaller than they already are if ($vn_width > $o_sheet->getColumnDimension($vs_supercol . $vs_column)->getWidth()) { $o_sheet->getColumnDimension($vs_supercol . $vs_column)->setWidth($vn_width); } if ($vn_height > $o_sheet->getRowDimension($vn_line)->getRowHeight()) { $o_sheet->getRowDimension($vn_line)->setRowHeight($vn_height);
public function generate_xls($products_array, $add_images, $add_description) { require_once "additional_libraries/Classes/PHPExcel.php"; $objPHPExcel = new PHPExcel(); $objPHPExcel->getProperties()->setCreator("user")->setLastModifiedBy("username")->setTitle("Title")->setSubject("Название.")->setDescription("Описание")->setKeywords("php, all results")->setCategory("some category"); // Redirect output to a client’s web browser (Excel5) header('Content-Type: application/vnd.ms-excel'); //header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="export_' . date("Y-m-d H:i:s") . '.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'); $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(5); $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow('A', 1)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getStyle('B')->getNumberFormat()->setFormatCode('0000'); $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(50); $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setAutoSize(true); // setAutoSize(true); if ($add_description == 1) { $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(60); } if ($add_images == 1) { $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(100); } $objPHPExcel->getActiveSheet()->setCellValue('A1', '№')->setCellValue('B1', 'Артикул')->setCellValue('C1', 'Название')->setCellValue('D1', 'Цена'); if ($add_description == 1) { $objPHPExcel->getActiveSheet()->setCellValue('E1', 'Описание'); } if ($add_images == 1) { $objPHPExcel->getActiveSheet()->setCellValue('F1', 'Изображение'); } $row_count = 2; $img_max_width = 0; foreach ($products_array as $data) { $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $row_count, $row_count - 1); $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow(0, $row_count)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER)->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP); $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, $row_count, $data['sku']); $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow(1, $row_count)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER)->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP); $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, $row_count, $data['name']); $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow(2, $row_count)->getAlignment()->setWrapText(true)->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP); $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(3, $row_count, ltrim(rtrim($data['prices']), "\n")); $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow(3, $row_count)->getAlignment()->setWrapText(true)->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP); if ($add_description == 1) { $description = strip_tags($data['short_description']); $description = trim($description); $description = html_entity_decode($description); $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $row_count, $description); $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow(4, $row_count)->getAlignment()->setWrapText(true)->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP); } if ($add_images == 1) { if (isset($data['img'])) { foreach ($data['img'] as $img) { $objDrawing = new PHPExcel_Worksheet_Drawing(); $objDrawing->setName('pr_img'); $objDrawing->setDescription('img'); $objDrawing->setPath('.' . $img); $objDrawing->setCoordinates('F' . $row_count); $objDrawing->setWorksheet($objPHPExcel->getActiveSheet()); // 12 пунктов * (96/72) = 16 пикселей. $img_size = getimagesize('.' . $img); if ($img_size[0] > $img_max_width) { $img_max_width = $img_size[0]; } if ($objPHPExcel->getActiveSheet()->getRowDimension($row_count)->getRowHeight() < $img_size[1] / (96 / 72)) { $objPHPExcel->getActiveSheet()->getRowDimension($row_count)->setRowHeight($img_size[1] / (96 / 72)); } } } } $row_count++; } if ($add_images == 1) { $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth($img_max_width * 9.140625 / 64); } $objPHPExcel->getActiveSheet()->setTitle('Результат поиска'); $objPHPExcel->setActiveSheetIndex(0); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save('php://output'); return true; }
public function postAction() { $post = $this->getRequest()->getPost(); if ($post['file_type'] == 'csv') { $dir = $post['filetype'] . '_' . date('Y-m-d'); mkdir('image/' . $dir, 0777); $name = $dir . '.csv'; header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename=csv/' . $name); header('Pragma: no-cache'); header("Expires: 0"); touch('/csv'); chmod('/csv', 0777); define('SAVE_FEED_LOCATION', 'csv/' . $name); set_time_limit(1800); try { $handle = fopen(SAVE_FEED_LOCATION, 'w'); $heading = array('STYLE NUMBER', 'STYLE NAME', 'LONG DESCRIPTION', 'GENDER', 'IMAGES PROVIDED', 'IMAGE FILENAME', 'COMPOSITION: STONES', 'COMPOSITION: SETTING', 'COMPOSITION: OTHER', 'SECONDARY COLOR', 'STONE CUT', 'CLARITY', 'COLOUR', 'SETTING TYPE', 'RING SIZE 6', 'RING SIZE 7', 'RING SIZE 7.5', 'RING SIZE 8', 'RING SIZE 8.5', 'RING SIZE 9', 'RING SIZE 9.5', 'RING SIZE 10', 'RING SIZE 10.5', 'RING SIZE 11', 'RING SIZE 11.5', 'RING SIZE 12', 'RING SIZE 12.5', 'RING SIZE 13', 'LENGTH', 'HEIGHT', 'WIDTH', 'SPECIAL CARE', 'MADE IN "COUNTRY"', 'WHOLESALE', 'RETAIL', 'SPECIAL PRICE', 'INVENTORY'); $feed_line = implode(",", $heading) . "\r\n"; fwrite($handle, $feed_line); $products = Mage::getModel('catalog/product')->getCollection(); $products->addAttributeToSelect('*'); $prodIds = $products->getAllIds(); $product = Mage::getModel('catalog/product'); $counter_test = 0; foreach ($post['id'] as $productId) { if (++$counter_test < 30000) { $product->load($productId); $product_data = array(); $product_data['style_number'] = str_replace('"', '""', $product->getSku()); $product_data['style_name'] = $product->getName(); $product_data['description'] = htmlspecialchars(iconv("UTF-8", "UTF-8//IGNORE", $product->getDescription())); $product_data['gender'] = $product->getResource()->getAttribute('filter_for')->getFrontend()->getValue($product); if ($product->getImage()) { if ($product->getImage() == 'no_selection') { $product_data['image_provided'] = 'No'; } else { $product_data['image_provided'] = 'Yes'; } } else { $product_data['image_provided'] = 'No'; } if ($product->getImage() == 'no_selection') { $product_data['image_link'] = ''; } else { $product_data['image_link'] = $product->getImage(); } $image_break = explode("/", $product->getImage()); $imagename = end($image_break); $file = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product' . $product->getImage(); $newfile = 'image/' . $dir . '/' . $imagename; if (!copy($file, $newfile)) { echo "failed to copy {$file}...\n"; } $product_data['stone'] = $product->getAttributeText('product_stones'); $product_data['setting'] = ''; $product_data['other'] = ''; $product_data['s_color'] = ''; $product_data['stone_cut'] = ''; $product_data['clarity'] = ''; $product_data['color'] = $product->getAttributeText('product_color'); $product_data['setting_type'] = ''; $product_data['ring_size6'] = ''; $product_data['ring_size7'] = ''; $product_data['ring_size75'] = ''; $product_data['ring_size8'] = ''; $product_data['ring_size85'] = ''; $product_data['ring_size9'] = ''; $product_data['ring_size95'] = ''; $product_data['ring_size10'] = ''; $product_data['ring_size105'] = ''; $product_data['ring_size11'] = ''; $product_data['ring_size115'] = ''; $product_data['ring_size12'] = ''; $product_data['ring_size125'] = ''; $product_data['ring_size13'] = ''; $product_data['length'] = str_replace('"', '""', $product->getLengthDimensions()); $product_data['height'] = str_replace('"', '""', $product->getHeightDimensions()); $product_data['width'] = str_replace('"', '""', $product->getWidthDimensions()); $product_data['special_care'] = ''; $product_data['made_in'] = ''; $product->setCustomerGroupId(2); if (number_format($product->getPriceModel()->getFinalPrice(1, $product), 2) == number_format($product->getPrice(), 2)) { $product_data['wholesale'] = ''; } else { $product_data['wholesale'] = number_format($product->getPriceModel()->getFinalPrice(1, $product), 2); } $price_temp = round($product->getPrice(), 2); $product_data['price'] = round($product->getPrice(), 2); if ($product->getSpecialPrice() == '') { $product_data['special_price'] = ''; } else { $product_data['special_price'] = number_format($product->getSpecialPrice(), 2); } $product_data['qty'] = $product->getStockItem()->getQty(); foreach ($product_data as $k => $val) { $product_data[$k] = '"' . $val . '"'; } $feed_line = implode(",", $product_data) . "\r\n"; fwrite($handle, $feed_line); fflush($handle); } } fclose($handle); $dir12 = 'image/' . $dir; $archive = 'csv/' . $dir . '.zip'; $zip = new ZipArchive(); $zip->open($archive, ZipArchive::CREATE); $files = scandir($dir12); unset($files[0], $files[1]); foreach ($files as $file) { $zip->addFile($dir12 . '/' . $file); } $zip->close(); header('Content-Type: application/zip'); header('Content-disposition: attachment; filename=' . $archive); header('Content-Length: ' . filesize($archive)); $dirPath = 'image/' . $dir; if (!is_dir($dirPath)) { throw new InvalidArgumentException("{$dirPath} must be a directory"); } if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') { $dirPath .= '/'; } $files = glob($dirPath . '*', GLOB_MARK); foreach ($files as $file) { if (is_dir($file)) { self::deleteDir($file); } else { unlink($file); } } rmdir($dirPath); } catch (Exception $e) { die($e->getMessage()); } } if ($post['file_type'] == 'xls') { error_reporting(E_ALL); /** Include PHPExcel */ require_once 'Classes/PHPExcel.php'; // Create new PHPExcel object //echo date('H:i:s') , " Create new PHPExcel object" , EOL; $objPHPExcel = new PHPExcel(); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE); define('EOL', PHP_SAPI == 'cli' ? PHP_EOL : '<br />'); date_default_timezone_set('Europe/London'); /** Include PHPExcel_IOFactory */ require_once 'Classes/PHPExcel/IOFactory.php'; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); //********* CUSTOM CODE **************************** // Create a first sheet, representing sales data //echo date('H:i:s') , " Add some data" , EOL; $objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->getActiveSheet()->getCell('B1')->setValue("500 Sauve West\nMontreal, Quebec\nCanada\nH3L 1Z8"); $objPHPExcel->getActiveSheet()->getStyle('B1')->getAlignment()->setWrapText(true); $objPHPExcel->getActiveSheet()->getCell('C1')->setValue("info@italgemjewellers.com\nTel (514) 388-5777\nFax (514) 384-5777"); $objPHPExcel->getActiveSheet()->getStyle('C1')->getAlignment()->setWrapText(true); // Merge cells //echo date('H:i:s') , " Merge cells" , EOL; $objPHPExcel->getActiveSheet()->mergeCells('F1:G1'); $objPHPExcel->getActiveSheet()->getCell('F1')->setValue("Quotation preparred for \nClientABCD"); $objPHPExcel->getActiveSheet()->getStyle('F1')->getAlignment()->setWrapText(true); $objPHPExcel->getActiveSheet()->setCellValue('A3', 'STYLE CODE #'); $objPHPExcel->getActiveSheet()->setCellValue('B3', 'PICTURE'); $objPHPExcel->getActiveSheet()->setCellValue('C3', 'DESCRIPTION'); $objPHPExcel->getActiveSheet()->setCellValue('D3', 'RETAIL'); $objPHPExcel->getActiveSheet()->setCellValue('E3', 'WHOLE SALE PRICE'); $objPHPExcel->getActiveSheet()->setCellValue('F3', 'YOUR PRICE'); $objPHPExcel->getActiveSheet()->setCellValue('G3', 'Quanity '); // Set column widths //echo date('H:i:s') , " Set column widths" , EOL; $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(98); $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(40); $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(50); $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(80); $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(20); $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20); $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(20); $objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(20); // Set fonts //echo date('H:i:s') , " Set fonts" , EOL; $objPHPExcel->getActiveSheet()->getStyle("B1")->getFont()->setName('Times New Roman')->setSize(15)->getColor()->setRGB('000000'); $objPHPExcel->getActiveSheet()->getStyle("C1")->getFont()->setName('Times New Roman')->setSize(15)->getColor()->setRGB('000000'); $objPHPExcel->getActiveSheet()->getStyle("F1")->getFont()->setBold(true)->setName('Times New Roman')->setSize(18)->getColor()->setRGB('000000'); $objPHPExcel->getActiveSheet()->getStyle('B1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('C1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('F1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('F1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); // Set thin black border outline around column //echo date('H:i:s') , " Set thin black border outline around column" , EOL; $styleThinBlackBorderOutline = array('borders' => array('outline' => array('style' => PHPExcel_Style_Border::BORDER_THIN, 'color' => array('argb' => 'FF000000')))); $objPHPExcel->getActiveSheet()->getStyle('A1:D1')->applyFromArray($styleThinBlackBorderOutline); $objPHPExcel->getActiveSheet()->getStyle('G1')->applyFromArray($styleThinBlackBorderOutline); $objPHPExcel->getActiveSheet()->getStyle('A2')->applyFromArray($styleThinBlackBorderOutline); $objPHPExcel->getActiveSheet()->getStyle('B2')->applyFromArray($styleThinBlackBorderOutline); $objPHPExcel->getActiveSheet()->getStyle('C2')->applyFromArray($styleThinBlackBorderOutline); $objPHPExcel->getActiveSheet()->getStyle('D2')->applyFromArray($styleThinBlackBorderOutline); $objPHPExcel->getActiveSheet()->getStyle('E2')->applyFromArray($styleThinBlackBorderOutline); $objPHPExcel->getActiveSheet()->getStyle('F2')->applyFromArray($styleThinBlackBorderOutline); $objPHPExcel->getActiveSheet()->getStyle('G2')->applyFromArray($styleThinBlackBorderOutline); $objPHPExcel->getActiveSheet()->getStyle('A3')->applyFromArray($styleThinBlackBorderOutline); $objPHPExcel->getActiveSheet()->getStyle('B3')->applyFromArray($styleThinBlackBorderOutline); $objPHPExcel->getActiveSheet()->getStyle('C3')->applyFromArray($styleThinBlackBorderOutline); $objPHPExcel->getActiveSheet()->getStyle('D3')->applyFromArray($styleThinBlackBorderOutline); $objPHPExcel->getActiveSheet()->getStyle('E3')->applyFromArray($styleThinBlackBorderOutline); $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); //Extra Block $objPHPExcel->getActiveSheet()->getStyle('D' . $i)->applyFromArray($styleThinBlackBorderOutline); $objPHPExcel->getActiveSheet()->getStyle('E' . $i)->applyFromArray($styleThinBlackBorderOutline); $objPHPExcel->getActiveSheet()->getStyle('F' . $i)->applyFromArray($styleThinBlackBorderOutline); $objPHPExcel->getActiveSheet()->getStyle('G' . $i)->applyFromArray($styleThinBlackBorderOutline); //2 $objPHPExcel->getActiveSheet()->getStyle('B' . $i)->applyFromArray($styleThinBlackBorderOutline); $objDrawing = new PHPExcel_Worksheet_Drawing(); if (file_exists('./media/catalog/product' . $image_link)) { if ($product->getImage() == 'no_selection') { $objDrawing->setPath('./images/logo.png'); $objDrawing->setOffsetX(5); $objDrawing->setOffsetY(50); } else { $objDrawing->setPath('./media/catalog/product' . $image_link); $objDrawing->setOffsetX(5); $objDrawing->setOffsetY(5); } } else { $objDrawing->setPath('./images/logo.png'); $objDrawing->setOffsetX(5); $objDrawing->setOffsetY(50); } $objDrawing->setCoordinates('B' . $i); //$objDrawing->setHeight(190); //$objDrawing->setWidth(340); $objDrawing->setResizeProportional(true); $objDrawing->setWidthAndHeight(340, 210); $objDrawing->setWorksheet($objPHPExcel->getActiveSheet()); //3 Cell $objPHPExcel->getActiveSheet()->getStyle('C' . $i)->applyFromArray($styleThinBlackBorderOutline); $objPHPExcel->getActiveSheet()->setCellValue('C' . $i, $description); $objPHPExcel->getActiveSheet()->getStyle('C' . $i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('C' . $i)->getFont()->setName('Arial')->setSize(10)->getColor()->setRGB('000000'); $objPHPExcel->getActiveSheet()->getStyle('C' . $i)->getFont()->setBold(true); //4 Cell $objPHPExcel->getActiveSheet()->getStyle('D' . $i)->applyFromArray($styleThinBlackBorderOutline); if ($price_temp == '0') { $objPHPExcel->getActiveSheet()->setCellValue('D' . $i, ''); } else { $objPHPExcel->getActiveSheet()->getStyle('D' . $i)->getNumberFormat()->applyFromArray(array('code' => PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD)); $objPHPExcel->getActiveSheet()->setCellValue('D' . $i, $price_temp); } $objPHPExcel->getActiveSheet()->getStyle('D' . $i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('D' . $i)->getAlignment()->setIndent(9); $objPHPExcel->getActiveSheet()->getStyle('D' . $i)->getFont()->setName('Arial')->setSize(10)->getColor()->setRGB('000000'); $objPHPExcel->getActiveSheet()->getStyle('D' . $i)->getFont()->setBold(true); //5 Cell $objPHPExcel->getActiveSheet()->getStyle('E' . $i)->applyFromArray($styleThinBlackBorderOutline); if ($wholesale == $price_temp) { $objPHPExcel->getActiveSheet()->setCellValue('E' . $i, ''); } else { $objPHPExcel->getActiveSheet()->getStyle('E' . $i)->getNumberFormat()->applyFromArray(array('code' => PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD)); $objPHPExcel->getActiveSheet()->setCellValue('E' . $i, $wholesale); } $objPHPExcel->getActiveSheet()->getStyle('E' . $i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('E' . $i)->getAlignment()->setIndent(9); $objPHPExcel->getActiveSheet()->getStyle('E' . $i)->getFont()->setName('Arial')->setSize(10)->getColor()->setRGB('000000'); $objPHPExcel->getActiveSheet()->getStyle('E' . $i)->getFont()->setBold(true); //6 Cell $objPHPExcel->getActiveSheet()->getStyle('F' . $i)->applyFromArray($styleThinBlackBorderOutline); if ($special_price == '0') { $objPHPExcel->getActiveSheet()->setCellValue('F' . $i, ''); } else { $objPHPExcel->getActiveSheet()->getStyle('F' . $i)->getNumberFormat()->applyFromArray(array('code' => PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD)); $objPHPExcel->getActiveSheet()->setCellValue('F' . $i, $special_price); } $objPHPExcel->getActiveSheet()->getStyle('F' . $i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('F' . $i)->getAlignment()->setIndent(9); $objPHPExcel->getActiveSheet()->getStyle('F' . $i)->getFont()->setName('Arial')->setSize(10)->getColor()->setRGB('000000'); $objPHPExcel->getActiveSheet()->getStyle('F' . $i)->getFont()->setBold(true); //7 Cell $objPHPExcel->getActiveSheet()->getStyle('G' . $i)->applyFromArray($styleThinBlackBorderOutline); $objPHPExcel->getActiveSheet()->setCellValue('G' . $i, $qty); $objPHPExcel->getActiveSheet()->getStyle('G' . $i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('G' . $i)->getAlignment()->setIndent(9); $objPHPExcel->getActiveSheet()->getStyle('G' . $i)->getFont()->setName('Arial')->setSize(10)->getColor()->setRGB('FF0000'); $objPHPExcel->getActiveSheet()->getStyle('G' . $i)->getFont()->setBold(true); } $i++; } //echo "come"; //die(); $name = $post['filetype'] . '_' . date('Y-m-d') . '.xlsx'; $changeFilename = $name; $allvalues_array = explode('/', $changeFilename); $lastvalues = count($allvalues_array) - 1; $finalname_array = array(); $finalname = ''; for ($pl = 0; $pl < count($allvalues_array); $pl++) { if ($pl == $lastvalues) { $finalname_array[] = 'xls'; $finalname_array[] = $allvalues_array[$pl]; } else { $finalname_array[] = $allvalues_array[$pl]; } } $finalname = implode('/', $finalname_array); //********* CUSTOM CODE **************************** $objWriter->save($finalname); } try { if (empty($post)) { Mage::throwException($this->__('Invalid form data.')); } /* here's your form processing */ if ($post['file_type'] == 'csv') { $message = $this->__('Your CSV successfully exported.'); } if ($post['file_type'] == 'xls') { $message = $this->__('Your XLSX successfully exported.'); } Mage::getSingleton('adminhtml/session')->addSuccess($message); } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); } $this->_redirect('*/*'); }
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("Operaciones Usuario ")->setSubject("Operaciones Usuario ")->setDescription("Operaciones Usuario ")->setKeywords("office 2007 openxml php")->setCategory("Operaciones Usuario "); $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 <= 'L'; $columna++) { $objPHPExcel->getActiveSheet()->getColumnDimension($columna)->setAutoSize(true); } $objPHPExcel->getActiveSheet()->setCellValue('F2', 'Operaciones por Usuario (Solo abonos)'); $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')); $renglon = 6; for ($user = 0; $user < count($this->operaciones['usuarios']); $user++) { $objPHPExcel->getActiveSheet()->setCellValue('F' . $renglon, 'Usuario')->setCellValue('G' . $renglon, $this->operaciones['usuarios'][$user]->username); $renglon++; for ($operacion = 0; $operacion < count($this->operaciones['operaciones'][$user]); $operacion++) { $objPHPExcel->getActiveSheet()->setCellValue('G' . $renglon, 'Operacion')->setCellValue('H' . $renglon, 'Folio')->setCellValue('H' . ($renglon + 1), $this->operaciones['operaciones'][$user][$operacion]['operacion']->id_operacion)->setCellValue('I' . $renglon, 'Fecha')->setCellValue('I' . ($renglon + 1), $this->operaciones['operaciones'][$user][$operacion]['operacion']->fecha); $renglon += 3; if ($this->operaciones['operaciones'][$user][$operacion]['abonos_mensualidad'] != null) { $objPHPExcel->getActiveSheet()->setCellValue('H' . $renglon, 'Abonos a Mensualidad'); } $renglon++; for ($abono = 0; $abono < count($this->operaciones['operaciones'][$user][$operacion]['abonos_mensualidad']); $abono++) { $objPHPExcel->getActiveSheet()->setCellValue('H' . $renglon, 'Abono')->setCellValue('H' . $renglon, 'Mensualidad')->setCellValue('H' . ($renglon + 1), $this->operaciones['operaciones'][$user][$operacion]['abonos_mensualidad'][$abono]->numero)->setCellValue('I' . $renglon, 'Expediente')->setCellValue('I' . ($renglon + 1), $this->operaciones['operaciones'][$user][$operacion]['abonos_mensualidad'][$abono]->id_expediente); $renglon += 2; } if ($this->operaciones['operaciones'][$user][$operacion]['abonos_enganche'] != null) { $renglon++; $objPHPExcel->getActiveSheet()->setCellValue('H' . $renglon, 'Abonos a Enganche'); $renglon++; } for ($abono = 0; $abono < count($this->operaciones['operaciones'][$user][$operacion]['abonos_enganche']); $abono++) { $objPHPExcel->getActiveSheet()->setCellValue('H' . $renglon, 'Abono')->setCellValue('H' . $renglon, 'Fecha Promesa')->setCellValue('H' . ($renglon + 1), $this->operaciones['operaciones'][$user][$operacion]['abonos_enganche'][$abono]->fecha_promesa)->setCellValue('I' . $renglon, 'Expediente')->setCellValue('I' . ($renglon + 1), $this->operaciones['operaciones'][$user][$operacion]['abonos_enganche'][$abono]->id_expediente); $renglon += 2; } if ($this->operaciones['operaciones'][$user][$operacion]['abonos_capital'] != null) { $renglon++; $objPHPExcel->getActiveSheet()->setCellValue('H' . $renglon, 'Abonos a Capital'); $renglon++; } for ($abono = 0; $abono < count($this->operaciones['operaciones'][$user][$operacion]['abonos_capital']); $abono++) { $objPHPExcel->getActiveSheet()->setCellValue('H' . $renglon, 'Abono')->setCellValue('H' . $renglon, 'Cantidad')->setCellValue('H' . ($renglon + 1), $this->operaciones['operaciones'][$user][$operacion]['abonos_capital'][$abono]->monto)->setCellValue('I' . $renglon, 'Expediente')->setCellValue('I' . ($renglon + 1), $this->operaciones['operaciones'][$user][$operacion]['abonos_capital'][$abono]->id_expediente); $renglon += 2; } $renglon += 2; } $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 . '-reporte_abonos.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; }