Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.
Private Sub WorkingWithExcel() 'Declaring variable for Excel sheet Dim xlApp As New Microsoft.Office.Interop.Excel.ApplicationClass Dim xlWorkBook As Microsoft.Office.Interop.Excel.Workbook Dim xlWorkSheet As Microsoft.Office.Interop.Excel.Worksheet 'Set the File path xlWorkBook = xlApp.Workbooks.Open("File Path") xlWorkSheet = xlWorkBook.Worksheets("Sheet1$") With xlWorkSheet 'ASSIGN VALUE TO A CELL. Here below the value is assigned to 8th Row 12th 'column .Cells(8, 12).Value ="This is test sentence." 'Add Rows to the Excel sheet.Here it inserts the row at 10th position .Range("A10").EntireRow.Insert() 'Delete Rows to the Excel sheet.Here it Deletes the 10th Row .Range("A10").EntireRow.Delete() 'Below code Merges the Entire row .Range("A" & RowNo).EntireRow.MergeCells = True 'If you want to Merge only Cells not rows then Below code does it. 'Below merges Cells from C to F of 10th ROW .Range("C10:F10").MergeCells = True End With 'Before Saving if you want to Protect the Excel sheet with Password then 'below code tells how to assign the password for Excel workbook xlWorkBook.Password = "TEST" 'Save the WORKBOOK.. xlWorkBook.Save() 'Close the WorkBook xlWorkBook.Close() xlApp.Quit() 'Below Releases the Excel sheet from the system process. releaseObject(xlApp) releaseObject(xlWorkBook) releaseObject(xlWorkSheet) End Sub ''' <summary> ''' Releases the excel from the system process ''' </summary> ''' <param name="obj"> </param> ''' <remarks></remarks> Private Sub releaseObject(ByVal obj As Object) Try System.Runtime.InteropServices.Marshal.ReleaseComObject(obj) obj = Nothing Catch ex As Exception obj = Nothing Finally GC.Collect() End Try End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
|Building a Formless WinForms Application with a NotifyIcon in VB.Net 2008||22,216|
|Having fun with graphics: a VB.net GlassLabel control||8,361|
|Key concepts of Delegate using C#||1,118|