'Java ERROR: package X is declared in the unnamed module, but module Y does not read it

I am trying to make my javafx project to create an Excel file. One of the first steps for it would be XSSFWorkbook workbook = new XSSFWorkbook(); for which to work I need import org.apache.poi.xssf.usermodel.XSSFWorkbook; to work. But when I try to run the program I get an error:

  (package org.apache.poi.xssf.usermodel is declared in module org.apache.poi.ooxml, but module group.proga does not read it)

I use IntelliJ IDEA 2022.1.1 (Community Edition). I downloaded Apache POI 5.2.2 and poi-ooxml-5.2.2 and commons-collections4-4.4 JAR files. I tried adding them to external Libraries by opening Files-Project Structure - Libraries - +. They were added to the External Libraries List but do not work. I also added dependencies to the POM file:

<dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>5.2.2</version>
        </dependency>

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

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-collections4</artifactId>
            <version>4.4</version>
        </dependency>

It did not help either. Please, I have a project deadline soon and I can not finish it without it creating an Excel file.



Solution 1:[1]

Try looking at my new project to write large XLSX files without using POI at all: https://github.com/Yaytay/streaming-xlsx-writer

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1