方式一:

<%
Dim ranNum,FileUrl,MyFile

Randomize

ranNum=Int(90000*Rnd)+10000 ' 随机输出五位数

Set Fso=CreateObject("Scripting.FileSystemObject")

FileUrl=Server.MapPath (ranNum&".xls")

If Fso.FileExists(FileUrl) Then
 Response.Write "相同文件名的文件已经存在!"
Else
 Set MyFile=Fso.CreateTextFile(FileUrl,true)
 MyFile.WriteLine("第一列"&chr(9)&"第二列"&chr(9)&"第三列")
 
 For i=1 To 10
  MyFile.Writeline("'00001"&i&chr(9)&"'00002"&i&chr(9)&"'00003"&i)
 Next
 
 Response.Write "点击下载"
End If
%>

方式二:

Dim ranNum,i

Randomize

ranNum=Int(90000*Rnd)+10000 ' 随机输出五位数

Response.AddHeader "Content-Disposition", "p_w_upload;filename="&ranNum&".xls"
Response.ContentType = "application/vnd.ms-excel"
Response.Write "第一列"&vbtab&"第二列"&vbtab&"第三列"

For i=1 To 10
 Response.Write vbcrlf
 Response.Write "'00001"&i&vbtab&"'00002"&i&vbtab&"'00003"&i
Next

方式三:

Dim ranNum,m,n

Randomize

ranNum=Int(90000*Rnd)+10000 ' 随机输出五位数

Response.AddHeader "Content-Disposition", "p_w_upload;filename="&ranNum&".xls"
Response.ContentType = "application/vnd.ms-excel"
Response.Write "

"
Response.Write ""
For m=1 To 10
 Response.Write ""
 For n=1 To 3
  Response.Write ""
 Next
 Response.Write ""
Next
Response.Write "
第一列第二列第三列
0000"&n&m&"
"

方式四:csv

Dim ranNum,FileUrl,MyFile

Randomize

ranNum=Int(90000*Rnd)+10000 ' 随机输出五位数

Set Fso=CreateObject("Scripting.FileSystemObject")

FileUrl=Server.MapPath (ranNum&".csv")

If Fso.FileExists(FileUrl) Then
 Response.Write "相同文件名的文件已经存在!"
Else
 Set MyFile=Fso.CreateTextFile(FileUrl,true)
 MyFile.WriteLine("第一列,第二列,第三列")
 
 For i=1 To 10
  MyFile.Writeline("'00001"&i&",'00002"&i&",'00003"&i)
 Next
 
 Response.Write "点击下载"
End If