none
Reading Wrod Doc in asp.net 2.0 RRS feed

  • Question

  • For one of my rdlc report  i need to read a word doc and display the content in text box .I am using the following code to read word document
    Which works fine .But it not preserving the formats .Like bold ,Underlined ,paragraph etc .....Is there any way to read word without loosing format and display the same in rdlc report text box.

    Thanks,


                Word.Application obj_app = new Word.ApplicationClass();
                Word.Document obj_doc = new Word.DocumentClass();
                object readOnly = false;
                object isVisible = true;
                object missing = System.Reflection.Missing.Value;
                object filepath = (@"c:\PrintedPlan.doc"); //file to be read
                obj_doc = obj_app.Documents.Open(ref filepath, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);
                obj_doc.Select();
                string input = obj_app.Selection.FormattedText.Text;
                TextBox1.Text = input;

                ReportParameter[] parms = new ReportParameter[1];
                parms[0] = new ReportParameter("fx", input);
                ReportViewer1.LocalReport.SetParameters(parms);
                obj_doc.Close(ref missing, ref missing, ref missing);
                obj_app.Quit(ref missing, ref missing, ref missing);
    Wednesday, May 14, 2008 3:54 PM

Answers

  • Sorry, this is currently not supported.

     

    A future version of the report viewer control will add the SSRS 2008 capabilities of Richtext, which can parse HTML tags (such as bold, font styles, colors) on the fly.  However, this will still not work for loading in Word document and preserve all styles.  Although, you will be able to copy&paste contents from a Word document into a report textbox during design time of the report (and the Word text is automatically converted in RS RichText on paste preserving most of the Word formatting).

     

     

    -- Robert

    Friday, May 16, 2008 4:25 PM
    Moderator