No XMLEventFactory.newFactory () method when creating Groovy Script to read .xlsx files on IntelliJ IDEA with JDK 1.8

I am trying to make a groovy script that reads specific .xlsx files and parses them. I want to use Apache POI, but I have several problems. If I try to run the script from IntelliJ IDEA on Mac OS X using JDK 1.8 with POI @Grab annotation 3.11 (previous versions won't load due to xml-apis dependency issues) this is what happens

Caught: java.lang.NoSuchMethodError: 

javax.xml.stream.XMLEventFactory.newFactory()Ljavax/xml/stream/XMLEventFactory;
java.lang.NoSuchMethodError: javax.xml.stream.XMLEventFactory.newFactory()Ljavax/xml/stream/XMLEventFactory;

      

However, the same code in the console throws:

Caught: java.lang.NoClassDefFoundError: org/openxmlformats/schemas/spreadsheetml/x2006/main/CTExtensionList
java.lang.NoClassDefFoundError: org/openxmlformats/schemas/spreadsheetml/x2006/main/CTExtensionList
Caused by: java.lang.ClassNotFoundException: org.openxmlformats.schemas.spreadsheetml.x2006.main.CTExtensionList

      

This is the code I'm trying to run:

import org.apache.poi.xssf.usermodel.XSSFSheet
import org.apache.poi.xssf.usermodel.XSSFWorkbook

@Grapes([
        @Grab(group='org.apache.poi', module='poi', version='3.11'),
        @Grab(group='org.apache.poi', module='poi-ooxml', version='3.11'),
        @Grab(group='org.apache.poi', module='poi-ooxml-schemas', version='3.11')
])
    def path = args[0]
    File file = new File(path)

    XSSFWorkbook workbook = new XSSFWorkbook(file)
    XSSFSheet sheet = workbook.getSheetAt(0)
    println sheet.getRow(2).getCell(2).getStringCellValue()

      

Where can the problem arise?

+3
java intellij-idea groovy apache-poi


source to share


No one has answered this question yet

Check out similar questions:

304
What is a shortcut in IntelliJ IDEA for finding method / functions?
258
How do I make IntelliJ IDEA insert a new line at each end of the file?
218
How can I read a file in Groovy into a string?
198
How to search all files of a project in IntelliJ Idea?
3
XML-BEANS compiled schema: Could not find compiled schema resource schemaorg_apache_xmlbeans / system / sE130CAA0A01A7CDE5A2B4FEB8B311707 / index.xsb
3
Reading .xlsx file from android application Using POI 3.17
1
Java.lang.NoClassDefFoundError: org / openxmlformats / schemas / spreadsheetml / x2006 / main / ctextensionlist in groovy
0
Apache POI using Xml Beans 2.0.0
0
Apache POI Workbook class not found
0
Error creating XSSFWorkbook



All Articles
Loading...
X
Show
Funny
Dev
Pics