How to convert CSV to proper Excel file (every name in diffrent cell)

M

Marzena

Hi,
I made application which needs to save the report file. I got report
file from the database and i got it as ResulSet.
I found in internet library calls CSVWriter which helps me save the
raport. The problem is that i dont know how to parse it to proper
Excel look.The code looks like this :

FileDialog d = new FileDialog(frame,"What file do you want to
save?",FileDialog.SAVE);
d.setFile("*.csv");
d.setDirectory(".");
d.show();
String saveFile;
if((saveFile = d.getFile()) != null) {
filename.setText(saveFile);
directory.setText(d.getDirectory());
try{
CSVWriter writer = new CSVWriter(new
FileWriter(directory.getText()+filename.getText()), ',');
writer.writeAll(rsDane2 , t);
writer.close();
}catch(java.sql.SQLException e){e.printStackTrace();}
catch(java.io.IOException f){ f.printStackTrace(); }
} else {
filename.setText("You pressed cancel");
directory.setText("");
}

I would be greatfull for any help. Im looking for two solutions.
1) How can I convert saved csv file to Excel or diffrent type of file
( The prioritet is the data be visable ) Cause with comma i cant see
anything :(
2) Maybe there is diffrent way to save ResultSet to the excel file.
This is really big array so i think the best way is to save it in
excel file
 
J

Jeff Higgins

Marzena wrote:


How can I convert saved csv file to Excel ...

Open the csv file in Excel and save as worksheet or workbook.
 
M

Marzena

Im talking about doing this using Java.
Save ResultSet to CSV which will be parse to fit Excel file. Or any
other way ...dont know :/
 
J

Jeff Higgins

Marzena said:
Im talking about doing this using Java.
Save ResultSet to CSV which will be parse to fit Excel file. Or any
other way ...dont know :/

I'm sorry, but I don't understand "parse to fit Excel file".
 
A

Alex.From.Ohio.Java

Hi,
I made application which needs to save the report file. I got report
file from the database and i got it as ResulSet.
I found in internet library calls CSVWriter which helps me save the
raport. The problem is that i dont know how to parse it to proper
Excel look.The code looks like this :

FileDialog d = new FileDialog(frame,"What file do you want to
save?",FileDialog.SAVE);
d.setFile("*.csv");
d.setDirectory(".");
d.show();
String saveFile;
if((saveFile = d.getFile()) != null) {
filename.setText(saveFile);
directory.setText(d.getDirectory());
try{
CSVWriter writer = new CSVWriter(new
FileWriter(directory.getText()+filename.getText()), ',');
writer.writeAll(rsDane2 , t);
writer.close();
}catch(java.sql.SQLException e){e.printStackTrace();}
catch(java.io.IOException f){ f.printStackTrace(); }
} else {
filename.setText("You pressed cancel");
directory.setText("");
}

I would be greatfull for any help. Im looking for two solutions.
1) How can I convert saved csv file to Excel or diffrent type of file
( The prioritet is the data be visable ) Cause with comma i cant see
anything :(
2) Maybe there is diffrent way to save ResultSet to the excel file.
This is really big array so i think the best way is to save it in
excel file

Two good free products:
http://poi.apache.org/
http://jexcelapi.sourceforge.net/

Alex.
http://www.myjavaserver.com/~alexfromohio/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top