Click here to Skip to main content
15,893,564 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have excel file contains the following data:
ID    Mobile      Name
1     0394389544  Mary
2     0439898844  Katrin
3     0443874387  Maha

and i want to have textBox c# which contains the names as checkBox:
C#
Mary 
Katrin
Maha

and when I check one of them or some , the function get the Mobile (which is in excel) Corresponding to checked name and save it in string.
how can i do this in c#?
Posted
Updated 21-Sep-13 13:18pm
v2
Comments
[no name] 21-Sep-13 14:59pm    
So open the Excel file and query the data the you want out of it. What is the problem?

1 solution

There is such a thing as an ODBC driver for Excel, which I think would allow you to execute SQL queries against a spreadsheet. However, I am not familiar with it.

I am more familiar with something called ClosedXML (which is open source despite the name). You can used it to open an .xlsx file and read the cells. It's also pretty handy for creating .xlsx files. Documentation and download at http://closedxml.codeplex.com/[^]. Rather than download it from there, you might want to get NuGet package.

ClosedXML only works with .xlsx files. If you have a .xls file, you can write code to load into Excel and save it as a .xlsx file. If you want the code for that just ask.
 
Share this answer
 
Comments
Nelek 21-Sep-13 19:20pm    
If that "read xls and write xlsx" code is yours... have you considered to write it as an article or a tip here? It could be easier to find and help other people

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900