iOS:读入XLS [英] iOS: Read in XLS
问题描述
我正在试图弄清楚如何阅读XLS文档的内容,我能够很好地获取字节,但我没有任何线索从这里开始。尝试 [[NSString alloc] initWithBytes:data.bytes length:data.length encoding:NSUTF8StringEncoding]
and [NSString stringWithUTF8String:data.bytes]
两者都没有让我到处(null)。您应该怎么做才能读取XLS文件的内容?
I'm trying to figure out how to read in the contents of an XLS document and I'm able to get the bytes just fine, but I don't have any clue where to go from here. Trying [[NSString alloc] initWithBytes:data.bytes length:data.length encoding:NSUTF8StringEncoding]
and [NSString stringWithUTF8String:data.bytes]
both don't get me anywhere (null). What are you supposed to do to read in the contents of an XLS file?
推荐答案
尝试结合两个答案。
没有先天的能力将Excel数据读入Foundation容器,如NSArray或NSDictionary。但是,您可以将文件(使用Excel)转换为逗号分隔值(CSV)文件,然后使用NSString实例方法-componentsSeparatedByString:解析iPhone上每行的单元格。
"There is no innate ability to read Excel data into a Foundation container, like an NSArray or NSDictionary. You could, however, convert the file (with Excel) to a comma-separated-value (CSV) file and then parse each line's cells on the iPhone using the NSString instance method -componentsSeparatedByString:."
逗号分隔值(CSV)文件以纯文本形式存储表格数据(数字和文本)。纯文本表示文件是一系列字符,没有必须被解释的数据,作为二进制数.CSV文件由任意数量的记录组成,由某种类型的换行符分隔;每个记录由字段组成,由其他字符或字符串分隔,最常见的是文字TAB或逗号。通常,所有记录都有相同的字段序列
"A comma-separated values (CSV) file stores tabular data (numbers and text) in plain-text form. Plain text means that the file is a sequence of characters, with no data that has to be interpreted instead, as binary numbers. A CSV file consists of any number of records, separated by line breaks of some kind; each record consists of fields, separated by some other character or string, most commonly a literal TAB or comma. Usually, all records have an identical sequence of fields"
-
这篇关于iOS:读入XLS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!