I want to read from an excel file in C. The excel 2007 file contains about 6000 rows and 2 columns. I want to store the contents in a 2-D array in C. If there exists a C library or any other method then please let me know.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Excel 2007 stores the data in a bunch of files, most of them in XML, all crammed together into a zip file. If you want to look at the contents, you can rename your
.xlsxtowhatever.zipand then open it and look at the files inside.Assuming your Excel file just contains raw data, and all you care about is reading it (i.e., you do not need/want to update its contents and get Excel to open it again), reading the data is actually pretty easy. Inside the zip file, you’re looking for the subdirectory
xl\worksheets\, which will contain a number of.xmlfiles, one for each worksheet from Excel (e.g., a default workbook will have three worksheets namedsheet1.xml,sheet2.xmlandsheet3.xml).Inside of those, you’re looking for the
<sheet data>tag. Inside of that, you’ll have<row>tags (one for each row of data), and inside of them<c>tags with an attributer=RCwhereRCis replaced by the normal row/column notation (e.g., “A1”). The<c>tag will have nested<v>tag where you’ll find the value for that cell.I do feel obliged to add a warning though: while reading really simple data can indeed be just this easy, life can get a lot more complex in a hurry if you decide to do much more than reading simple rows/columns of numbers. Trying to do anything even slightly more complex than that can get a lot more complex in a hurry.