https://github.com/molangwu/ExcelParseForIOS

解析Excel

1、导入ExcelParser文件夹

iOS解析Excel表格内容-LMLPHP

2、设置Link Binary With Libraries

iOS解析Excel表格内容-LMLPHP

3、新建PrefixHeader.pch文件

#import <Availability.h>

#ifndef __IPHONE_4_0
#warning "This project uses features only available in iOS SDK 4.0 and later."
#endif

#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif

iOS解析Excel表格内容-LMLPHP

4、设置Precompile Prefix Header 为true

设置Prefix Header路径

iOS解析Excel表格内容-LMLPHP

5、运用代码:设置代理 实现代理 需要传入表格路径 根据表格格式进行解析 有CSV XLS XLSX三种格式解析

#import "ViewController.h"
#import "ExcelParser/LAWExcelTool.h"

@interface ViewController ()<LAWExcelParserDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

#pragma mark 开始解析
- (IBAction)didClicked:(id)sender {
    NSString *filePath = [[NSBundle mainBundle]pathForResource:@"test" ofType:@"xls"];
    [LAWExcelTool shareInstance].delegate = self;
    [[LAWExcelTool shareInstance] parserExcelWithPath:filePath];

}

- (void)parser:(LAWExcelTool *)parser success:(id)responseObj {
    NSLog(@"%@", responseObj);
}
10-31 13:09