How to read excel cvs file from C#

A

Andy Lee

Could someone tell me how I can read excel csv (comma separated variable)
file using C#? I know how to do it by parsing each line myself. Since
reading excel csv file in C# is a pretty common technique, I just wonder
whether there is a class or a way to do it out there already.

Thanks,

Andy
 
G

Guest

What are you trying to read the file into? Are you trying to open it programmatically into an instance of an Excel Worksheet or just into an array type structure

Thanks

Travis Merke
(e-mail address removed)
 
A

Andy Lee

I tried to read a .CSV file into an array of string. I can use the
string.split method to do it if the .CSV file just contain "," without
quotas. But if there is quota, split function can't handle it. For
example, file like this
1234,"546,345",564
should be split into three pieces. But split function will make it four
pieces. Also if a cell in excel has data like
sgs"gdfgs"sdfsd
it is stored as
"sgs""gdfgs""sdfsd
I would like to see
sgs"gdfgs"sdfsd
when it is read into an string.

Thanks,

Andy
 
S

skinc

Use RegularExpression matches to parse it, that way you can match both
situations you described.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top