使用c#读取excel文件可以通过OleDbDataAdapter来进行读取,将excel文件作为数据库,以检索数据的方式来读取excel内容。具体代码如下:
var fileName = string.Format("{0}\\fileNameHere", Directory.GetCurrentDirectory());
var connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; data source={0}; Extended Properties=Excel 8.0;", fileName);
var adapter = new OleDbDataAdapter("SELECT * FROM [workSheetNameHere$]", connectionString);
var ds = new DataSet();
adapter.Fill(ds, "anyNameHere");
DataTable data = ds.Tables["anyNameHere"];
也可以设置data为
var data = ds.Tables["anyNameHere"].AsEnumerable();
这种方式可以使用LINQ进行搜索,并从字段中构建结构
var query = data.Where(x => x.Field<string>("phoneNumber") != string.Empty).Select(x =>
new MyContact
{
firstName= x.Field<string>("First Name"),
lastName = x.Field<string>("Last Name"),
phoneNumber =x.Field<string>("Phone Number"),
}
);
支付宝-交易订单处理失败,请稍后再试。(ALI59)的解决办法
重庆微信小程序开发
有客户咨询,在Wordpress,如何去掉页面底部的Powered by wordpress字符呢?在后台设置的“页面显示-自定义”中,也没有底部页脚内容设置的选项,这个要怎么去掉呢?其实这个问题很简单,只需要进入该主题的目录,对相关的...
int main() { auto hello= struct { int test() { return 1; } }().test(); }有初学C++的小伙伴提问,在运行C++代码时报错,错误提示如下:<source :2:...
开源节流,控制生产成本,限制开销,是每个企业和单位都要采取的成本控制和管理措施。其中,人力成本是企业在经营中支出占比较大的一块。以IT信息化部门为例,一个负责企业软件系统运维的IT部门,至少需要配置3个员工,每个员工按照IT工程师3-5年工...
在使用uniapp开发微信小程序,微信开发者工具调试时,明明已经给了获取位置权限,但还是提示需要打开gps获取位置,具体解决办法如下:打开uniapp的manifest.json文件,切换到源码模式,找到mp-weixin节点"p...
在使用uniapp开发的小程序内,打开图片,长按没有弹出菜单,无法扫码,此时只需在图片上加入show-menu-by-longpress即可完整代码:<image :src="picture" mode="...
在php代码中,遇到复杂的sql语句,需要拼装sql语句,如:$sql='id 10;' $sql=' and( status in(1,2,3,4,5) and id not in (select id from ...