473,405 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How to read excel cvs file from C#

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
Nov 15 '05 #1
4 11666
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
v-******@microsoft.com
Nov 15 '05 #2
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #3
Use RegularExpression matches to parse it, that way you can match both
situations you described.

"Andy Lee" <ji*********@hotmail.com> wrote in message
news:u6**************@TK2MSFTNGP12.phx.gbl...
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 15 '05 #4
Hi Andy,

Take a look at http://www.opennetcf.org/Csv.asp

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Andy Lee" <ji*********@hotmail.com> wrote in message
news:Oz**************@TK2MSFTNGP10.phx.gbl...
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

Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: QQ | last post by:
I am trying to read data from Excel files I use the following codes, however, it didn't work Can anyone tell me what the format excel files have, what I should do to read it from C? Thanks a...
0
by: Peter | last post by:
I am having a problem reading an Excel file that is XML based. The directory I am reading contains Excel files that can be of two types. Either generic Microsoft based or XML based. I am reading...
1
by: Roger Twomey | last post by:
I have a form that allows a user to upload a microsoft Excel Spreadsheet. (I am testing with one created in Excel 2000) The spreadsheet is uploaded correctly. It is then supposed to be read...
2
by: Reza Solouki | last post by:
Hello, I never had to do anything with office tools programmatically till now(I guess there is first time for everything), so this might be a very silly and simple question for some of you. Any...
4
by: Seok Bee | last post by:
Dear Experts, I have created a script to extract the Event Logs from the system into an excel sheet. The logs are separated into 2 worksheets (Application Log and System Log). After this excel...
1
by: ashok0866 | last post by:
I had created a macro to read data from an excel sheet and write the values to a text file. I had used "ActiveSheet.Range("GB" & k).Value" command to read the values from the excel. The issue...
2
by: wstsoi | last post by:
hi I have to read images from spreadsheet, is it possible to do with php?
4
by: sukhmeet | last post by:
Hi, I am trying to load a csv file in Iframe element. I just want to load it as a text file. however when i load the file in iframe it asks to open the file and finally opens it with excel in IE...
3
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store...
3
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.