接分,顺便贡献点想法。
第一,用IE 打开word,鼠标右键点 doc 文件,选 open with,选IE。
第二, <a href="a.doc" target="_blank">open a.doc </a> 这样也是在IE 里打开word。
下面是我用的几种方法
<script language="javascript">
function openmydoc(){
var doc=new ActiveXObject("Word.Application");
doc.visible=true;
doc.Documents.Open("jsp学习笔记.doc");
}
</script>
</head>
<body>
<input type="button" value="ok" name="b1" onclick="openmydoc()" />
<a href="jsp学习笔记.doc" type="application/ms-word">打开word </a>
<a href="worddocument.doc" target=_blank>clickme </a>
HTML 页面直接显示word内容
办法很多
通过poi 把word转成pdf。
如果是windows平台 可以通过Jacob把word转成html
还有利用adobe公司提供的组件FlashPaper,把word转换成flash文件 百度的解决方案就是最后这一种
c#读取Word文本并用html页面方式显示出来
测试成功,分享给你
先添加COM引用:
Microsoft Word 12.0 Object Library
示例代码
using System;
using System.Collections.Generic;
using System.Text;
using MSWord = Microsoft.Office.Interop.Word;
using System.IO;
using System.Reflection;
namespace WordProcesser
{
class Program
{
static void Main(string[] args)
{
MSWord.Application wordApp;
MSWord.Document wordDoc;
Object Nothing = Missing.Value;
Console.WriteLine("Input path:");
Object path = Console.ReadLine();
path = @"E:\mobile.docx";
wordApp = new MSWord.ApplicationClass();
wordDoc = wordApp.Documents.Add(ref path, ref Nothing, ref Nothing, ref Nothing);
object format = MSWord.WdSaveFormat.wdFormatFilteredHTML;
Object newPath = @"E:\mobile.html";
wordDoc.SaveAs(ref newPath, ref format, ref Nothing, ref Nothing, ref Nothing,
ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing,
ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
wordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
wordApp.Quit(ref Nothing, ref Nothing, ref Nothing);
Console.WriteLine("Created!");
}
}
}
这里实现了把word转成html的功能,要显示的话直接调用浏览器或者写个winform里面加个webbrowser控件来显示网页页面。
请教下,我想在HTML中直接显示一个WORD文档的内容,而不是点击这个WORD链接查看。想请教下该怎么做。
1. word自动转换布局的功能其实并不是很好,往往造成与word内的布局错乱的情况。让很多本来费了很多心思设计word布局的人非常恼火。对于这种问题,我采用了现在word内设计表格布局的方法,把所有的内容都放在事先画好的表格内,并将表格的边框都设成无。在设计时可以看到边框,在运行时就没有了,非常的便于设计。一切都做好了,就该动手转换成网页了。
2. word提供了三种转换成网页的方式:
a) 单个文件网页b) 网页c) 筛选过的网页
l 如果选择a,word将会把文件转换为mhtml格式,所有word内的内容都会包含在一个文件里包括图片、表格等;
l 如果选择b,则会把文件转换成一个带word自身标记符的html文件,并产生一个与此相关的网页图片存放文件夹,里边就是word内嵌的图片,但是已经经过了优化。一般不大于60k;
l 如果选择c,则会把文件转换成完全符合html标记的网页,并产生一个与此相关的网页图片存放文件夹,里边就是word内嵌的图片,但是已经经过了优化。一般不大于60k;
3.碰到的难题:要求将word转成单个文件网页――因为带图片文件夹维护起来比较麻烦。但是发现将word转换为单个网页文件后,文件太大,完全不适合在internet上传输。
实战秘技:先将word文件按照c方式转换,会产生一个网页文件和一个图片文件夹。这时将所有的文档都关掉,将产生的新网页文件打开。然后全选(ctrl+a,ctrl+c)网页内容。新建一个word文件,让后将内容拷贝其中(ctrl+v),然后在将这个文件转为 单个网页文件。这时你会惊奇的发现,新产生的单个文件的网页的大小已经变的很小了。
如何读取word文档显示到html
1网上有人说直接 <a href="a.doc">已经 </a>结果是下载
2activxobject(word.application)结果是本地word打开的
3还有人说word 的save as ,晕我的天,你怎么不看看word的格式都没有了,我还怎么编辑和提取呢?
我想要的是在网页上面就直接编辑了,自己下个frontpage2003-插入-web组件-高级控件-activx控件 -里面居然没有找到word
<script language="javascript">
function openmydoc(){
var doc=new ActiveXObject("Word.Application");
doc.visible=true;
doc.Documents.Open("jsp学习笔记.doc");
}
</script>
</head>
<body>
<input type="button" value="ok" name="b1" onclick="openmydoc()" />
<a href="jsp学习笔记.doc" type="application/ms-word">打开word </a>
<a href="worddocument.doc" target=_blank>clickme </a>
如何在html网页中显示word文档的内容
办法很多的啊
通过poi 把word转成pdf。
如果是windows平台 可以通过Jacob把word转成html
还有利用adobe公司提供的组件FlashPaper,把word转换成flash文件 百度的解决方案就是最后这一种
word 转成html为什么不能显示图片?很着急............
你再把html改名为*.asp,然后加入以下代码后直接请求这个asp试试
Response.ContentType = "application/x-msdownload ; charset=utf-8";
Response.AddHeader("Content-Disposition", "attachment; filename=...");
word显示html文件
html是网页格式的,不是文档格式,肯定是不能复制到WORD中去的
转载请注明出处51数据库 » html在线显示word 怎么在html中显示word