简体   繁体   中英

EPPLUS import excel file without header ASP.net

嗨,是否可以使用 EPPLUS 读取没有标题的 Excel 文件?

You can save the excel in csv format and skip the first line after reading all line.

var lines = File.ReadAllLines(FileName).Skip(1);

or you can use oledb connection to import data from excel to datatable .

string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + filename + ";" + "Extended  Properties='Excel 12.0;HDR=YES;IMEX=1;';";

string query = string.Format("SELECT * FROM [{0}$]", tablename);
        using (OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, connectionString))
        {
            DataSet jobDataSet = new DataSet();
            dataAdapter.Fill(jobDataSet, "jobInfo");
            DataTable jobDataTable = jobDataSet.Tables["jobInfo"];
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM