Question:
Hello,
I am revamping a user report from html to csv. Depending on the user's options this report can be very large. I would like to stream the report to the browser the same way that I can stream or chunk a pdf or zip file to the browser. I think I am on the right track but I have two issues. First, Excel reports the file is incomplete and second, all the the data is on a single line
Thanks,
Erik
Code
Set oStr = Server.CreateObject("Chilkat_9_5_0.StringArray")
oStr.LoadFromText oCsv.SaveToString
With Response
.Buffer = true
.Expires = 0
.Clear
.ContentType = "text/csv"
.AddHeader "content-length", oStr.Length -1
.AddHeader "content-disposition", "inline; filename=""Report.csv"""
.flush
End With
Idx = 0: Ctr = 0
For Idx = 0 To oStr.Count -1
Ctr = Ctr + 1
If Ctr = 100 Then
Response.Flush
Ctr = 0
End If
Response.Write oStr.GetString(Idx) & vbLf
Next
Response.Flush
oStr.Clear
Set oStr = Nothing
A few thoughts: