读取.java
package com.test.applications; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; import org.apache.poi.ss.usermodel.DateUtil; // xmlbeans,Commons Collections,poi-ooxml-schemas除了以上引入的包、还需要加入这些jar包 import javax.swing.plaf.synth.SynthEditorPaneUI; import java.io.*; import java.text.SimpleDateFormat; /** * Created by xiapf on 2017/10/19 0019. */ public class readFile2 { public static String[][] readExcel(File file){ SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); String res = ""; // 先声明一下要返回的值 try { //同时支持Excel 2003、2007 File excelFile = file; //创建文件对象 FileInputStream is = new FileInputStream(excelFile); //文件流 Workbook workbook = WorkbookFactory.create(is); //这种方式 Excel 2003/2007/2010 都是可以处理的 int sheetCount = workbook.getNumberOfSheets(); //Sheet的数量 //遍历每个Sheet for (int s = 0; s < sheetCount; s++) { Sheet sheet = workbook.getSheetAt(s); int rowCount = sheet.getPhysicalNumberOfRows(); //获取总行数 //遍历每一行 for (int r = 0; r < rowCount; r++) { Row row = sheet.getRow(r);