codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Problen encounter when generate excel file using ASP  skullcastle1014 at 08:53 on Tuesday, November 09, 2004
 

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
%>








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  iframe help
•  Re: shopping cart
•  File save when generating excel using ASP
•  Re: Menu Problems
•  Re: Help: Trouble with z-Index and SELECT lists
•  Problen encounter when generate excel file using ASP
•  Re: Column count
•  AutoScoll
•  Re: email validation problem


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2004