Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a Exel file and read/write data to a cel

Status
Not open for further replies.

Bvisual

Programmer
Jul 1, 2005
35
BE
how can you create a exel-file with vb.net and then send data from a array to a cel


exemple:
form.load
create a exel-file


write.click
data(1) ----> cel(A,1)
data(2) ----> cel(B,1)

read.click
cel(A,1) ---> data(1)
cel(B,1) ---> data(2)
_________________________

auther possible options that work are ok

pls give some code exemple
thx
 
Code:
Dim EXL As New Excel.Application
'Checking if Excel object initiated succesfully or not
If EXL Is Nothing Then 
    MsgBox("Couldn't start Excel")
    Exit Sub
End If

'Creating Excel Worksheet
Dim WSheet As New Excel.Worksheet
'Adding new worksheet to excel workbooks
WSheet = EXL.Workbooks.Add.Worksheets.Add 

'Writing values in Work Sheet
With WSheet
.Cells(2, 1).Value = "1st Quarter"
.Cells(2, 2).Value = "2nd Quarter"
.Cells(3, 1).Value = 123.45
.Cells(3, 2).Value = 435.56
End With

WSheet.SaveAs("C:\TEST.XLS")

EXL.Workbooks.Close()
EXL = Nothing


Sweep
...if it works dont f*** with it
...if its f****ed blame someone else
...if its your fault that its f***ed, say and admit nothing.
 
Excel.application and excel.worksheet

are not defined says vb.net ????

how come and how solf problem ??


thx
 
Add a Com Reference to Excel to your project.
If unsure what to do just do a google on Excel Automation in VB.Net...you will find lots of good sources.


Sweep
...if it works dont f*** with it
...if its f****ed blame someone else
...if its your fault that its f***ed, say and admit nothing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top