点击回首页
我的浏览记录 | | 帮助?
当前位置:
首页>> 企业应用>> 新翔网络OA系统V1.0>> 源文件浏览
[商业版 200RMB] WebForm,下载次数:1 次 | 关键字: PHP MYSQL OA 办公 网络办公

源码截图

源码目录树

;
当前路径:Classes/PHPExcel/Writer/Excel2007/Worksheet.php
<?php
/**
 * PHPExcel
 *
 * Copyright (c) 2006 - 2015 PHPExcel
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category   PHPExcel
 * @package    PHPExcel_Writer_Excel2007
 * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
 * @version    ##VERSION##, ##DATE##
 */


/**
 * PHPExcel_Writer_Excel2007_Worksheet
 *
 * @category   PHPExcel
 * @package    PHPExcel_Writer_Excel2007
 * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
 */
class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_WriterPart
{
    /**
     * Write worksheet to XML format
     *
     * @param    PHPExcel_Worksheet        $pSheet
     * @param    string[]                $pStringTable
     * @param    boolean                    $includeCharts    Flag indicating if we should write charts
     * @return    string                    XML Output
     * @throws    PHPExcel_Writer_Exception
     */
    public function writeWorksheet($pSheet = null, $pStringTable = null, $includeCharts = false)
    {
        if (!is_null($pSheet)) {
            // Create XML writer
            $objWriter = null;
            if ($this->getParentWriter()->getUseDiskCaching()) {
                $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
            } else {
                $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
            }

            // XML header
            $objWriter->startDocument('1.0', 'UTF-8', 'yes');

            // Worksheet
            $objWriter->startElement('worksheet');
            $objWriter->writeAttribute('xml:space', 'preserve');
            $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
            $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');

                // sheetPr
                $this->writeSheetPr($objWriter, $pSheet);

                // Dimension
                $this->writeDimension($objWriter, $pSheet);

                // sheetViews
                $this->writeSheetViews($objWriter, $pSheet);

                // sheetFormatPr
                $this->writeSheetFormatPr($objWriter, $pSheet);

                // cols
                $this->writeCols($objWriter, $pSheet);

                // sheetData
                $this->writeSheetData($objWriter, $pSheet, $pStringTable);

                // sheetProtection
                $this->writeSheetProtection($objWriter, $pSheet);

                // protectedRanges
                $this->writeProtectedRanges($objWriter, $pSheet);

                // autoFilter
                $this->writeAutoFilter($objWriter, $pSheet);

                // mergeCells
                $this->writeMergeCells($objWriter, $pSheet);

                // conditionalFormatting
                $this->writeConditionalFormatting($objWriter, $pSheet);

                // dataValidations
                $this->writeDataValidations($objWriter, $pSheet);

                // hyperlinks
                $this->writeHyperlinks($objWriter, $pSheet);

                // Print options
                $this->writePrintOptions($objWriter, $pSheet);

                // Page margins
                $this->writePageMargins($objWriter, $pSheet);

                // Page setup
                $this->writePageSetup($objWriter, $pSheet);

                // Header / footer
                $this->writeHeaderFooter($objWriter, $pSheet);

                // Breaks
                $this->writeBreaks($objWriter, $pSheet);

                // Drawings and/or Charts
                $this->writeDrawings($objWriter, $pSheet, $includeCharts);

                // LegacyDrawing
                $this->writeLegacyDrawing($objWriter, $pSheet);

                // LegacyDrawingHF
                $this->writeLegacyDrawingHF($objWriter, $pSheet);

            $objWriter->endElement();

            // Return
            return $objWriter->getData();
        } else {
            throw new PHPExcel_Writer_Exception("Invalid PHPExcel_Worksheet object passed.");
        }
    }

    /**
     * Write SheetPr
     *
     * @param    PHPExcel_Shared_XMLWriter        $objWriter        XML Writer
     * @param    PHPExcel_Worksheet                $pSheet            Worksheet
     * @throws    PHPExcel_Writer_Exception
     */
    private function writeSheetPr(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null)
    {
        // sheetPr
        $objWriter->startElement('sheetPr');
        //$objWriter->writeAttribute('codeName',        $pSheet->getTitle());
        if ($pSheet->getParent()->hasMacros()) {//if the workbook have macros, we need to have codeName for the sheet
            if ($pSheet->hasCodeName()==false) {
                $pSheet->setCodeName($pSheet->getTitle());
            }
            $objWriter->writeAttribute('codeName', $pSheet->getCodeName());
        }
        $autoFilterRange = $pSheet->getAutoFilter()->getRange();
        if (!empty($autoFilterRange)) {
            $objWriter->writeAttribute('filterMode', 1);
            $pSheet->getAutoFilter()->showHideRows();
        }

        // tabColor
        if ($pSheet->isTabColorSet()) {
            $objWriter->startElement('tabColor');
            $objWriter->writeAttribute('rgb', $pSheet->getTabColor()->getARGB());
            $objWriter->endElement();
        }

        // outlinePr
        $objWriter->startElement('outlinePr');
        $objWriter->writeAttribute('summaryBelow', ($pSheet->getShowSummaryBelow() ? '1' : '0'));
        $objWriter->writeAttribute('summaryRight', ($pSheet->getShowSummaryRight() ? '1' : '0'));
        $objWriter->endElement();

        // pageSetUpPr
        if ($pSheet->getPageSetup()->getFitToPage()) {
            $objWriter->startElement('pageSetUpPr');
            $objWriter->writeAttribute('fitToPage', '1');
            $objWriter->endElement();
        }

        $objWriter->endElement();
    }

    /**
     * Write Dimension
     *
     * @param    PHPExcel_Shared_XMLWriter    $objWriter        XML Writer
     * @param    PHPExcel_Worksheet            $pSheet            Worksheet
     * @throws    PHPExcel_Writer_Exception
     */
    private function writeDimension(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null)
    {
        // dimension
        $objWriter->startElement('dimension');
        $objWriter->writeAttribute('ref', $pSheet->calculateWorksheetDimension());
        $objWriter->endElement();
    }

    /**
     * Write SheetViews
     *
     * @param    PHPExcel_Shared_XMLWriter            $objWriter        XML Writer
     * @param    PHPExcel_Worksheet                    $pSheet            Worksheet
     * @throws    PHPExcel_Writer_Exception
     */
    private function writeSheetViews(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null)
    {
        // sheetViews
        $objWriter->startElement('sheetViews');

        // Sheet selected?
        $sheetSelected = false;
        if ($this->getParentWriter()->getPHPExcel()->getIndex($pSheet) == $this->getParentWriter()->getPHPExcel()->getActiveSheetIndex()) {
            $sheetSelected = true;
        }

        // sheetView
        $objWriter->startElement('sheetView');
        $objWriter->writeAttribute('tabSelected', $sheetSelected ? '1' : '0');
        $objWriter->writeAttribute('workbookViewId', '0');

        // Zoom scales
        if ($pSheet->getSheetView()->getZoomScale() != 100) {
            $objWriter->writeAttribute('zoomScale', $pSheet->getSheetView()->getZoomScale());
        }
        if ($pSheet->getSheetView()->getZoomScaleNormal() != 100) {
            $objWriter->writeAttribute('zoomScaleNormal', $pSheet->getSheetView()->getZoomScaleNormal());
        }

        // View Layout Type
        if ($pSheet->getSheetView()->getView() !== PHPExcel_Worksheet_SheetView::SHEETVIEW_NORMAL) {
            $objWriter->writeAttribute('view', $pSheet->getSheetView()->getView());
        }

        // Gridlines
        if ($pSheet->getShowGridlines()) {
            $objWriter->writeAttribute('showGridLines', 'true');
        } else {
            $objWriter->writeAttribute('showGridLines', 'false');
        }

        // Row and column headers
        if ($pSheet->getShowRowColHeaders()) {
            $objWriter->writeAttribute('showRowColHeaders', '1');
        } else {
            $objWriter->writeAttribute('showRowColHeaders', '0');
        }

        // Right-to-left
        if ($pSheet->getRightToLeft()) {
            $objWriter->writeAttribute('rightToLeft', 'true');
        }

        $activeCell = $pSheet->getActiveCell();

        // Pane
        $pane = '';
        $topLeftCell = $pSheet->getFreezePane();
        if (($topLeftCell != '') && ($topLeftCell != 'A1')) {
            $activeCell = empty($activeCell) ? $topLeftCell : $activeCell;
            // Calculate freeze coordinates
            $xSplit = $ySplit = 0;

            list($xSplit, $ySplit) = PHPExcel_Cell::coordinateFromString($topLeftCell);
            $xSplit = PHPExcel_Cell::columnIndexFromString($xSplit);

            // pane
            $pane = 'topRight';
            $objWriter->startElement('pane');
            if ($xSplit > 1) {
                $objWriter->writeAttribute('xSplit', $xSplit - 1);
            }
            if ($ySplit > 1) {
                $objWriter->writeAttribute('ySplit', $ySplit - 1);
                $pane = ($xSplit > 1) ? 'bottomRight' : 'bottomLeft';
            }
            $objWriter->writeAttribute('topLeftCell', $topLeftCell);
            $objWriter->writeAttribute('activePane', $pane);
            $objWriter->writeAttribute('state', 'frozen');
            $objWriter->endElement();

            if (($xSplit > 1) && ($ySplit > 1)) {
                //    Write additional selections if more than two panes (ie both an X and a Y split)
                $objWriter->startElement('selection');
                $objWriter->writeAttribute('pane', 'topRight');
                $objWriter->endElement();
                $objWriter->startElement('s...
完整源码文件,请先购买后再查看
关于我们 | 顾问团队 | 发展历程 | 联系我们 | 源码上传
联系电话(Tel):4008-010-151(免长途)
地址:北京市海淀区大恒科技大厦五层 邮编:100080
Floor 5th,Daheng Building,Zhongguancun,Beijing,China,100080
51Aspx.com 版权所有 CopyRight © 2006-2022. 京ICP备09089570号 | 京公网安备11010702000869号