Reputation:
I am Using OLEDB to read Excel Sheet with C#. In that Column header Name is "Sr.No." in my "Sheet1". When i fetch Excel Sheet Data into my Datatable , i am getting "Sr#No#" as a column header name instead of original one. Can you please tell me why it’s happening so? And what is the solution for the same.
Thanks.
Upvotes: 4
Views: 3457
Reputation: 41
After some testing I've found out that OleDB converts the following characters:
. becomes #
! becomes _
` becomes _
[ becomes (
] becomes )
All the other characters are read correctly. Hope this helps someone.
Best Regards.
Upvotes: 4
Reputation: 63338
Googling around suggests that this is an inherent feature of OLEDB, rather than being anything to do with Excel - it seems to simply not like periods (.) in column names.
My suggestions would be either to cope with it - it seems to be a deterministic replacement of .s with #s - or if possible use an alternative means of reading Excel data from C# (search this site for alternatives).
Upvotes: 2