java 导入文件的步骤:
1:从页面传过来一下File文件,文件的路径,文件的信息。
2:在后台写把这个File读到流里的方法。
3:循环这个流的文件。
public void getExcelData(File file,TestPoJo pojo){
InputStream excelInput=null;
Workbook wb = null;
Cell cell = null;
String cellStringBuffer = null;
int line = 0;
int col = 0;
excelInput=new new FileInputStream(file);
if (excelInput!= null && !excelInput.equals("")) {
wb = Workbook.getWorkbook(excelInput);
/***循环wb***/
Sheet sheet = wb.getSheet(0);
if (sheet != null && sheet.getRows() > 0) {
for (int i = 1; i < sheet.getRows(); i++) {
cell = sheet.getCell(0, i);
/**拿到cell的值去便利操作 一列一列的去读数据***/
cellStr = cell.getContents();
}
}
}