且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用EPPLUS .CSV文件加载速度慢

更新时间:2023-02-10 20:40:06

在这里我的建议是自己读取该文件,然后使用该库创建该文件。

My suggestion here is to read the file by yourself and then use the library to create the file.

读取CSV代码可以是简单的:

The code to read the CSV could be as simple as:

List<String> lines = new List<String>();
using (StreamReader reader = new StreamReader("file.csv"))
{
    String line; 
    while((line = reader.ReadLine()) != null)
    {
        lines.add(line);
    }
}

//Now you got all lines of your CSV

//Create your file with EPPLUS

foreach(String line in lines)
{
    var values = line.Split(';');
    foreach(String value in values)
    {
        //use EPPLUS library to fill your file
    }
}