1.用poi事件模式解析Excel2007版本以上的文件,想要获取一个sheet中的总行数
2.读到标签
public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException {
if (“dimension”.equals(name)) {
//获得总计录数
String d = attributes.getValue(“ref”);
int total =getNumber(d.substring(d.indexOf(“:”)+1,d.length()));
}
……………..
}
3.解析标签获取总行数
private static int getNumber(String column) {
String c = column.toUpperCase().replaceAll(“[A-Z]”, “”);
return Integer.parseInt(c);
}
4.注意:sheet第一行和最后一行中间可能存在空行(即没有数据)
5.没有空行的sheet—total=5
6.有空行的sheet—total=10