 |
|
 |
I really appreciate for your time you have taken to post your article. it has really helped me and there is some thing i would like to add to the rest of the people who are trying to access a excel 2007 file there needs to be a change to the configuration as follows
Private Const connstring As String = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=C:\Test.xlsx;Extended Properties=""Excel 12.0 Xml;HDR=YES;"""
http://www.connectionstrings.com/excel-2007[^]
And the rest of the code is all the same.
Brother Raman ! thanks again thanks a lot and please keep ur posts coming and kindly ignore the comments of the lazy people who want you to stop development.
Regards
Ravi Shankar Vattikuti
|
|
|
|
 |
|
 |
| Thanks a lot Ravi Raman Tayal
Microsoft Certified Technology Specialist in BizTalk Server 2006
Microsoft Certified Application Developer .NET
My Blog: - http://ramantayal.blogspot.com/
|
|
|
|
 |
|
 |
thanks this article helped me as well.
|
|
|
|
 |
|
 |
I have excel file and I set username and pwd for that file. How can I open that file and insert and select rows from it. Please clarify, its urgent.
|
|
|
|
 |
|
 |
How can i make a primary key like if column is ID how can i make it as my primary key and control it in my insert statment?
|
|
|
|
 |
|
 |
Hi
In this I am loading the data into the dataset when reading the values from Excel file. Datatable in dataset supports the primary key contraints enforncement on the dataset which restrict the duplicate value to be insert in dataset. This will helps you to achive the functionality. But in this you need to check whether the data loaded in dataset should be unique otherwise you will get an exception while puting the primary key constraints.
Or you can also predefine the datatable in dataset and put the primary key contraint on respective column and then load the data from the excel but you must ensure that the excel has not been tempered by the user manually. In case user has manually instert the duplicate row in excel then you will get an exception while reading the value from excel.
You can refer to the below link to create primary key constraints in datatable.
http://msdn.microsoft.com/en-us/library/system.data.datatable.primarykey.aspx[^]
Raman Tayal
Microsoft Certified Technology Specialist in BizTalk Server 2006
Microsoft Certified Application Developer .NET
My Blog: - http://ramantayal.blogspot.com/
|
|
|
|
 |
|
 |
hi, i want to make Korean to Khmer dictionary.
1. how can i load font in vb.net?
2. how can i load the word list and definition from Access 2007?
3. how can i publish this application in smaller size?
4. Please give me some more advice for making a dictionary.
|
|
|
|
 |
|
 |
The problem I have is I do my development on my work PC at home. The SQL Server (SQL 2000) is located in our Home Office on a server farm. Running a query that looks at the C: drive will not work when run on the SQL server as my excel file is not located there (it's on my PC). The only solution I've been able to come up with is NewRow and Rows.Add to do this, but OMG is it slow. I have a spreadsheet on 2 tabs that has a little over 100k rows and it takes about 3-4 hours to upload this. And it's 2 fields that I'm uploading, a number and a bit. Any suggestions on what I can do otherwise? Due to NT security with the company I work with we can't place files on the SQL server, and we also cannot create linked servers.
Thank you.
Wendell
|
|
|
|
 |
|
 |
Don't use OleDB nor Excel Interop on server side. It is just wrong.
Use some 3rd party library for writing Excel files that doesn't rely on Excel Automation so you are independent of Excel app to be installed on server.
Take a look at GemBox.Spreadsheet component for reading and writing Excel files in .NET.
It is about 250 times faster that Excel Interop so your upload time goes from 4 hours to 1 minute.
And you can save Excel files in SQL database as raw byte data, you don't need permission to save files on SQL server hard drive.
|
|
|
|
 |
|
 |
Hi there, Great Job !!!the code works perfect !!!
I have one question, how can i update an excell file that is shared among other users ???
The code you wrote DOES update the file when it's in shared mode, BUT I have to close the file and open it again to see the changes. For some reason it won't refresh automatically. Can you help me with this ??
Thanks in advance.
Facu20yo.
modified on Sunday, April 19, 2009 10:04 AM
|
|
|
|
 |
|
 |
i trying to read and write data from/to excel file row by row.how i can identified row and column.your code given only to read the entire data.please help me...
|
|
|
|
 |
|
 |
Hi
Actually I am not very clear with your requirement. I have two points coming in my mind. Please confrim are you looking the solution corresponding to that points or any other requirement you have.
1. Are you want to constantly conecting to Excel sheet and read the row one by one.
2. Or you want to read the complete data from Excel at one shot and use the data one by one with the help of Binding Manager. For e.g. in you application you want to display the data in some form and move between different records by pressing the Next, Previous button on the form.
Raman Tayal
Microsoft Certified Technology Specialist in BizTalk Server 2006
Microsoft Certified Application Developer .NET
My Blog: - http://ramantayal.blogspot.com/
|
|
|
|
 |
|
 |
actually i'm trying to read data from cell and use it for calculation in my program.i have a lot of data in excel file.
i want to read data from row 1 and multiple column.for example : i read data from row 1 and column A to P.i need to read the A1 and do the calculation.read data B1 and do the calculation and so on...
i think i should put some looping.but i don't know how??please help me...
|
|
|
|
 |
|
 |
Hi,
hope it's not to late with answer. Since i'm not familiar with VB (I'm into C#) i can try to explain it in pseudo code. Let's say you want to go from A1 to P1
string cellname="A1";
do
{
read cell with name cellname;
do calculations;
increase value of char cellname[0] by 1 so you get B1 from A1;
}
while (cellname equals "P1")
This way you change name of cell you want to read. Another way is to use GemBox Excel component for .NET. I use this component and it is very useful and very easy to use. Here is a list of reasons why it's better to use this component then Excel Automation (but it can also go for OLEDB).
|
|
|
|
 |
|
 |
by the way bro, im Paul Jacquez, 2nd year student SSCT Surigao City, Philippines. i want studying vb.net bro because i want a programmer someday bro, plz help me bro. i want codes edit,delete and search with use of excel as database bro. plz help me bro.?
Thank you bro. God Bless U.
|
|
|
|
 |
|
 |
Hi Paul
Please check the code given below which helps you to edit and update the record in Excel. Rest of the code same as I was posted on website.
olecomm1 = New OleDbCommand
olecomm1.CommandText = "Update [Sheet1$] set " & _
"FirstName=@FName, LastName=@LName, Age=@Age, Phone=@Phone where " & _
"FirstName=@Name"
olecomm1.Connection = olecon
pram = olecomm1.Parameters.Add("@FName", OleDbType.VarChar)
pram.SourceColumn = "FirstName"
pram = olecomm1.Parameters.Add("@LName", OleDbType.VarChar)
pram.SourceColumn = "LastName"
pram = olecomm1.Parameters.Add("@Age", OleDbType.VarChar)
pram.SourceColumn = "Age"
pram = olecomm1.Parameters.Add("@Phone", OleDbType.VarChar)
pram.SourceColumn = "Phone"
pram = olecomm1.Parameters.Add("@Name", OleDbType.VarChar)
pram.SourceColumn = "FirstName"
pram.SourceVersion = DataRowVersion.Original
If IsNothing(ds) = False Then
dr = ds.Tables(0).Rows(0)
dr.BeginEdit()
dr("FirstName") = "Bunty"
dr("LastName") = "Aggarwal"
dr("Age") = 26
dr("Phone") = 98989898
dr.EndEdit()
oleadpt.UpdateCommand = olecomm1
Dim i As Integer = oleadpt.Update(ds, "Sheet1")
MessageBox.Show(i & " row affected")
End If
The above code shows that how you can update the first row from dataset, you can customize your code to delete the specific row from the dataset.
As far as delete is concerned, it is currently not allowed in Excel using code but you can achive the same by delete the old excel file and writing the new one.
In case of any query please feel free to contact me.
Thanks
Raman Tayal
Microsoft Certified Technology Specialist in BizTalk Server 2006
Microsoft Certified Application Developer .NET
My Blog: - http://ramantayal.blogspot.com/
|
|
|
|
 |
|
 |
base in your program about "TestExcel2" bro, i need your help bro on how to edit the existing record bro, using vb.net bro. plz help me bro?
|
|
|
|
 |
|
 |
Hi bro,i have a question how to delete data in excel 2007 using vb.net?..pls reply with this codes thank you....and god bless...
|
|
|
|
 |
|
 |
Hi bro, wow very nice bro like it. Thank you so much bro, i really appreciate your code project "Reading and writing excel file using VB.NET."
|
|
|
|
 |
|
 |
Please remove yourself from the computer programming field, jesus.
|
|
|
|
 |
|
 |
Thanks for the suggention. I will definatly think about this, but could you please let me know why you want me to quite from my job. If you are having some issue with the code then let me know. I will try my best to reslove your issue.
Regards
Raman Tayal
Raman Tayal
Microsoft Certified Technology Specialist in BizTalk Server 2006
Microsoft Certified Application Developer .NET
My Blog: - http://ramantayal.blogspot.com/
|
|
|
|
 |
|
 |
Because the code you posted doesn't not run "out of the box". What's the point of posting code that doesn't work? When I say doesn't work, I should be able to download a code example and it should run without an issue.
|
|
|
|
 |
|
 |
Hi
I really appologies for the inconvenience caused. I forget to include the sample excel file in the source code. This code is running perfectly and thousands for users are using this code. As of now to run this code please create an excel file on c drive name as test.xls. Add the four column in the excel as shown in the image given in the article.
e.g.: -
1. FirstName
2. LastName
3. Age
4. Phone.
Now try to run the code, this should work as expected. If you are still facing any issue please feel free to contact me.
Thanks
Raman Tayal
Microsoft Certified Technology Specialist in BizTalk Server 2006
Microsoft Certified Application Developer .NET
My Blog: - http://ramantayal.blogspot.com/
|
|
|
|
 |
|
 |
Thanks bro, don't listen to lazy people that instead of critizicing should thank you for your time uploading this solution.
Regards,
|
|
|
|
 |
|
 |
Thanks for the appriciation
Raman Tayal
Microsoft Certified Technology Specialist in BizTalk Server 2006
Microsoft Certified Application Developer .NET
My Blog: - http://ramantayal.blogspot.com/
|
|
|
|
 |