本文介绍了从用C excel文件阅读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从C中的Excel 2007文件一个Excel文件中读取包含约6000行2列。我想存储在C的2-D数组的内容,如果存在一个C库或任何其他方法,那么请让我知道。

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.

推荐答案

Excel 2007中保存在一堆文件中的数据,XML中的大多数人,都挤在一起成一个zip文件。如果你想看看内容,您可以重命名你的的.xlsx whatever.zip ,然后打开它,看看里面的文件。

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 .xlsx to whatever.zip and then open it and look at the files inside.

假设你的Excel文件只包含原始数据,以及所有你关心的是阅读它(即你的的需要/想更新其内容,并得到Excel中再次打开它),阅读数据实际上是pretty容易。里面的zip文件,你正在寻找的子目录 XL \\工作表\\ ,其中将包含许多的.xml 文件,一个用于从Excel(例如,默认工作簿将有一个名为三个工作表 sheet1.xml sheet2.xml sheet3.xml )。

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 .xml files, one for each worksheet from Excel (e.g., a default workbook will have three worksheets named sheet1.xml, sheet2.xml and sheet3.xml).

里面的那些,你要寻找的<表数据> 标记。里面的话,你就会有<排> 标签(一个用于每行数据),并把它们放在 c为C> 与属性标记 R = RC ,其中 RC 是由正常的行/列符号代替(例如,A1)。在 c为C> 标记将嵌套< V> 标记在那里你会找到的价值该小区

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 attribute r=RC where RC is 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.

这篇关于从用C excel文件阅读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 18:56