?? toexcel.txt
字號:
.LineStyle = 1
.Weight = -4138
.ColorIndex = -4105
End with
with .Range(.Cells(1,1), .Cells(rowcount + 1, colcount + 1)).Borders(11) '畫下邊界
.LineStyle = 1
.Weight = 2
.ColorIndex = -4105
End with
with .Range(.Cells(1,1), .Cells(rowcount + 1, colcount + 1)).Borders(12) '畫下邊界
.LineStyle = 1
.Weight = 2
.ColorIndex = -4105
End with
End with
rowcount = 0
colcount = 0
End if
end sub
sub PowerList(flag, obj)
Dim x, y, c, a, str_key, str_sql, l_start, location, b, b_start, str_bkey
If flag= true then
x = rowcount
y = colcount
Else
x = colcount
y = rowcount
End if
l_start=1
for a = 1 to y
location=dhCountTime(Userskey,";", a)
str_key=Mid(Userskey, l_start, location - l_start)
l_start=location + 1
str_sql="select user_sincluder from ksweb_usertable where user_ssyskey='<%=sAppkey%>' and user_skey='" & str_key & "'"
FunRunADC(str_sql)
If ADC.Recordset.RecordCount > 0 then
If len(Trim(ADC.Recordset("user_sincluder"))) > 0 then
b_start=1
for b = 1 to x
location=dhCountTime(UserGroupkey,";", b)
str_bkey=Mid(UserGroupkey, b_start, location - b_start)
b_start=location + 1
If instr(1, Trim(ADC.Recordset("user_sincluder")), str_bkey) > 0 then
If flag=true then
obj.ActiveWorkBook.Activesheet.Cells(b+1, a+1)="√"
Else
obj.ActiveWorkBook.Activesheet.Cells(a+1, b+1)="√"
end if
end if
next
End if
End if
next
End sub
確保文件名唯一
strFileName = Session.SessionID & ".xls"
strAppPath = Request.ServerVariables("PATH_TRANSLATED")
strAppPath = Left(strAppPath, InstrRev(strAppPath, "\"))
strFullPath = strAppPath & strFileName
'保存文件
myWorkbook.SaveAs(strFullPath)
'關(guān)閉Excel
myWorkbook.Close
xlApp.Quit
set myWorksheet = Nothing
set myWorkbook = Nothing
set myxlApp = Nothing
'寫出到瀏覽器中
Response.Redirect strFileName
---------------------------------------------------------------
<%@ LANGUAGE="VBSCRIPT" %>
<%option explicit%>
<HTML>
<HEAD>
<meta content="text/html; charset=gb2312" http-equiv="Content-Type">
<TITLE>生成EXCEL文件</TITLE>
</HEAD>
<body>
<a href="dbtoexcel.asp?act=make">生成在線人口的EXCEL</a>
<hr size=1 align=left width=300px>
<%
if Request("act") = "" then
Response.Write "生成EXCEL文件"
else
dim conn,strconn
strconn="driver={SQL Server};server=wen;uid=sa;pwd=;database=DB_Test"
set conn=server.CreateObject("adodb.connection")
conn.Open strconn
dim rs,sql,filename,fs,myfile,x
Set fs = server.CreateObject("scripting.filesystemobject")
'--假設你想讓生成的EXCEL文件做如下的存放
filename = Server.MapPath("online.xls")
'--如果原來的EXCEL文件存在的話刪除它
if fs.FileExists(filename) then
fs.DeleteFile(filename)
end if
'--創(chuàng)建EXCEL文件
set myfile = fs.CreateTextFile(filename,true)
Set rs = Server.CreateObject("ADODB.Recordset")
'--從數(shù)據(jù)庫中把你想放到EXCEL中的數(shù)據(jù)查出來
sql = "select * from Tb_Execl order by sort desc"
rs.Open sql,conn
if rs.EOF and rs.BOF then
Response.Write "庫里暫時沒有數(shù)據(jù)!"
else
dim strLine,responsestr
strLine=""
For each x in rs.fields
strLine= strLine & x.name & chr(9)
Next
'--將表的列名先寫入EXCEL
myfile.writeline strLine
Do while Not rs.EOF
strLine=""
for each x in rs.Fields
strLine= strLine & x.value & chr(9)
next
'--將表的數(shù)據(jù)寫入EXCEL
myfile.writeline strLine
rs.MoveNext
loop
end if
rs.Close
set rs = nothing
conn.close
set conn = nothing
set myfile = nothing
Set fs=Nothing
end if
%>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -