0

I want to create an .xlsx workbook. Following instructions from tutorials and other Stackoverflow questions such as the following

Cannot import XSSF in Apache POI

I added the following dependency :

<dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.12</version>
    </dependency>   

My piece of code to convert a multipart file to xlsx workbook is the following:

 public void readExcelWorkbook(EuropeanAwards euApp, MultipartFile file) throws IllegalStateException, IOException
    {

        File excelFile = new File(file.getOriginalFilename());
        file.transferTo(excelFile);
        FileInputStream fIP = new FileInputStream(excelFile);
        XSSFWorkbook workbook = new XSSFWorkbook(fIP);


    }

The following import:

import org.apache.poi.xssf.usermodel.*;

is not recognized. I tried to add the poi-ooxml-schemas depencency instead but the import is still not recognized. Note that the hssf files are correctly recognized when adding the corresponding import:

import org.apache.poi.hssf.usermodel.*;

Any ideas ?

Community
  • 1
  • 1
rpd
  • 462
  • 1
  • 9
  • 24
  • 1
    Weird. I cannot reproduce this experiment: When trying your same dependency and code, Maven downloaded the poi-ooxml-3.12 artifact, and so, the import is well recognized. Are you sure that you have in your classpath the poi-ooxml-3.12.jar? – Little Santi Jul 27 '15 at 12:50
  • Can you try with a very simple pom? It might be that you've added some broken plugins or something – Gagravarr Jul 27 '15 at 22:08
  • I pulled the project from a colleague and everything went ok. No idea what was the problem unfortunately – rpd Jul 30 '15 at 09:29

1 Answers1

0

Looks like you havent rebuild your maven project after adding the dependency. Try to clean and build the project.

mvn clean install
Surendran Duraisamy
  • 2,431
  • 5
  • 26
  • 29