📄 worksheet.php
字号:
$this->_screen_gridlines = 1; $this->_print_headers = 0; $this->_fit_page = 0; $this->_fit_width = 0; $this->_fit_height = 0; $this->_hbreaks = array(); $this->_vbreaks = array(); $this->_protect = 0; $this->_password = null; $this->col_sizes = array(); $this->_row_sizes = array(); $this->_zoom = 100; $this->_print_scale = 100; $this->_outline_row_level = 0; $this->_outline_style = 0; $this->_outline_below = 1; $this->_outline_right = 1; $this->_outline_on = 1; $this->_merged_ranges = array(); $this->_input_encoding = ''; $this->_dv = array(); $this->_initialize(); } /** * Open a tmp file to store the majority of the Worksheet data. If this fails, * for example due to write permissions, store the data in memory. This can be * slow for large files. * * @access private */ function _initialize() { // Open tmp file for storing Worksheet data $fh = tmpfile(); if ($fh) { // Store filehandle $this->_filehandle = $fh; } else { // If tmpfile() fails store data in memory $this->_using_tmpfile = false; } } /** * Add data to the beginning of the workbook (note the reverse order) * and to the end of the workbook. * * @access public * @see Spreadsheet_Excel_Writer_Workbook::storeWorkbook() * @param array $sheetnames The array of sheetnames from the Workbook this * worksheet belongs to */ function close($sheetnames) { $num_sheets = count($sheetnames); /*********************************************** * Prepend in reverse order!! */ // Prepend the sheet dimensions $this->_storeDimensions(); // Prepend the sheet password $this->_storePassword(); // Prepend the sheet protection $this->_storeProtect(); // Prepend the page setup $this->_storeSetup(); /* FIXME: margins are actually appended */ // Prepend the bottom margin $this->_storeMarginBottom(); // Prepend the top margin $this->_storeMarginTop(); // Prepend the right margin $this->_storeMarginRight(); // Prepend the left margin $this->_storeMarginLeft(); // Prepend the page vertical centering $this->_storeVcenter(); // Prepend the page horizontal centering $this->_storeHcenter(); // Prepend the page footer $this->_storeFooter(); // Prepend the page header $this->_storeHeader(); // Prepend the vertical page breaks $this->_storeVbreak(); // Prepend the horizontal page breaks $this->_storeHbreak(); // Prepend WSBOOL $this->_storeWsbool(); // Prepend GRIDSET $this->_storeGridset(); // Prepend GUTS if ($this->_BIFF_version == 0x0500) { $this->_storeGuts(); } // Prepend PRINTGRIDLINES $this->_storePrintGridlines(); // Prepend PRINTHEADERS $this->_storePrintHeaders(); // Prepend EXTERNSHEET references if ($this->_BIFF_version == 0x0500) { for ($i = $num_sheets; $i > 0; $i--) { $sheetname = $sheetnames[$i-1]; $this->_storeExternsheet($sheetname); } } // Prepend the EXTERNCOUNT of external references. if ($this->_BIFF_version == 0x0500) { $this->_storeExterncount($num_sheets); } // Prepend the COLINFO records if they exist if (!empty($this->_colinfo)) { $colcount = count($this->_colinfo); for ($i = 0; $i < $colcount; $i++) { $this->_storeColinfo($this->_colinfo[$i]); } $this->_storeDefcol(); } // Prepend the BOF record $this->_storeBof(0x0010); /* * End of prepend. Read upwards from here. ***********************************************/ // Append $this->_storeWindow2(); $this->_storeZoom(); if (!empty($this->_panes)) { $this->_storePanes($this->_panes); } $this->_storeSelection($this->_selection); $this->_storeMergedCells(); /* TODO: add data validity */ /*if ($this->_BIFF_version == 0x0600) { $this->_storeDataValidity(); }*/ $this->_storeEof(); } /** * Retrieve the worksheet name. * This is usefull when creating worksheets without a name. * * @access public * @return string The worksheet's name */ function getName() { return $this->name; } /** * Retrieves data from memory in one chunk, or from disk in $buffer * sized chunks. * * @return string The data */ function getData() { $buffer = 4096; // Return data stored in memory if (isset($this->_data)) { $tmp = $this->_data; unset($this->_data); $fh = $this->_filehandle; if ($this->_using_tmpfile) { fseek($fh, 0); } return $tmp; } // Return data stored on disk if ($this->_using_tmpfile) { if ($tmp = fread($this->_filehandle, $buffer)) { return $tmp; } } // No data to return return ''; } /** * Sets a merged cell range * * @access public * @param integer $first_row First row of the area to merge * @param integer $first_col First column of the area to merge * @param integer $last_row Last row of the area to merge * @param integer $last_col Last column of the area to merge */ function setMerge($first_row, $first_col, $last_row, $last_col) { if (($last_row < $first_row) || ($last_col < $first_col)) { return; } // don't check rowmin, rowmax, etc... because we don't know when this // is going to be called $this->_merged_ranges[] = array($first_row, $first_col, $last_row, $last_col); } /** * Set this worksheet as a selected worksheet, * i.e. the worksheet has its tab highlighted. * * @access public */ function select() { $this->selected = 1; } /** * Set this worksheet as the active worksheet, * i.e. the worksheet that is displayed when the workbook is opened. * Also set it as selected. * * @access public */ function activate() { $this->selected = 1; $this->activesheet = $this->index; } /** * Set this worksheet as the first visible sheet. * This is necessary when there are a large number of worksheets and the * activated worksheet is not visible on the screen. * * @access public */ function setFirstSheet() { $this->firstsheet = $this->index; } /** * Set the worksheet protection flag * to prevent accidental modification and to * hide formulas if the locked and hidden format properties have been set. * * @access public * @param string $password The password to use for protecting the sheet. */ function protect($password) { $this->_protect = 1; $this->_password = $this->_encodePassword($password); } /** * Set the width of a single column or a range of columns. * * @access public * @param integer $firstcol first column on the range * @param integer $lastcol last column on the range * @param integer $width width to set * @param mixed $format The optional XF format to apply to the columns * @param integer $hidden The optional hidden atribute * @param integer $level The optional outline level */ function setColumn($firstcol, $lastcol, $width, $format = null, $hidden = 0, $level = 0) { $this->_colinfo[] = array($firstcol, $lastcol, $width, &$format, $hidden, $level); // Set width to zero if column is hidden $width = ($hidden) ? 0 : $width; for ($col = $firstcol; $col <= $lastcol; $col++) { $this->col_sizes[$col] = $width; } } /** * Set which cell or cells are selected in a worksheet * * @access public * @param integer $first_row first row in the selected quadrant * @param integer $first_column first column in the selected quadrant * @param integer $last_row last row in the selected quadrant * @param integer $last_column last column in the selected quadrant */ function setSelection($first_row,$first_column,$last_row,$last_column) { $this->_selection = array($first_row,$first_column,$last_row,$last_column); } /** * Set panes and mark them as frozen. * * @access public * @param array $panes This is the only parameter received and is composed of the following: * 0 => Vertical split position, * 1 => Horizontal split position * 2 => Top row visible * 3 => Leftmost column visible * 4 => Active pane */ function freezePanes($panes) { $this->_frozen = 1; $this->_panes = $panes; } /** * Set panes and mark them as unfrozen. * * @access public * @param array $panes This is the only parameter received and is composed of the following: * 0 => Vertical split position, * 1 => Horizontal split position * 2 => Top row visible * 3 => Leftmost column visible * 4 => Active pane */ function thawPanes($panes) { $this->_frozen = 0; $this->_panes = $panes; } /** * Set the page orientation as portrait. * * @access public */ function setPortrait() { $this->_orientation = 1; } /** * Set the page orientation as landscape. * * @access public */ function setLandscape() { $this->_orientation = 0; } /** * Set the paper type. Ex. 1 = US Letter, 9 = A4 * * @access public * @param integer $size The type of paper size to use */ function setPaper($size = 0) { $this->_paper_size = $size; } /** * Set the page header caption and optional margin. * * @access public * @param string $string The header text * @param float $margin optional head margin in inches. */ function setHeader($string,$margin = 0.50) { if (strlen($string) >= 255) { //carp 'Header string must be less than 255 characters'; return; } $this->_header = $string; $this->_margin_head = $margin; } /** * Set the page footer caption and optional margin. * * @access public * @param string $string The footer text * @param float $margin optional foot margin in inches. */ function setFooter($string,$margin = 0.50) { if (strlen($string) >= 255) { //carp 'Footer string must be less than 255 characters'; return; } $this->_footer = $string; $this->_margin_foot = $margin; } /** * Center the page horinzontally. * * @access public * @param integer $center the optional value for centering. Defaults to 1 (center). */ function centerHorizontally($center = 1) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -