如何使用CsvHelper在asp.net内核中读写csv文件
发布于 2020-02-15 09:54:40
您是在问如何编写代码吗?你看过网上的例子了吗?
请注意,SoftCircuits.CsvParser大约比CsvHelper快四倍。下面是使用SoftCircuits.CsvParser读取文件的样子:
string[] columns = null;
using (CsvReader reader = new CsvReader(path))
{
while (reader.ReadRow(ref columns))
{
// Here columns contains an array of string values that
// were read from the current line
}
}请注意,这两个库还能够将列直接映射到对象属性,因此您只需创建具有与每个列对应的属性的类,所有内容都将为您映射。上面的示例只是将列作为字符串数组读取。
https://stackoverflow.com/questions/60166902
复制相似问题