diff --git a/src/main/java/com/taover/util/UtilExcel.java b/src/main/java/com/taover/util/UtilExcel.java index 409db74..680b791 100644 --- a/src/main/java/com/taover/util/UtilExcel.java +++ b/src/main/java/com/taover/util/UtilExcel.java @@ -462,8 +462,9 @@ public class UtilExcel { // 如果是date类型则 ,获取该cell的date值 return new SimpleDateFormat("yyyy-MM-dd").format(DateUtil.getJavaDate(cell.getNumericCellValue())); } else { - // 纯数字 - return df.format(cell.getNumericCellValue()); + // 纯数字gaoming 新增兼容浮点型,转成字符串读取,不然小数点被省略了 + cell.setCellType(CellType.STRING); + return UtilString.trimCodePage(cell.getRichStringCellValue().getString()); } }else if(currCellType.compareTo(CellType.BOOLEAN) == 0){ return cell.getBooleanCellValue(); @@ -504,19 +505,21 @@ public class UtilExcel { public static void main(String args[]){ //String filepath = "C:\\Users\\root\\Desktop\\千丁-6.27.xlsx"; -// String filepath = "C:\\Users\\gaoming\\Desktop\\qwer.xls"; -// List> data = null; -// -// try { -// data = UtilExcel.readExcelAllSheetMap(filepath).get("0"); -// System.out.println(data); -// System.out.println(data.size()); -// System.out.println(UtilExcel.readExcelAllSheetMap(filepath)); -// } catch (Exception e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// List styleList = new ArrayList(); + String filepath = "C:\\Users\\gaoming\\Desktop\\mmm.xlsx"; + List> data = null; + + try { + Map>> map = UtilExcel.readExcelAllSheetMap(filepath); + System.out.println(map); + data = map.get("0"); + System.out.println(data); + System.out.println(data.size()); + System.out.println(UtilExcel.readExcelAllSheetMap(filepath)); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + List styleList = new ArrayList(); // for(int i=0; i headerList = new ArrayList(); - headerList.add("shhe1"); - headerList.add("shhe2"); - List>> dataList = new ArrayList>>(); - List> list1 = new ArrayList>(); - List list11 = new ArrayList(); - list11.add("hahaha"); - list11.add("hahaha"); - list11.add("hahaha"); - list1.add(list11); - - List> list2 = new ArrayList>(); - List list22 = new ArrayList(); - list22.add("hahaha2"); - list22.add("hahaha2"); - list22.add("hahaha2"); - list2.add(list22); - list2.add(list22); - - dataList.add(list1); - dataList.add(list2); - - UtilExcel.saveExcelContailSheet(headerList, dataList, "C:\\Users\\gaoming\\Desktop\\qwer.xls"); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } +// try { +// List headerList = new ArrayList(); +// headerList.add("shhe1"); +// headerList.add("shhe2"); +// List>> dataList = new ArrayList>>(); +// List> list1 = new ArrayList>(); +// List list11 = new ArrayList(); +// list11.add("hahaha"); +// list11.add("hahaha"); +// list11.add("hahaha"); +// list1.add(list11); +// +// List> list2 = new ArrayList>(); +// List list22 = new ArrayList(); +// list22.add("hahaha2"); +// list22.add("hahaha2"); +// list22.add("hahaha2"); +// list2.add(list22); +// list2.add(list22); +// +// dataList.add(list1); +// dataList.add(list2); +// +// UtilExcel.saveExcelContailSheet(headerList, dataList, "C:\\Users\\gaoming\\Desktop\\qwer.xls"); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } } } -- libgit2 0.21.2