Jxl和POI的区别

来源:互联网 发布:sql注入检测网站 编辑:程序博客网 时间:2024/05/16 03:36

JXL.jar http://www.andykhan.com/jexcelapi/download.html 下载地址
优点:
Jxl对中文支持非常好,操作简单,方法看名知意。
Jxl是纯javaAPI,在跨平台上表现的非常完美,代码可以再windows或者Linux上运行而无需重新编写
支持Excel 95-2000的所有版本
生成Excel 2000标准格式
支持字体、数字、日期操作
能够修饰单元格属性
支持图像和图表,但是这套API对图形和图表的支持很有限,而且仅仅识别PNG格式。
缺点:效率低,图片支持部完善,对格式的支持不如POI强大
POI,http://www.apache.org/dyn/closer.cgi/jakarta/poi/ 下载poi包
1. 效率高,这点很好
2. 支持公式,宏,一些企业应用上会非常实用
3. 能够修饰单元格属性
4. 支持字体、数字、日期操作
缺点:不成熟,代码不能跨平台,貌似不少同行在使用工程中还碰到让人郁闷的BUG
——————————–性能测试————————————————
jxl包:好像是1.4 低于2.0 (忘记了)
poi:poi-3.5-FINAL-20090928.jar
环境:CPU:Intel(R) Core(TM)2 Duo CPU T65702.1GHZ ,2GB内存 MyEclipse1.6 JDK1.6
先前做过一些关于POI和jxl效率的比较,但是由于那时候测试工具很简单,不标准,偶尔在网上获得以为网友提供的简单测试包,还不错。所以重新测试下POI和JXL的性能
/**
* poi 创xcel
*/
public void writerPOI() {
try {
long dir= (long) Math.round(Math.floor(Math.random() * 10000000));
String dirPath = “c://11//”.concat(String.valueOf(dir)) ;
File file = new File(dirPath);
if(file.exists()) {
System.out.println(file.getName()+”存oi”);
if(file.delete()) {
file.mkdir();
}
}else {
file.mkdir();
}
// 创xcel 工
HSSFWorkbook newbook = new HSSFWorkbook();
int j = 0;
while(j < sheet){ //控heet创
HSSFSheet sheet = newbook.createSheet(“test”+j);
HSSFRow row = null ;//行
HSSFCell cell1 = null ;//列
HSSFCell cell2 = null ;//列
for(int i = 0 ; i < leng ; i ++){
row = sheet.createRow(i) ;
cell1 = row.createCell(0);//列
cell2 = row.createCell(1);//列
if(cell1 == null){
System.out.println(“cell1 null “);
}
cell1.setCellType(HSSFCell.CELL_TYPE_STRING);// 定
cell1.setCellValue(“A数OI”+i);// 在
cell2.setCellType(HSSFCell.CELL_TYPE_STRING);// 定
cell2.setCellValue(“B数OI”+1);// 在
}
j++ ;
}
// 新
long l = (long) Math.round(Math.floor(Math.random() * 10000000));
String name = “poi_”.concat(String.valueOf(l)).concat(“.xls”);
FileOutputStream fp = new FileOutputStream(dirPath.concat(“//”).concat(name));
newbook.write(fp);// 把xcel 工
fp.flush();
fp.close();// 操
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

0 0
原创粉丝点击