Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 28th, 2004, 11:40 AM
Authorized User
 
Join Date: Jul 2003
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Default Downloading Excel File

Hello Everyone and thanks for your help in advance. I have an application that needs to download many files from a website. One of these files is an Excel spreadsheet. My code downloads the file, but when I go to open it, the data is scrambled. I think the problem is that I am encoding it improperly, but can't figure out what I nned to do. The following code is what I am using now:

        'Put user code to initialize the page here
        Dim URL As String = "http://filetoget.xls
        Dim outputfile As String = "C:\filetoget.xls"
        Dim wReq As WebRequest
        Dim wResp As WebResponse
        Dim respStream As Stream
        Dim reader As StreamReader
        Dim writer As StreamWriter

        ' create the Web Request
        wReq = WebRequest.Create(URL)

        ' get the response
        wResp = wReq.GetResponse()
        respStream = wResp.GetResponseStream()
        reader = New StreamReader(respStream, False)

        ' and write it to the required file
        writer = New StreamWriter(outputfile)
        'writer = New BinaryWriter(outputfile)
        writer.Write(reader.ReadToEnd())

Could someone get me going in the right direction? Any help is greatly appreciated. Thanks.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Downloading a File RobC ASP.NET 2.0 Basics 4 February 4th, 2006 09:37 PM
Issue of downloading Excel file(resent) zuolinbai Classic ASP Professional 3 June 15th, 2004 11:10 AM
Issue of downloading Excel file(resent) zuolinbai Classic ASP Basics 1 June 10th, 2004 05:24 PM
Issue of downloading Excel file zuolinbai Classic ASP Professional 1 June 7th, 2004 05:50 PM
Downloading data from Web into Excel Blase Excel VBA 2 October 24th, 2003 09:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.