MCPcopy Create free account
hub / github.com/LisenCoding/cangku / poiImport

Method poiImport

boot/src/main/java/com/utils/PoiUtil.java:26–50  ·  view source on GitHub ↗

导入 @param url @return @throws Exception

(String url)

Source from the content-addressed store, hash-verified

24 * @throws Exception
25 */
26 public static List<List<String>> poiImport(String url) throws Exception {
27 List<List<String>> list = new ArrayList<>();
28 // 创建Excel 读取文件内容
29 HSSFWorkbook workbook = new HSSFWorkbook(FileUtils.openInputStream(new File(url)));
30 /**
31 * 第一种方式读取Sheet页
32 */
33// HSSFSheet sheet = workbook.getSheet("Sheet0");
34 /**
35 * 第二种方式读取Sheet页
36 */
37 HSSFSheet sheet = workbook.getSheetAt(0);//获取工作表
38 for (int i = 0; i < sheet.getLastRowNum()+1; i++) {
39 HSSFRow row = sheet.getRow(i);//获取行
40 List<String> rowlist = new ArrayList<>();//行数据
41 for (int j = 0; j < row.getLastCellNum(); j++) {
42 HSSFCell cell = row.getCell(j);
43 cell.setCellType(Cell.CELL_TYPE_STRING);
44 String value = cell.getStringCellValue();
45 rowlist.add(value);//行中数据添加到行中
46 }
47 list.add(rowlist);//将行数据添加到list中
48 }
49 return list;
50 }
51
52
53

Callers 15

mainMethod · 0.95
saveMethod · 0.95
saveMethod · 0.95
saveMethod · 0.95
saveMethod · 0.95
saveMethod · 0.95
saveMethod · 0.95
saveMethod · 0.95
saveMethod · 0.95
saveMethod · 0.95
saveMethod · 0.95
saveMethod · 0.95

Calls 1

addMethod · 0.45

Tested by

no test coverage detected