在ASP页面中显示文档 [英] Displaying documents in ASP Page

查看:79
本文介绍了在ASP页面中显示文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个带表的asp.net页,并且在表的每个单元格中我都想显示".DOC"文件的内容.
这可能吗?

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 ?

推荐答案


遵循将数据显示到表中的步骤

1.在ASPX页面上添加一个Table控件
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.在.CS文件中添加代码


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);

        }


尝试一下.这会为您提供帮助.
http://www.daniweb.com/web-development/aspnet/threads/124134 [ ^ ]

http://www.c-sharpcorner.com/UploadFile/Globalking/fileAccessingusingcsharp02242006050050AM/fileAccessingusingcsharp02.aspx [ ^ ]
Try this. This will help you.
http://www.daniweb.com/web-development/aspnet/threads/124134[^]

http://www.c-sharpcorner.com/UploadFile/Globalking/fileAccessingusingcsharp02242006050207AM/fileAccessingusingcsharp.aspx[^]


这篇关于在ASP页面中显示文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆