Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help request for vb .net in excel
Hi evry one,
I have an excel file which contain group of cells from A2 to A10, those cell values are changing almost each 10 seconds. Any one can help me how to read those values in visual basic studio .net 2003. The excel file is always open, I do not need to open it, I need to define this file and read the cell values in my vb studio. Help please. Kh |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help request for vb .net in excel
kh,
You can use an OleDbDataReader (ADO.NET) and query the cells in your range: Dim cmd As OleDbCommand = dbConn.CreateCommand() cmd.CommandText = " select * from [Sheet1$A2:A10] " rdr = cmd.ExecuteReader() Use Console.WriteLine() or whatever to output the data where you need. Ciao, |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help request for vb .net in excel
Hi
Thank you for your time, appreciated. Please write to me the complete code, because the lines you wrote are not working. I am using visual studio vb 2005. Thank you. Best Regards, kh "campwes" wrote: kh, You can use an OleDbDataReader (ADO.NET) and query the cells in your range: Dim cmd As OleDbCommand = dbConn.CreateCommand() cmd.CommandText = " select * from [Sheet1$A2:A10] " rdr = cmd.ExecuteReader() Use Console.WriteLine() or whatever to output the data where you need. Ciao, |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help request for vb .net in excel
Here ya go:
Dim dbConn As OleDbConnection Dim strConn As String Dim strSQL As String Dim rdr As OleDbDataReader strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=FileName.xls;Extended Properties=""Excel 8.0;IMEX=1""" dbConn = New OleDbConnection(strConn) dbConn.Open() Dim cmd As OleDbCommand = dbConn.CreateCommand() cmd.CommandText = " select * from [Sheet1$A2:A10] " rdr = cmd.ExecuteReader() Let me know if you need help with how to output the data from the query. Cheers, |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help request for vb .net in excel
Hi
Yes please let me know how to query data. For example, after reading data A2:A10 , I wish to paste them in cells H2:H10 same sheet. I wish to know each item of theses data as array, to be manipulated easily. Many thanks for your time. Best Regards, kh "campwes" wrote: Here ya go: Dim dbConn As OleDbConnection Dim strConn As String Dim strSQL As String Dim rdr As OleDbDataReader strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=FileName.xls;Extended Properties=""Excel 8.0;IMEX=1""" dbConn = New OleDbConnection(strConn) dbConn.Open() Dim cmd As OleDbCommand = dbConn.CreateCommand() cmd.CommandText = " select * from [Sheet1$A2:A10] " rdr = cmd.ExecuteReader() Let me know if you need help with how to output the data from the query. Cheers, |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help request for vb .net in excel
kh,
Unfortunately, you'll need to use VBA or macros to do what you want. Selects are easy with ADO.NET, but inserts are another matter altogether. I have no idea how to do that. Try posting to one of the VBA boards. Good luck! "kh" wrote: Hi Yes please let me know how to query data. For example, after reading data A2:A10 , I wish to paste them in cells H2:H10 same sheet. I wish to know each item of theses data as array, to be manipulated easily. Many thanks for your time. Best Regards, kh "campwes" wrote: Here ya go: Dim dbConn As OleDbConnection Dim strConn As String Dim strSQL As String Dim rdr As OleDbDataReader strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=FileName.xls;Extended Properties=""Excel 8.0;IMEX=1""" dbConn = New OleDbConnection(strConn) dbConn.Open() Dim cmd As OleDbCommand = dbConn.CreateCommand() cmd.CommandText = " select * from [Sheet1$A2:A10] " rdr = cmd.ExecuteReader() Let me know if you need help with how to output the data from the query. Cheers, |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel formula request | Excel Worksheet Functions | |||
Using SQLRequest with Excel 2003 | Excel Discussion (Misc queries) | |||
Excel 2007: request for help | Excel Worksheet Functions | |||
Does SQL.REQUEST work in Excel X? | Excel Discussion (Misc queries) | |||
Excel help request | Excel Programming |