Results 1 to 7 of 7
  1. #1
    lemontree45 is offline Member
    Join Date
    Oct 2010
    Posts
    25
    Rep Power
    0

    Default Text read and write between *.txt file and *.xls file

    I am new to java and netbeans. I have already picked up the necessary concepts and basic programming skills in Java. I am now trying to do a specific java application which does the following things. This file might look lil dumb. but please consider it as an example.


    tasks:

    I have an input file (*.txt) and a database file (*.xls).

    for eg:##

    1. students.txt

    input file:

    ##########
    Hi this is my input file
    #############
    List of students
    ############

    Leonard
    Age:32

    Sheldon Cooper
    Age:45

    Leonard
    Place:New Jersey

    Sheldon Cooper
    Place: New York

    ###############
    This is the end of the file

    2. data.xls

    eg #####

    Database(3 columns):

    Name Age Place

    Leonard 30 Toronto
    Raj K 22 Delhi


    So what I need to do here is to edit this input file automatically and insert the correct 'Age' and 'Place' of the students as given in the database.

    If a student is not present in the database. Pop up a window and show the list of students with the parameters 'Age' and 'Place' so that I can edit it from there. Once I edit it, these new students have to be added to the Database in the same format as the others with the edited value of parameters.

    So, Could someone shed some light on some basic ideas to proceed. For eg: I heard, inorder to work with Excel sheets you need to have a separate library included to netbeans.

    #What sort of search should I have to do to find the 'name' match between the input and that in the database?

    # Someone could provide me a sample example somewhat related to it?

    It would be of real help. I have already made the basic windows and all that stuffs using the swing api on netbeans. Thanks in advance.

    Regards

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default

    Don't double post. I've removed the other thread you started with the identically same question.

    db

  3. #3
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,890
    Rep Power
    25

    Default

    a database file (*.xls).
    The .xls extension looks like that for the MS Excel program. How are you accessing (read and write) that file?
    The Apache POI framework has classes for working with MS office files.

  4. #4
    lemontree45 is offline Member
    Join Date
    Oct 2010
    Posts
    25
    Rep Power
    0

    Default

    Yea. database is an excel sheet. I still haven't figured out a way to do it. is it really possible to edit a .txt file by comparing the name from the database? Thanks for the advice about Apache POI framework. I will consider that.

  5. #5
    lemontree45 is offline Member
    Join Date
    Oct 2010
    Posts
    25
    Rep Power
    0

    Default

    sorry. lack on experience being in a forum.

  6. #6
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,890
    Rep Power
    25

    Default

    is it really possible to edit a .txt file by comparing the name from the database?
    Yes, usually if you can design it, it can be programmed.
    The contents of a text file can be changed as desired.
    Define what the text file looks like. What is in a line/record? What are the fields/subparts of a line?
    When text files are updated, if the new data is NOT exactly a one for one byte replacement of the old data, then the file will have to be rewritten from where the changes were made to the end of the file.
    If the new stuff will overlay the old stuff exactly then you could just update those bytes. This does NOT happen very often.

  7. #7
    stchman's Avatar
    stchman is offline Member
    Join Date
    Apr 2011
    Location
    Saint Louis, Missouri
    Posts
    97
    Rep Power
    0

    Default

    In order to read a .xls file in Java you need to get a library that does it. There are two I know of:

    Apache POI
    JExcelAPI

    I have used both and find JExcelAPI easier to use.
    If you aren't programming in Java, well that's just too bad.
    I'd rather be using Ubuntu.

Similar Threads

  1. Replies: 6
    Last Post: 12-01-2010, 06:31 AM
  2. Read/edit/Write text file
    By Graupner1000 in forum New To Java
    Replies: 17
    Last Post: 08-25-2010, 03:04 PM
  3. Replies: 5
    Last Post: 02-05-2009, 11:28 AM
  4. How to read a text file from a Java Archive File
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-08-2008, 10:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •