Hi Friends,
I need your help. Please help me.
I am trying to retrieve data from Excel Spreadsheet to fill the DataGridView for display prior to updating SQL SERVER with individual DataGridView row and encounter this error message: Public member 'WorkbookOpen' on type 'ApplicationCla ss' not found. which is caused by this coding trying to open the Excel WorkBook with the Excel name and Folder path.
Dim objBook As Excel.Workbook = CType(objExcel. WorkbookOpen(ex celPathName), Excel.Workbook)
-------------------------------------------------------------------
This coding prompt user to select Excel name and folder path - Private Sub btnFolderDialog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFolderDialog.Click
-
'prompt user to select Excel name and folder path
-
excelPathName = ""
-
Dim openFileDialog1 As System.Windows.Forms.OpenFileDialog
-
openFileDialog1 = New System.Windows.Forms.OpenFileDialog
-
-
With OpenFileDialog1
-
.Title = "Excel Spreadsheet"
-
.FileName = ""
-
.DefaultExt = ".xls"
-
.AddExtension = True
-
.Filter = "Excel (*.xls)| *.xls|All File(*.xls)|.xls"
-
-
If .ShowDialog = Windows.Forms.DialogResult.OK Then
-
excelPathName = (CType(.FileName, String))
-
End If
-
End If
-
End With
-
-
End Sub
----------------------------------------------------------------------
This coding retrieve data from Excel to fill DataGridView and error generated here - Private Sub btnOpenExcel_Click(ByVal sender As System.Object,
-
ByVal e As System.EventArgs) Handles btnOpenExcel.Click
-
-
Dim objExcel As Excel.Application = CType(CreateObject("Excel.Application"), Excel.Application)
-
Dim objBook As Excel.Workbook = CType(objExcel.WorkbookOpen(excelPathName)) <---- cause Error messsage *******
-
Dim objSheet As Excel.Worksheet = CType(objExcel.Worksheets(1), Excel.Worksheet)
-
objSheet.Visible = True
-
-
Dim bolFlag As Boolean = True
-
Dim excelRow = 6
-
Dim excelCol = 1
-
Dim DGVRow = 0
-
-
Try
-
Do While bolFlag = True
-
-
With DataGridView1
-
.Rows.Add()
-
DGVRow += 1
-
excelRow += 1
-
-
If objSheet.Cells(excelRow, 0) = "" Then
-
bolFlag = False
-
Exit Do
-
End If
-
-
.Rows(DGVRow).Cells(0).Value = objSheet.Cells(excelRow, 0)
-
.Rows(DGVRow).Cells(0).Value = objSheet.Cells(excelRow, 1)
-
.Rows(DGVRow).Cells(0).Value = objSheet.Cells(excelRow, 2)
-
.Rows(DGVRow).Cells(0).Value = objSheet.Cells(excelRow, 3)
-
.Rows(DGVRow).Cells(0).Value = objSheet.Cells(excelRow, 4)
-
.Rows(DGVRow).Cells(0).Value = objSheet.Cells(excelRow, 5)
-
.Rows(DGVRow).Cells(0).Value = objSheet.Cells(excelRow, 6)
-
.Rows(DGVRow).Cells(0).Value = objSheet.Cells(excelRow, 7)
-
.Rows(DGVRow).Cells(0).Value = objSheet.Cells(excelRow, 8)
-
-
End With
-
Loop
-
-
Catch ex As Exception
-
MessageBox.Show(ex.Message)
-
-
Finally
-
objBook.Close()
-
objExcel.Quit()
-
End Try
-
End Sub
Thank you for your help
Have a Good Day.
Cheers,
Lennie
0 1636 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Claudia Fong |
last post by:
Hi,
I have a form where I need to display the data of a department that
stores in a access db.
When I first load the form it will call a function name loaddata which
will get the first record from the db and then display for the user:
oleDbConnection1.Open();
|
by: Rachel |
last post by:
Hi All:
I would like to know how to prevent a dataset from being filled with garbage
data.
Forinstance, if I am importing data from an excel spreadsheet into a
dataadapter and the first column has data with decimal places and I do not
want ANY data to go into the dataset if this condition is true, instead I
want to have a message box appear telling the user what is wrong. How should
I code this? I will do the same sort of thing with...
|
by: funcSter |
last post by:
I want to retrieve data from an Excel file like how I would with a
database. I understand that I would have to use OLE DB. Somehow I
think I cannot get the connection string right, as the bit of code
fails at "objConn.Open()" with the error:
System.Data.OleDb.OleDbException: Could not find installable ISAM.
Can somebody please help me out? I'm still a learning programmer, so
if someone can point out my mistakes, it'll be great! Thanks!
...
|
by: Greg P |
last post by:
I'm new to VS2005 and want to simply update my data with the dataGridView
that was generated when I draged my query from the Data Sources Pane. I
think I may need to create a Data Adaptor but I'm not sure? The other think
I saw was to implement IEditable? How would I do that? Where in my code
woudl I do that considering I am not creating the DataGridView via code?
I know this is probably the easist thing to do I just don't know how?...
|
by: Yoshitha |
last post by:
Hi
I want to Extracet(retrieve) data from some of websites and the retrieved
data has to be saved in excel or.csv files.
I need to develop this in ASP.net(using C#.net Vs 2003).
Can any one tell me the idea of how to get data from websites?
| |
by: pauljohns353 |
last post by:
Hi,
I am new to VB.net programming and was wondering if anybody has any suggestions as to how I can export data from a DataGridView via a command button to a CSV file.
Any suggestions or sample code would be really appreciated.
Many thank.
Paul.
|
by: RajithaV |
last post by:
Hi,
I am developing a web application using ASP.Net
I am using sql server.My coding is in VB.net
I want to know how to move data from excel file into the Database.
I also need to know how to retrieve data from Database and show it in excel file.
Thanks in advance for any replies.
rajitha
|
by: Anthoni |
last post by:
Dear All,
I need to export data of unbound datagridview to XML file.
Since my DataSource is NULL, What other options do I have?
Does i need to make 2 loops (on all the records and inside loop of all
the cells)
read data and export it to XML?
TIA,
|
by: trint |
last post by:
How can I retrieve all of the data from a datagridview?
Any help is appreciated.
Thanks,
Trint
|
by: dillipdhal |
last post by:
Hi This is Dillip from HSBC Software,Hyd.
Now I m working in a financial domain.
Please help me in "How can I insert data from a datagridview to database in vb .net and also retrive the data "
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 we have to send another system
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |