在网页中显示word的问题,高手帮忙!

wangwei8117 2004-04-23 10:42:16
我在做网页的时候希望点击链接后能把我的WORD文档掉出来显示在页面上,不知道怎么处理,哪位高手能帮忙啊,小弟不胜感激.
...全文
149 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
0csdn0 2004-08-09
  • 打赏
  • 举报
回复
学习
tqhchina 2004-06-26
  • 打赏
  • 举报
回复
up
jie115 2004-05-10
  • 打赏
  • 举报
回复
可以实现
见 http://www.delphibbs.com/delphibbs/dispq.asp?lid=2597952 ,下载后有VBS技术既是你需要的代码。。。

<SCRIPT LANGUAGE="JavaScript">
<!--
var FileSource;
var FileDesource;
var word;
var xmlhttp;
var filename;

function Load(){
try{
var fso = new ActiveXObject("Scripting.FileSystemObject");
filename = fso.GetSpecialFolder(2) + "\\" + "WjTemp.doc";
//alert(filename);
//OpenWeb();
}catch(e){alert(e.message);};
}
function UnLoad(){
try{
var fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFile(filename);
f.Delete();
}catch(e){ShowErrorMsg();};
}
function OpenWeb(){
try{
FileSource = document.WebForm.FileSource.value + "&ID=" + document.WebForm.ID.value + "&FileMode=" + document.WebForm.FileMode.value + "&FileType=" + document.WebForm.FileType.value;
//alert(FileSource);
var binData;
xmlhttp = new ActiveXObject("msxml2.xmlhttp");
xmlhttp.Open("get",FileSource,false);
xmlhttp.Send();
binData=xmlhttp.ResponseBody;

var objsm = new ActiveXObject("ADODB.STREAM");
objsm.Type=1;
objsm.Open();
objsm.Write(binData);
objsm.SaveToFile(filename,2);
objsm.Close();

word = new ActiveXObject("word.application");
word.Visible = true;
word.documents.open(filename);
}catch(e){ShowErrorMsg(e);};
}
function SaveWeb(){
try{
FileDesource = document.WebForm.FileDesource.value + "&ID=" + document.WebForm.ID.value + "&FileMode=" + document.WebForm.FileMode.value + "&FileType=" + document.WebForm.FileType.value;
if (document.WebForm.FileMode.value == "new"){
var Name;
if (Name=window.prompt("请输入文档名称!","")){
FileDesource = FileDesource + "&Name=" + Name
};
};
//alert(FileDesource);
if (word != null){
word.activedocument.save();
word.quit();
};

var binData
var objsm = new ActiveXObject("ADODB.STREAM");
objsm.Type=1;
objsm.Open();
objsm.LoadFromFile(filename);
binData=objsm.read(objsm.size);
objsm.Close

xmlhttp = new ActiveXObject("msxml2.xmlhttp");
xmlhttp.Open("post",FileDesource,false);
xmlhttp.Send(binData);

//document.WebForm.FileMode.value = "open";
history.go(-1);
}catch(e){ShowErrorMsg(e);};
}
function OpenLocal(){
try{
word.dialogs.item(80).show();
}catch(e){ShowErrorMsg(e);};
}

function SaveLocal(){
try{
//parent.frames.main.WebForm.WJOnlineEdit.SaveLocal();
word.Dialogs.Item(84).Show();
}catch(e){ShowErrorMsg(e);};
}
function ProtectDoc(){
try{
word.ActiveDocument.Protect(1);
}catch(e){ShowErrorMsg(e);};
}
function UnProtectDoc(){
try{
word.ActiveDocument.UnProtect();
}catch(e){ShowErrorMsg(e);};
}
function ShowDialog(index){
try{
word.Dialogs(index).Show();
}catch(e){ShowErrorMsg(e);};
}
//设定用户名
function SetUserName(){
try{
var UserName;
if (UserName=window.prompt("请输入文档编辑者的名称,程序将记录此编辑者对文档的编辑痕迹!", word.UserName)){
word.UserName="" + UserName + "";
};
}catch(e){ShowErrorMsg(e);};
}
//痕迹保留
function TrackRevisions(){
try{
word.ActiveDocument.TrackRevisions =!word.ActiveDocument.TrackRevisions;
}catch(e){ShowErrorMsg(e);};
}
//痕迹显示
function ShowRevisions(){
try{
word.ActiveDocument.ShowRevisions =!word.ActiveDocument.ShowRevisions;
}catch(e){ShowErrorMsg(e);};
}
function ShowErrorMsg(e){
debug = true;
if (debug) {
alert(e.message);
}
}

//-->
</SCRIPT>
yijiang 2004-04-30
  • 打赏
  • 举报
回复
有控件,在网站上应该能下到
若白师妹 2004-04-30
  • 打赏
  • 举报
回复
<a href="test.doc">test.doc</a>
或者
<%
response.ContentType="application/x-msword"
Const adTypeBinary = 1
Dim strFilePath
strFilePath = server.mappath("test.doc") 'test.doc
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath
Response.BinaryWrite objStream.Read
objStream.Close
Set objStream = Nothing
%>
swich 2004-04-30
  • 打赏
  • 举报
回复
导出到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>
yslcuk 2004-04-30
  • 打赏
  • 举报
回复
用框架吧,上面是链接直接指向你的WORD文档,下面显示
xiaop1108 2004-04-30
  • 打赏
  • 举报
回复
关注
longxin21 2004-04-30
  • 打赏
  • 举报
回复
关注,我也遇到相同的问题

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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