I need to generate/export a excel file from a table that is generated from a list of objects. I can see that there is a module for Play 1.x but not for Play 2.x and. I found a possible solution but it is written in scala (I think) here: http://aishwaryasinghal.wordpress.com/2012/05/17/generating-excel-in-play-2/
I've tried to implement this but I think my imports doesn't work.
import java.io.FileOutputStream;
import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.xssf.*;
import org.apache.poi.xssf.eventusermodel.XSSFReader;
import org.apache.poi.xssf.model.SharedStringsTable;
import org.apache.poi.openxml4j.opc.OPCPackage;
public static void generateExcel(List<Infoobject> list) {
File file = new File("mydata.xlsx");
FileOutputStream fileOut = new FileOutputStream(file);
XSSFWorkbook wb = new XSSFWorkbook();
//Workbook wb = new XSSFWorkbook(); Doesn't work either
Sheet sheet = wb.createSheet("Sheet1");
int rNum = 0;
Row row = sheet.createRow(rNum);
int cNum = 0;
Cell cell = row.createCell(cNum);
cell.setCellValue("My Cell Value");
wb.write(fileOut);
fileOut.close();
}
It can't find either XSSFWorkbook, Sheet, Row and Cell. Do you guys know what the problem could be?
Can I use an another solution and just write it in clean Java? Or Javascript maybe?
And I do know that I have to iterate my List later to get some stuff in my excel file. This is just a try to see if it works.