在Asp.Net中显示Word文件 [英] Display Word File in Asp.Net

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

问题描述

我想在asp.net中显示ms word文档,但是我希望以原始格式显示单词...带有空格和每行的方法应该在新行中显示



我试过这个但是它们之间没有空格

I want to display ms word document in asp.net, but I want to display word as it is in original format ... Means with spaces and each line should be dislplay in new line

I have tried this but their are no spaces between words

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

string filePath = path;
object file = filePath;
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);  

Microsoft.Office.Interop.Word.Document doc1 = wordApp.ActiveDocument;
Range m_Content = doc1.Content.FormattedText;

Label3.Text =m_Content.text;
doc.Close(ref nullobj, ref nullobj, ref nullobj);



我的输出显示为


My Output is display as

Resume Name:-Raju Bhaiyyalal Khangare E-Mail id :-rajukhangare2211@gmail.com    Contact no. :-8793166274 Carrier Objective:-    To build my self in fast growing IT field & provide best of services to the organization, with hard work and skill which will take me to the pinnacle while contributing to the growth of the organization. Personal Skills:- Creative and positive mindset. Work with devotion and give my 100% at worktime. Efficient and effective in prioritizing work well under pressure . Educational Details:- Course University/Board Passing Year Percentage  S.S.C. Pune Board 2007 72%  H.S.C Pune Board 2009 74%  B.C.A RTM Nagpur University  2012 47.11%  M.C.A.-II RTM Nagpur University  2013  (Appeared)   Computer Skills:-     JAVA VB HTML Oracle MS-OFFICE 03/07 Windows vista/xp/07,Unix,DOS Curricular Activities:- UR of RCC college for 2 years Organized Gathering in RCC college Other Courses :- Done diploma in Core and Advance java programming Done diploma in VB     Done diploma in computer application from RSMIT Personal Details:- Name     :Raju Khangare Father’s Name    :Bhaiyyalal Bhagwan Khangare Address    :At post Saoner,Near Radheshyam Temple, Ward No.16 , Pahlepar Saoner,Dist.-Nagpr State-     Maharashta Date Of Birth    :22 october 1991 Gender     :Male Nationality   :Indian Language Known :Hindi,Marathi,English   Hobbies     :Chess ,Cricket, Music, travelling Declaration:- I here by declare that above mentioned information is true to the best of my knowledge. Date;-     Raju khangare Place:-



Plz帮帮我。


Plz help me.

推荐答案

试试Google Doc Viewer。它使用起来非常简单,免费和你不需要任何外部工具也不需要dll!在您的网页中添加如下标记代码:



Just try Google Doc Viewer. It's very simple to use, free & you do not need any external tool nor dll! Add a markup code like the following in your webpage:

<iframe src="http://docs.google.com/gview?url=URL-TO-YOUR-DOC-FILE&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>





只需将url查询字符串参数设置为您的Word doc文件,作为绝对URI和th at's it!



Just set "url" query string param to your Word doc file as an absolute URI and that's it!


好吧,在word文件中没有< br /> 标签。换行序列与浏览器无关,它们不会破坏行。

您应该使用 m_Content.text 并替换所有\\\\ n序列为< br />

这也代表空格。浏览器忽略重复的空格    将仅呈现。您可以用& nbsp; 实体替换空格,但请注意,这些是不间断的空格。



好吧,这是一种显示数据的极简主义方式,但这是你的问题。
Well, in the word file there is no <br/> tag. Newline sequences are irrelevant to the browser, they won't break the rows.
You should take m_Content.text and replace all "\r\n" sequences with "<br/>".
This stands also for the spaces. The browser is ignoring repeated spaces "    " will render only " ". You could replace spaces with &nbsp; entities, but be aware, these are non-breaking spaces.

Ok, this is a really minimalist way of showing that data, but this was your question.


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

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