How do I get the selected cell value from the Microsoft Office SpreadSheet.

upul

New member
Joined
Mar 7, 2006
Messages
2
Location
Colombo, Sri Lanka
Programming Experience
3-5
<SPAN><FONT face=Arial><FONT size=1>Dear all
I have added a form to a project.
After that I have added Microsoft Office SpreadSheet 11.0 (OWC11) control and in the Form_Load() event add some random numbers to SpreadSheet.
After that I have added Label control to show the values which generated randomly.
 

Attachments

  • WindowsApplication3.zip
    9.1 KB · Views: 26
Not sure how to read from an excel spreadsheet, but here is how to write to one:
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] EXL [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Excel.Application
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] WSheet [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Excel.Worksheet
WSheet = EXL.Workbooks.Add.Worksheets.Add
.
.
.
.
[SIZE=2]WSheet.Cells(row, column).value = some string value  '(row and column should be numbers, not a number and a letter like excel has it)[/SIZE][/SIZE]

So I might try something like this:
VB.NET:
[COLOR=#0000ff] [/COLOR]
Dim[SIZE=2] EXL [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Excel.Application
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] WSheet [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Excel.Worksheet
WSheet = EXL.Workbooks.Add.Worksheets.Add
.
.
.
.
[/SIZE][SIZE=2]some variable = WSheet.Cells(row, column).value
[/SIZE]

Again I have never tried this but it might be a good place to start.
 
Back
Top