Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As 
System.EventArgs) Handles Button1.Click
Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook
Dim ws As Microsoft.Office.Interop.Excel.Worksheet
Dim rng As Microsoft.Office.Interop.Excel.Range
Try
excel = New Microsoft.Office.Interop.Excel.Application
wb = excel.Workbooks.Add()
ws = wb.ActiveSheet()
rng = ws.Range("A1")
rng.Value = "Techrepublic.com"
rng = ws.Range("A3")
rng.Value = "Quarter"
rng = ws.Range("B3")
rng.Value = "Sales"
rng = ws.Range("A5")
rng.Value = "First"
rng = ws.Range("B5")
rng.Value = 1000.0
rng = ws.Range("A6")
rng.Value = "Second"
rng = ws.Range("B6")
rng.Value = 2000.0
rng = ws.Range("A7")
rng.Value = "Third"
rng = ws.Range("B7")
rng.Value = 4500.0
rng = ws.Range("A8")
rng.Value = "Fourth"
rng = ws.Range("B8")
rng.Value = 4000.0
rng = ws.Range("A10")
rng.Value = "Total"
rng = ws.Range("B10")
rng.Formula = "=@Sum(B5..B8)"
rng.Calculate()
excel.Visible = True
wb.Activate()
Catch ex As COMException
MessageBox.Show("Error accessing Excel: " + ex.ToString())
Catch ex As Exception
MessageBox.Show("Error: " + ex.ToString())
End Try
End Sub