Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.cn.led; import java.awt.Color; import java.awt.Font; import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.xssf.usermodel.XSSFColor; /** * * @author LFeng */ class Grid { private boolean show; private int row; //Excelrow,??cells[i][j]i private int col; //Excelcol,??cells[i][j]j private int x; //x?? private int y; //y?? private int width; private int height; private String text; private java.awt.Font font = new Font("", Font.PLAIN, 12); private java.awt.Color bgColor = null; private java.awt.Color ftColor = null; public int getRow() { return row; } public void setRow(int row) { this.row = row; } public int getCol() { return col; } public void setCol(int col) { this.col = col; } public int getX() { return x; } public void setX(int x) { this.x = x; } public int getY() { return y; } public void setY(int y) { this.y = y; } public boolean isShow() { return show; } public void setShow(boolean show) { this.show = show; } public int getWidth() { return width; } public void setWidth(int width) { this.width = width; } public int getHeight() { return height; } public void setHeight(int height) { this.height = height; } public String getText() { return text; } public void setText(String text) { this.text = text; } public Color getBgColor() { return bgColor; } /** * poi.ss.usermodel.Color ?? java.awt.Color * <a href="http://home.cnblogs.com/u/309701/" target="_blank">@param</a> color */ public void setBgColor(org.apache.poi.ss.usermodel.Color color) { this.bgColor = poiColor2awtColor(color); } public void setBgColor(java.awt.Color color) { this.bgColor = color; } public Color getFtColor() { return ftColor; } public void setFtColor(org.apache.poi.ss.usermodel.Color color) { this.ftColor = poiColor2awtColor(color); } public Font getFont() { return font; } public void setFont(org.apache.poi.ss.usermodel.Font font) { if (font != null) { this.font = new java.awt.Font(font.getFontName(), Font.BOLD, font.getFontHeight() / 20 + 2); } } private java.awt.Color poiColor2awtColor(org.apache.poi.ss.usermodel.Color color) { java.awt.Color awtColor = null; if (color instanceof XSSFColor) { //.xlsx XSSFColor xc = (XSSFColor) color; String rgbHex = xc.getARGBHex(); if (rgbHex != null) { awtColor = new Color(Integer.parseInt(rgbHex.substring(2), 16)); } } else if (color instanceof HSSFColor) { //.xls HSSFColor hc = (HSSFColor) color; short[] s = hc.getTriplet(); if (s != null) { awtColor = new Color(s[0], s[1], s[2]); } } return awtColor; } }