Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 15 of 15

Thread: How to change html data into excel in java?

  1. #1
    Junior Member
    Join Date
    May 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to change html data into excel in java?

    Anyone can know how to change html data into excel in java. I have 1 Healthcare related application in which monthly report is to be generated at the end of the month. so this gonna possible in java????


  2. #2
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Posts
    834
    My Mood
    Cynical
    Thanks
    7
    Thanked 105 Times in 90 Posts

    Default Re: Programming Code

    Ye it is possible, but you will need to give us alot of inforamtion on what you are trying to acheive. Most importantly sample input and sample output. The best way would be to produce a CSV which can then be imported into Excel.

    Sorry for the slow reply.

    Regards,
    Chris

  3. #3
    Junior Member
    Join Date
    May 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Programming Code

    Suppose I have databse in which daliy I entered some information of student like roll no., class, age , sex, fee status etc. at the end of the month I want that a file will generate in the excel format that comprises of all the details of the student for the particular month. Please respond me as soon as possible. If you have code in java for this than it will be very helpul for me.

    Thanks

  4. #4
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Posts
    834
    My Mood
    Cynical
    Thanks
    7
    Thanked 105 Times in 90 Posts

    Default Re: Programming Code

    You will need to write a Java application that connects to the Database you are using and then convert the data into an CSV since it is easier and then imort that data into Excel.

    Regards,
    Chris

  5. #5
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Programming Code

    Quote Originally Posted by rgupta31 View Post
    Suppose I have databse in which daliy I entered some information of student like roll no., class, age , sex, fee status etc. at the end of the month I want that a file will generate in the excel format that comprises of all the details of the student for the particular month. Please respond me as soon as possible. If you have code in java for this than it will be very helpul for me.

    Thanks
    What database are you using? Let me know and I will help you with the code..
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  6. #6
    Junior Member
    Join Date
    May 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Programming Code

    Please provide me how to change data into CSV.

  7. #7
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Posts
    834
    My Mood
    Cynical
    Thanks
    7
    Thanked 105 Times in 90 Posts

    Default Re: Programming Code


  8. #8
    Junior Member
    Join Date
    May 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Programming Code

    Let me explain

    I just design 2 -3 web pages in java, one for to registration form to enter student information in databse, and 2 nd page to fetch the data from database to show details of the student into a tabular form and third page is the home page where there are 3 links 1.for registration page 2. display details 3. generate report. for 3rd page i does not understand how to initiate shall i make a button that have written Generate report and call an action event on that or make link on the main page to redirect that main page onto some other page???

    for trail purposes i used ms-access.

    pls provide me your gmail id so that i will chat wid u whenever i'm get stuck into in the problem.

  9. #9
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Programming Code

    Quote Originally Posted by rgupta31
    for 3rd page i does not understand how to initiate shall i make a button that have written Generate report and call an action event on that or make link on the main page to redirect that main page onto some other page???
    Both of these methods would work. I would probably go for the action event on the button..
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  10. #10
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Programming Code

    This tutorial will help you connect to the access database:

    http://www.javaprogrammingforums.com...jdbc-java.html

    You just need to select 'Microsoft Access Database' at the ODBC Data Source Administor stage.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  11. #11
    Junior Member
    Join Date
    May 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Programming Code

    Thank you very much who posted(JavaPF) this useful information for me.
    I'll try this, if i face any problem i'll get back to you.

    Thnaks again.

  12. #12
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Programming Code

    No problem

    If you get stuck then please post whatever code you have so far and hopefully I will be able to help you move forward.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  13. #13
    Junior Member
    Join Date
    May 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Programming Code

    Please provide me full code for convert some database data into excel, i.e. from jsp to excel. I did but not got it.

  14. #14
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Programming Code

    rgupta31, please don't double post. Creating another duplicate thread won't make things happen any faster.

    First you need to work out the logic for how you are going to do this.

    I suggest you first connect to the database, extract the information line by line, and then write it out again as a .csv file. Chris provided you a link with information on .csv.

    I already gave you the link to a tutorial on how to connect to the database and you can use this tutorial to write the csv file:

    http://www.javaprogrammingforums.com...sing-java.html
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  15. #15
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Programming Code

    This is untested but it will look something like this:

    import java.sql.*;
    import java.io.*;
     
    public class Rgupta31 {
     
        /**
         * JavaProgrammingForums.com
         */    
        public static void main(String[] args) {
     
            try {
     
                String newLine = System.getProperty("line.separator");
     
                Writer output = null;
                File file = new File("ExcelFile.csv");
                output = new BufferedWriter(new FileWriter(file));
     
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                Connection con = DriverManager.getConnection("jdbc:odbc:schooldb");
                Statement st = con.createStatement();
                ResultSet rs = st.executeQuery("Select * from [Sheet1$]");
     
                ResultSetMetaData rsmd = rs.getMetaData();
                int numberOfColumns = rsmd.getColumnCount();
     
                while (rs.next()) {
     
                    for (int i = 1; i <= numberOfColumns; i++) {
                        if (i > 1)
                            System.out.print(", ");
                        String columnValue = rs.getString(i);
     
                        System.out.print(columnValue);
                        output.write(columnValue);
                        output.write(newLine);
     
                    }
                    System.out.println("");
                }
     
                st.close();
                con.close();
                output.close();
     
            } catch (Exception ex) {
                System.err.print("Exception: ");
                System.err.println(ex.getMessage());
            }
        }
    }

    Don't just try and run this without reading the JDBC tutorial first:

    http://www.javaprogrammingforums.com...jdbc-java.html
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. Robo Code - The funny Java Programming Game
    By Freaky Chris in forum The Cafe
    Replies: 20
    Last Post: October 8th, 2009, 03:42 PM