views:

122

answers:

6

Hi

Can someone point me in the right direction for writing to an excel file in java?? I am not understanding the links I found online. Could you just send me a link or anything which I could follow through??

Thank you, J

+1  A: 

Not to be banal, but Apache POI can do it. You can find some code examples here:
http://poi.apache.org/spreadsheet/examples.html

Nikita Rybak
+2  A: 

Another alternative to Apache POI is the JExcelAPI, which (IMO) has an easier to use API. Some examples:

WritableWorkbook workbook = Workbook.createWorkbook(new File("output.xls"));

WritableSheet sheet = workbook.createSheet("First Sheet", 0);

Label label = new Label(0, 2, "A label record"); 
sheet.addCell(label); 

Number number = new Number(3, 4, 3.1459); 
sheet.addCell(number);
matt b
A: 

I've used Apache's POI Library when I've had to write to excel files from Java. I found it rather straight forward once you get the hang of it. Java World has a good tutorial about starting out using POI that I found very helpful.

+2  A: 

Posting useful examples for API's.

Step by step example for using JExcelAPI:

http://www.vogella.de/articles/JavaExcel/article.html

http://www.java-tips.org/other-api-tips/jexcel/how-to-create-an-excel-file.html

Step by step example for using POI (little old one but useful):

http://www.javaworld.com/javaworld/jw-03-2004/jw-0322-poi.html

YoK
A: 

I've used JExcelAPI and learned how from this tutorial.

aniri
A: 

Another commercial Java Excel component,SmartXLS For Java, it supports most Excel features like Charts,Pivot Tables,Formula calculations,and can read/write both Excel97-2003 xls files and Excel2007 xlsx/xlsm files.

liya