Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.
Private Sub btnExcelExport_Click(sender As Object, e As EventArgs) Handles btnExcelExport.Click Dim oXLApp As Excel.Application 'Declare the object variables Dim oXLBook As Excel.Workbook Dim oXLSheet As Excel.Worksheet oXLApp = New Excel.Application 'Create a new instance of Excel oXLBook = oXLApp.Workbooks.Add 'Add a new workbook oXLSheet = oXLBook.Worksheets(1) 'Work with the first worksheet oXLApp.Visible = True 'Show it to the user With oXLApp Dim Col As DataGridViewColumn Dim i As Integer = 1 For Each Col In DataGridView1.Columns .Cells(1, i).Value = Col.HeaderText i += 1 Next i = 2 Dim RowItem As DataGridViewRow Dim Cell As DataGridViewCell For Each RowItem In DataGridView1.Rows Dim j As Integer = 1 For Each Cell In RowItem.Cells .Cells(i, j).Value = Cell.Value j += 1 Next i += 1 Next End With 'oXLSheet.Range("P:P").EntireColumn.Delete() oXLSheet.UsedRange.Borders.LineStyle = 1 oXLApp.Columns.AutoFit() oXLSheet.Range("A:A").Font.Bold = True oXLBook = Nothing 'Disconnect from Excel (let the user take over) oXLApp = Nothing oXLSheet = Nothing End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.