permaculture playing cards
The moose likes Beginning Java and the fly likes Excel steps - Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Excel steps - " Watch "Excel steps - " New topic

Excel steps -

Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36

Hello every one ..

I was wondering if any one can help me with converting the results of my outputs to an excel file.
In other words,

The assignment was to implement 3-4 sorting algorithms - and test them using charts in Excel.
But the question, how to go from java (the output on the console) to excel .. ?

Is it that I am going to copy past from java to my excel file ?
If so, what type of data is required ?

Thanks alot, and hope hearing from very soon ...
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14917

How to work with Excel files in Java is a frequently asked question, so we have a page about it in our FAQ: Accessing File Formats.

One of the simplest ways to get data in a format that Excel understands is by writing it in a CSV file (comma-separated values). If you want to do more sophisticated things, then have a look at one of the libraries mentioned on the FAQ page.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Inder Kumar Rathore
Ranch Hand

Joined: Apr 14, 2010
Posts: 41
try Jxl API which is used to read or write the excel sheet


Living is easy with your eyes closed.....
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

Trying to use Excel directly to make your charts is probably not the best option you have. If you want to make charts in Java, maybe you should look in libraries like JFreeChart.

[My Blog]
All roads lead to JavaRanch
Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36

Thaks ..
But the idea is to produce some code that writes the results into a file, and then open that file using Excel.

This is how the question is designed ..

I don't know if you can help me with that code ..

when I know how to write into a file, but reading - am not sure ...

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42956
It's a bit unclear to me what, exactly, you're asking help with, but APIs such jExcelApi and Apache POI both can create Excel files. I concur with Christophe that the way to add charts for embedding in an Excel file would be to create those using a Java library (such as JFreeChart) and add them as images to the Excel file. Both libraries mentioned above can do that.
Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36

This question is asking to write the output into a file, and then open it via excel ..

Besides, I am not really familiar with the methods you've mentioned.

In other words, it's required to write code that does that ..

Thanks alot ..
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42956
Have you checked out the web sites that go with those libraries? They contain plenty of example code to get you started. Or were you expecting that people here would write the code for you? That's not really how JavaRanch works.
Ganesh Shirsat
Ranch Hand

Joined: Jan 10, 2010
Posts: 33

hi ,

you can use poi library to create a excel file.

example :-

HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet();

// --- Creating GridHeader Row for xls file ---
HSSFRow headerRow = sheet.createRow(0);
HSSFCell headerCell = null;
HSSFRichTextString richtextString = null;

poi library help

Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36

Thanks alot ..

I really appreaite your help ..
I wasn't expecting a code, but rather a hint so I would start my code ..

I got it now !!

Thanks once again Ganesh Shirsat
I agree. Here's the link:
subject: Excel steps -
It's not a secret anymore!