Created
June 28, 2013 17:26
-
-
Save wytten/5886446 to your computer and use it in GitHub Desktop.
Create an Excel spreadsheet from Groovy (Java) using Apache POI 3.9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def export = { | |
| // create a new file | |
| FileOutputStream out = new FileOutputStream("workbook.xls"); | |
| // create a new workbook | |
| Workbook wb = new HSSFWorkbook(); | |
| // create a new sheet | |
| Sheet s = wb.createSheet(); | |
| int rownum = 0 | |
| for (ClaimDocumentReferenceDTO ref : docRefs) { | |
| // create a row | |
| Row r = s.createRow(rownum++) | |
| for (int cellnum=0; cellnum <10; cellnum++) { | |
| Cell c = r.createCell(cellnum); | |
| c.setCellValue( "Test" ); | |
| } | |
| } | |
| wb.write(out); | |
| out.close(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is my own version of Jeff Byrd's code that previously existed on that website:
https://gist.github.com/wytten/32be05889f84673d6187561699eeb253