Here are some topics which I know want to share with others whom this might help.
First of all if you are working with Excel then you need to Download the Following
http://www.microsoft.com/d
And then extract it and then add Microsoft.Office.Interop.E
This Blog or Article helps you to write values to excel,Merge Cells,Protect Excel sheet with Passwords and Many more stuffs.
Import the Statement in to your form or Class
Imports Microsoft.Office.Interop.E
Private Sub WorkingWithExcel()
'Declaring variable for Excel sheet
Dim xlApp As New Microsoft.Office.Interop.E
Dim xlWorkBook As Microsoft.Office.Interop.E
Dim xlWorkSheet As Microsoft.Office.Interop.E
'Set the File path
xlWorkBook = xlApp.Workbooks.Open("File
xlWorkSheet = xlWorkBook.Worksheets("She
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.In
'Delete Rows to the Excel sheet.Here it Deletes the 10th Row
.Range("A10").EntireRow.De
'Below code Merges the Entire row
.Range("A" & RowNo).EntireRow.MergeCell
'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").MergeCel
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.InteropServ
obj = Nothing
Catch ex As Exception
obj = Nothing
Finally
GC.Collect()
End Try
End Sub
If you have any query or suggestion to the code please send me a message or leave comment here..
Hope you liked this code .
by: Avinash_Desai on 2011-04-03 at 02:57:35ID: 25454
Dear Readers
If any question or any errors please let me know so that i can correct it
Regards
Avinash Desai