eHow launches Android app: Get the best of eHow on the go.

How To

How to Write to an Excel File from VB.net

Member
By Mike
User-Submitted Article
(1 Ratings)
Write to an Excel File from VB.net
Write to an Excel File from VB.net

In many instances I have had to write data directly from a VB.net application to an excel spreadsheet. It provides a way for the end user to do whatever it is they need to do to that data as how they please. Regardless of what the user does with it if they need it written to an excel spreadsheet file, it can be done directly from within VB.net. Here is how you write data directly to an excel spreadsheet.

Difficulty: Easy
Instructions

Things You'll Need:

  • VB.net
  • Excel
  1. Step 1

    Launch the application that will be using this code to write data to an excel spreadsheet. In order for this code to work Excel has to be installed on the PC where the file is going to be created (which makes sense since why would the user want it if they don't have the means to open it).

  2. Step 2

    Declare the variables that will be needed in order to make this process happen. eHow does now allow code to be written within the steps so refere to the picture.

  3. Step 3

    With your variables declared, lets set up the object that will represent the spreadsheet. Again look at the picture associated with this step for the code. The first line of code creates our excel object, the second line, adds a workbook to the excel object and then finally we create a worksheet.

  4. Step 4

    You can now write data to specific rows and columns just as it looks in the picture associated with this step. The cell values (i.e. "A1", "B1" etc.) can also be variable names assigned to rows and columns. This allows you to dynamically populate those cells.

  5. Step 5

    Save the file and close the object. Just remember to give your filename variable the path to where you want it saved and of course a name with the ".xls" extension.

Post a Comment

Post a Comment
  • Have you done this? Click here to let us know.
I Did This

Related Ads

Computers
Alexia Petrakos,

Meet Alexia Petrakos eHow's Computers Expert.

Get Free Computers Newsletters

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy.   en-US Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.

eHow Computers
eHow_eHow Technology and Electronics