Dim xlApp As Excel.Applicati on
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 .DispatchWrappe r(Nothing)
xlApp = CType(CreateObj ect("Excel.Appl ication"), Excel.Applicati on)
xlApp.Visible = False 'True if you want to see it on the screen
xlWB = xlApp.Workbooks .Open(sRept )
xlWS = CType(xlWB.Shee ts(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(Save Changes:=True)
xlApp.Visible = True
xlApp.Quit()
System.Runtime. InteropServices .Marshal.Releas eComObject(xlAp p)
"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