相城seo网站优化软件企业建立网站需要提供什么
相城seo网站优化软件,企业建立网站需要提供什么,衡水网站推广的网络公司,网站建设目的分析最近做项目遇到了读取Excel数据到数据库做数据的初始化。于是找一个。发现(poi-3.13)可以解决问题。可以解析两种格式(xlsx和xls)以下是实现的步骤1.下载poi3.13包#xff0c;地址(http://poi.apache.org/download.html#POI-3.13)2.学习APi。接下来是还是demo来说明问题吧地址(http://poi.apache.org/download.html#POI-3.13)2.学习APi。接下来是还是demo来说明问题吧1.准备Excel文件:2.项目的目录结构代码实战/*** 读取Excel数据* param file*/public List readExcel(File file){List list new ArrayList();try {InputStream inputStream new FileInputStream(file);String fileName file.getName();Workbook wb null;if(fileName.endsWith(xls)){//解析xls格式wb new HSSFWorkbook(inputStream);}else if(fileName.endsWith(xlsx)){//解析xlsx格式wb new XSSFWorkbook(inputStream);}//第一个工作表Sheet sheet wb.getSheetAt(0);//第一行的行号int firstRowIndex sheet.getFirstRowNum();//最后一行的行号int lastRowIndex sheet.getLastRowNum();for(int rIndex firstRowIndex; rIndex lastRowIndex; rIndex ){//获取每一行Row row sheet.getRow(rIndex);Student student new Student();if(row ! null){//获取第一例int firstCellIndex row.getFirstCellNum();int lastCellIndex row.getLastCellNum();for(int cIndex firstCellIndex; cIndex lastCellIndex; cIndex ){switch (cIndex) {case 0:student.setNo1(row.getCell(0).toString());break;case 1:student.setNo2(row.getCell(1).toString());break;case 2:student.setNo3(row.getCell(2).toString());break;case 3:student.setNo4(row.getCell(3).toString());break;case 4:student.setNo5(row.getCell(4).toString());break;case 5:student.setNo6(row.getCell(5).toString());break;case 6:student.setNo7(row.getCell(6).toString());break;default:break;}}}list.add(student);}} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}return list;}结果展示就这样了有问题可以联系我QQ1561281670
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/89267.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!