Excel读取
来源:互联网 发布:ubuntu关闭apache服务 编辑:程序博客网 时间:2024/06/06 19:14
1、读取,传入excel地址,如:D:\1.xls
public static List Excel(String path) throws Exception { FileInputStream file = new FileInputStream(path); HSSFWorkbook wb = new HSSFWorkbook(file); HSSFSheet sheet = wb.getSheetAt(0); List<Map<String, Object>> mapList = new ArrayList<>(); //获取Excel总行数,然后循环 for (int j = 2; j <= sheet.getLastRowNum(); j++) { Row row = sheet.getRow(j);//获取某行 int coloumNum=sheet.getRow(0).getPhysicalNumberOfCells();//获得总列数 Map<String, Object> map = new HashMap<>(); String merc_order_no = getCell((HSSFCell) row.getCell(4)); System.out.println("order_amt:" + order_amt + ","); }}public static String getCell(HSSFCell cell) { if (cell == null) return ""; switch (cell.getCellType()) { case HSSFCell.CELL_TYPE_NUMERIC: return cell.getNumericCellValue() + ""; case HSSFCell.CELL_TYPE_STRING: return cell.getStringCellValue(); case HSSFCell.CELL_TYPE_FORMULA: return cell.getCellFormula(); case HSSFCell.CELL_TYPE_BLANK: return ""; case HSSFCell.CELL_TYPE_BOOLEAN: return cell.getBooleanCellValue() + ""; case HSSFCell.CELL_TYPE_ERROR: return cell.getErrorCellValue() + ""; } return ""; }
阅读全文
0 0
- 读取excel
- EXCEL读取
- 读取excel
- 读取excel
- 读取Excel
- 读取Excel
- 读取excel
- 读取excel
- excel读取
- 读取Excel
- 读取excel
- 读取excel
- excel读取
- excel读取
- Excel 读取
- 读取excel
- Excel读取
- 读取excel
- socket网络通讯详细实现过程、解释
- 会场安排问题(贪心)
- C++之尽量少做转型动作(27)---《Effective C++》
- 阶乘之和
- git 常用命令
- Excel读取
- 7.26--SSH学习之SpringMVC控制器注释
- JS程序设计
- mysql-5.7.17.msi安装
- Eclipse报错 Unable to build: the file dx.jar was not loaded from the SDK folder
- PAT(Basic Level)_1045_快速排序
- 数据语言
- 10进制/16进制字符串和数字转换
- RzPageControl(pagecontrol)实现多标签的动态添加,切换,关闭