How to read .Doc, pdf, .xls etc file?
-
HI, I need to read .doc,.xls,.pdf etc... file and then encrypt/decrypt the same but I am not able to read the file properly using CFile object. How to read these files? what are the functions to read the same? Any example if possible. I am not using Doc/View architecure. I am developing MFC Dialog based application. Your help and time is much appreciated. Thanks & Best Regards, Mahesh
-
HI, I need to read .doc,.xls,.pdf etc... file and then encrypt/decrypt the same but I am not able to read the file properly using CFile object. How to read these files? what are the functions to read the same? Any example if possible. I am not using Doc/View architecure. I am developing MFC Dialog based application. Your help and time is much appreciated. Thanks & Best Regards, Mahesh
they are not text files, they are binary files, so, if you use
fscanf()
,cin
or such basic functions, you'll get "strange" data. search for any api provided with Office...
TOXCCT >>> GEII power
[toxcct][VisualCalc 2.20][VCalc 3.0 soon...] -
HI, I need to read .doc,.xls,.pdf etc... file and then encrypt/decrypt the same but I am not able to read the file properly using CFile object. How to read these files? what are the functions to read the same? Any example if possible. I am not using Doc/View architecure. I am developing MFC Dialog based application. Your help and time is much appreciated. Thanks & Best Regards, Mahesh
Amarelia wrote:
...but I am not able to read the file properly using CFile object.
Why not?
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
-
HI, I need to read .doc,.xls,.pdf etc... file and then encrypt/decrypt the same but I am not able to read the file properly using CFile object. How to read these files? what are the functions to read the same? Any example if possible. I am not using Doc/View architecure. I am developing MFC Dialog based application. Your help and time is much appreciated. Thanks & Best Regards, Mahesh
You can get text from MS Office files by using COM, but this requires office installed. Next, on new systems you can check IFilter interface - system uses it to index office files. Finaly, you can use third party libraries. I can recommend http://www.wordcnv.com[^] - their libraries are very fast and support is the simply the best I have seen. Igor Green http://www.grigsoft.com/ - files and folders comparison tools
-
HI, I need to read .doc,.xls,.pdf etc... file and then encrypt/decrypt the same but I am not able to read the file properly using CFile object. How to read these files? what are the functions to read the same? Any example if possible. I am not using Doc/View architecure. I am developing MFC Dialog based application. Your help and time is much appreciated. Thanks & Best Regards, Mahesh
-
HI, I need to read .doc,.xls,.pdf etc... file and then encrypt/decrypt the same but I am not able to read the file properly using CFile object. How to read these files? what are the functions to read the same? Any example if possible. I am not using Doc/View architecure. I am developing MFC Dialog based application. Your help and time is much appreciated. Thanks & Best Regards, Mahesh
Hi, i guess you need to go through automation please see any standard MFC book and you can sail through easily,reading of excelfile is most time consuming if they have large data ,if posible convert them to CSV ( if you can ) and then parse them as you do on a text file . actually you can convert all the above formats to text format and parse ,for that you need to CreateDispatch on the respective application object and ask them to save the coressponding data in text formats . Regards, FarPointer
-
Amarelia wrote:
...but I am not able to read the file properly using CFile object.
Why not?
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
Hi, Thanks for the reply, I do it the following way... CStdioFile fileToRead; char * StringBlock = new char[64000]; fileToRead.Open(sCurrPath, CFile::modeRead | CFile::typeBinary, &feError); nBytesRead = fileToRead.Read((unsigned short *)StringBlock, 60000); The value of nBytesRead = 60000 after the last statement executes, but the StringBlock contains only few junk characters only. May be it encounters NULL or something like that which truncates it to only few chars. According to this the function reads the file correctly but the problem is in storing the data. I want to read maximum data possible at one go for the sake of my app's speed . Please give appropriate solution. Best regards and Thanks, Mahesh
-
Hi, Thanks for the reply, I do it the following way... CStdioFile fileToRead; char * StringBlock = new char[64000]; fileToRead.Open(sCurrPath, CFile::modeRead | CFile::typeBinary, &feError); nBytesRead = fileToRead.Read((unsigned short *)StringBlock, 60000); The value of nBytesRead = 60000 after the last statement executes, but the StringBlock contains only few junk characters only. May be it encounters NULL or something like that which truncates it to only few chars. According to this the function reads the file correctly but the problem is in storing the data. I want to read maximum data possible at one go for the sake of my app's speed . Please give appropriate solution. Best regards and Thanks, Mahesh
If the Read() tells you that it did read 60000 bytes, then that's the truth. Your current problem is to display those bytes. Since most word processing files (all of them) contains a lot of binary information, your buffer is bound to have a lot of '\0'-chars. Just trust nBytesRead.