point.java

来自「一个java生成自动生成Excel」· Java 代码 · 共 83 行

JAVA
83
字号
package net.sf.jxls.tag;

import org.apache.poi.hssf.util.CellReference;

/**
 * Represents a single cell
 * @author Leonid Vysochyn
 */
public class Point {
    int row;
    short col;

    public Point(int row, short col) {
        this.row = row;
        this.col = col;
    }

    public Point(String refCell) {
        CellReference cellReference = new CellReference(refCell);
        row = cellReference.getRow();
        col = cellReference.getCol();
    }

    public Point shift( int rowOffset, int colOffset){
        return new Point( row + rowOffset, (short) (col + colOffset) );
    }

    public int getRow() {
        return row;
    }

    public void setRow(int row) {
        this.row = row;
    }

    public short getCol() {
        return col;
    }

    public void setCol(short col) {
        this.col = col;
    }

    public String getCellRef(){
        CellReference cellRef = new CellReference( row, col );
        return cellRef.toString();
    }

    public String toString() {
        return "(" + row + "," + col + ")";
    }

    public String toString(String sheetName){
        String cellname;
        CellReference cellRef = new CellReference( row, col );
        if( sheetName != null ){
            cellname = sheetName + "!" + cellRef.toString();
        }else{
            cellname = cellRef.toString();
        }
        return cellname;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        final Point point = (Point) o;

        if (col != point.col) return false;
        if (row != point.row) return false;

        return true;
    }

    public int hashCode() {
        int result;
        result = row;
        result = 29 * result + (int) col;
        return result;
    }
}

⌨️ 快捷键说明

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