在asp里提交的内容如何从sql中自动读取写入word中
在asp里提交的内容怎么从sql中自动读取写入word中
在asp页面填写的内容会保存到sql中,
管理员在后台审核后会发送一份邮件到用户的邮箱中
同时发送的邮件里会包含下载word文件地址,
word里会自动有用户提交的信息。
word也应该有美观的排版格式
这样的功能能实现吗?
这个问题希望大家能给个演示样本或者清晰的思路
谢谢
------解决思路----------------------
asp中将内容生成word文档的函数
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>生成word文档</title>
</head>
<script language="vbscript">
sub builddoc()
On Error Resume Next
Dim wApp
Set wApp = CreateObject("Word.Application")
If Err.number > 0 Then
Alert "没法保存为Word文件,请正确安装Word97"
else
wApp.visible = True
wApp.Documents.add
wApp.Selection.TypeParagraph
wApp.Selection.Font.Bold = True
wApp.Selection.TypeText "programfan"
wApp.Selection.ParagraphFormat.Alignment = 1
rem 居 中
wApp.Selection.TypeParagraph
wApp.Selection.Font.Bold = false
wApp.Selection.TypeText "-- programfan.com"
wApp.Selection.TypeParagraph
wApp.Selection.ParagraphFormat.LeftIndent = wApp.CentimetersToPoints(0)
wApp.Selection.ParagraphFormat.FirstLineIndent = wApp.CentimetersToPoints(0.72/2*2)
wApp.Selection.TypeParagraph
wApp.Selection.Font.Bold = false
wApp.Selection.ParagraphFormat.Alignment = 0
wapp.selection.typetext document.form1.doc1.value
wApp.Selection.TypeParagraph
rem 居 右
wApp.Selection.TypeParagraph
wApp.Selection.Font.Bold = false
wApp.Selection.TypeText Now()
wApp.Selection.TypeParagraph
wApp.Saved = true
wapp.ActiveDocument.SaveAs "c:\a.doc"
wapp.close
end if
end sub
</script>
<body>
<form name="form1" >
<p> </p>
<p><textarea rows="8" name="doc1" cols="46"></textarea></p>
<p> </p>
<p>生成word文档<input type="button" value="生成" name="B1" onclick="builddoc()"></p>
</form>
</body>
</html>
------解决思路----------------------
运行Word,
新建一个Word文档填上内容,设计好格式,
另存为“网页(*.htm)文件”,
找到这个文件重命名为a.asp,
记事本或dw打开a.asp,页面顶部加上<% response.ContentType="application/vnd.ms-word;%>并替换掉里面的文本内容
虽然不是word格式的,但是word可以识别,潜在的问题是有的下载工具会下载成.asp文件,下载之后只需要把扩展名改成.doc就好
在asp页面填写的内容会保存到sql中,
管理员在后台审核后会发送一份邮件到用户的邮箱中
同时发送的邮件里会包含下载word文件地址,
word里会自动有用户提交的信息。
word也应该有美观的排版格式
这样的功能能实现吗?
这个问题希望大家能给个演示样本或者清晰的思路
谢谢
------解决思路----------------------
asp中将内容生成word文档的函数
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>生成word文档</title>
</head>
<script language="vbscript">
sub builddoc()
On Error Resume Next
Dim wApp
Set wApp = CreateObject("Word.Application")
If Err.number > 0 Then
Alert "没法保存为Word文件,请正确安装Word97"
else
wApp.visible = True
wApp.Documents.add
wApp.Selection.TypeParagraph
wApp.Selection.Font.Bold = True
wApp.Selection.TypeText "programfan"
wApp.Selection.ParagraphFormat.Alignment = 1
rem 居 中
wApp.Selection.TypeParagraph
wApp.Selection.Font.Bold = false
wApp.Selection.TypeText "-- programfan.com"
wApp.Selection.TypeParagraph
wApp.Selection.ParagraphFormat.LeftIndent = wApp.CentimetersToPoints(0)
wApp.Selection.ParagraphFormat.FirstLineIndent = wApp.CentimetersToPoints(0.72/2*2)
wApp.Selection.TypeParagraph
wApp.Selection.Font.Bold = false
wApp.Selection.ParagraphFormat.Alignment = 0
wapp.selection.typetext document.form1.doc1.value
wApp.Selection.TypeParagraph
rem 居 右
wApp.Selection.TypeParagraph
wApp.Selection.Font.Bold = false
wApp.Selection.TypeText Now()
wApp.Selection.TypeParagraph
wApp.Saved = true
wapp.ActiveDocument.SaveAs "c:\a.doc"
wapp.close
end if
end sub
</script>
<body>
<form name="form1" >
<p> </p>
<p><textarea rows="8" name="doc1" cols="46"></textarea></p>
<p> </p>
<p>生成word文档<input type="button" value="生成" name="B1" onclick="builddoc()"></p>
</form>
</body>
</html>
------解决思路----------------------
运行Word,
新建一个Word文档填上内容,设计好格式,
另存为“网页(*.htm)文件”,
找到这个文件重命名为a.asp,
记事本或dw打开a.asp,页面顶部加上<% response.ContentType="application/vnd.ms-word;%>并替换掉里面的文本内容
虽然不是word格式的,但是word可以识别,潜在的问题是有的下载工具会下载成.asp文件,下载之后只需要把扩展名改成.doc就好