Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

How to parse excel spreadsheet from scriptrunner

Edited

Hi All,   I am trying to pull data from an excel spreadsheet.   I have found several excel parsers for groovy that are based on apache poi which seem like what I need.

https://github.com/dtanner/groovy-excel-reader/blob/master/ExcelReader.groovy

https://gist.github.com/jkeam/4083570

http://www.technipelago.se/blog/show/groovy-poi-excel

https://community.atlassian.com/t5/Answers-Developer-Questions/Script-Reading-XLSX-File-from-Server/qaq-p/562934

But I am having trouble just loading the libraries,  

I  tried using  grape to get this to resolve.

//@Grab('org.apache.poi:poi:4.0')
//@Grab('org.apache.poi:poi-ooxml:4.0')
/*import groovy.grape.Grape
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')
*/

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


import org.apache.poi.ss.usermodel.*
import org.apache.poi.hssf.usermodel.*
import org.apache.poi.sssf.usermodel.*
import org.apache.poi.ss.util.*

InputStream inp = new FileInputStream("C:\\temp\\testFile.xlsx")
Workbook wb = WorkbookFactory.create(inp);

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

Failed, on all saying that org.apache.poi was unresolved.

So I have downloaded the apache.poi jar files version 4.0 and placed the 6 jar files into web-inf/lib folder

Now I removed the grapes code and ran it and I get no errors on the import lines but it says it cannot resolve Workbook.  (Even if I scope it to org.apache.poi.ss.usermodel.Workbook)

I tried doing import org.apache.poi.ss.usermodel.Workbook and that does fail.

But the documentation for java says that is where it is located.

https://poi.apache.org/apidocs/dev/org/apache/poi/ss/usermodel/Workbook.html

 

I am running the above script from the Jira->Add ons->Script Console

Scriptrunner is 5.5.2

Jira 7.5.2

 

Any Ideas??

Thanks

 

2 answers

Suggest an answer

Log in or Sign up to answer

Hi @OToole ,

Did you find a way to do this ?

-Abrar

0 votes
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 07, 2021

Hi @OToole  Kindly check below post for reading CSV file in Script Runner :- 

https://community.atlassian.com/t5/Adaptavist-discussions/How-to-read-csv-file-in-script-runner/td-p/1701649

Thanks

TAGS
AUG Leaders

Atlassian Community Events