没有回应iPad显示excel细胞数据

时间:2014-06-13 03:48:20

标签: ios excel

我想使用QZXLSReader Framework从Xcode 5.1.1的项目文件夹中读取excel文件。说到执行。它不起作用并显示所需的值。请您告诉我有没有其他选择来读取Excel数据?如何读取项目目录下的excel文件的内容?

enter image description here

以下是我的输出日志消息

2014-06-13 16:25:13.558 marker[4130:60b] conetnt /var/mobile/Applications/D01BD499-C336-4A73-870A-6643B621E28E/marker.app/test_fr.xls
2014-06-13 16:25:13.559 marker[4130:60b] conetnt /var/mobile/Applications/D01BD499-C336-4A73-870A-6643B621E28E/marker.app/test_fr.xls
2014-06-13 16:25:13.560 marker[4130:60b] firstname (null)

以下是我的代码:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"test_fr" ofType:@"xls"];
NSURL *url = [NSURL URLWithString:filePath];
QZWorkbook *excelReader = [[QZWorkbook alloc] initWithContentsOfXLS:url];
NSArray *sheets =excelReader.workSheets;
NSMutableArray *words = [[NSMutableArray alloc] init];

for(int i = 0 ; i < [sheets count] ; i ++){
    QZWorkSheet *sheet = [sheets objectAtIndex:i];
    NSArray *columns = [ sheet columns];
    NSArray *rows =  columns.firstObject;
    for(int  j = 0  ; j < [rows count] ; j ++){
        QZCell *nextObject =  [ rows objectAtIndex:j ] ;
        [words addObject:            nextObject.content ];
NSLog(@"%@", extObject.content);

    }
}

1 个答案:

答案 0 :(得分:-1)

我正在使用这个框架,并没有问题来展示它,

我用过:

NSUrl* url = [NSURL fileURLWithPath:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"NameOfXls.xls"]]; // caminho do xls

QZWorkbook* excelReader = [[QZWorkbook alloc] initWithContentsOfXLS:url]; // pega o workbook
QZWorkSheet* firstWorkSheet = excelReader.workSheets.firstObject; // pega a primeira worksheet daquele workbook
[firstWorkSheet open];

NSLog(@"%@",firstWorkSheet.rows); // to show all rows, is obvious have some nulls values, check the output