473,513 Members | 2,401 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using excel data in vb once its in my application..?

11 New Member
For work I've been tasked with creating some verification programs. So I thought best way to do this is to take their excel sheet and compare the data...

I've been able to open the excel sheet and place it into a DataGridView, but now I'm stumped on how I actually use the data Im seeing...

I.E - The sheet has 2 columns (min) and (max) with about 20 rows of values... I want to be able to compare the data a user inputs against these two columns... so if the user enters the number 20, it makes sure its greater then any of the (min) values and less then any of the (max) values via a text box and button... any ideas?


**Edit**
Ok i figured out I can use the values from a datagrid using the

DataGridMatrix(value,value) but As I'm trying to place it into a text it says it cannot be converted to 'string'.

Oh! Im using VB.net '05 with my excel document being imported from the Excel 8.0 version, and below is my code to read the excel file.



Dim sqlData As String = "SELECT * FROM [Sheet1$]"

Dim xlCon As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Documents and Settings\eneal\Desktop\matrix.xls;" & _
"Extended Properties=""Excel 8.0;HDR=YES"""

Dim conn As New OleDbConnection(xlCon)
Dim db As New OleDbDataAdapter(sqlData, conn)
Dim dbExcelData As New DataSet
db.Fill(dbExcelData, "matrix")
Me.DataGridMatrix.DataSource = dbExcelData.Tables("matrix")
dbExcelData.Dispose()
db.Dispose()
conn.Dispose()
Sep 10 '07 #1
6 1722
VBPhilly
95 New Member
For work I've been tasked with creating some verification programs. So I thought best way to do this is to take their excel sheet and compare the data...

I've been able to open the excel sheet and place it into a DataGridView, but now I'm stumped on how I actually use the data Im seeing...

I.E - The sheet has 2 columns (min) and (max) with about 20 rows of values... I want to be able to compare the data a user inputs against these two columns... so if the user enters the number 20, it makes sure its greater then any of the (min) values and less then any of the (max) values via a text box and button... any ideas?


**Edit**
Ok i figured out I can use the values from a datagrid using the

DataGridMatrix(value,value) but As I'm trying to place it into a text it says it cannot be converted to 'string'.

Oh! Im using VB.net '05 with my excel document being imported from the Excel 8.0 version, and below is my code to read the excel file.



Dim sqlData As String = "SELECT * FROM [Sheet1$]"

Dim xlCon As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Documents and Settings\eneal\Desktop\matrix.xls;" & _
"Extended Properties=""Excel 8.0;HDR=YES"""

Dim conn As New OleDbConnection(xlCon)
Dim db As New OleDbDataAdapter(sqlData, conn)
Dim dbExcelData As New DataSet
db.Fill(dbExcelData, "matrix")
Me.DataGridMatrix.DataSource = dbExcelData.Tables("matrix")
dbExcelData.Dispose()
db.Dispose()
conn.Dispose()

What is the code causing the conversion error?
Sep 10 '07 #2
Nimion
11 New Member
Private Sub DataGridMatrix_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridMatrix.CellContentClick

txtdata.Text = DataGridMatrix(4, 1)

End Sub


The error is:
Value of type 'System.Windows.Forms.DataGridViewCell' cannot be converted to 'String'.

I want the actual value of the cell to be placed into the textbox when I click it in DataGridView, I've got the 'location' several times..but thats not what I need : /
Sep 10 '07 #3
VBPhilly
95 New Member
Private Sub DataGridMatrix_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridMatrix.CellContentClick

txtdata.Text = DataGridMatrix(4, 1)

End Sub


The error is:
Value of type 'System.Windows.Forms.DataGridViewCell' cannot be converted to 'String'.

I want the actual value of the cell to be placed into the textbox when I click it in DataGridView, I've got the 'location' several times..but thats not what I need : /
what does this do:

Expand|Select|Wrap|Line Numbers
  1. txtData.Text = DataGridMatrix(4,1).ToString 
  2.  
Sep 10 '07 #4
Nimion
11 New Member
That actually returned a value into my text box...but it returned this..



DataGridViewTextBoxCell { ColumnIndex=4, RowIndex=1 }
Sep 10 '07 #5
VBPhilly
95 New Member
what does this do:

Expand|Select|Wrap|Line Numbers
  1. txtData.Text = DataGridMatrix(4,1).ToString 
  2.  
Better still :) :

Expand|Select|Wrap|Line Numbers
  1. txtData.Text = DataGridMatrix(4,1).value
  2.  
Sep 10 '07 #6
Nimion
11 New Member
It worked...Haha. It was that easy..... -.- wow...I used every combination I could think of but the obvious eluded me... thanks a lot :)
Sep 10 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
47722
by: Jim, N2VX | last post by:
I'd like to create/display an Excel spreadsheet from javascript. We have an HTML page with results of a search and it can be reasonably large. The first attempt was to format the data into an...
1
3104
by: ST | last post by:
Hi, I'm having problems opening up excel thru my code. It will write and saveas an excel file, but the application won't open on the user's computer, excel seems to be hidden, because it shows up...
2
4168
by: Ronny Sigo | last post by:
Hello all, As one of a few ways to let a user bring in data into my database I have made 3 excel files. Once the data are in the excel files my program checks if a required value (Taal (Dutch)...
14
5733
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the...
3
1851
by: Rich Ulichny | last post by:
Not sure if this is correct newsgroup but I figured I had to start somewhere. We need to build a Web based application to allow users to choose an Excel file from their hard drive (or other...
0
2222
by: Rich Wallace | last post by:
Hello all, Looking for suggestions and tips if possible. I have an application running on a file server that utilizes the FileSystemWatcher to trap when any Excel files are saved by a user. I...
7
2415
by: Alain \Mbuna\ | last post by:
Hi everybody. In my program I have some data that is calculated after some input from the user. I have written some code that opens an Excel workbook, with 5 worksheets and the calculated data...
3
2066
by: Agnes | last post by:
Dim dsExcelExport As New System.Data.DataSet Dim daExcelExport As New System.Data.SqlClient.SqlDataAdapter Dim Excel As New Excel.Application Dim strExcelFile As String Dim strFileName As...
3
7335
by: akristensen | last post by:
I am new to this site, so be patient if I do not ask the question correctly. Current Target Platform: Browser: MS IE, script language: Javascript (will use VBScript, but JS is preferred), External...
16
5152
by: Phil Stanton | last post by:
I have a form with a button which is supposed to open an Excel file (With lots of Macros /VBA) in it. The Excel file gets it's data from the Access program Here is the code Private Sub...
0
7264
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7166
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7534
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5689
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5094
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1601
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
805
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
459
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.