By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,098 Members | 1,950 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,098 IT Pros & Developers. It's quick & easy.

Excel worksheet

P: n/a
Hello all,

Am not sure if this is the right newgroup.

I want to open and excel worksheet from VB.Net, populate data and save it.

Any idea how it can be done?

Thanks in advance
Regards
Ishan
Mar 6 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Dim xlApp As Excel.Application
Dim xlWB As Excel.Workbook
Dim xlWS As Excel.Worksheet

Dim inVal As Object

'Create Report Name for this month
Dim sRept As String = "fullpath to sheet..XLS"

'Open the report template
inVal = New System.Runtime.InteropServices.DispatchWrapper(Not hing)
xlApp = CType(CreateObject("Excel.Application"), Excel.Application)
xlApp.Visible = False 'True if you want to see it on the screen
xlWB = xlApp.Workbooks.Open(sRept )
xlWS = CType(xlWB.Sheets(1), Excel.Worksheet)
xlWS.PageSetup.RightHeader = "Last Updated: " & Format(Today, "dd-MMM-yy")

Dim nCol, nRow as Integer
'To save word Data in cell B3
nRow = 3
nCol = 2

xlWS.Cells(nRow, nCol) = "Data"

'Save & Close the Excel Sheet
xlWB.Close(SaveChanges:=True)
xlApp.Visible = True
xlApp.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComO bject(xlApp)

"Ishan Bhalla" wrote:
Hello all,

Am not sure if this is the right newgroup.

I want to open and excel worksheet from VB.Net, populate data and save it.

Any idea how it can be done?

Thanks in advance
Regards
Ishan

Mar 7 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.