|
Dear all,
I am now using asp to generate a excel file, using the following code. However I have encounter a problem. After I have complete loaded my asp, then I open my excel file, it prompts me the error: File not loaded completely.
Since the recordcount of table trade is larger than 65535, however at most an excel activesheet can have 65535 rows of data, so I cannot save all the records into excel file. I would like to keep the following code, since I have try other methods, but all the other methods prompt me a confirmation box asking me whether want to open or save the file. Therefore I would like to ask if i can open a new spreadsheet to save my records? Or any other method I can do so?
Thanks so much for help.
<%@LANGUAGE="VBScript"%>
<% Server.ScriptTimeout = 960 %>
<%
dim strConnectStr
strConnectStr ="Provider=Sybase.ASEOLEDBProvider.2;"
strConnectStr = strConnectstr & "Password=password;"
strConnectStr = strConnectstr & "Persist Security Info=True;"
strConnectStr = strConnectstr & "User ID=user;"
strConnectStr = strConnectstr & "Data Source=testdb"
set connObj = Server.CreateObject("ADODB.Connection")
connObj.Open strConnectStr
strSQL = "select * from trade"
set rsObj = connObj.Execute(strSQL)
filePath= Server.mapPath("/forum/test2.html")
filepath=mid(filepath,1,len(filepath)-9)
filepath = filepath + "temp"
filename = filepath + "/forum/test5.xls"
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = fs.CreateTextFile(filename, True)
strLine="" 'Initialize the variable for storing the filednames
For each x in rsObj.fields
strLine= strLine & x.name & chr(9)
Next
MyFile.writeline strLine
Do while Not rsObj.EOF
strLine=""
for each x in rsObj.Fields
strLine= strLine & x.value & chr(9)
next
MyFile.writeline strLine
rsObj.MoveNext
Loop
MyFile.Close
Set MyFile=Nothing
Set fs=Nothing
rsObj.close
connObj.close
set connObj = Nothing
%>
|
|
|
|
|
|
|
|