hi,
I am working on a project that is able to display real time data from sensors from micro-controller. I am able to do so by sending the data through the serial port and then use vb 2005 to show the data. However, I want to save those data from vb 2005 to excel. How am I able to do it ? I am able to use vb to insert data to excel step by step, cell by cell using the following codes.
Ok. Lets say TextBox1.Text and TextBox2.Text is my real time data. How do I save it to the excel sheet displaying the data in cell A2, A3, A4 when the time goes by. Eg. If I want to save TextBox1.Text to excel it would be, the data in the 1st seconds in cell A2, data in the 2nd seconds in A3, 3rd seconds A4, 4th seconds in A5, A6 and so on...
I am working on a project that is able to display real time data from sensors from micro-controller. I am able to do so by sending the data through the serial port and then use vb 2005 to show the data. However, I want to save those data from vb 2005 to excel. How am I able to do it ? I am able to use vb to insert data to excel step by step, cell by cell using the following codes.
VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
TextBox1.Text = "1"
TextBox2.Text = "2"
'Start a new workbook in Excel
oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Add
'Add data to cells of the first worksheet in the new workbook
oSheet = oBook.Worksheets(1)
oSheet.Range("A1").Value = "TextBox1"
oSheet.Range("B1").Value = "TextBox2"
oSheet.Range("A1:B1").Font.Bold = True
oSheet.Range("A2").Value = TextBox1.Text
oSheet.Range("B2").Value = TextBox2.Text
'Save the Workbook and Quit Excel
oBook.SaveAs("C:\exceltest.xls")
oExcel.Quit()
End Sub
Ok. Lets say TextBox1.Text and TextBox2.Text is my real time data. How do I save it to the excel sheet displaying the data in cell A2, A3, A4 when the time goes by. Eg. If I want to save TextBox1.Text to excel it would be, the data in the 1st seconds in cell A2, data in the 2nd seconds in A3, 3rd seconds A4, 4th seconds in A5, A6 and so on...