Hi @Rajendra Deshpande ,
Try using Microsoft.Office.Interop.Excel
.
Check the following steps and code.
- Add a reference to the Microsoft Office Interop Excel library:
- Right-click on your project in the Solution Explorer and select "Add" > "Reference..."
- In the Reference Manager, go to "Assemblies" > "Extensions".
- Look for "Microsoft.Office.Interop.Excel" and check it. Then click "OK".
Imports Excel = Microsoft.Office.Interop.Excel
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' Create a new instance of Excel application
Dim excelApp As New Excel.Application
' Make the Excel application visible
excelApp.Visible = True
' Add a new workbook
Dim workbook As Excel.Workbook = excelApp.Workbooks.Add()
' Optional: Access the first worksheet
Dim worksheet As Excel.Worksheet = CType(workbook.Sheets(1), Excel.Worksheet)
worksheet.Name = "MySheet"
' Optional: Write some data to the worksheet
worksheet.Cells(1, 1).Value = "Hello, Excel!"
End Sub
End Class
Best Regards.
Jiachen Li
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.