无法获取从iPad读取的Excel文件使用QZXLSReader

时间:2014-06-13 09:33:12

标签: ios excel

我正在使用QZXLSReader创建用于通过iPad / iPhone读取excel文件的模块。在执行时,显示的消息显示我的iPad / iPhone没有此文件,因此变为空。如何读取放在项目目录中的excel文件,并添加了复制包文件?

enter image description here

以下是我在xCode的输出日志

2014-06-13 17:20:21.851 marker[4198:60b] conetnt /var/mobile/Applications/D01BD499-C336-4A73-870A-6643B621E28E/marker.app/test_fr.xls
2014-06-13 17:20:21.852 marker[4198:60b] conetnt /var/mobile/Applications/D01BD499-C336-4A73-870A-6643B621E28E/marker.app/test_fr.xls
2014-06-13 17:20:21.855 marker[4198:60b] firstname (null)

以下是我的代码

#import "ExcelViewController.h"
#import <QZXLSReader/QZWorkbook.h>
#import <QZXLSReader/QZWorkSheet.h>
#import <QZXLSReader/QZCell.h>

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"test_fr" ofType:@"xls"];
  //  NSString *filePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"test_fr.xls"];
    NSLog(@"conetnt %@",  filePath);

    NSURL *url = [NSURL URLWithString:filePath];
    NSLog(@"conetnt %@",  url);

    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 ] ;
            NSLog(@"conetnt %@",  nextObject.content);
            [words addObject:            nextObject.content ];
        }
    }
    //   buttonDe.se

    QZWorkSheet *firstWorkSheet = excelReader.workSheets.firstObject;
    [firstWorkSheet open];
    NSLog(@"firstname %@", firstWorkSheet.rows.firstObject);

}

0 个答案:

没有答案