ASP如何让数据库的数据导出为Excel格式?要详细说明?代码或步骤都行!
2个回答
2014-03-05
展开全部
<%
'文 件 名:excel.asp
'文件功能:生成EXCEL文件
'作 者:高明
'创建时间:2006-03-14
%>
生成EXCEL文件...
<%
Dim sqlStr,type2,start,over
type2=request.form("select")
start=request.form("start_date")
over=request.form("end_date")
set rs=server.CreateObject("adodb.recordset")
If type2="1" then
sqlStr="select corporation,register_capi,register_date,register_addr,legal_repr,storage_capi,storage_term,storage_powe,tel,m_tel,linkman,licence,inputdate from mart_food where inputdate between '"&start&"' and '"&over&"'"
ElseIf type2="2" Then
sqlStr="select corporation,quality,register_addr,office_addr,year_date,year_circs,linkman,tel,m_tel,remark,inputdate from mart_food where inputdate between '"&start&"' and '"&over&"'"
End if
rs.open sqlStr,conn,3,4
set xlApp = Server.CreateObject("Excel.Application")
'使服务端不出现Excel窗口
xlApp.Visible = false
'建立一个worksheet
set myWorkbook = xlApp.Workbooks.Add
set myWorksheet = myWorkbook.Worksheets(1) '设置工作区
'建立表头
If type2="1" Then
myWorksheet.Range("A1").Value =" 办理《粮食收购许可证》情况台帐 "
myWorksheet.Range("A1").Font.Size = 20
myWorksheet.Range("A1").Font.Bold = true '字体加粗
'文 件 名:excel.asp
'文件功能:生成EXCEL文件
'作 者:高明
'创建时间:2006-03-14
%>
生成EXCEL文件...
<%
Dim sqlStr,type2,start,over
type2=request.form("select")
start=request.form("start_date")
over=request.form("end_date")
set rs=server.CreateObject("adodb.recordset")
If type2="1" then
sqlStr="select corporation,register_capi,register_date,register_addr,legal_repr,storage_capi,storage_term,storage_powe,tel,m_tel,linkman,licence,inputdate from mart_food where inputdate between '"&start&"' and '"&over&"'"
ElseIf type2="2" Then
sqlStr="select corporation,quality,register_addr,office_addr,year_date,year_circs,linkman,tel,m_tel,remark,inputdate from mart_food where inputdate between '"&start&"' and '"&over&"'"
End if
rs.open sqlStr,conn,3,4
set xlApp = Server.CreateObject("Excel.Application")
'使服务端不出现Excel窗口
xlApp.Visible = false
'建立一个worksheet
set myWorkbook = xlApp.Workbooks.Add
set myWorksheet = myWorkbook.Worksheets(1) '设置工作区
'建立表头
If type2="1" Then
myWorksheet.Range("A1").Value =" 办理《粮食收购许可证》情况台帐 "
myWorksheet.Range("A1").Font.Size = 20
myWorksheet.Range("A1").Font.Bold = true '字体加粗
2014-03-05
展开全部
通过ASP么?没必要吧。多数数据库自带导出功能。SQL,ACCESS都能导出。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询