473,396 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 1163
* "Tommy Malone" <to***@angula.net> 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.connectionstrings.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 OledDBConnection 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=Microsoft.Jet.OLEDB.4.0;data source=c:\FileNam.xls;Extended Properties=Excel 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**@discussions.microsoft.com> wrote in message
news:B8**********************************@microsof t.com...
If you want something simple you can also use OledDBConnection 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=Microsoft.Jet.OLEDB.4.0;data source=c:\FileNam.xls;Extended Properties=Excel 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.Application 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.Application 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
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...
4
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...
3
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...
3
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...
3
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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...
0
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
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,...

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.