Click here to Skip to main content
Sign Up to vote bad
good
Hi All,
 
how to read word file into richtextbox or in textbox using asp.net in c#
 
Regards,
VenkateshDesai.
Posted 20 Sep '12 - 3:56

Comments
ridoy - 20 Sep '12 - 13:13
do you want to load the contents of word file in richtextbox?If so then i say it is possible,it do it a couple of days ago in a small work

6 solutions

You don't.
 
The TextBox control is just a normal HTML TextBox and doesn't know anything about Word documents so it can't display them.
 
ASP.NET doesn't have a RichTextBox control and even if it did, it has the same problem as the TextBox. It wouldn't know about the Word document format.
 
Now, I'm not saying it's impossible. You would have to use a 3rd party control to display the Word document. Most don't support Word so you'll have to do some research and find one that does.
  Permalink  
Try Using 3rd Party Controls like Telerik or DevExpress
  Permalink  
Use Open Xml SDK[^]. It's free, you don't need any Office libraries and there are many resources on the web.
Take a look at Read Microsoft Word Document File by using C#[^].
 
--Amit
  Permalink  
Hi Venkatesh Desai,
 
I hope this code will helpful for you.
Microsoft.Office.Interop.Word.ApplicationClass Application =  new Microsoft.Office.Interop.Word.ApplicationClass();
            object nullobj = System.Reflection.Missing.Value;
            object file = Server.MapPath("CV.docx");
            object value = System.Reflection.Missing.Value;
            Microsoft.Office.Interop.Word.Document doc = Application.Documents.Open(ref file,ref nullobj, ref nullobj, ref nullobj,ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj,ref value,ref value,ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj);
 
            doc.Activate();
            //var ss = doc.Words[0];  
            var x = doc.Words;
            cn.Open();
            SqlCommand cmd = new SqlCommand("SELECT DISTINCT SkillId FROM tblSkills ORDER BY SkillId", cn);
            cmd.CommandType = CommandType.Text;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            string SkillName = "";
            string SetSkills = "";
            string FetchSkill = "";
            
            if (ds.Tables[0].Rows.Count > 0)
            {
                string Doc_Content = doc.Content.Text;
                for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
                {
                    SkillName = ds.Tables[0].Rows[i]["SkillId"].ToString();                    
                    if (Doc_Content.ToString().IndexOf(SkillName) > 0)
                    {
                        SetSkills += SkillName + ",";
                    }
                    
                }
            }
 
            cn.Close();
            
            txtResult.Text = SetSkills.TrimEnd(',').ToString();
            // txtContent.Text = Doc_Content;
            doc.Close(ref nullobj, ref nullobj, ref nullobj);
  Permalink  
Below link works for windows application, see if you can use for web application:
Read MS word using C#[^]
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 425
1 OriginalGriff 330
2 Arun Vasu 253
3 Zoltán Zörgő 194
4 CPallini 173
0 Sergey Alexandrovich Kryukov 10,105
1 OriginalGriff 7,739
2 CPallini 4,181
3 Rohan Leuva 3,482
4 Maciej Los 2,999


Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 7 Dec 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid