473,609 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Read from Excel

Would someone mind please posting sample code for reading data from a column
in Excel? And/or providing any recommended reading on the subject?

Thanks!
Nov 20 '05 #1
6 1169
* "Tommy Malone" <to***@angula.n et> scripsit:
Would someone mind please posting sample code for reading data from a column
in Excel? And/or providing any recommended reading on the subject?


<URL:http://www.connections trings.com/>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
Hi Tommy,

I hope these helps?

Cor

Office
http://support.microsoft.com/default...b;EN-US;311452

http://msdn.microsoft.com/office/

Pia Download
http://www.microsoft.com/downloads/d...displaylang=en

Excel dataset fill and update
http://support.microsoft.com/default...b;EN-US;316934
Would someone mind please posting sample code for reading data from a column in Excel? And/or providing any recommended reading on the subject?

Thanks!

Nov 20 '05 #3
If you want something simple you can also use OledDBConnectio n of ADO.NET to connect to excel workbook as datasource. Use DataReader or DataSet to iterate through rows. You will need a valid connection string:

"provider=Micro soft.Jet.OLEDB. 4.0;data source=c:\FileN am.xls;Extended Properties=Exce l 5.0;"

Then just open connection and you can pretty much treat excel as any other datasource for simple queries of course.

Also use this SQL to select your column from Sheet1:
select ColumnName from [Sheet1$]

"Tommy Malone" wrote:
Would someone mind please posting sample code for reading data from a column
in Excel? And/or providing any recommended reading on the subject?

Thanks!

Nov 20 '05 #4
Thank you all. Great articles and examples. I feel stupid for asking after
seeing how easy it is.

Thanks again.

"Lenn" <Le**@discussio ns.microsoft.co m> wrote in message
news:B8******** *************** ***********@mic rosoft.com...
If you want something simple you can also use OledDBConnectio n of ADO.NET to connect to excel workbook as datasource. Use DataReader or DataSet to
iterate through rows. You will need a valid connection string:
"provider=Micro soft.Jet.OLEDB. 4.0;data source=c:\FileN am.xls;Extended Properties=Exce l 5.0;"
Then just open connection and you can pretty much treat excel as any other datasource for simple queries of course.
Also use this SQL to select your column from Sheet1:
select ColumnName from [Sheet1$]

"Tommy Malone" wrote:
Would someone mind please posting sample code for reading data from a column in Excel? And/or providing any recommended reading on the subject?

Thanks!

Nov 20 '05 #5
Hi Tommy,

Not asking is stupid.
Thank you all. Great articles and examples. I feel stupid for asking after
seeing how easy it is.


Next time you can give these answers.

:-)

Cor
Nov 20 '05 #6
>> The only problem that I found and haven't figured out yet is that you need to know the name of the sheet.

Well ... Same arguement can be made about a databse table. You have to know its name to begin with. Yes, you can look it up in system tables, but you have to know what you're looking for.

Do you have to use the Excel.Applicati on object model to get it and then use it with ADO?


Are building some kind of Excel data explorer application? Yes, you can use Excel.Applicati on to get the names of all sheets in a workbook.
Also Sheet1 is a default name.
Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3152
by: Reza Solouki | last post by:
Hello, I never had to do anything with office tools programmatically till now(I guess there is first time for everything), so this might be a very silly and simple question for some of you. Any way, the new system that I am programming will need to be feeded daily with an excel file. So I need to read a given file and write it to the database - hopefully they all will follow the same structure. My issue is I haven't found anything...
4
5830
by: Marco Aschwanden | last post by:
Hi I would like to 1. import an existing Excel-sheet (a template) 2. and add some data to it 3. and save it under a different name afterwards. To me it seems, that pyExcelerator does not support the reading for modification of an Excel-sheet. It allows only the "parse_xls" but I would like to keep the "formatting" in the template.
3
6237
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store that multiple worksheet data in different table.How can i do it.Below is my xml file. <?xml version="1.0"?> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" ...
3
5384
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store that multiple worksheet data in different table.How can i do it.Below is my xml file. <?xml version="1.0"?> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office"...
3
3366
by: secure | last post by:
Hi all, I just registered to this forum, sorry to start with a question. I have written two formulas in excel and want to extend to many cells in a certain interval and generalize to other similar worksheets. So, I need to write them as vba code. The formulas: =INDEX('sheet1'!$A2:$BI$7000,MATCH(MAX('sheet1'!I2:I7),'sheet1'!I2:I7,0),COLUMN('sheet1'!A1)) ...
0
8044
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8548
Oralloy
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...
0
8510
jinu1996
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...
1
8197
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6042
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5503
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();...
0
4063
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2509
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
1
1635
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.