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. Read diffrent formats file in MFC.

Read diffrent formats file in MFC.

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorialquestion
7 Posts 5 Posters 2 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.
  • L Offline
    L Offline
    Le rner
    wrote on last edited by
    #1

    Hi all, i want to read diffrents formats(like: txt,doc,xls,csv,pdf etc) file,and inserts these values in ListCtrl of dialog box. please tell me how can i do this. please help me for this. if possible please explain me with example. thanks in advance.

    To accomplish great things, we must not only act, but also dream; not only plan, but also believe.

    CPalliniC R P H 4 Replies Last reply
    0
    • L Le rner

      Hi all, i want to read diffrents formats(like: txt,doc,xls,csv,pdf etc) file,and inserts these values in ListCtrl of dialog box. please tell me how can i do this. please help me for this. if possible please explain me with example. thanks in advance.

      To accomplish great things, we must not only act, but also dream; not only plan, but also believe.

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      "_$h@nky_" wrote:

      i want to read diffrents formats(like: txt,doc,xls,csv,pdf etc) file

      Fine.

      "_$h@nky_" wrote:

      nd inserts these values in ListCtrl of dialog box.

      What values? :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      In testa che avete, signor di Ceprano?

      L 1 Reply Last reply
      0
      • CPalliniC CPallini

        "_$h@nky_" wrote:

        i want to read diffrents formats(like: txt,doc,xls,csv,pdf etc) file

        Fine.

        "_$h@nky_" wrote:

        nd inserts these values in ListCtrl of dialog box.

        What values? :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        L Offline
        L Offline
        Le rner
        wrote on last edited by
        #3

        CPallini wrote:

        "_$h@nky_" wrote: nd inserts these values in ListCtrl of dialog box. What values?

        means file data.

        To accomplish great things, we must not only act, but also dream; not only plan, but also believe.

        CPalliniC 1 Reply Last reply
        0
        • L Le rner

          CPallini wrote:

          "_$h@nky_" wrote: nd inserts these values in ListCtrl of dialog box. What values?

          means file data.

          To accomplish great things, we must not only act, but also dream; not only plan, but also believe.

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          And why do you want to do that? For instance, what is the rationale behind putting the content of a PDF document into a list control item? :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          In testa che avete, signor di Ceprano?

          1 Reply Last reply
          0
          • L Le rner

            Hi all, i want to read diffrents formats(like: txt,doc,xls,csv,pdf etc) file,and inserts these values in ListCtrl of dialog box. please tell me how can i do this. please help me for this. if possible please explain me with example. thanks in advance.

            To accomplish great things, we must not only act, but also dream; not only plan, but also believe.

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

            You can read .txt, and .csv with relative ease (CFile, if you're using MFC). Other formats are not text-based and you will need to use the respective APIs/techniques to access those. I can think of office automation for reading .xls and .doc files, and haru[^] to deal with .pdf files. There are some articles that demonstrate reading from .doc and .xls, etc., files here at CP and you could do a search to find them out.

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

            1 Reply Last reply
            0
            • L Le rner

              Hi all, i want to read diffrents formats(like: txt,doc,xls,csv,pdf etc) file,and inserts these values in ListCtrl of dialog box. please tell me how can i do this. please help me for this. if possible please explain me with example. thanks in advance.

              To accomplish great things, we must not only act, but also dream; not only plan, but also believe.

              P Offline
              P Offline
              Pankaj D Dubey
              wrote on last edited by
              #6

              Hi Dude, You try the following Code, hope it can help u reading the files. Try to reduce the code, its too lengthy.... /****** This function is made to search a given string in the file and returns 1 or 0 *****/ int Search_Tag(char* input_line, char* tag_value) { int tag_len=0; Flag=FAIL; while(*input_line !='\n') { if(*tag_value=='\0') break; else { while(*tag_value!='\0') { if (*input_line==*tag_value) { input_line++; tag_value++; Flag=PASS; } else { Flag=FAIL; input_line++; tag_value++; } } } } if(Flag==FAIL) return FAIL; else return PASS; } /******This function searches the next occurance of the given string in the file******/ GetNext(FILE *ptr_read_file, char *str) { while(1) { fgets(line_buffer, 200, ptr_read_file); // read the input file line by line if(Search_Tag(line_buffer, str)) { break; } } return 0; } /***** This function traverses through the whole file and gives the position of the given strings *****/ int Search(FILE *ptr_read_file, char *str1, char* str2) { while(1) { fgets(line_buffer, 200, ptr_read_file); // read the input file line by line if(Search_Tag(line_buffer, str1)) { GetNext(ptr_read_file, str2); //Find Second Parameter break; } } return 0; } /*********** Reading the File *************/ void CABCDlg::OnButton1() { // TODO: Add your control notification handler code here ctr++; if(ctr == 1) { fp1 = fopen("File 1.txt","r"); //if the file doesnot exist or cannot be opened then return if(fp1 == NULL) { MessageBox("File Not found 'File 1.txt' Check source directory and try again...","Error",0); ctr--; return; } fp2 = fopen("File 1.txt","r"); fp3 = fopen("File 1.txt","r"); Search(fp3, "Object number: 2", "Message contents"); fgets(line_buffer, 200, fp3); /*********** READ 1st Four Bits From the File *********/ for(i=0; i<4; i++) { msg[i] = (fgetc(fp3)); } m_txt1 = msg; UpdateData(FALSE); } } ** Similarly u can read the .csv(dot csv) files as well. Note: Save the files in the same folder where .dsw was saved, to save the search time. All the best :) :)

              French is the language of love, for everything else there is c++ ...(anonymous)

              1 Reply Last reply
              0
              • L Le rner

                Hi all, i want to read diffrents formats(like: txt,doc,xls,csv,pdf etc) file,and inserts these values in ListCtrl of dialog box. please tell me how can i do this. please help me for this. if possible please explain me with example. thanks in advance.

                To accomplish great things, we must not only act, but also dream; not only plan, but also believe.

                H Offline
                H Offline
                Hamid Taebi
                wrote on last edited by
                #7

                You need to some library for them(you can find articles for pdf on the codeproject).

                Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

                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