Click here to Skip to main content
15,921,577 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai All,
I am Developing one VB Application in Visual Studio 2010. Now i need to Save String data into Excel file........ I am using Serialport in this application ........ whenever data has been coming from this serialport i append that data to one string variable..... Now i need to save that String data into Excel file.....
Give me direction to do this task........

Thanks in ADV....... :)
Posted

1 solution

this is just some code that i thourght of of the top of my head hope it helps.

VB
Imports Microsoft.Office.Interop
Imports System.Runtime.InteropServices

Public Class Form_Main

Public MyExcel As New Excel.Application
public VarYourString1 as string = "your value"


sub Write_Data()
 MyExcel.Visible = True ' this will show the workbook in MS Excel
MyExcel.Sheets(Sheet1).Select() ' Sheet1, Sheet2, Sheet3 See this is Excel they need to be the same.



MyExcel.Range("A1048575").End(Excel.XlDirection.xlUp).Select() ' Select Last Used cell in A## ,    1048576 Max Rows

MyExcel.ActiveCell.Offset(1, 0).Select()' move down 1 cell
MyExcel.ActiveCell.Offset(0, 2).Select() move right 2 cells
MyExcel.ActiveCell.Offset(0, -1).Select() move left 1 cell


MyExcel.ActiveCell.Offset("A1").Select()' i havent tested this one



' you are looking for something like this
MyExcel.ActiveCell.Value = VarYourString1 ' this will enter "Your Value"
MyExcel.ActiveCell.Offset(1, 0).Select()' move down 1 cell

MyExcel.Workbooks.Close()' closes the Excel File

End Sub
End Class
 
Share this answer
 
v3
Comments
Himachandra 22-Dec-11 23:39pm    
I need not understand this code......... Can u explain breafly plzzzz....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900