知道 大家都知道用poi读取xls 当时有时候 必须要读取xlsx 现在我把我做测试的demo分享给大家
package ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
public class ReadMain {
public static void readFile(File file){
Connection con = null;
PreparedStatement ps = null;
String sql = "insert into t_xls(mobile) values(?)";
int count = 0;
try {
con = ();
ps = (sql);
InputStream is = new FileInputStream(file);
XSSFWorkbook wb = new XSSFWorkbook(is);
XSSFCell cell = null;
for (int sheetIndex = 0; sheetIndex < (); sheetIndex++) {
XSSFSheet st = (sheetIndex);
for (int rowIndex = 0; rowIndex <= (); rowIndex++) {
XSSFRow row = (rowIndex);
cell = (0);
(XSSFCell.CELL_TYPE_STRING);
count++;
(1, ());
();
if(count % 10000 == 0){
();
}
}
}
();
}catch (Exception e) {
();
}finally{
(ps);
(con);
}
}
public static void main(String[] args) {
();
readFile(new File("C:\\Documents and Settings\\Administrator\\桌面\\"));
}
}
里面会涉及把内容写入到数据库的