File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes exporting information to MS  excel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "exporting information to MS  excel" Watch "exporting information to MS  excel" New topic

exporting information to MS excel

luc comeau
Ranch Hand

Joined: Jan 20, 2005
Posts: 97
Hi guys, i havn't put a whole lot of thought to wheter or not this will work, but it would be nice if i could export some formatted data to an excel spreadsheet:A- that exists(append), b-or create.

I am generating alot of statistical data while running the tests for my program, and would just like to be able to use the features of excel to help me analyse it.

So if anyone has any ideas for me, the dicussion on this would be awesome.For all i know it could be as simple as putting the info out to a text file with an excel spreadsheet file extension, but im no expert on that,thats what you guy can help me with !thanks so much


National Research Council<br />Internet Logic Department
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
As it says on that page: In short, you can read and write MS Excel files using Java.

On an even simpler note, what about outputting a comma-separated file? Can't excel import that?

There is no emoticon for what I am feeling!
payal agrawal
Ranch Hand

Joined: Oct 11, 2005
Posts: 44
Look at the URL below:

How to create an Excel file
luc comeau
Ranch Hand

Joined: Jan 20, 2005
Posts: 97
I took a look at that POI page, in theory seems like that would probably be the best solution...maybe.But the reality of the situation is i have to submit a paper based on these results to the ICEC confrence by Feb 20th, so it doesnt leave me much time to go learn how to use the api.

I am intrested in this comma separated text file solution, thats more along the lines i was considering.But i have no idea about the details on this.Perhaps its just as easy as separating every item in a column by a comma, then making a new row by a semi colon or something liek that.Is anyone more familar with this sort of thing?

Joe Ess

Joined: Oct 29, 2001
Posts: 8876

Yes, Excel can read CSV. In the simplest case, columns are seperated by commas and rows are simply new lines. It can get ugly if you have data that contains special characters. Have a look at this class and see if it meets your requirements.

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
luc comeau
Ranch Hand

Joined: Jan 20, 2005
Posts: 97
so has anyone ever installed the the jxl api before? on windows specifically?
It did not come with instructions as where to put the extracted files and i couldnt find any help when i google'd it
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114

Luc, the website where you probably got the JXL API from contains a tutorial.

I just downloaded it myself and I see that the tutorial and Javadoc documentation is included in the package.

The thing you download from the download page is a *.tar.gz file. You have to unzip that using Winzip or another program that can unzip it.

Lik with any other Java API, you just have to put the JAR file (jxl.jar in this case) in your classpath. If you don't know what classpath is and how to set it, read this: How Classes are Found
[ February 03, 2006: Message edited by: Jesper de Jong ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
luc comeau
Ranch Hand

Joined: Jan 20, 2005
Posts: 97
i dropped the jxl.jar file in the jre/ext folder and (using emacs) the program will compile until i start adding the classes in to actually use some of the api.
So this is where i fiured i had to change the classpath, but this is new territory for me and i read some of the tutorials on setting it but the only thing im scared of is setting it to the path where these new classes are, will it erase the path for loading all the other classes in?
On the tutorial it said this:
C:> sdkTool -classpath classpath1;classpath2...


C:> set CLASSPATH=classpath1;classpath2...


A command-line tool, such as java, javac, javadoc, or apt

--this kinda scares me some..unless classpath variable is specifically for adding new class paths ..NOT overwriting them. Can i get some more adivce on this before i go screwring around with it ..thanks much.

more specifically, i still want to be able to load classes from my current directory that i have well as these new jxl well as all the other java classes that would normally be able to be found..i just want to make sure that setting this classpath variable will not make it look STRICTLY in that path for classes.

also note that when you extract that file, inside the jexcelapi folder there is a file named
with contains
"<?xml version="1.0" encoding="UTF-8"?>
<classpathentry kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="E:/usr/local/woodstock/jexcelapi/2_4_3/jxl.jar"/>
<classpathentry kind="output" path=""/>
that E:/usr/local/woodstock... path does not even exist on my machine. im confused what they want me to do with this.

[ February 03, 2006: Message edited by: luc comeau ]
[ February 03, 2006: Message edited by: luc comeau ]
luc comeau
Ranch Hand

Joined: Jan 20, 2005
Posts: 97

The reason it was not recognizing my the new api classes, was something to do with the way emacs chooses the classpath variable for sessions. I have figuredthat out and things are good to go now. Although i may revive this thread when i have some questions about the xcel work itself with java.thanks again
I agree. Here's the link:
subject: exporting information to MS excel