⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 workbook.php

📁 完美的在线教育系统
💻 PHP
📖 第 1 页 / 共 4 页
字号:
        for ($i = 0; $i < $total_formats; $i++) {            $xf = $this->_formats[$i]->getXf('cell');            $this->_append($xf);        }    }    /**    * Write all STYLE records.    *    * @access private    */    function _storeAllStyles()    {        $this->_storeStyle();    }    /**    * Write the EXTERNCOUNT and EXTERNSHEET records. These are used as indexes for    * the NAME records.    *    * @access private    */    function _storeExterns()    {        // Create EXTERNCOUNT with number of worksheets        $this->_storeExterncount(count($this->_worksheets));        // Create EXTERNSHEET for each worksheet        foreach ($this->_sheetnames as $sheetname) {            $this->_storeExternsheet($sheetname);        }    }    /**    * Write the NAME record to define the print area and the repeat rows and cols.    *    * @access private    */    function _storeNames()    {        // Create the print area NAME records        $total_worksheets = count($this->_worksheets);        for ($i = 0; $i < $total_worksheets; $i++) {            // Write a Name record if the print area has been defined            if (isset($this->_worksheets[$i]->print_rowmin)) {                $this->_storeNameShort(                    $this->_worksheets[$i]->index,                    0x06, // NAME type                    $this->_worksheets[$i]->print_rowmin,                    $this->_worksheets[$i]->print_rowmax,                    $this->_worksheets[$i]->print_colmin,                    $this->_worksheets[$i]->print_colmax                    );            }        }        // Create the print title NAME records        $total_worksheets = count($this->_worksheets);        for ($i = 0; $i < $total_worksheets; $i++) {            $rowmin = $this->_worksheets[$i]->title_rowmin;            $rowmax = $this->_worksheets[$i]->title_rowmax;            $colmin = $this->_worksheets[$i]->title_colmin;            $colmax = $this->_worksheets[$i]->title_colmax;            // Determine if row + col, row, col or nothing has been defined            // and write the appropriate record            //            if (isset($rowmin) && isset($colmin)) {                // Row and column titles have been defined.                // Row title has been defined.                $this->_storeNameLong(                    $this->_worksheets[$i]->index,                    0x07, // NAME type                    $rowmin,                    $rowmax,                    $colmin,                    $colmax                    );            } elseif (isset($rowmin)) {                // Row title has been defined.                $this->_storeNameShort(                    $this->_worksheets[$i]->index,                    0x07, // NAME type                    $rowmin,                    $rowmax,                    0x00,                    0xff                    );            } elseif (isset($colmin)) {                // Column title has been defined.                $this->_storeNameShort(                    $this->_worksheets[$i]->index,                    0x07, // NAME type                    0x0000,                    0x3fff,                    $colmin,                    $colmax                    );            } else {                // Print title hasn't been defined.            }        }    }    /******************************************************************************    *    * BIFF RECORDS    *    */    /**    * Stores the CODEPAGE biff record.    *    * @access private    */    function _storeCodepage()    {        $record          = 0x0042;             // Record identifier        $length          = 0x0002;             // Number of bytes to follow        $cv              = $this->_codepage;   // The code page        $header          = pack('vv', $record, $length);        $data            = pack('v',  $cv);        $this->_append($header . $data);    }    /**    * Write Excel BIFF WINDOW1 record.    *    * @access private    */    function _storeWindow1()    {        $record    = 0x003D;                 // Record identifier        $length    = 0x0012;                 // Number of bytes to follow        $xWn       = 0x0000;                 // Horizontal position of window        $yWn       = 0x0000;                 // Vertical position of window        $dxWn      = 0x25BC;                 // Width of window        $dyWn      = 0x1572;                 // Height of window        $grbit     = 0x0038;                 // Option flags        $ctabsel   = $this->_selected;       // Number of workbook tabs selected        $wTabRatio = 0x0258;                 // Tab to scrollbar ratio        $itabFirst = $this->_firstsheet;     // 1st displayed worksheet        $itabCur   = $this->_activesheet;    // Active worksheet        $header    = pack("vv",        $record, $length);        $data      = pack("vvvvvvvvv", $xWn, $yWn, $dxWn, $dyWn,                                       $grbit,                                       $itabCur, $itabFirst,                                       $ctabsel, $wTabRatio);        $this->_append($header . $data);    }    /**    * Writes Excel BIFF BOUNDSHEET record.    * FIXME: inconsistent with BIFF documentation    *    * @param string  $sheetname Worksheet name    * @param integer $offset    Location of worksheet BOF    * @access private    */    function _storeBoundsheet($sheetname,$offset)    {        $record    = 0x0085;                    // Record identifier        if ($this->_BIFF_version == 0x0600) {            $length    = 0x08 + strlen($sheetname); // Number of bytes to follow        } else {            $length = 0x07 + strlen($sheetname); // Number of bytes to follow        }        $grbit     = 0x0000;                    // Visibility and sheet type        $cch       = strlen($sheetname);        // Length of sheet name        $header    = pack("vv",  $record, $length);        if ($this->_BIFF_version == 0x0600) {            $data      = pack("Vvv", $offset, $grbit, $cch);        } else {            $data      = pack("VvC", $offset, $grbit, $cch);        }        $this->_append($header.$data.$sheetname);    }    /**    * Write Internal SUPBOOK record    *    * @access private    */    function _storeSupbookInternal()    {        $record    = 0x01AE;   // Record identifier        $length    = 0x0004;   // Bytes to follow        $header    = pack("vv", $record, $length);        $data      = pack("vv", count($this->_worksheets), 0x0104);        $this->_append($header . $data);    }    /**    * Writes the Excel BIFF EXTERNSHEET record. These references are used by    * formulas.    *    * @param string $sheetname Worksheet name    * @access private    */    function _storeExternsheetBiff8()    {        $total_references = count($this->_parser->_references);        $record   = 0x0017;                     // Record identifier        $length   = 2 + 6 * $total_references;  // Number of bytes to follow        $supbook_index = 0;           // FIXME: only using internal SUPBOOK record        $header           = pack("vv",  $record, $length);        $data             = pack('v', $total_references);        for ($i = 0; $i < $total_references; $i++) {            $data .= $this->_parser->_references[$i];        }        $this->_append($header . $data);    }    /**    * Write Excel BIFF STYLE records.    *    * @access private    */    function _storeStyle()    {        $record    = 0x0293;   // Record identifier        $length    = 0x0004;   // Bytes to follow        $ixfe      = 0x8000;   // Index to style XF        $BuiltIn   = 0x00;     // Built-in style        $iLevel    = 0xff;     // Outline style level        $header    = pack("vv",  $record, $length);        $data      = pack("vCC", $ixfe, $BuiltIn, $iLevel);        $this->_append($header . $data);    }    /**    * Writes Excel FORMAT record for non "built-in" numerical formats.    *    * @param string  $format Custom format string    * @param integer $ifmt   Format index code    * @access private    */    function _storeNumFormat($format, $ifmt)    {        $record    = 0x041E;                      // Record identifier        if ($this->_BIFF_version == 0x0600) {            $length    = 5 + strlen($format);      // Number of bytes to follow            $encoding = 0x0;        } elseif ($this->_BIFF_version == 0x0500) {            $length    = 3 + strlen($format);      // Number of bytes to follow        }        $cch       = strlen($format);             // Length of format string        $header    = pack("vv", $record, $length);        if ($this->_BIFF_version == 0x0600) {            $data      = pack("vvC", $ifmt, $cch, $encoding);        } elseif ($this->_BIFF_version == 0x0500) {            $data      = pack("vC", $ifmt, $cch);        }        $this->_append($header . $data . $format);    }    /**    * Write DATEMODE record to indicate the date system in use (1904 or 1900).    *    * @access private    */    function _storeDatemode()    {        $record    = 0x0022;         // Record identifier        $length    = 0x0002;         // Bytes to follow        $f1904     = $this->_1904;   // Flag for 1904 date system        $header    = pack("vv", $record, $length);        $data      = pack("v", $f1904);        $this->_append($header . $data);    }    /**    * Write BIFF record EXTERNCOUNT to indicate the number of external sheet    * references in the workbook.    *    * Excel only stores references to external sheets that are used in NAME.    * The workbook NAME record is required to define the print area and the repeat    * rows and columns.    *    * A similar method is used in Worksheet.php for a slightly different purpose.    *    * @param integer $cxals Number of external references    * @access private    */    function _storeExterncount($cxals)    {        $record   = 0x0016;          // Record identifier        $length   = 0x0002;          // Number of bytes to follow        $header   = pack("vv", $record, $length);        $data     = pack("v",  $cxals);        $this->_append($header . $data);    }    /**    * Writes the Excel BIFF EXTERNSHEET record. These references are used by    * formulas. NAME record is required to define the print area and the repeat    * rows and columns.    *    * A similar method is used in Worksheet.php for a slightly different purpose.    *    * @param string $sheetname Worksheet name    * @access private    */    function _storeExternsheet($sheetname)    {        $record      = 0x0017;                     // Record identifier        $length      = 0x02 + strlen($sheetname);  // Number of bytes to follow        $cch         = strlen($sheetname);         // Length of sheet name        $rgch        = 0x03;                       // Filename encoding        $header      = pack("vv",  $record, $length);        $data        = pack("CC", $cch, $rgch);        $this->_append($header . $data . $sheetname);    }    /**    * Store the NAME record in the short format that is used for storing the print    * area, repeat rows only and repeat columns only.    *    * @param integer $index  Sheet index    * @param integer $type   Built-in name type    * @param integer $rowmin Start row    * @param integer $rowmax End row    * @param integer $colmin Start colum    * @param integer $colmax End column    * @access private    */    function _storeNameShort($index, $type, $rowmin, $rowmax, $colmin, $colmax)    {        $record          = 0x0018;       // Record identifier        $length          = 0x0024;       // Number of bytes to follow        $grbit           = 0x0020;       // Option flags        $chKey           = 0x00;         // Keyboard shortcut        $cch             = 0x01;         // Length of text name        $cce             = 0x0015;       // Length of text definition        $ixals           = $index + 1;   // Sheet index        $itab            = $ixals;       // Equal to ixals        $cchCustMenu     = 0x00;         // Length of cust menu text        $cchDescription  = 0x00;         // Length of description text        $cchHelptopic    = 0x00;         // Length of help topic text        $cchStatustext   = 0x00;         // Length of status bar text        $rgch            = $type;        // Built-in name type        $unknown03       = 0x3b;        $unknown04       = 0xffff-$index;        $unknown05       = 0x0000;        $unknown06       = 0x0000;        $unknown07       = 0x1087;        $unknown08       = 0x8005;        $header             = pack("vv", $record, $length);        $data               = pack("v", $grbit);        $data              .= pack("C", $chKey);        $data              .= pack("C", $cch);        $data              .= pack("v", $cce);        $data              .= pack("v", $ixals);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -