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

📄 worksheet.java

📁 非常实用的java描述的excel组件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* =================================================
 * JWorkbook : data export from Java to spreadsheets
 * =================================================
 *
 * Project Info:  http://www.jfree.org/jworkbook/index.html;
 * Project Lead:  David Gilbert (david.gilbert@object-refinery.com);
 *
 * (C) Copyright 2001-2003, by Object Refinery Limited.
 *
 * 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., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * --------------
 * Worksheet.java
 * --------------
 * (C) Copyright 2001, 2003, by Object Refinery Limited.
 *
 * Original Author:  David Gilbert (for Object Refinery Limited);
 * Contributor(s):   -;
 *
 * $Id$
 *
 * Changes:
 * --------
 * 05-Nov-2001 : Version 1 (DG);
 * 11-Feb-2002 : Implemented GnumericWriter.java and XLWriter.java (DG);
 * 07-Jul-2003 : Changed GPL --> LGPL, changed package name, updated company name (DG);
 *
 */

package org.jfree.workbook;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.jfree.workbook.date.SerialDate;

/**
 * Represents one worksheet within a workbook.
 */
public class Worksheet {

    /** The maximum number of columns in a worksheet. */
    public static final int MAX_COLUMNS = 256;

    /** The maximum number of rows in a worksheet. */
    public static final int MAX_ROWS = 65536;

    /** The default width for columns. */
    public static final double DEFAULT_COLUMN_WIDTH = 48;

    /** The default height for rows. */
    public static final double DEFAULT_ROW_HEIGHT = 12.8;

    /** The name of the worksheet. */
    protected String name;

    /** Display formulae rather than calculated values (true/false). */
    protected boolean displayFormulae;

    /** Hide zeros (true/false). */
    protected boolean hideZeros;

    /** A flag indicating whether or not the grid is visible. */
    protected boolean gridVisible;

    /** A flag indicating whether or not the column header is visible. */
    protected boolean columnHeaderVisible;

    /** A flag indicating whether or not the row header is visible. */
    protected boolean rowHeaderVisible;

    /** The index of the right-most column used in the worksheet. */
    protected int maxColumn;

    /** The index of the bottom-most row used in the worksheet. */
    protected int maxRow;

    /** The current zoom factor (in the range 0.05 to 5.00, that is 5% to 500%). */
    protected double zoom;

    /** Manager for names defined in the worksheet. */
    protected NamesManager namesManager;

    /** Print setup. */
    protected PrintInformation printInfo;

    /** Styles that apply to ranges within the worksheet. */
    protected Styles styles;

    /** Column attributes (width, margins, hidden etc). */
    protected ColumnAttributesManager columnAttributesManager;

    /** Row attributes (height, margins, hidden etc). */
    protected RowAttributesManager rowAttributesManager;

    /** Ranges that are selected. */
    protected Selections selections;

    /** The cells in the worksheet. */
    protected Cells cells;

    /** Comments for cells in the worksheet. */
    protected List comments;

    /** Settings for the solver utility. */
    protected Solver solver;

    /**
     * Standard constructor: creates a named empty worksheet.
     * 
     * @param name  the name of the worksheet.
     */
    public Worksheet(String name) {

        this.name = name;
        this.maxColumn = -1;
        this.maxRow = -1;
        this.zoom = 1.0;
        this.namesManager = new NamesManager();
        this.printInfo = new PrintInformation();
        this.styles = new Styles();
        this.columnAttributesManager = new ColumnAttributesManager();
        this.rowAttributesManager = new RowAttributesManager();
        this.selections = new Selections();
        this.cells = new Cells();
        this.comments = new ArrayList();
        this.solver = new Solver();

    }

    /**
     * Returns the name of the worksheet.
     * 
     * @return The name of the worksheet.
     */
    public String getName() {
        return this.name;
    }

    /**
     * Sets the name of the worksheet.
     * 
     * @param name  the name.
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * Returns the index of the rightmost column in the sheet.
     * 
     * @return The maximum column index.
     */
    public int getMaxColumn() {
        return this.maxColumn;
    }

    /**
     * Returns the index of the bottommost row in the sheet.
     * 
     * @return The maximum row index.
     */
    public int getMaxRow() {
        return this.maxRow;
    }

    /**
     * Returns the zoom factor.
     * 
     * @return The zoom factor.
     */
    public double getZoom() {
        return this.zoom;
    }

    /**
     * Sets the zoom factor.
     * 
     * @param percent  the new zoom factor (should be in the range 0.05 to 5.00).
     */
    public void setZoom(double percent) {

        if ((percent < 0.05) || (percent > 5.00)) {
            throw new IllegalArgumentException("Worksheet.setZoom(): value outside valid range.");
        }

        this.zoom = percent;

    }

    /**
     * Returns true if formulae rather than values are being displayed in the worksheet.
     * 
     * @return True if formulae rather than values are being displayed in the worksheet.
     */
    public boolean getDisplayFormulae() {
        return this.displayFormulae;
    }

    /**
     * Returns a flag indicating whether or not zero values are displayed.
     * 
     * @return A boolean.
     */
    public boolean getHideZeros() {
        return this.hideZeros;
    }

    /**
     * Returns a flag indicating whether or not the grid is visible.
     * 
     * @return A boolean.
     */
    public boolean isGridVisible() {
        return this.gridVisible;
    }

    /**
     * Returns a flag indicating whether or not the column header is visible.
     * 
     * @return A boolean.
     */
    public boolean isColumnHeaderVisible() {
        return this.columnHeaderVisible;
    }

    /**
     * Returns a flag indicating whether or not the row header is visible.
     * 
     * @return A boolean.
     */
    public boolean isRowHeaderVisible() {
        return this.rowHeaderVisible;
    }

    /**
     * Returns a reference to the names manager.
     * 
     * @return A reference to the names manager.
     */
    public NamesManager getNamesManager() {
        return this.namesManager;
    }

    /**
     * Returns the print information for the sheet.
     * 
     * @return Print information.
     */
    public PrintInformation getPrintInformation() {
        return this.printInfo;
    }

    /**
     * Returns the styles information for the sheet.
     * 
     * @return Styles information.
     */
    public Styles getStyles() {
        return this.styles;
    }

    /**
     * Returns the selections for the sheet.
     * 
     * @return The selections.
     */
    public Selections getSelections() {
        return this.selections;
    }

    /**
     * Returns the cells for the worksheet.
     * 
     * @return The cells.
     */
    public Cells getCells() {
        return this.cells;
    }

    /**
     * Returns the solver for the worksheet.
     * 
     * @return The solver.
     */
    public Solver getSolver() {
        return this.solver;
    }

    /**
     * Returns the comments for the worksheet.
     * 
     * @return The comments.
     */
    public List getComments() {
        return this.comments;
    }

    /**
     * Returns a reference to the object managing the column attributes.
     * 
     * @return The column attributes manager.
     */
    public ColumnAttributesManager getColumnAttributesManager() {
        return this.columnAttributesManager;
    }

    /**
     * Returns a reference to the object managing the row attributes.
     * 
     * @return The row attributes manager.
     */
    public RowAttributesManager getRowAttributesManager() {
        return this.rowAttributesManager;
    }

    /**
     * Sets the height of one row.
     * 
     * @param row  the row (0 <= startRow < Worksheets.MAX_ROWS).
     * @param height  the new height.
     */
    public void setRowHeight(int row, double height) {

⌨️ 快捷键说明

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