Java读取Excel2007

关于Java读取Excel2007的文章在Google、百度上搜索一下,没有太好的例子,实现的也不算太好。查看了一下Poi,最新的 POI 3.5 beta 4 支持读写 Excel2007和PPT2007(XLSX and PPTX),自己来实现Java读取Excel2007了。

 

1,下载 POI 3.5 beta 4 解压,把其中的jar包导入项目文件。以我的读取为例,导入了以下jar包。


没有配置 log4j,测试时报告警报信息,应该为加载顺序导致的初始化问题造成(暂时没有找原因)。

 

2,建立读取 Excel2007 方法

 

 

Java代码
  1. public static void main(String[] args) {  
  2.      SimpleDateFormat sdf = new SimpleDateFormat( "HH:mm:ss:SS" );  
  3.      TimeZone t = sdf.getTimeZone();  
  4.      t.setRawOffset(0 );  
  5.      sdf.setTimeZone(t);  
  6.      Long startTime = System.currentTimeMillis();  
  7.      String fileName = "F:\\我的文档\\学生缴费代码.xlsx" ;  
  8.     // 检测代码   
  9.     try {  
  10.          PoiReadExcel er = new PoiReadExcel();  
  11.         // 读取excel2007   
  12.          er.testPoiExcel2007(fileName);  
  13.      } catch (Exception ex) {  
  14.          Logger.getLogger(FastexcelReadExcel.class .getName()).log(Level.SEVERE, null , ex);  
  15.      }  
  16.      Long endTime = System.currentTimeMillis();  
  17.      System.out.println("用时:" + sdf.format( new Date(endTime - startTime)));  
  18. }  
public static void main(String[] args) {         SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss:SS");         TimeZone t = sdf.getTimeZone();         t.setRawOffset(0);         sdf.setTimeZone(t);         Long startTime = System.currentTimeMillis();         String fileName = "F:\\我的文档\\学生缴费代码.xlsx";         // 检测代码         try {             PoiReadExcel er = new PoiReadExcel();             // 读取excel2007             er.testPoiExcel2007(fileName);         } catch (Exception ex) {             Logger.getLogger(FastexcelReadExcel.class.getName()).log(Level.SEVERE, null, ex);         }         Long endTime = System.currentTimeMillis();         System.out.println("用时:" + sdf.format(new Date(endTime - startTime)));     }

 

读取所用时间为:4.172秒

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值