复选框和Excel文件c# [英] checkbox and excel file c#

查看:106
本文介绍了复选框和Excel文件c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有excel文件包含以下数据:

I have excel file contains the following data:

ID    Mobile      Name
1     0394389544  Mary
2     0439898844  Katrin
3     0443874387  Maha



我希望textBox c#包含名称为checkBox:


and i want to have textBox c# which contains the names as checkBox:

Mary 
Katrin
Maha



当我检查其中一个或一些时,该函数获取Mobile(在excel中)对应于已检查的名称并保存它在字符串中。

如何在c#中执行此操作?


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#?

推荐答案

有一个用于Excel的ODBC驱动程序,我认为允许您对电子表格执行SQL查询。但是,我并不熟悉它。



我更熟悉一些叫做ClosedXML的东西(尽管这个名字是开源的)。您可以使用它来打开.xlsx文件并读取单元格。它对于创建.xlsx文件也非常方便。文档和下载 http://closedxml.codeplex.com/ [ ^ ]。而不是从那里下载它,你可能想要获得NuGet包。



ClosedXML仅适用于.xlsx文件。如果您有.xls文件,则可以编写代码以加载到Excel中并将其另存为.xlsx文件。如果你想要的代码只是问。
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.


这篇关于复选框和Excel文件c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆