Calls finalization methods.
This method should always be the last one to be called on every workbook

@access public
@return mixed true on success. PEAR_Error on failure
511197
function close()
    {
        if ($this->_fileclosed) { // Prevent close() from being called twice.
            return true;
        }
        $res = $this->_storeWorkbook();
        if ($this->isError($res)) {
            return $this->raiseError($res->getMessage());
        }
        $this->_fileclosed = 1;
        return true;
    }
1220766
function close()
	{
		$_phpSheet = $this->_phpSheet;

		$num_sheets = $_phpSheet->getParent()->getSheetCount();

		// Write BOF record
		$this->_storeBof(0x0010);

		// Write PRINTHEADERS
		$this->_writePrintHeaders();

		// Write PRINTGRIDLINES
		$this->_writePrintGridlines();

		// Write GRIDSET
		$this->_writeGridset();

		// Calculate column widths
		$_phpSheet->calculateColumnWidths();

		// Column dimensions
		if (($defaultWidth = $_phpSheet->getDefaultColumnDimension()->getWidth()) < 0) {
			$defaultWidth = PHPExcel_Shared_Font::getDefaultColumnWidthByFont($_phpSheet->getParent()->getDefaultStyle()->getFont());
		}

		$columnDimensions = $_phpSheet->getColumnDimensions();
		$maxCol = $this->_lastColumnIndex -1;
		for ($i = 0; $i <= $maxCol; ++$i) {
			$hidden = 0;
			$level = 0;
			$xfIndex = 15; // there are 15 cell style Xfs

			$width = $defaultWidth;

			$columnLetter = PHPExcel_Cell::stringFromColumnIndex($i);
			if (isset($columnDimensions[$columnLetter])) {
				$columnDimension = $columnDimensions[$columnLetter];
				if ($columnDimension->getWidth() >= 0) {
					$width = $columnDimension->getWidth();
				}
				$hidden = $columnDimension->getVisible() ? 0 : 1;
				$level = $columnDimension->getOutlineLevel();
				$xfIndex = $columnDimension->getXfIndex() + 15; // there are 15 cell style Xfs
			}

			// Components of _colinfo:
			// $firstcol first column on the range
			// $lastcol  last column on the range
			// $width	width to set
			// $xfIndex  The optional cell style Xf index to apply to the columns
			// $hidden   The optional hidden atribute
			// $level	The optional outline level
			$this->_colinfo[] = array($i, $i, $width, $xfIndex, $hidden, $level);
		}

		// Write GUTS
		$this->_writeGuts();

		// Write DEFAULTROWHEIGHT
		$this->_writeDefaultRowHeight();

		// Write WSBOOL
		$this->_writeWsbool();

		// Write horizontal and vertical page breaks
		$this->_writeBreaks();

		// Write page header
		$this->_writeHeader();

		// Write page footer
		$this->_writeFooter();

		// Write page horizontal centering
		$this->_writeHcenter();

		// Write page vertical centering
		$this->_writeVcenter();

		// Write left margin
		$this->_writeMarginLeft();

		// Write right margin
		$this->_writeMarginRight();

		// Write top margin
		$this->_writeMarginTop();

		// Write bottom margin
		$this->_writeMarginBottom();

		// Write page setup
		$this->_writeSetup();

		// Write sheet protection
		$this->_writeProtect();

		// Write SCENPROTECT
		$this->_writeScenProtect();

		// Write OBJECTPROTECT
		$this->_writeObjectProtect();

		// Write sheet password
		$this->_writePassword();

		// Write DEFCOLWIDTH record
		$this->_writeDefcol();

		// Write the COLINFO records if they exist
		if (!empty($this->_colinfo)) {
			$colcount = count($this->_colinfo);
			for ($i = 0; $i < $colcount; ++$i) {
				$this->_writeColinfo($this->_colinfo[$i]);
			}
		}
		$autoFilterRange = $_phpSheet->getAutoFilter()->getRange();
		if (!empty($autoFilterRange)) {
			// Write AUTOFILTERINFO
			$this->_writeAutoFilterInfo();
		}

		// Write sheet dimensions
		$this->_writeDimensions();

		// Row dimensions
		foreach ($_phpSheet->getRowDimensions() as $rowDimension) {
			$xfIndex = $rowDimension->getXfIndex() + 15; // there are 15 cellXfs
			$this->_writeRow( $rowDimension->getRowIndex() - 1, $rowDimension->getRowHeight(), $xfIndex, ($rowDimension->getVisible() ? '0' : '1'), $rowDimension->getOutlineLevel() );
		}

		// Write Cells
		foreach ($_phpSheet->getCellCollection() as $cellID) {
			$cell = $_phpSheet->getCell($cellID);
			$row = $cell->getRow() - 1;
			$column = PHPExcel_Cell::columnIndexFromString($cell->getColumn()) - 1;

			// Don't break Excel!
//			if ($row + 1 > 65536 or $column + 1 > 256) {
			if ($row > 65535 || $column > 255) {
				break;
			}

			// Write cell value
			$xfIndex = $cell->getXfIndex() + 15; // there are 15 cell style Xfs

			$cVal = $cell->getValue();
			if ($cVal instanceof PHPExcel_RichText) {
				// $this->_writeString($row, $column, $cVal->getPlainText(), $xfIndex);
				$arrcRun = array();
				$str_len = PHPExcel_Shared_String::CountCharacters($cVal->getPlainText(), 'UTF-8');
				$str_pos = 0;
				$elements = $cVal->getRichTextElements();
				foreach ($elements as $element) {
					// FONT Index
					if ($element instanceof PHPExcel_RichText_Run) {
						$str_fontidx = $this->_fntHashIndex[$element->getFont()->getHashCode()];
					}
					else {
						$str_fontidx = 0;
					}
					$arrcRun[] = array('strlen' => $str_pos, 'fontidx' => $str_fontidx);
					// Position FROM
					$str_pos += PHPExcel_Shared_String::CountCharacters($element->getText(), 'UTF-8');
				}
				$this->_writeRichTextString($row, $column, $cVal->getPlainText(), $xfIndex, $arrcRun);
			} else {
				switch ($cell->getDatatype()) {
					case PHPExcel_Cell_DataType::TYPE_STRING:
					case PHPExcel_Cell_DataType::TYPE_NULL:
						if ($cVal === '' || $cVal === null) {
							$this->_writeBlank($row, $column, $xfIndex);
						} else {
							$this->_writeString($row, $column, $cVal, $xfIndex);
						}
						break;

					case PHPExcel_Cell_DataType::TYPE_NUMERIC:
						$this->_writeNumber($row, $column, $cVal, $xfIndex);
						break;

					case PHPExcel_Cell_DataType::TYPE_FORMULA:
						$calculatedValue = $this->_preCalculateFormulas ?
							$cell->getCalculatedValue() : null;
						$this->_writeFormula($row, $column, $cVal, $xfIndex, $calculatedValue);
						break;

					case PHPExcel_Cell_DataType::TYPE_BOOL:
						$this->_writeBoolErr($row, $column, $cVal, 0, $xfIndex);
						break;

					case PHPExcel_Cell_DataType::TYPE_ERROR:
						$this->_writeBoolErr($row, $column, self::_mapErrorCode($cVal), 1, $xfIndex);
						break;

				}
			}
		}

		// Append
		$this->_writeMsoDrawing();

		// Write WINDOW2 record
		$this->_writeWindow2();

		// Write PLV record
		$this->_writePageLayoutView();

		// Write ZOOM record
		$this->_writeZoom();
		if ($_phpSheet->getFreezePane()) {
			$this->_writePanes();
		}

		// Write SELECTION record
		$this->_writeSelection();

		// Write MergedCellsTable Record
		$this->_writeMergedCells();

		// Hyperlinks
		foreach ($_phpSheet->getHyperLinkCollection() as $coordinate => $hyperlink) {
			list($column, $row) = PHPExcel_Cell::coordinateFromString($coordinate);

			$url = $hyperlink->getUrl();

			if ( strpos($url, 'sheet://') !== false ) {
				// internal to current workbook
				$url = str_replace('sheet://', 'internal:', $url);

			} else if ( preg_match('/^(http:|https:|ftp:|mailto:)/', $url) ) {
				// URL
				// $url = $url;

			} else {
				// external (local file)
				$url = 'external:' . $url;
			}

			$this->_writeUrl($row - 1, PHPExcel_Cell::columnIndexFromString($column) - 1, $url);
		}

		$this->_writeDataValidity();
		$this->_writeSheetLayout();

		// Write SHEETPROTECTION record
		$this->_writeSheetProtection();
		$this->_writeRangeProtection();

		$arrConditionalStyles = $_phpSheet->getConditionalStylesCollection();
		if(!empty($arrConditionalStyles)){
			$arrConditional = array();
			// @todo CFRule & CFHeader
			// Write CFHEADER record
			$this->_writeCFHeader();
			// Write ConditionalFormattingTable records
			foreach ($arrConditionalStyles as $cellCoordinate => $conditionalStyles) {
				foreach ($conditionalStyles as $conditional) {
					if($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_EXPRESSION
						|| $conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS){
						if(!in_array($conditional->getHashCode(), $arrConditional)){
							$arrConditional[] = $conditional->getHashCode();
							// Write CFRULE record
							$this->_writeCFRule($conditional);
						}
					}
				}
			}
		}

		$this->_storeEof();
	}
1007334
public function finalize()
    {
        $this->initialize();

        if (is_resource($this->handle)) {
            fwrite($this->handle, "\n]");
            fclose($this->handle);
        }
    }
1121201
public function finalize() {
        if (!$this->isFinalized) {
            if (strlen($this->streamFilePath) > 0) {
                $this->closeStream();
            }
            $cd = implode("", $this->cdRec);

            $cdRecSize = pack("v", sizeof($this->cdRec));
            $cdRec = $cd . self::ZIP_END_OF_CENTRAL_DIRECTORY
                     . $cdRecSize . $cdRecSize
                     . pack("VV", strlen($cd), $this->offset);
            if (!empty($this->zipComment)) {
                $cdRec .= pack("v", strlen($this->zipComment)) . $this->zipComment;
            } else {
                $cdRec .= "\x00\x00";
            }

            $this->zipwrite($cdRec);

            $this->isFinalized = TRUE;
            $this->cdRec = NULL;

            return TRUE;
        }
        return FALSE;
    }
951219
protected function finaliseRollback() {

		// Figure out the status by inspecting specific rollback steps.
		$success = true;
		$rollback1 = $this->RollbackStep1();
		$rollback2 = $this->RollbackStep2();
		if (!empty($rollback1) && $rollback1->Status=='Failed') $success = false;
		if (!empty($rollback2) && $rollback2->Status=='Failed') $success = false;

		// Send messages.
		if ($success) {
			$this->log("Pipeline failed, but rollback completed successfully.");
			$this->sendMessage(self::ALERT_ROLLBACK_SUCCESS);
		} else {
			$this->log("Pipeline failed, rollback failed.");
			$this->sendMessage(self::ALERT_ROLLBACK_FAILURE);
		}

		// Finish off the pipeline - rollback will only be triggered on a failed pipeline.
		$this->Status = 'Failed';
		$this->write();
	}
1199417
public function finalize()
    {
        @flock($this->getFileResource(), LOCK_UN);
        @fclose($this->getFileResource());
        @unlink($this->getFileName());
    }
880880
public static function end(){
		$script = ob_get_clean();
		$widget = parent::end();
		
		if(preg_match("/^\\s*\\<script\\>(.*)\\<\\/script\\>\\s*$/s", $script, $matches)){
			$script = $matches[1];
		}
		
		$widget->view->registerJs($script, $widget->position, $widget->key);
		
	}
794202
function finish_output($closeexportclassdoc = true) {
        if ($this->exportclass!==null) {
            $this->exportclass->finish_table();
            if ($closeexportclassdoc) {
                $this->exportclass->finish_document();
            }
        } else {
            $this->finish_html();
        }
    }
439988
public function finalize()
    {
        // Output our chunks.
        // Every output is split into 4 chunk strings (header, messages,
        // data, footer).
        foreach ($this->chunkStrings as $chunkString) {
            // Save everything to the file after we are done.
            $this->pool->chunks->saveDechunkedToFile($chunkString);
        }
    }
845850
public function finish(){
        $this->running = 0;
        $this->success = 1;
        $this->last_execution_time = self::execution_time();
        
        if ($this->save()){
            Console::stdout(Console::ansiFormat("*** finished ".$this->controller."/".$this->action." (time: " . sprintf("%.3f", $this->last_execution_time) . "s)\n\n", [Console::FG_GREEN]));
            return true;
        }else{
            Console::stdout(Console::ansiFormat("*** failed to finish ".$this->controller."/".$this->action." (time: " . sprintf("%.3f", $this->last_execution_time) . "s)\n\n", [Console::FG_RED]));
            return false;
        }
    }
196457
protected function end()
    {
        if ($this->matchChar(';')) {
            return true;
        }

        if ($this->count === strlen($this->buffer) || $this->buffer[$this->count] === '}') {
            // if there is end of file or a closing block next then we don't need a ;
            return true;
        }

        return false;
    }
788810
function close() {
        if (isset($this->res)) {
            $this->stdout->close();
            fclose($this->pipes[0]);
            $status = $this->status();
            $exit = $status['running'] ? proc_close($this->res) : $status['exitcode'];
            unset($this->res, $this->pipes, $this->stdout);
            return $exit;
        }
        return null;
    }
1065555
function finalise(&$parsed_code) {
        // Remove end parts of important declarations
        // This is BUGGY!! My fault for bad code: fix coming in 1.2
        // @todo Remove this crap
        if ($this->enable_important_blocks &&
            (strpos($parsed_code, $this->hsc(GESHI_START_IMPORTANT)) === false)) {
            $parsed_code = str_replace($this->hsc(GESHI_END_IMPORTANT), '', $parsed_code);
        }

        // Add HTML whitespace stuff if we're using the <div> header
        if ($this->header_type != GESHI_HEADER_PRE && $this->header_type != GESHI_HEADER_PRE_VALID) {
            $this->indent($parsed_code);
        }

        // purge some unnecessary stuff
        /** NOTE: memorypeak #1 */
        $parsed_code = preg_replace('#<span[^>]+>(\s*)</span>#', '\\1', $parsed_code);

        // If we are using IDs for line numbers, there needs to be an overall
        // ID set to prevent collisions.
        if ($this->add_ids && !$this->overall_id) {
            $this->overall_id = 'geshi-' . substr(md5(microtime()), 0, 4);
        }

        // Get code into lines
        /** NOTE: memorypeak #2 */
        $code = explode("\n", $parsed_code);
        $parsed_code = $this->header();

        // If we're using line numbers, we insert <li>s and appropriate
        // markup to style them (otherwise we don't need to do anything)
        if ($this->line_numbers != GESHI_NO_LINE_NUMBERS && $this->header_type != GESHI_HEADER_PRE_TABLE) {
            // If we're using the <pre> header, we shouldn't add newlines because
            // the <pre> will line-break them (and the <li>s already do this for us)
            $ls = ($this->header_type != GESHI_HEADER_PRE && $this->header_type != GESHI_HEADER_PRE_VALID) ? "\n" : '';

            // Set vars to defaults for following loop
            $i = 0;

            // Foreach line...
            for ($i = 0, $n = count($code); $i < $n;) {
                //Reset the attributes for a new line ...
                $attrs = array();

                // Make lines have at least one space in them if they're empty
                // BenBE: Checking emptiness using trim instead of relying on blanks
                if ('' == trim($code[$i])) {
                    $code[$i] = '&nbsp;';
                }

                // If this is a "special line"...
                if ($this->line_numbers == GESHI_FANCY_LINE_NUMBERS &&
                    $i % $this->line_nth_row == ($this->line_nth_row - 1)) {
                    // Set the attributes to style the line
                    if ($this->use_classes) {
                        //$attr = ' class="li2"';
                        $attrs['class'][] = 'li2';
                        $def_attr = ' class="de2"';
                    } else {
                        //$attr = ' style="' . $this->line_style2 . '"';
                        $attrs['style'][] = $this->line_style2;
                        // This style "covers up" the special styles set for special lines
                        // so that styles applied to special lines don't apply to the actual
                        // code on that line
                        $def_attr = ' style="' . $this->code_style . '"';
                    }
                } else {
                    if ($this->use_classes) {
                        //$attr = ' class="li1"';
                        $attrs['class'][] = 'li1';
                        $def_attr = ' class="de1"';
                    } else {
                        //$attr = ' style="' . $this->line_style1 . '"';
                        $attrs['style'][] = $this->line_style1;
                        $def_attr = ' style="' . $this->code_style . '"';
                    }
                }

                //Check which type of tag to insert for this line
                if ($this->header_type == GESHI_HEADER_PRE_VALID) {
                    $start = "<pre$def_attr>";
                    $end = '</pre>';
                } else {
                    // Span or div?
                    $start = "<div$def_attr>";
                    $end = '</div>';
                }

                ++$i;

                // Are we supposed to use ids? If so, add them
                if ($this->add_ids) {
                    $attrs['id'][] = "$this->overall_id-$i";
                }

                //Is this some line with extra styles???
                if (in_array($i, $this->highlight_extra_lines)) {
                    if ($this->use_classes) {
                        if (isset($this->highlight_extra_lines_styles[$i])) {
                            $attrs['class'][] = "lx$i";
                        } else {
                            $attrs['class'][] = "ln-xtra";
                        }
                    } else {
                        array_push($attrs['style'], $this->get_line_style($i));
                    }
                }

                // Add in the line surrounded by appropriate list HTML
                $attr_string = '';
                foreach ($attrs as $key => $attr) {
                    $attr_string .= ' ' . $key . '="' . implode(' ', $attr) . '"';
                }

                $parsed_code .= "<li$attr_string>$start{$code[$i-1]}$end</li>$ls";
                unset($code[$i - 1]);
            }
        } else {
            $n = count($code);
            if ($this->use_classes) {
                $attributes = ' class="de1"';
            } else {
                $attributes = ' style="'. $this->code_style .'"';
            }
            if ($this->header_type == GESHI_HEADER_PRE_VALID) {
                $parsed_code .= '<pre'. $attributes .'>';
            } elseif ($this->header_type == GESHI_HEADER_PRE_TABLE) {
                if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) {
                    if ($this->use_classes) {
                        $attrs = ' class="ln"';
                    } else {
                        $attrs = ' style="'. $this->table_linenumber_style .'"';
                    }
                    $parsed_code .= '<td'.$attrs.'><pre'.$attributes.'>';
                    // get linenumbers
                    // we don't merge it with the for below, since it should be better for
                    // memory consumption this way
                    // @todo: but... actually it would still be somewhat nice to merge the two loops
                    //        the mem peaks are at different positions
                    for ($i = 0; $i < $n; ++$i) {
                        $close = 0;
                        // fancy lines
                        if ($this->line_numbers == GESHI_FANCY_LINE_NUMBERS &&
                            $i % $this->line_nth_row == ($this->line_nth_row - 1)) {
                            // Set the attributes to style the line
                            if ($this->use_classes) {
                                $parsed_code .= '<span class="xtra li2"><span class="de2">';
                            } else {
                                // This style "covers up" the special styles set for special lines
                                // so that styles applied to special lines don't apply to the actual
                                // code on that line
                                $parsed_code .= '<span style="display:block;' . $this->line_style2 . '">'
                                                  .'<span style="' . $this->code_style .'">';
                            }
                            $close += 2;
                        }
                        //Is this some line with extra styles???
                        if (in_array($i + 1, $this->highlight_extra_lines)) {
                            if ($this->use_classes) {
                                if (isset($this->highlight_extra_lines_styles[$i])) {
                                    $parsed_code .= "<span class=\"xtra lx$i\">";
                                } else {
                                    $parsed_code .= "<span class=\"xtra ln-xtra\">";
                                }
                            } else {
                                $parsed_code .= "<span style=\"display:block;" . $this->get_line_style($i) . "\">";
                            }
                            ++$close;
                        }
                        $parsed_code .= $this->line_numbers_start + $i;
                        if ($close) {
                            $parsed_code .= str_repeat('</span>', $close);
                        } elseif ($i != $n) {
                            $parsed_code .= "\n";
                        }
                    }
                    $parsed_code .= '</pre></td><td'.$attributes.'>';
                }
                $parsed_code .= '<pre'. $attributes .'>';
            }
            // No line numbers, but still need to handle highlighting lines extra.
            // Have to use divs so the full width of the code is highlighted
            $close = 0;
            for ($i = 0; $i < $n; ++$i) {
                // Make lines have at least one space in them if they're empty
                // BenBE: Checking emptiness using trim instead of relying on blanks
                if ('' == trim($code[$i])) {
                    $code[$i] = '&nbsp;';
                }
                // fancy lines
                if ($this->line_numbers == GESHI_FANCY_LINE_NUMBERS &&
                    $i % $this->line_nth_row == ($this->line_nth_row - 1)) {
                    // Set the attributes to style the line
                    if ($this->use_classes) {
                        $parsed_code .= '<span class="xtra li2"><span class="de2">';
                    } else {
                        // This style "covers up" the special styles set for special lines
                        // so that styles applied to special lines don't apply to the actual
                        // code on that line
                        $parsed_code .= '<span style="display:block;' . $this->line_style2 . '">'
                                          .'<span style="' . $this->code_style .'">';
                    }
                    $close += 2;
                }
                //Is this some line with extra styles???
                if (in_array($i + 1, $this->highlight_extra_lines)) {
                    if ($this->use_classes) {
                        if (isset($this->highlight_extra_lines_styles[$i])) {
                            $parsed_code .= "<span class=\"xtra lx$i\">";
                        } else {
                            $parsed_code .= "<span class=\"xtra ln-xtra\">";
                        }
                    } else {
                        $parsed_code .= "<span style=\"display:block;" . $this->get_line_style($i) . "\">";
                    }
                    ++$close;
                }

                $parsed_code .= $code[$i];

                if ($close) {
                  $parsed_code .= str_repeat('</span>', $close);
                  $close = 0;
                }
                elseif ($i + 1 < $n) {
                    $parsed_code .= "\n";
                }
                unset($code[$i]);
            }

            if ($this->header_type == GESHI_HEADER_PRE_VALID || $this->header_type == GESHI_HEADER_PRE_TABLE) {
                $parsed_code .= '</pre>';
            }
            if ($this->header_type == GESHI_HEADER_PRE_TABLE && $this->line_numbers != GESHI_NO_LINE_NUMBERS) {
                $parsed_code .= '</td>';
            }
        }

        $parsed_code .= $this->footer();
    }
269459
def finalize(self):
        
        self.pause_session_logging()
        self._disable_logging()
        self._msg_callback = None
        self._error_msg_callback = None
        self._warning_msg_callback = None
        self._info_msg_callback = None
665790
def do_finalize(self):
		
		shutit_global.shutit_global_object.yield_to_draw()
		def _finalize(self):
			# Stop all the modules
			self.stop_all()
			# Finalize in reverse order
			self.log('PHASE: finalizing object ' + str(self), level=logging.DEBUG)
			# Login at least once to get the exports.
			for module_id in self.module_ids(rev=True):
				# Only finalize if it's thought to be installed.
				if self.is_installed(self.shutit_map[module_id]):
					self.login(prompt_prefix=module_id,command=shutit_global.shutit_global_object.bash_startup_command,echo=False)
					if not self.shutit_map[module_id].finalize(self):
						self.fail(module_id + ' failed on finalize', shutit_pexpect_child=self.get_shutit_pexpect_session_from_id('target_child').pexpect_child) # pragma: no cover
					self.logout(echo=False)
		_finalize(self)
1205432
function finalize () {
  stats.stop()
  if (argv.summary === true && rwWorkers > 0) {
    return stats.reportFinal(argv, console.log)
  }
}
1030593
def finalize(self, result):
        """"""
        sys.stderr = self._stderr.pop()
        sys.stdout = self._stdout.pop()
        pdb.set_trace = self._set_trace.pop()
        pdb.Pdb.cmdloop = self._cmdloop.pop()