解析excel问题,急急急.......... 当解析excel文件时,如果遇到一行是空的,想要跳过以后继续读下面的内容该怎么做呢?我用的是jxl解析的,请大家帮个忙,谢谢........ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 搞出来了,判断为空是做不出来的,不相信的可以自己试试 我是这样做的: 指定程序读多少行,遇到你指定的符号后就不读了。。 代码拿出来我分享一下...... Workbook workbook = null; String[][] str = null; try { workbook = Workbook.getWorkbook(in); } catch (Exception e1) { e1.printStackTrace(); } Sheet sheet = workbook.getSheet(0); Cell cell = null; /**总列数*/ if(columnCount==0) columnCount=sheet.getColumns(); /**总行数*/ if(rowCount==0) rowCount=sheet.getRows(); System.out.println("总行数:"+rowCount+" 总列数:"+columnCount); try { /**指定读多少行,遇到*号结束*/ int localRows = 0; for (int j = 0; j <rowCount; j++) { cell=sheet.getCell(0,j); if((cell.getContents().contains("***"))) { break; } localRows++; } str = new String[localRows][columnCount]; for(int i=0;i<localRows;i++) { for(int j=0;j<columnCount;j++) { /**第一个参数代表列数,第二个参数代表行数*/ cell = sheet.getCell(j,i); if(cell.getContents()!=null && !cell.getContents().equals("")) { str[i][j] = cell.getContents(); } else break; } } } catch(Exception e) { e.printStackTrace(); } finally { if(workbook!=null) workbook.close(); } 关于java class对象的一个小问题 poi.jar 这个jar包都支持excel哪些版本啊 java中如何判断字符串是否含有英文? 用bat文件启动编译好的jar包程序该怎么做? 怎么自学JAVA? 两个timestamp类型表示时间,怎么算这两个时间的差? 求救,对象初始化问题 求一个java方法实现如下的转换 请问sun的java api文档能不能下载,还是只能在线查看? 我是JAVA新手。有一个关于错误处理的问题。请高手们帮着解决 求教一个eclipse使用中的关于泛型的问题 java菜鸟 问题求解
我是这样做的:
指定程序读多少行,遇到你指定的符号后就不读了。。 代码拿出来我分享一下......
Workbook workbook = null;
String[][] str = null; try
{
workbook = Workbook.getWorkbook(in);
}
catch (Exception e1)
{
e1.printStackTrace();
}
Sheet sheet = workbook.getSheet(0);
Cell cell = null; /**总列数*/
if(columnCount==0)
columnCount=sheet.getColumns();
/**总行数*/
if(rowCount==0)
rowCount=sheet.getRows(); System.out.println("总行数:"+rowCount+" 总列数:"+columnCount); try
{
/**指定读多少行,遇到*号结束*/
int localRows = 0;
for (int j = 0; j <rowCount; j++)
{
cell=sheet.getCell(0,j);
if((cell.getContents().contains("***")))
{
break;
}
localRows++;
}
str = new String[localRows][columnCount];
for(int i=0;i<localRows;i++)
{
for(int j=0;j<columnCount;j++)
{
/**第一个参数代表列数,第二个参数代表行数*/
cell = sheet.getCell(j,i);
if(cell.getContents()!=null && !cell.getContents().equals(""))
{
str[i][j] = cell.getContents();
}
else
break;
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
if(workbook!=null)
workbook.close();
}