public class ExcelUtils
extends java.lang.Object
构造器和说明 |
---|
ExcelUtils() |
限定符和类型 | 方法和说明 |
---|---|
static void |
checkPOI()
判断是否存在poi2007包
|
static boolean |
checkPOIJarExist()
判断lib目录下是否存在jar包
|
static void |
checkThirdJarPOI() |
static boolean |
checkThirdJarSupportPOI()
检查是否为新版的third包,新版third包内置了支持excel2007的poi
added by loy on 20160923
|
static java.lang.Object |
getCellValue(com.fr.third.v2.org.apache.poi.ss.usermodel.Cell cell)
获取Excel中指定单元格的值
如果是公式, 那么获取的就是一个公式
|
static java.lang.Object |
getCellValue(com.fr.third.v2.org.apache.poi.ss.usermodel.Cell cell,
boolean noFormula)
获取单元格的值
|
static java.lang.Object |
getCellValueNoFormula(com.fr.third.v2.org.apache.poi.ss.usermodel.Cell cell)
获取Excel中指定单元格的值(不保留公式)
如果是公式, 那么获取的是公式在Excel中解析留存的值
|
static java.lang.Object |
getHSSFCellValue(com.fr.third.org.apache.poi.hssf.usermodel.HSSFCell cell) |
static java.lang.Object |
getHSSFCellValueNoFormula(com.fr.third.org.apache.poi.hssf.usermodel.HSSFCell cell) |
static short |
printWidth2Design(short pw)
不容易啊,经过一番测量,终于找到了Excel总Design和Print状态的Column宽度之间的差异规律,单位都为像素 Print_Width
Design_Width Distance 260 244 16 250 234 16 240 225 15 230 216 14 220 206
14 210 197 13 200 187 13 190 178 12 180 168 12 170 159 11 160 150 10 150
140 10 140 131 9 130 121 9 120 112 8 110 102 8 108 101 7 100 93 7 98 91 7
90 84 6 80 74 6 70 65 5 60 55 5 58 54 4 50 46 4 48 44 4 40 36 4 38 35 3
30 27 3 20 18 2 10 8 2
根据数据找到的规律如下 Print_width distance(negative) [-30,-10) 0 [-10,10) 1 [10,20]
2 (20,40) 3
[40,60) 4 [60,80) 5 [80,90] 6 (90,110) 7
[110,130) 8 [130,150) 9 [150,160] 10 (160,180) 11
总结为数学公式为: dw:Design Width pw:Print Width vd:Value distance dw = dw - vd
vd = [(pw+30)/70]*4+mv mv =
[(pw+30)%70]的值在[0,20)区间时为0,在[20,40)时为1,在[40,50]是为2,在(50,70)时为3
|
public static final java.lang.String XLS
public static final java.lang.String XLSX
public static short printWidth2Design(short pw)
pw
- 像素单位public static java.lang.Object getHSSFCellValue(com.fr.third.org.apache.poi.hssf.usermodel.HSSFCell cell)
public static java.lang.Object getHSSFCellValueNoFormula(com.fr.third.org.apache.poi.hssf.usermodel.HSSFCell cell)
public static java.lang.Object getCellValue(com.fr.third.v2.org.apache.poi.ss.usermodel.Cell cell)
cell
- 指定的单元格public static java.lang.Object getCellValueNoFormula(com.fr.third.v2.org.apache.poi.ss.usermodel.Cell cell)
cell
- 指定的单元格public static java.lang.Object getCellValue(com.fr.third.v2.org.apache.poi.ss.usermodel.Cell cell, boolean noFormula)
public static boolean checkPOIJarExist()
public static void checkPOI()
public static boolean checkThirdJarSupportPOI()
public static void checkThirdJarPOI()