标签:
import java.io.File; import java.util.ArrayList; import jxl.Sheet; import jxl.Workbook; import com.jielan.util.DBUtil; import com.jielan.util.Oracle; public class Test { private ArrayList<String> filelist = new ArrayList<String>(); public static void main(String[] args) { DBUtil.startProxool(); Test t=new Test(); t.getFiles("C:\\Documents and Settings\\Administrator\\桌面\\wenzhou\\sanyue"); t.duqu(); } public void duqu(){ Bean bean=null; try { for(int j=0 ;j<filelist.size() ;j++){ Workbook wbook=Workbook.getWorkbook(new File(filelist.get(j))); Sheet sheet=wbook.getSheet(0); int i=0; for( i=1 ;i<sheet.getRows();i++){//第一行为标题行不导入 bean=new Bean();//excel的列相相应的bean bean.setShoujihao(sheet.getCell(0, i).getContents()); bean.setCtime(sheet.getCell(1, i).getContents()); bean.setCtype(sheet.getCell(2, i).getContents()); bean.setMoney(sheet.getCell(3, i).getContents()); bean.setStatus(sheet.getCell(4, i).getContents()); //把bean插入oracle } } } catch (Exception e) { e.printStackTrace(); } } private void getFiles(String filePath){ File dir = new File(filePath); File[] files = dir.listFiles(); if (files == null) return; for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { getFiles(files[i].getAbsolutePath()); } else { filelist.add(files[i].getAbsolutePath()); } } } }
为了解决问题所编写的代码
以上方法导百万数据没问题
标签:
原文地址:http://www.cnblogs.com/mengfanrong/p/5173129.html