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

Discussion in 'Java' started by Marzena, Apr 19, 2008.

  1. Marzena

    Marzena Guest

    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
    Marzena, Apr 19, 2008
    #1
    1. Advertising

  2. Marzena

    Jeff Higgins Guest

    Marzena wrote:


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

    Open the csv file in Excel and save as worksheet or workbook.
    Jeff Higgins, Apr 19, 2008
    #2
    1. Advertising

  3. Marzena

    Jeff Higgins Guest

    Marzena wrote:
    Maybe there is diffrent way to save ResultSet to the excel file.

    <http://office.microsoft.com/en-us/excel/HA100996641033.aspx>
    Jeff Higgins, Apr 19, 2008
    #3
  4. Marzena

    Marzena Guest

    Re: How to convert CSV to proper Excel file (every name in diffrentcell)

    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 :/
    Marzena, Apr 19, 2008
    #4
  5. Marzena

    Jeff Higgins Guest

    Marzena wrote:
    > 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".
    Jeff Higgins, Apr 19, 2008
    #5
  6. Marzena

    Roedy Green Guest

    On Sat, 19 Apr 2008 09:28:45 -0700 (PDT), Marzena
    <> wrote, quoted or indirectly quoted someone
    who said :

    >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 loo


    see http://mindprod.com/jgloss/excel.html
    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
    Roedy Green, Apr 19, 2008
    #6
  7. Marzena

    Guest

    Re: How to convert CSV to proper Excel file (every name in diffrentcell)

    On Apr 19, 11:28 am, Marzena <> wrote:
    > 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/
    , Apr 19, 2008
    #7
  8. Marzena

    Marzena Guest

    Re: How to convert CSV to proper Excel file (every name in diffrentcell)

    Tnx
    JExcelApi was perfect:) and helped me :)
    Marzena, Apr 20, 2008
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michal Mikolajczyk
    Replies:
    0
    Views:
    628
    Michal Mikolajczyk
    Feb 13, 2004
  2. Skip Montanaro
    Replies:
    0
    Views:
    691
    Skip Montanaro
    Feb 13, 2004
  3. Justin
    Replies:
    1
    Views:
    91
    Lasse Reichstein Nielsen
    Sep 28, 2003
  4. Santana
    Replies:
    1
    Views:
    118
    Serman D.
    Aug 7, 2007
  5. Santana

    How i convert a excel file to csv file

    Santana, Aug 9, 2007, in forum: Perl Misc
    Replies:
    2
    Views:
    327
Loading...

Share This Page