Thread: Reading Excel

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    1

    Reading Excel

    I have problem in reading excel file . I have to read cell wise data and i have to evaluate the data. My file looks like as below

    DATE Hectare No. Tag No. Species Size Leaf Flower Fruit
    None Flush Mature None Buds Opened None Young Ripe

    16.12.99 2 1320 RAND 68 0 0 100 100 0 0 0 100 0
    1325 RAND 90 0 0 100 100 0 0 100 0 0
    1326 ANOL 88 0 0 100 100 0 0 100 100 0
    I have to read data for the given month and i have to read how many individual species are there with 100 as data in leaf(none),leaf(flush),leaf(mature) and so on for flower and fruit...
    i have to count the no. of species in each category for the given month.

  2. #2
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    Maybe it's best to try it yourself first and then post your code.
    I'm not sure how good you are in C programming but you can start with opening en closing a file.
    There are several ways of reading a file (fgets, fread, fgetc, fscanf).

    Check this site for the manual pages...

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Excel (.xls) files are in Microsoft's "almost secret" format (you pay $$$ to find out).

    The only practical way you will be able to do this is if you export your data into a text file (say a .csv - comma separated values) file. This is just a text file, and is easy to read using standard C features.

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Try wotsit.org. They have all the major formats, but like he said earlier, they're ***-TOP SECRET-***

  5. #5
    Registered User govi's Avatar
    Join Date
    Nov 2001
    Posts
    14

    Wink

    Hi All,

    Long time since i have logged onto the board. Been a busy time for me...

    Ok about the excel thing....

    The objective can be achieved through a VB script...(.VBS extension)

    I will give you a hint.....work upon it...you will reach there ;-)

    Use ADODB libraries to connect to the Excel sheet ( Treat it as a database)....i.e the Connection, Command & Recordset objects...

    Best Of Luck,

    Rest in the next,

    Bye
    govi

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    I think the format is documented around the web, but as its a COM document its very difficult to tranlate unless you use COM........

  7. #7
    Registered User govi's Avatar
    Join Date
    Nov 2001
    Posts
    14
    Hi All,

    True..you can use COM to do the same..

    Since nobody has come up with answers..here is the link...

    This should definetly help you'all out to complete the task.. Hit Me Baby
    govi

  8. #8
    Registered User
    Join Date
    Jul 2002
    Posts
    13

    reading and MS Excel

    meena....
    i think the following method should work...
    read the file , into a character array until you encounter a tab (\t)

    try sth like this:

    char a[25];
    int i=0;
    while(ch != '\t')
    {
    fscanf( filename ,"%c",&a[i] );
    i++;
    }


    with this you can read the first cell.
    and so on..
    i have not try, but this should work..

    chandra sekhar

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading Excel Row Cells A through J
    By CheyenneWay in forum C++ Programming
    Replies: 37
    Last Post: 03-17-2011, 08:00 AM
  2. Replies: 7
    Last Post: 02-02-2009, 07:27 AM
  3. reading excel files...
    By gaah in forum C++ Programming
    Replies: 2
    Last Post: 02-18-2005, 09:55 PM
  4. Reading Excel Files?
    By Daniel in forum C++ Programming
    Replies: 2
    Last Post: 08-13-2003, 06:03 PM