Results 1 to 5 of 5

Thread: Outputting to Excel File

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2009
    Posts
    10

    Outputting to Excel File

    Hi all

    I've been having a bit of difficulty when outputting to an excel file using my vb program. While it does output the file, it does so without any structure i.e. all the code on a line is in the same cell.

    Is there anyway so that when it outputs it do so with the headers seperated then each piece of data in the lines underneath with the right heading.

    Thanks

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Outputting to Excel File

    what are you trying to output?

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2009
    Posts
    10

    Re: Outputting to Excel File

    I'm trying to output the remains of a string after i've sliced it up.

    Example piece would be

    Club GP Wins Draws Loss GS GA GD Points
    Stevenage 34 23 10 1 45 32 13 79

    It outputs that sort of thing however it does it all within column A and then Row 1,2 etc.

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Outputting to Excel File

    format the string. seperate columns with vbtab + rows with environment.newline.
    copy to clipboard, select the correct number of cells (columns + rows) in excel as a range, then call range.paste.

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Outputting to Excel File

    I have a thread in the .NET CodeBank that exports datatables and datareaders to Excel. While you are not doing either of those things, it would have the code in it to save data to different cells, which would be pretty much what you are looking for. That class loops through the fields in a datarow and saves each one to a subsequent column.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width