How to read excel file using spring boot

后端 未结 4 1077
北恋
北恋 2021-02-02 00:46

I am making a spring boot application which will take the excel file and store its content and store it in database. I have tried many ways..but not successful. Is anyone has id

4条回答
  •  既然无缘
    2021-02-02 01:16

    Finally found the solution.

    Html file for uploading the form is

    Controller class is

    @PostMapping("/import")
    public void mapReapExcelDatatoDB(@RequestParam("file") MultipartFile reapExcelDataFile) throws IOException {
        
        List tempStudentList = new ArrayList();
        XSSFWorkbook workbook = new XSSFWorkbook(reapExcelDataFile.getInputStream());
        XSSFSheet worksheet = workbook.getSheetAt(0);
        
        for(int i=1;i

    Make sure to add the dependecy

    
        org.apache.poi
        poi
        3.12
    
    
    
        org.apache.poi
        poi-ooxml
        3.12
    
    

    Now it will work fine.

提交回复
热议问题