一下代码是在网络上参考的!我要实现的是点击word查看按钮,可以在显示的word页面中查看到内容,但是下面的代码不可以实现,希望高手可以指导下!<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<form action="" method="post" name="form1">
<table>
<tr>
<td>
会议标题:<input type="text" name="title" size="50">
</td>
</tr>
<tr>
<td>
会议时间:<input type="text" name="meetingTime">
</td>
</tr>
<tr>
<td>
会议主持人:<input type="text" name="compere">
</td>
</tr>
<tr>
<td>
出席人员:<input type="text" name="attend">
</td>
</tr>
<tr>
<td>
会议内容:<input type="text" name="content">
</td>
</tr>
<tr>
<td>
<input name="submit" type="button" class="btn_grey" onclick="outDoc()" value="WORD查看">
</td>
</tr>
</form>
</body>
</html>
<%
int at=request.getRequestURL().lastIndexOf("/");
String path_part=request.getRequestURL().substring(0,at+1);
%>
<script language="javascript">
function outDoc(){
var wdapp=new ActiveXObject("Word.Application");
wdapp.visible=true;
wddoc=wdapp.Documents.Open("<%=path_part%>meeting.doc"); //打开指定的文档
var form=document.all.form1;
title=form.title.value;
meetingTime=form.meetingTime.value;
compere=form.compere.value;
attend=form.attend.value;
content=form.content.value;
//输出会议标题
range =wdapp.ActiveDocument.Books("title").Range;
range.Text=title;
//输出会议时间
range =wdapp.ActiveDocument.Books("meetingTime").Range;
range.Text=meetingTime;
//输出会议主持人
range =wdapp.ActiveDocument.Books("compere").Range;
range.Text=compere;
//输出出席人员
range =wdapp.ActiveDocument.Books("attend").Range;
range.Text=attend;
//输出会议内容
range =wdapp.ActiveDocument.Books("content").Range;
range.Text=content;
wddoc.Application.Open();
wdapp=null;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<form action="" method="post" name="form1">
<table>
<tr>
<td>
会议标题:<input type="text" name="title" size="50">
</td>
</tr>
<tr>
<td>
会议时间:<input type="text" name="meetingTime">
</td>
</tr>
<tr>
<td>
会议主持人:<input type="text" name="compere">
</td>
</tr>
<tr>
<td>
出席人员:<input type="text" name="attend">
</td>
</tr>
<tr>
<td>
会议内容:<input type="text" name="content">
</td>
</tr>
<tr>
<td>
<input name="submit" type="button" class="btn_grey" onclick="outDoc()" value="WORD查看">
</td>
</tr>
</form>
</body>
</html>
<%
int at=request.getRequestURL().lastIndexOf("/");
String path_part=request.getRequestURL().substring(0,at+1);
%>
<script language="javascript">
function outDoc(){
var wdapp=new ActiveXObject("Word.Application");
wdapp.visible=true;
wddoc=wdapp.Documents.Open("<%=path_part%>meeting.doc"); //打开指定的文档
var form=document.all.form1;
title=form.title.value;
meetingTime=form.meetingTime.value;
compere=form.compere.value;
attend=form.attend.value;
content=form.content.value;
//输出会议标题
range =wdapp.ActiveDocument.Books("title").Range;
range.Text=title;
//输出会议时间
range =wdapp.ActiveDocument.Books("meetingTime").Range;
range.Text=meetingTime;
//输出会议主持人
range =wdapp.ActiveDocument.Books("compere").Range;
range.Text=compere;
//输出出席人员
range =wdapp.ActiveDocument.Books("attend").Range;
range.Text=attend;
//输出会议内容
range =wdapp.ActiveDocument.Books("content").Range;
range.Text=content;
wddoc.Application.Open();
wdapp=null;
}
</script>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货