skip first row in read of Excel file

后端 未结 4 520
春和景丽
春和景丽 2020-12-17 02:43

Hello I\'m trying to translate an Excel file to my dataGridView and it\'s having column name issues because the way the Excel file is formatted, there are two setup cells fo

4条回答
  •  孤城傲影
    2020-12-17 03:28

    There is an easier way than programatically removing the rows, use the header row property of the connection string. This should skip the first row for you and you can then do what you do with the rest of the rows from there. From ConnectionStrings.com:

    Provider=Microsoft.ACE.OLEDB.12.0; Data Source=myOldExcelFile.xls; 
    Extended Properties="Excel 12.0;HDR=YES";
    

    "HDR=Yes;" indicates that the first row contains columnnames, not data. "HDR=No;" indicates the opposite.

提交回复
热议问题