Link to home
Start Free TrialLog in
Avatar of Chuck_Loftin
Chuck_Loftin

asked on

Creating and populating an excel worksheet from VB.Net 2005.

How do I create an Excel workbook and worksheet, set data types for cells and transfer data to the worksheet?
ASKER CERTIFIED SOLUTION
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Chuck_Loftin
Chuck_Loftin

ASKER

Thanks, the "code behind" hint really made it work for me.
Glad I could help and thanks for the grade!
I've kind of had mixed results with this site, but you really nailed the solution in a way that I didn't have to to any extensive research to apply the results. The only other thing that I can see right now that I might give me a problem later is setting the data type for a range of cells. I don't see a way to do that, however it might not even be a problem. I won't know until I get the specs for the spreadsheet.
If you have any problem when you get the spec just say it!
How would I format a cell from VB.Net to display a given number of decimal places?
It depends the method that you have follow, but you can do:

    Selection.NumberFormat = "0.00"

If you choose this on (sheet.Cells(i, 1) = f.Name) then you must format after add the value:

sheet.Cells(i, 1).NumberFormat = "0.00"
sheet.Cells(i, 1) = f.Name
Works great, I'm trying to find a good source of documantation for the Microsoft.Office.Interop.Excel namespace. Any suggestions on where to find this information?
You've been very helpful. Thank you.
Just glad I could help you. Good luck with your projects.