简体   繁体   English

在读取Excel工作表数据时,请保持原样的空列名

[英]Keeping empty column names as such while reading the excel sheet data

I am reading an excel file and saving contents to database. 我正在读取一个Excel文件并将内容保存到数据库。 I have two columns , first column name is blank and second column name is A. Both columns has rows under it . 我有两列,第一列的名称为空白,第二列的名称为A。两列下都有行。

When I am executing "select * from ["+excel[i]+"]") using oledbconnection, 当我使用oledbconnection执行"select * from ["+excel[i]+"]")

empty column is automatically replaced with F1. 空列将自动替换为F1。 I need both the columns and data as it is available from excel sheet. 我需要列和数据,因为它们可以从excel工作表中获得。

How to avoid it? 如何避免呢?

I don't think there is a way to avoid this. 我认为没有办法避免这种情况。 This is a normal behaviour of OleDB when connected to Excel, if it finds empty columns, it will either take the first row as column name or generate some default names as of F1,F2,F3...etc 连接到Excel时,这是OleDB的正常行为,如果它发现空列,它将以第一行作为列名或生成一些默认名称,例如F1,F2,F3等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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