Happy July 4th & thanks for reading.
I am using VS 2010 to produce .aspx code in framework 3.5 to run on IIS (6- I believe).
I want to do the equivalent of response.writefile("hello.txt") where hello.txt is a local file on the server.
HOWEVER, I need to generate the file stream through code running on IIS, that is, I will not be extracting the data from a file.
For example, I might want to generate a small text file containing "hello, world". I need to have the client click a browser button, activating a server process that appears to send a file to the client. Actually I will be sending .csv data which will represent an excel spreadsheet, thus I will need to tell the client the name of the file, "hello.xls", generate the csv code by looping through some database items, then flush or terminate the stream.
I do not need any fancy formatting and do not want to use any excel 'objects' or special excel 'includes', etc. Just want to tell the client the file name to use and generate and send the data.
Sorry, I know the answer is out here somewhere but I just cannot seem to search for it properly. I keep running into load of info on streaming files using response.write, response.transmitfile, and so on.
I need something like . . . pseudo code here
'set up database dataset here . . .
response.beginfilestream("junk.xls") ' tell client file name to create
response.sendstreamdata(any_special_headers_for_this_file_type)
response.sendstreamdata("'Column 1', 'Column 2', 'Column 3'" & CRLF)
do while myreader.read()
response.sendstreamdata("'" & myreader.item(0) & "', " & myreader.item(1) & "', " & myreader.item(1) & "'" & CRLF)
loop
response.sendstreamdata(any_special_file_footers)
response.endstreamdata 'tells client we are done
As I mentioned, response.writefile works just fine, but I need to generate the data in real time, not pull it off a file.
Many thanks,
DJ
I am using VS 2010 to produce .aspx code in framework 3.5 to run on IIS (6- I believe).
I want to do the equivalent of response.writefile("hello.txt") where hello.txt is a local file on the server.
HOWEVER, I need to generate the file stream through code running on IIS, that is, I will not be extracting the data from a file.
For example, I might want to generate a small text file containing "hello, world". I need to have the client click a browser button, activating a server process that appears to send a file to the client. Actually I will be sending .csv data which will represent an excel spreadsheet, thus I will need to tell the client the name of the file, "hello.xls", generate the csv code by looping through some database items, then flush or terminate the stream.
I do not need any fancy formatting and do not want to use any excel 'objects' or special excel 'includes', etc. Just want to tell the client the file name to use and generate and send the data.
Sorry, I know the answer is out here somewhere but I just cannot seem to search for it properly. I keep running into load of info on streaming files using response.write, response.transmitfile, and so on.
I need something like . . . pseudo code here
'set up database dataset here . . .
response.beginfilestream("junk.xls") ' tell client file name to create
response.sendstreamdata(any_special_headers_for_this_file_type)
response.sendstreamdata("'Column 1', 'Column 2', 'Column 3'" & CRLF)
do while myreader.read()
response.sendstreamdata("'" & myreader.item(0) & "', " & myreader.item(1) & "', " & myreader.item(1) & "'" & CRLF)
loop
response.sendstreamdata(any_special_file_footers)
response.endstreamdata 'tells client we are done
As I mentioned, response.writefile works just fine, but I need to generate the data in real time, not pull it off a file.
Many thanks,
DJ