Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports Excel = Microsoft.Office.Interop.Excel
- Imports Microsoft.Office
- Public Class Form1
- Dim appXL As Excel.Application = Nothing
- Dim wbXL As Excel.Workbook = Nothing
- Dim shXL As Excel.Worksheet = Nothing
- Dim raXL As Excel.Range = Nothing
- Dim style As Microsoft.Office.Interop.Excel.Style
- Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
- 'Membuat workbook
- appXL = CreateObject("Excel.Application")
- appXL.Visible = True
- wbXL = appXL.Workbooks.Add
- shXL = wbXL.Sheets("Sheet2")
- shXL.Activate()
- Exit Sub
- Err_Handler:
- MsgBox(Err.Description, vbCritical, "Error: " & Err.Number)
- End Sub
- Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
- 'Menutup WorkBook
- raXL = Nothing
- shXL = Nothing
- wbXL = Nothing
- appXL.Quit()
- appXL = Nothing
- End Sub
- Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
- 'Menerapkan style
- style = wbXL.Styles.Add("Style1")
- style.NumberFormat = "Text"
- style.Font.Name = "Arial"
- style.Font.Bold = True
- style.Font.Size = 5
- style.Interior.Pattern = Microsoft.Office.Interop.Excel.XlPattern.xlPatternSolid
- shXL.Cells(1, 1) = "repairing car"
- shXL.Cells(1, 1).Style = "Style1"
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement