在excel文件中阅读列标题 [英] reading column header in excel file

查看:158
本文介绍了在excel文件中阅读列标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用OLEDB连接从excel文件读取数据。但问题是我无法读取列标题。
我正在使用

I am reading data from excel file using OLEDB connection. But the problem is I can't read the column 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.

推荐答案

将Excel加载到数据集并访问列集合以获取列名给列标题

Load the Excel in Dataset and Access the Column collection to get the ColumnName gives the Column header

       foreach (DataColumn dc in output.Tables[0].Columns)
       {
           Console.WriteLine(dc.ColumnName);
       }

这篇关于在excel文件中阅读列标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆