读取word在网页中显示

wsldnl 2009-11-06 03:51:19
我在后台上传了一个word文档
然后要在页面上
取出该文件的路径
将该word文档读取出来
在页面上显示.

怎么实现啊??
...全文
1046 31 打赏 收藏 转发到动态 举报
写回复
用AI写文章
31 条回复
切换为时间正序
请发表友善的回复…
发表回复
p5q5o5w5 2011-07-26
  • 打赏
  • 举报
回复
word的ClassID找到叶没用的,大家早试过了,PDF和EXCEL是可以的。
ws_hgo 2009-11-07
  • 打赏
  • 举报
回复
[Quote=引用 29 楼 yuanmanguo 的回复:]
引用 28 楼 ws_hgo 的回复:
引用 27 楼 yuanmanguo 的回复:
HTML code <headrunat="server"> <title>无标题页 </title> </head> <body> <formid="form1" runat="server"> <div> <div> <iframesrc="../../temp/aa.doc" marginwidth="0" marginheight="0" frameborder="0"
                  ?-

这个肯定不行的


不行那就研究这种吧:

如何在网页中内嵌PDF,word和Excel文档

在网页在 <body>标签中插入如下代码:

  <object  classid="clsid:CA8A9780-280D-11CF-A24D-444553540000"  width="760"  height="411"  border="0">           
              <param  name="SRC"  value="aa.pdf">   
  </object>

即可在网页中嵌入pdf文档,上述代码的classid="clsid:CA8A9780-280D-11CF-A24D-444553540000"是pdf应用程序在注册表中的id号,同理若把该classid换成word,excel程序的注册id,可以网页中插入word和excel文档.


不过我也没搞出来
[/Quote]
不一样没有搞出来
呵呵
yuanmanguo 2009-11-07
  • 打赏
  • 举报
回复
[Quote=引用 28 楼 ws_hgo 的回复:]
引用 27 楼 yuanmanguo 的回复:
HTML code <headrunat="server"> <title>无标题页 </title> </head> <body> <formid="form1" runat="server"> <div> <div> <iframesrc="../../temp/aa.doc" marginwidth="0" marginheight="0" frameborder="0"
                  ?-

这个肯定不行的
[/Quote]

不行那就研究这种吧:

如何在网页中内嵌PDF,word和Excel文档

在网页在<body>标签中插入如下代码:

<object classid="clsid:CA8A9780-280D-11CF-A24D-444553540000" width="760" height="411" border="0">
<param name="SRC" value="aa.pdf">
</object>

即可在网页中嵌入pdf文档,上述代码的classid="clsid:CA8A9780-280D-11CF-A24D-444553540000"是pdf应用程序在注册表中的id号,同理若把该classid换成word,excel程序的注册id,可以网页中插入word和excel文档.


不过我也没搞出来
ws_hgo 2009-11-07
  • 打赏
  • 举报
回复
[Quote=引用 27 楼 yuanmanguo 的回复:]
HTML code<headrunat="server"><title>无标题页</title></head><body><formid="form1" runat="server"><div><div><iframesrc="../../temp/aa.doc" marginwidth="0" marginheight="0" frameborder="0"
?-
[/Quote]
这个肯定不行的
yuanmanguo 2009-11-07
  • 打赏
  • 举报
回复

<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<div>
<iframe src="../../temp/aa.doc" marginwidth="0" marginheight="0" frameborder="0"
width="100%" height="100%"></iframe>
</div>
</div>
</form>
</body>
</html>

wsldnl 2009-11-07
  • 打赏
  • 举报
回复
高手啊
wsldnl 2009-11-07
  • 打赏
  • 举报
回复
up
crskyp 2009-11-06
  • 打赏
  • 举报
回复
mark
happy664618843 2009-11-06
  • 打赏
  • 举报
回复
没有用过友情帮顶
ws_hgo 2009-11-06
  • 打赏
  • 举报
回复
UP
liminlovemama 2009-11-06
  • 打赏
  • 举报
回复
我们就是用上面的代码实现在IE里头显示服务器excel文件的。
你试过没有。
下面那句应该是: response.ContentType ="application/msword"
liminlovemama 2009-11-06
  • 打赏
  • 举报
回复
[Quote=引用 19 楼 wsldnl 的回复:]
引用 17 楼 liminlovemama 的回复:
我们做过网页里显示Excel,关键是那个inline,直接打开。 如果变成attachment,那就是弹出下载对话框。
C# codeResponse.AppendHeader("Content-Disposition","inline;filename="& fileName)
            Response.ContentType="application/ms-excel"
            Response.WriteFile(strPath)
                      Response.Flush()

word的话,改成Response.ContentType = "application/ms-word" 看看行不行吧


你的代码有问题啊
[/Quote]

搞错了。 我的是vb.net代码。
wsldnl 2009-11-06
  • 打赏
  • 举报
回复
[Quote=引用 17 楼 liminlovemama 的回复:]
我们做过网页里显示Excel,关键是那个inline,直接打开。 如果变成attachment,那就是弹出下载对话框。
C# codeResponse.AppendHeader("Content-Disposition","inline;filename="& fileName)
Response.ContentType="application/ms-excel"
Response.WriteFile(strPath)
Response.Flush()

word的话,改成Response.ContentType = "application/ms-word" 看看行不行吧

[/Quote]
你的代码有问题啊
angusn 2009-11-06
  • 打赏
  • 举报
回复
导出到Word代码

<input type="hidden" name="out_word" onclick="vbscript:buildDoc" value="导出到word" class="notPrint">


<script language="vbscript">
Sub buildDoc
set table = document.all.data
row = table.rows.length
column = table.rows(1).cells.length

Set objWordDoc = CreateObject("Word.Document")

'objWordDoc.Application.Documents.Add theTemplate, False
objWordDoc.Application.Visible=True

Dim theArray(20,10000)
for i=0 to row-1
for j=0 to column-1
theArray(j+1,i+1) = table.rows(i).cells(j).innerTEXT
next
next
objWordDoc.Application.ActiveDocument.Paragraphs.Add.Range.InsertBefore("综合查询结果集") //显示表格标题

objWordDoc.Application.ActiveDocument.Paragraphs.Add.Range.InsertBefore("")
Set rngPara = objWordDoc.Application.ActiveDocument.Paragraphs(1).Range
With rngPara
.Bold = True //将标题设为粗体
.ParagraphFormat.Alignment = 1 //将标题居中
.Font.Name = "隶书" //设定标题字体
.Font.Size = 18 //设定标题字体大小
End With
Set rngCurrent = objWordDoc.Application.ActiveDocument.Paragraphs(3).Range
Set tabCurrent = ObjWordDoc.Application.ActiveDocument.Tables.Add(rngCurrent,row,column)

for i = 1 to column

objWordDoc.Application.ActiveDocument.Tables(1).Rows(1).Cells(i).Range.InsertAfter theArray(i,1)
objWordDoc.Application.ActiveDocument.Tables(1).Rows(1).Cells(i).Range.ParagraphFormat.alignment=1
next
For i =1 to column
For j = 2 to row
objWordDoc.Application.ActiveDocument.Tables(1).Rows(j).Cells(i).Range.InsertAfter theArray(i,j)
objWordDoc.Application.ActiveDocument.Tables(1).Rows(j).Cells(i).Range.ParagraphFormat.alignment=1
Next
Next

End Sub
</SCRIPT>


简单点可以用控件baidu一下你就知道
liminlovemama 2009-11-06
  • 打赏
  • 举报
回复
我们做过网页里显示Excel,关键是那个inline,直接打开。 如果变成attachment,那就是弹出下载对话框。
Response.AppendHeader("Content-Disposition", "inline;filename=" & fileName)
Response.ContentType = "application/ms-excel"
Response.WriteFile(strPath)
Response.Flush()


word的话,改成Response.ContentType = "application/ms-word" 看看行不行吧
hyfzz123 2009-11-06
  • 打赏
  • 举报
回复

//filePath:word源文件地址,savePath:保存的文件夹地址
public static void Doc2html(string filePath, string savePath)
{
//转化后的mhtml保存地址
object fileSaveName = savePath + filePath.Substring(filePath.LastIndexOf("\\"), filePath.LastIndexOf(".") - filePath.LastIndexOf("\\")) + ".mhtml";
if (File.Exists(fileSaveName.ToString()))
{
return;
}
//实例化COM
Microsoft.Office.Interop.Word.ApplicationClass wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
object fileobj = filePath;
object nullobj = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.Document doc = null;
object vk_read_only = false;
object vk_visible = true;
object vk_false = false;
try
{
doc = wordApp.Documents.Open(ref fileobj, ref nullobj, ref vk_read_only,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref vk_read_only, ref nullobj, ref nullobj, ref nullobj, ref nullobj);

if (!Directory.Exists(savePath))
{
Directory.CreateDirectory(savePath);
}
//word转换格式
object format = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatWebArchive;
//将word转换为mhtml
doc.SaveAs(ref fileSaveName, ref format, 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);
}
catch (Exception exp)
{
MessageBox.Show(exp.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
finally
{
if (doc != null)
{
//关闭文件
doc.Close(ref vk_false, ref nullobj, ref nullobj);
}
if (wordApp != null)
{
wordApp.NormalTemplate.Saved = true;
//关闭COM
wordApp.Quit(ref vk_false, ref nullobj, ref nullobj);
}
}
}

wsldnl 2009-11-06
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 sweetsuzyhyf 的回复:]
吧转换后的mhtml地址传出去就可以了啊
[/Quote]
麻烦写下注视
我看不懂
谢谢
hyfzz123 2009-11-06
  • 打赏
  • 举报
回复
吧转换后的mhtml地址传出去就可以了啊
wsldnl 2009-11-06
  • 打赏
  • 举报
回复
11楼的
关键是怎么现实出来啊
wsldnl 2009-11-06
  • 打赏
  • 举报
回复
没有人会吗
加载更多回复(11)

7,765

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧