您的位置:程序门 -> java -> j2se / 扩展类



写一个程序读取xls文件(在线等待)


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


写一个程序读取xls文件(在线等待)
发表于:2007-09-24 09:21:33 楼主
序号   对端号码       通话类型   呼叫时间             时长   话费
1         2968900566   市话费       2007-8-1   8:45   176     0.2

xls文件里的数据同上   有很多条

请教高手将所有数据筛选出来,条件是时间要 <8:15   并且> 17:45   时长> 600s

不能用组键,用流读取。
发表于:2007-09-24 16:07:251楼 得分:0
用jexcelapi
try   {
workbook   =   workbook.getworkbook(xlsfile);
}   catch   (biffexception   ex)   {
ex.printstacktrace();
}   catch   (ioexception   ex)   {
ex.printstacktrace();
}
sheet   sheet   =   workbook.getsheet(0); //打开第一个sheet
int   rows   =   sheet.getrows(); //返回表格行数
system.out.println( "共 "+rows+ "行 ");
int   counter   =   0,   sucess   =   0;
cell   currentcell   =   null;
boolean   haserror   =   false;
for(int   i=1;   i <rows;   i++){
//操作excel中的数据
currentcell   =   sheet.getcell(3,i);
date   呼叫时间   =   new   java.sql.date(   ((datecell)currentcell).getdate().gettime()   );
currentcell   =   sheet.getcell(4,i); //total_lanes
int   时长   =   (int)((numbercell)currentcell).getvalue();
if(时间要 <8:15   并且> 17:45   时长> 600s){
//打印记录
}
}
workbook.close();
发表于:2007-09-24 16:08:232楼 得分:0
注:xlsfile可以是文件,可以是inputstream


快速检索

最新资讯
热门点击