如何在aspx页面中阅读带有格式和显示的word文档 [英] How to read word document with formatting and dispaly in aspx page

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

问题描述





我想在aspx页面中阅读带有格式(字体颜色,字体大小)和显示的word文档。我使用下面的代码来读取word文件。我能够在word文档中显示文本但我想以相同的格式显示。请帮我解决。







Hi,

I want to read word document with the formats (font color,font size) and dispaly in a aspx page. I am using below code to read the word file. I am able to display the text in word document but i want to display in same format. Please help me to come out of it.



Microsoft.Office.Interop.Word.ApplicationClass AC = new Microsoft.Office.Interop.Word.ApplicationClass();

FileUpload1.SaveAs(Server.MapPath(FileUpload1.FileName));
object objFile = Server.MapPath(FileUpload1.FileName);
object objNull = System.Reflection.Missing.Value;
object objReadOnly = true;

//Open Document
Microsoft.Office.Interop.Word.Document Doc
    = AC.Documents.Open(ref objFile, ref objNull,
                             ref objReadOnly, ref objNull,
                             ref objNull, ref objNull, ref objNull,
                             ref objNull, ref objNull, ref objNull,
                             ref objNull, ref objNull, ref objNull,
                             ref objNull, ref objNull, ref objNull);

int i = 1;

foreach (Microsoft.Office.Interop.Word.Paragraph objParagraph
         in Doc.Paragraphs)
{
    try
    {
        TextBox1.Text += Doc.Paragraphs[i].Range.Text;
    }
    catch (Exception ex)
    {
        throw ex;
    }
    i++;
}

AC.Quit(ref objNull, ref objNull, ref objNull);





提前致谢。



Thanks in advance.

推荐答案

请参阅 - 在网络表单中嵌入word文档 [ ^ ]。

Refer - Embedding word document in web form[^].
Quote:

如果浏览网站的所有客户端都要安装Word并使用Internet Explorer,则可以用ActiveX对象嵌入它 [ ^ ]。如果不满足这些要求,您可能需要将其转换为浏览器能够显示的更标准格式,例如jpeg图像。您还可以查看选项 [ ^ ]。

If all the clients that are browsing the site are going to have Word installed and use Internet Explorer, you could embed it with an ActiveX object[^]. If these requirements are not met you might need to convert it to some more standard format that a browser is capable of displaying such as a jpeg image. You may also look at this option[^].


您好,



感谢您的解决方案,



要显示格式相同的内容。我使用这个 [^]将word文档转换为Html并只显示html页面在iframe。
Hi,

Thanks for the solutions,

To display the content with same format. I used this[^] to convert the word document to Html and simply displayed html page in Iframe.


这篇关于如何在aspx页面中阅读带有格式和显示的word文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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