简体   繁体   中英

Import Excel (.xlsx) data using C# as strings

I am trying to import data from an .xlsx document. It keeps reading the data types incorrectly. I need every column to come in as a string.

My connection string looks like this:

"Provider=Microsoft.ACE.OLEDB.12.0; Data Source = " + FileName + "; Extended Properties = 'Excel 12.0 Xml; HDR = Yes; IMEX = 1';"

You may want to try something like linqtoexcel this turns excel worksheets into objects which can be queried using linq queries. Then you can turn columns into string if you want to by quering the linq objects.

you will find some documentation about how to read an excel file here (interop)

If you need information about connection string I think this website could be helpful : http://connectionstrings.com/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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