Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. getting data from non-.txt files properly

getting data from non-.txt files properly

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    UserNameless
    wrote on last edited by
    #1

    Is there any way to read files such as .doc, .xls and load their data into a buffer? I used fstream functions to open a file, get its data and put its data in another file. on .txt files it's able to take that data and successfully place it in another txt file fine. however it's not the same for .doc or .xls files (get weird characters, possibly japanese :wtf: ). was wondering if anyone could suggest an alternative, or a fix on reading data from non .txt files properly. thanks

    C R 2 Replies Last reply
    0
    • U UserNameless

      Is there any way to read files such as .doc, .xls and load their data into a buffer? I used fstream functions to open a file, get its data and put its data in another file. on .txt files it's able to take that data and successfully place it in another txt file fine. however it's not the same for .doc or .xls files (get weird characters, possibly japanese :wtf: ). was wondering if anyone could suggest an alternative, or a fix on reading data from non .txt files properly. thanks

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      Well, .doc and .xls files are binary files. They do not only contain text, but also all extra information (formating, styles, ...). Otherwise, where would this information be saved ? If you want to read the data in them, you have to use automation (google for word automation and excell automation). The subject is a bit too broad to cover here. For other file types, it really depends of which type of file you want to open. Each file type has its own format, and you either need to parse the file accordingly to the format (which is probably a though job) or find libraries that do that for you.

      Cédric Moonen Software developer
      Charting control [v2.0] OpenGL game tutorial in C++

      U 1 Reply Last reply
      0
      • C Cedric Moonen

        Well, .doc and .xls files are binary files. They do not only contain text, but also all extra information (formating, styles, ...). Otherwise, where would this information be saved ? If you want to read the data in them, you have to use automation (google for word automation and excell automation). The subject is a bit too broad to cover here. For other file types, it really depends of which type of file you want to open. Each file type has its own format, and you either need to parse the file accordingly to the format (which is probably a though job) or find libraries that do that for you.

        Cédric Moonen Software developer
        Charting control [v2.0] OpenGL game tutorial in C++

        U Offline
        U Offline
        UserNameless
        wrote on last edited by
        #3

        Just the thing I was afraid of :( thanks Cédric

        1 Reply Last reply
        0
        • U UserNameless

          Is there any way to read files such as .doc, .xls and load their data into a buffer? I used fstream functions to open a file, get its data and put its data in another file. on .txt files it's able to take that data and successfully place it in another txt file fine. however it's not the same for .doc or .xls files (get weird characters, possibly japanese :wtf: ). was wondering if anyone could suggest an alternative, or a fix on reading data from non .txt files properly. thanks

          R Offline
          R Offline
          Rajesh R Subramanian
          wrote on last edited by
          #4

          Hello, You've been explained why you can't just open and read XLS and DOC files. To read XLS files, you can try BasicExcel - A Class to Read and Write to Microsoft Excel[^] or XLW[^]. There are such wrappers around to read/write DOC files as well, just do a search. :)

          It is a crappy thing, but it's life -^ Carlo Pallini

          U 1 Reply Last reply
          0
          • R Rajesh R Subramanian

            Hello, You've been explained why you can't just open and read XLS and DOC files. To read XLS files, you can try BasicExcel - A Class to Read and Write to Microsoft Excel[^] or XLW[^]. There are such wrappers around to read/write DOC files as well, just do a search. :)

            It is a crappy thing, but it's life -^ Carlo Pallini

            U Offline
            U Offline
            UserNameless
            wrote on last edited by
            #5

            I've heard of the ADODB abstraction class, and I've seen it used successfully in VB codes (loading as bytes), but would that come under managed C++? thanks

            R 1 Reply Last reply
            0
            • U UserNameless

              I've heard of the ADODB abstraction class, and I've seen it used successfully in VB codes (loading as bytes), but would that come under managed C++? thanks

              R Offline
              R Offline
              Rajesh R Subramanian
              wrote on last edited by
              #6

              No, the class I referred to is not managed code.

              It is a crappy thing, but it's life -^ Carlo Pallini

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups