Click here to Skip to main content
15,910,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi
I have a asp.net page with a table on it and in each cell in the table i want to display the content of a ".DOC" file.
is this possible ?
Posted
Updated 14-Mar-11 20:56pm
v2

Hi
Follow the step to show the data into a table

1. Add a Table control on the ASPX page
<asp:Table ID="tblShowData" runat="server" width="100%" border="0" cellspacing="0" cellpadding="0">

2. Add a code in .CS file
private void readFileContent(string path)
        {

            ApplicationClass wordApp = new ApplicationClass();

            object file = path;

            object nullobj = System.Reflection.Missing.Value;

            Microsoft.Office.Interop.Word.Document doc = wordApp.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, ref nullobj);

            doc.ActiveWindow.Selection.WholeStory();

            doc.ActiveWindow.Selection.Copy();

            string sFileText = doc.Content.Text;

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

            wordApp.Quit(ref nullobj, ref nullobj, ref nullobj);

            TableRow myTableRow = new TableRow();
            TableCell myTableCell = new TableCell();
            myTableCell.Text = sFileText;
            myTableRow.Cells.Add(myTableCell);
            tblShowData.Rows.Add(myTableRow);

        }
 
Share this answer
 
v4
Comments
Toniyo Jackson 15-Mar-11 5:00am    
Use pre tag for code

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