package org.terry.jxls; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.xml.sax.SAXException; import net.sf.jxls.reader.ReaderBuilder; import net.sf.jxls.reader.XLSReadStatus; import net.sf.jxls.reader.XLSReader; public class ReadExcel { private final static String xmlConfig="student.xml"; public List read(){ InputStream inputXML = new BufferedInputStream(ReadExcel.class.getResourceAsStream(xmlConfig)); XLSReader mainReader; String path=ReadExcel.class.getResource("/").getPath(); path=path.substring(1,path.indexOf("/WebRoot")+1)+"WebRoot/Excel/stu.xls"; try { mainReader = ReaderBuilder.buildFromXML(inputXML ); InputStream inputXLS = new BufferedInputStream(new FileInputStream(path)); Student stu=new Student(); List students = new ArrayList(); Map beans = new HashMap(); beans.put("stu", stu); beans.put("students", students); XLSReadStatus readStatus = mainReader.read(inputXLS, beans); return students; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } public static void main(String[] args) { ReadExcel re=new ReadExcel(); List<Student> list=re.read(); System.out.println("ID\t name\t subject\t score"); for(Student stu:list){ System.out.println(stu.getIdname()+"\t "+stu.getName()+"\t "+stu.getSubject()+"\t "+stu.getScorename()); } } }

王涛的1 LV1
2023年8月4日
jinandfei LV12
2021年12月8日
sl0018 LV13
2021年9月23日
1_2_3_4_5_6_7 LV1
2021年2月21日
hdf999 LV12
2021年1月13日
子陵96 LV4
2020年9月7日
wjh12345654321 LV14
2020年7月17日
zmy001 LV11
2020年5月19日
丫丫123456 LV3
2020年2月26日
1848472526 LV15
2019年10月15日