Hey sharan i was just searching for it. Though I didn't follow it completely I heard your voice and some old memories came up. The way you typing java 8 code I am motivated now to read it...
i have error like this "java.lang.ClassNotFoundException: org.apache.poi.xssf.usermodel.XSSFWorkbookFactory". i use apache poi version 4.1.1 . any suggestion ?
Is it possible to have ORM kind of thing with excel, like we do in Repository. can we write class like : @ExcelSheet("sheet-name") class Emp { @Cell("id") int id; @Cell("empName") String empName; }
@@mickeyjava1580 Hello! I really need your advice on writing an MVC application that can convert the file format. Could you help, please. Could you give me some tips, please
Hey Mickey, is something missing in code ? i tried to execute the code as is and am getting "Cannot get a NUMERIC value from a STRING cell" error with same sample file
Converge streams, example: Map cellListMap = uploadUtil.getStream(row) .collect(Collectors.groupingBy(Cell::getCellType)); List cellList = Stream.of( cellListMap.get(CellType.NUMERIC).stream().map(Cell::getNumericCellValue), cellListMap.get(CellType.STRING).stream().map(Cell::getStringCellValue) ).collect(Collectors.toList()); but this may affect mapping it to the right header. Something to work on :)
@@mickeyjava1580 uploadUtil.getStream(row) it says row can not be resolved to a variable!! what is the real argument to be passed as a row? Cell::getCellType this getCellType is deprecated, in POI 3.15, getCellTypeEnum is deprecated too? what would you advise?
@@mickeyjava1580 I am getting same error "Cannot get a NUMERIC value from a STRING cell" error with same sample file, I tried your code of converge streams, but facing some issues with mapping as you mentioned in your above. can you suggest anything on it?
Resolved [org.springframework.web.multipart.support.MissingServletRequestPartException: Required part 'file' is not present.] how to resolve this issue??
Buen video, para aquellos que necesitan validar los tipos de datos de las columnas List cellList = uploadUtil.getStream(row).map(cell -> { String cellVal = ""; if (cell.getCellType().equals(CellType.STRING)) { cellVal = cell.getStringCellValue(); } else if (cell.getCellType().equals(CellType.NUMERIC)) { cellVal = String.valueOf(cell.getNumericCellValue()); if (DateUtil.isCellDateFormatted(cell)) { DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); Date date = cell.getDateCellValue(); cellVal = df.format(date); } } return cellVal; }).collect(Collectors.toList());
You can use switch case or if else. switch (cell.getCellTypeEnum()) { case STRING: return cell.getStringCellValue(); case NUMERIC: return cell.getNumeric...;
@@shaarg how to get string and integer using map(). Mickey Java used.map(cell::getstringcellvalue). It throws error cannot get a string from a numeric cell, when values like s.no is read. I have changed the cell format type to text. But no luck.
Converge streams, example: Map cellListMap = uploadUtil.getStream(row) .collect(Collectors.groupingBy(Cell::getCellType)); List cellList = Stream.of( cellListMap.get(CellType.NUMERIC).stream().map(Cell::getNumericCellValue), cellListMap.get(CellType.STRING).stream().map(Cell::getStringCellValue) ).collect(Collectors.toList()); but this may affect mapping it to the right header. Something to work on :)