I am using Visual Basic.I have two functions. I am creating a excel file and I assign a value in first function. after that, I need to reach a that value's cell and get the data in second function. But I can not reach it. How can i do that ? First Function :
Public Function FirstFunction As String:
Dim xls As Microsoft.Office.Interop.Excel.Application
Dim xlsworkbook As Microsoft.Office.Interop.Excel.Workbook
Dim xlsworksheet As Microsoft.Office.Interop.Excel.Worksheet
xls = New Microsoft.Office.Interop.Excel.Application
xlsworksheet = xlsworkbook.Worksheets("Template")
End Function
Second Function:
Public Function SecondFunction As String:
Dim a1 As String = xlsworksheet.Range("A1").Value2
xlsworksheet.Cells(B,2) = a1
End Function