Downloading Dynamic Excel

Downloading Dynamic Excel

am 13.04.2008 04:49:31 von MRW

Hello!

I've been on this for hours with little progress, so any help would be
appreciated.

I'm trying to use ASP.NET (VB) to send two variables to a server (not
mine), which uses those variables to create an Excel file and sends it
back (in binary format).

Using WebClient, I've been able to send the information and receive a
reply. However, I can't seem to encode the "response" into proper
format to save it properly without corruption.

Here's the code I've used so far:

Dim myWebClient = New System.Net.WebClient
myWebClient.Headers.Add("Content-Type", "application/x-www-
form-urlencoded")
Dim toEF As String = "sort=1&clientID=845"
Dim bytes() As Byte = myWebClient.UploadData("https://
blah, blah, blah.php", "POST",
System.Text.Encoding.ASCII.GetBytes(toEF))
myWebClient = Nothing

x = System.Text.Encoding.ASCII.GetString(bytes)

Dim fp As StreamWriter

Try
fp = File.CreateText(Server.MapPath("\test\") &
"test.xls")
fp.WriteLine(x)
fp.Close()