Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Script Reading XLSX-File from Server

Moritz Markgraf April 13, 2016

Hi Guys,

 

I am using the Add-On Adaptavist ScriptRunner for JIRA Standard Edition.

In my Script I need to read an Excel (xlsx)-File, but it continuously fails.

 

My Code:

File file = new File(path);
if(file.exists())
	Sheet mySheet = WorkbookFactory.create(new FileInputStream(file)).getSheetAt(0);

 

I am using the following jars:

dom4j.jar
xmlbeans-5.2.4.jar

 

If I use these jars:

poi-3.9.jar
poi-ooxml-3.9.jar
poi-ooxml-shemas-3.9.jar

I Get an this error:

org.apache.poi.openxml4j.exceptions.InvalidFormatException: Can't read content types part !

 

 

If I use these jars:

poi-3.11.jar
poi-ooxml-3.11.jar
poi-ooxml-shemas-3.11.jar

I Get an this error:

java.lang.NoClassDefFoundError: Could not initialize class org.apache.poi.openxml4j.opc.internal.marshallers.ZipPackagePropertiesMarshaller

although this class is in poi-ooxml-shemas-3.11.jar.

 

I also tried mixing them:

The error always depends on the poi-ooxml-shemas-x.x.jar

 

Does anyone know how to handle this? Thanks for your help.

 

PS: I have no problems opening the xlsx-File with Excel

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 21, 2016

Hi Moritz,

I am not familiar with the third party Jar's that you are using so cannot comment on why they do not work.

I have found an example located at https://gist.github.com/jkeam/4083570 which shows how you can read in an excel file in Groovy and I have been able to get this working in the Script Console of my JIRA 6.4.12 instance by pulling in the required using Grapes by adding in the code below at the top of the script.

@Grapes([
@Grab(group='org.apache.poi', module='poi', version='3.8'),
@Grab(group='org.apache.poi', module='poi-ooxml', version='3.8')
])

I hope this helps you to resolve your issue.

Thanks

Kristian

OToole November 9, 2018

Kristian, I am trying to implement this also, I have looked at the link but when I put your grapes code at the to of my script in the script console I get
startup failed:
Script21.groovy: 4: unexpected token: @ line 4, column 3.
])
^
1 error


Is there something I have to do to get grapes working with jira? I am using jira 7.12.3, scriptrunner 5.4.39
Thanks

 

I also tried ( 4.0 and several other versions )

groovy.grape.Grape.grab(group:'org.apache.poi', module:'poi', version:'4.0')
groovy.grape.Grape.grab(group:'org.apache.poi', module:'poi-ooxml', version:'4.0')

Error grabbing Grapes -- [unresolved dependency: org.apache.poi#poi;4.0: not found]

Damien Davis June 12, 2019

Did you make sure all of the 3rd party jars are owned by the jira user running the application?

TAGS
AUG Leaders

Atlassian Community Events