使用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"),
}
);
在使用前端框架Nuxt3开发时,如何配置自定义的scss文件路径呢?有同学使用loadPaths: ['@/assets/css']来设置路径,但是无效,是因为在loadPaths中,@符号不起作用,不能代表根目录。正确...
问题:在html中,如果checkbox为已选状态,进入下一个页面后再点后退时,该checkbox还是为已选中状态,但是依赖该checkbox选中后的事件却无法执行。解决:这种情况下,对checkbox的input设置autocompl...
js#replace替换var str="Hello world! world is beautiful.";var str_new=str.replace("world","JavaS...
1.composer版本更新文档版本号:https://getcomposer.org/download中文网:https://docs.phpcomposer.com/03-cli.html#self-update英文网:https:...
由老版本7.2自动升级时,会出现很多问题,建议在终端手动升级。升级命令:curl http://download.bt.cn/install/update_panel.sh|bash
用phpmyadmin导入大数据库文件时,容易502badgateway,可以直接在linux上用mysql原生命令导入。1.上传sql文件到目录用Xshell登录服务器,将迁移过来的sql文件移到home目录下,方便下一步的操作,站长之前...
安装fastadmin,打开后提示"你所浏览的页面暂时无法访问",无法安装,是因为程序的runtime没有写权限,需要对runtime目录,添加写权限。解决方法:windows:右键目录,写入按钮打勾。如果不行,在“安全...
正确的USB连线,其次打开开发者选项、USB调试,这些都是老生常谈,就不说了。在确保以上操作无误后,如果还找不到真机,关闭IDE,然后去adb的目录下,即HBuilderX\plugins\launcher\tools\adbs,把adb....