2.判断文件格式“.xls” 和 “.xlxs”(Excle的两种版本) 是,就返回路径
//选择窗口,返回路径
private static String chooser(Component comp){
String filePath = null;
JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog(comp);
if(chooser.getSelectedFile()==null){
SysUtil.abort();
}
filePath = chooser.getSelectedFile().getPath();
String endName = filePath.substring(filePath.lastIndexOf("."));
if(!".xls".equals(endName) && !".xlsx".equals(endName)){
MsgBox.showWarning(comp,"文件格式错误!");
SysUtil.abort();
}
return filePath;
}
3.我的做法是把每一行作为List,然后多少行就有多少个元素,最后存入一个大List中