Click here to Skip to main content
15,904,416 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Can anyone tell me what should I install, to convert word document or excel document in c#...e.x I call a file with extension .doc...and when a put it in a listbox or textbox there are different character..


for notepad files there is no Problem, I just use system.text.encoding.default..

but word and excel there is a problem !
Posted

1 solution

That is because Word and Excel are not text files. Very, very few files in computing are text files. Almost none, in fact.

If you want to display the content of a file in your application, then either you need to read the actual file format yourself (and it will be different for each application that created it, and normally different for each version of each application as well), or use the actual program that created it to read it, or use a converter program.
 
Share this answer
 
Comments
VJ Reddy 18-Apr-12 7:28am    
5!
h7h7h7 18-Apr-12 7:39am    
Ok I understand you and I get it as solution. but there I find that there is an opportunity to read Word file..... I shoul use a library called mirosoft office library and some dll file like interop.word.dll .... but I don't know how to implement.

Bthw thnx :)
h7h7h7 18-Apr-12 7:41am    
and when I insert that library and those dll file it works
here is a code:
Word.Document doc = app.Documents.Open(ref file, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj);

doc.ActiveWindow.Selection.WholeStory();

doc.ActiveWindow.Selection.Copy();

IDataObject data = Clipboard.GetDataObject();

string text = data.GetData(DataFormats.Text).ToString();

Console.WriteLine(text);

doc.Close(ref nullobj, ref nullobj, ref nullobj);

app.Quit(ref nullobj, ref nullobj, ref nullobj);
OriginalGriff 18-Apr-12 8:03am    
That's about the size of it!
h7h7h7 18-Apr-12 8:16am    
No man it isn't I fine the source code and I execute it and it workd...so I brows a file from a dektop .doc file....and then when I click a button SHOW...in a text box I can see the data inside the .doc file....But I dont now why to that work and in my app dont work

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900