write value in a excel file?

Hello

currently i'm developing a automatic test bench using GPIB device (multimeter, ammeter...)

i'm able to recover value from the GPIB device and export this value in a text file.

but I would like to improve this, by exporting the data directly in an Excel file.

But i have no idea how to do that!!!

If someone should give me an idea it would be very nice :)

thanks a lot for your kind help

BR

Teo

[456 byte] By [Teo73a] at [2007-11-27 6:35:25]
# 1
Define "Excel file". You could simply write a CSV file... Excel can read those.
CeciNEstPasUnProgrammeura at 2007-7-12 18:02:29 > top of Java-index,Java Essentials,Java Programming...
# 2
using 'jxl.jar' you can do the excel works easly.
achyuthba at 2007-7-12 18:02:29 > top of Java-index,Java Essentials,Java Programming...
# 3

thanks for you help

i have download the jlx package.

and i would like to try some simple command as for example create a worbook as following try{

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);

workbook.write();

workbook.close();

}

catch(Exception ex) {

JOptionPane.showMessageDialog(null, "Impossible de cr閑r le fichier xls", "Erreur", JOptionPane.ERROR_MESSAGE);

}

but i have a error when I try to execute it:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: jxl/write/WritableWorkbook

the compilation is good not the exe

do you know what i have forgot?

thanks

Teo73a at 2007-7-12 18:02:29 > top of Java-index,Java Essentials,Java Programming...
# 4
You haven't set up your classpath correctly.
DrClapa at 2007-7-12 18:02:29 > top of Java-index,Java Essentials,Java Programming...
# 5
another option is the jakarta poi project: http://jakarta.apache.org/poi/hssf/index.html
cappelleha at 2007-7-12 18:02:29 > top of Java-index,Java Essentials,Java Programming...
# 6

hi

thanks DrClap effectively it was due to an error of classpath :(

but now i have another exception.

when I execute the code step by step; after the line

workbook.write();

it generate an new exception :

Exception in thread "Thread-6" java.lang.ArrayIndexOutOfBoundsException: 100

do you know what does that mean... about which array it talk about?

thanks in advance for your kind help

BR

Teo73a at 2007-7-12 18:02:29 > top of Java-index,Java Essentials,Java Programming...
# 7

> when I execute the code step by step; after the line

> workbook.write();

> it generate an new exception :

> Exception in thread "Thread-6" java.lang.ArrayIndexOutOfBoundsException: 100

How do you know this? Where do you have that exception message line from?

I ask because, I see you're catching the exceptions that occur in or after workbook.write(), and your not mentioning ex.getMessage() in your optionpane.

So are you sure your exception is at workbook.write()?

Can you post the stacktrace?

Message was edited by:

tom_jansen

tom_jansena at 2007-7-12 18:02:29 > top of Java-index,Java Essentials,Java Programming...
# 8

actully i have used the debugger and follow the code step by step.

i use netbeans 5.0.

and just after the it pass the worbook.write(); in the debug window this exception is generated.

but effectively i'm not 100% sure it is due to this command."

i'm not sure what is exactly the Stacktrace

but i see that in the debug window:

init:

deps-jar:

compile:

0

Exception in thread "Thread-6" java.lang.ArrayIndexOutOfBoundsException: 100

at Controls.ATT$27.run(ATT.java:1505)

at java.lang.Thread.run(Thread.java:595)

i don't know if that can help you

thanks for your support

Teo73a at 2007-7-12 18:02:29 > top of Java-index,Java Essentials,Java Programming...
# 9
actually i have put my piece of code in a wrong place.i have used a dedicated place for it and it works correctly now.thanks to all of you for your kind helpsee you
Teo73a at 2007-7-12 18:02:29 > top of Java-index,Java Essentials,Java Programming...