[英]reading column header in excel file
I am reading data from excel file using OLEDB connection.我正在使用 OLEDB 连接从 excel 文件中读取数据。 But the problem is I can't read the column header.
但问题是我无法阅读 header 列。 I am using
我在用
String sConnectionString1 = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" +"E:\\"+
Sourcefilename + ";" + "Extended Properties='Excel 8.0;HDR=Yes;Format=xls;'";
in connection string.. please help me out.在连接字符串中..请帮帮我。
Load the Excel in Dataset and Access the Column collection to get the ColumnName gives the Column header在数据集中加载 Excel 并访问 Column 集合以获取 ColumnName 给出的列 header
foreach (DataColumn dc in output.Tables[0].Columns)
{
Console.WriteLine(dc.ColumnName);
}
You can use OLEDB to connect and read from excel sheets.您可以使用 OLEDB 连接和读取 excel 表。 Here is a good examplehttp://codehill.com/2009/01/reading-excel-2003-and-2007-files-using-oledb/
这是一个很好的例子http://codehill.com/2009/01/reading-excel-2003-and-2007-files-using-oledb/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.