├── .gitignore ├── 1.png ├── 2.png ├── 3.png ├── 4.png ├── 5.png ├── 6.png ├── 7.png ├── 8.png ├── ExcelView ├── UIView+YHCategory.h ├── UIView+YHCategory.m ├── YHExcel.h ├── YHExcelTitleView.h ├── YHExcelTitleView.m ├── YHExcelView.h ├── YHExcelView.m ├── YHExcelViewColumn.h ├── YHExcelViewColumn.m ├── YHExcelViewIndexPath.h └── YHExcelViewIndexPath.m ├── ExcelViewDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── apple.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── apple.xcuserdatad │ └── xcschemes │ ├── ExcelViewDemo.xcscheme │ └── xcschememanagement.plist ├── ExcelViewDemo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ └── icon.imageset │ │ ├── Contents.json │ │ └── icon.jpeg ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── ExcelViewDemoTests ├── ExcelViewDemoTests.m └── Info.plist ├── ExcelViewDemoUITests ├── ExcelViewDemoUITests.m └── Info.plist ├── LICENSE ├── README.md └── YHExcelView.podspec /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData 8 | 9 | ## Various settings 10 | *.pbxuser 11 | *.mode1v3 12 | *.mode2v3 13 | *.perspectivev3 14 | xcuserdata 15 | 16 | ## Other 17 | *.xccheckout 18 | *.moved-aside 19 | *.xcuserstate 20 | *.xcscmblueprint 21 | 22 | ## Obj-C/Swift specific 23 | *.hmap 24 | *.ipa 25 | 26 | # CocoaPods 27 | # 28 | # We recommend against adding the Pods directory to your .gitignore. However 29 | # you should judge for yourself, the pros and cons are mentioned at: 30 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 31 | # 32 | #Pods/ 33 | 34 | # Carthage 35 | # 36 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 37 | # Carthage/Checkouts 38 | 39 | Carthage/Build 40 | -------------------------------------------------------------------------------- /1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShenYahui/YHExcelView/bf6cf9e8bba26deb19c9d637c7f2e35083f44991/1.png -------------------------------------------------------------------------------- /2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShenYahui/YHExcelView/bf6cf9e8bba26deb19c9d637c7f2e35083f44991/2.png -------------------------------------------------------------------------------- /3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShenYahui/YHExcelView/bf6cf9e8bba26deb19c9d637c7f2e35083f44991/3.png -------------------------------------------------------------------------------- /4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShenYahui/YHExcelView/bf6cf9e8bba26deb19c9d637c7f2e35083f44991/4.png -------------------------------------------------------------------------------- /5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShenYahui/YHExcelView/bf6cf9e8bba26deb19c9d637c7f2e35083f44991/5.png -------------------------------------------------------------------------------- /6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShenYahui/YHExcelView/bf6cf9e8bba26deb19c9d637c7f2e35083f44991/6.png -------------------------------------------------------------------------------- /7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShenYahui/YHExcelView/bf6cf9e8bba26deb19c9d637c7f2e35083f44991/7.png -------------------------------------------------------------------------------- /8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShenYahui/YHExcelView/bf6cf9e8bba26deb19c9d637c7f2e35083f44991/8.png -------------------------------------------------------------------------------- /ExcelView/UIView+YHCategory.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+YHCategory.h 3 | // 4 | // Created by Yahui on 16/3/4. 5 | // Copyright © 2016年 Yahui. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | 11 | @interface UIView (YHCategory) 12 | 13 | @property (nonatomic,assign) CGPoint yh_origin; 14 | @property (nonatomic,assign) CGSize yh_size; 15 | @property (nonatomic,assign) CGFloat yh_width; 16 | @property (nonatomic,assign) CGFloat yh_height; 17 | @property (nonatomic,assign) CGFloat yh_y; 18 | @property (nonatomic,assign) CGFloat yh_x; 19 | @property (nonatomic, assign) CGFloat yh_centerX; 20 | @property (nonatomic, assign) CGFloat yh_centerY; 21 | 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /ExcelView/UIView+YHCategory.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+YHCategory.m 3 | // 4 | // Created by Yahui on 16/3/4. 5 | // Copyright © 2016年 Yahui. All rights reserved. 6 | // 7 | #import "UIView+YHCategory.h" 8 | 9 | @implementation UIView (YBFCategory) 10 | 11 | #pragma mark - origin 坐标点 12 | -(CGPoint)yh_origin 13 | { 14 | return self.frame.origin; 15 | } 16 | 17 | -(void)setYh_origin:(CGPoint)origin 18 | { 19 | CGRect frame = self.frame; 20 | frame.origin = origin; 21 | self.frame = frame; 22 | } 23 | 24 | #pragma mark - size 大小 25 | -(CGSize)yh_size 26 | { 27 | return self.frame.size; 28 | } 29 | 30 | -(void)setYh_size:(CGSize)size 31 | { 32 | CGRect frame = self.frame; 33 | frame.size = size; 34 | self.frame = frame; 35 | } 36 | 37 | #pragma mark - width 宽度 38 | -(CGFloat)yh_width 39 | { 40 | return self.yh_size.width; 41 | } 42 | 43 | -(void)setYh_width:(CGFloat)width 44 | { 45 | CGSize size = self.yh_size; 46 | size.width = width; 47 | self.yh_size = size; 48 | } 49 | 50 | #pragma mark - height 高度 51 | -(CGFloat)yh_height 52 | { 53 | return self.yh_size.height; 54 | } 55 | 56 | -(void)setYh_height:(CGFloat)height 57 | { 58 | CGSize size = self.yh_size; 59 | size.height = height; 60 | self.yh_size = size; 61 | } 62 | 63 | #pragma mark - x 横坐标 64 | -(CGFloat)yh_x 65 | { 66 | return self.yh_origin.x; 67 | } 68 | 69 | -(void)setYh_x:(CGFloat)x 70 | { 71 | CGPoint origin = self.yh_origin; 72 | origin.x = x; 73 | self.yh_origin = origin; 74 | } 75 | 76 | #pragma mark - y 纵坐标 77 | -(CGFloat)yh_y 78 | { 79 | return self.yh_origin.y; 80 | } 81 | 82 | -(void)setYh_y:(CGFloat)y 83 | { 84 | CGPoint origin = self.yh_origin; 85 | origin.y = y; 86 | self.yh_origin = origin; 87 | } 88 | 89 | - (void)setYh_centerX:(CGFloat)centerX 90 | { 91 | CGPoint center = self.center; 92 | center.x = centerX; 93 | self.center = center; 94 | } 95 | 96 | - (CGFloat)yh_centerX 97 | { 98 | return self.center.x; 99 | } 100 | 101 | - (void)setYh_centerY:(CGFloat)centerY 102 | { 103 | CGPoint center = self.center; 104 | center.y = centerY; 105 | self.center = center; 106 | } 107 | 108 | - (CGFloat)yh_centerY 109 | { 110 | return self.center.y; 111 | } 112 | 113 | 114 | @end -------------------------------------------------------------------------------- /ExcelView/YHExcel.h: -------------------------------------------------------------------------------- 1 | 2 | #import "YHExcelView.h" 3 | #import "YHExcelTitleView.h" 4 | #import "YHExcelViewIndexPath.h" 5 | #import "YHExcelViewColumn.h" 6 | -------------------------------------------------------------------------------- /ExcelView/YHExcelTitleView.h: -------------------------------------------------------------------------------- 1 | // 2 | // YHExcelTitleView.h 3 | // 4 | // Created by Yahui on 16/3/4. 5 | // Copyright © 2016年 Yahui. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @class YHExcelTitleView; 11 | 12 | @protocol YHExcelTitleViewDataSource 13 | //必须 14 | @required 15 | //列数 16 | - (NSInteger)excelTitleViewItemCount:(YHExcelTitleView *)titleView; 17 | //标题文字 18 | - (NSString *)excelTitleView:(YHExcelTitleView *)titleView titleNameAtIndex:(NSInteger)index; 19 | 20 | //可选 21 | @optional 22 | //列宽,默认按照列数等分 23 | - (CGFloat)excelTitleView:(YHExcelTitleView *)titleView widthForItemAtIndex:(NSInteger)index; 24 | //标题字体 25 | - (UIFont *)excelTitleView:(YHExcelTitleView *)titleView titleFontAtIndex:(NSInteger)index; 26 | //标题颜色 27 | - (UIColor *)excelTitleView:(YHExcelTitleView *)titleView titleColorAtIndex:(NSInteger)index; 28 | //对齐方式 29 | - (NSTextAlignment)excelTitleView:(YHExcelTitleView *)titleView titleAlignmentAtIndex:(NSInteger)index; 30 | 31 | @end 32 | 33 | @interface YHExcelTitleView : UIScrollView 34 | 35 | @property (weak,nonatomic)id dataSource; 36 | @property (strong,nonatomic)UIFont *titleFont;//default [UIFont systemFontOfSize:13] 37 | @property (strong,nonatomic)UIColor *titleColor;//default #333333 38 | @property (assign,nonatomic)NSTextAlignment titleAlignment;//default NSTextAlignmentCenter 39 | 40 | - (void)reload; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /ExcelView/YHExcelTitleView.m: -------------------------------------------------------------------------------- 1 | // 2 | // YBFIndexListTitleView.m 3 | // 4 | // Created by Yahui on 16/3/4. 5 | // Copyright © 2016年 Yahui. All rights reserved. 6 | // 7 | 8 | #import "YHExcelTitleView.h" 9 | #import "UIView+YHCategory.h" 10 | 11 | 12 | @interface YHExcelTitleView() 13 | @property (nonatomic, assign)NSInteger itemCount; 14 | @end 15 | 16 | @implementation YHExcelTitleView 17 | 18 | #pragma mark - init 19 | - (void)awakeFromNib { 20 | [self setupSubView]; 21 | } 22 | 23 | - (instancetype)initWithFrame:(CGRect)frame { 24 | if (self = [super initWithFrame:frame]) { 25 | [self setupSubView]; 26 | } 27 | return self; 28 | } 29 | 30 | #pragma mark - setter 31 | - (void)setupSubView { 32 | self.showsHorizontalScrollIndicator = NO; 33 | self.showsVerticalScrollIndicator = NO; 34 | self.titleFont = [UIFont systemFontOfSize:13]; 35 | self.titleColor = [UIColor grayColor]; 36 | self.titleAlignment = NSTextAlignmentCenter; 37 | } 38 | 39 | - (void)setDataSource:(id)dataSource { 40 | _dataSource = dataSource; 41 | [self reload]; 42 | } 43 | 44 | - (void)setTitleColor:(UIColor *)titleColor { 45 | _titleColor = titleColor; 46 | if (self.dataSource != nil) { 47 | [self reload]; 48 | } 49 | } 50 | 51 | - (void)setTitleFont:(UIFont *)titleFont { 52 | _titleFont = titleFont; 53 | if (self.dataSource != nil) { 54 | [self reload]; 55 | } 56 | } 57 | 58 | - (void)setTitleAlignment:(NSTextAlignment)titleAlignment { 59 | _titleAlignment = titleAlignment; 60 | if (self.dataSource != nil) { 61 | [self reload]; 62 | } 63 | } 64 | 65 | 66 | #pragma mark - layoutSubview 67 | - (void)reload { 68 | [self.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 69 | [obj removeFromSuperview]; 70 | }]; 71 | if (_dataSource != nil) { 72 | _itemCount = [_dataSource excelTitleViewItemCount:self]; 73 | for (NSInteger i = 0 ; i < _itemCount ; i++) { 74 | [self createItemWithIndex:i]; 75 | } 76 | }else{ 77 | NSLog(@"错误dataSource为空"); 78 | } 79 | [self setNeedsLayout]; 80 | } 81 | 82 | - (void)createItemWithIndex:(NSInteger)index { 83 | UILabel *label = [UILabel new]; 84 | label.tag = index; 85 | NSString *title = [_dataSource excelTitleView:self titleNameAtIndex:index]; 86 | label.text = title; 87 | if (_dataSource != nil && [_dataSource respondsToSelector:@selector(excelTitleView:titleFontAtIndex:)]) { 88 | label.font = [_dataSource excelTitleView:self titleFontAtIndex:index]; 89 | }else{ 90 | label.font = self.titleFont; 91 | } 92 | if (_dataSource != nil && [_dataSource respondsToSelector:@selector(excelTitleView:titleColorAtIndex:)]) { 93 | label.textColor = [_dataSource excelTitleView:self titleColorAtIndex:index]; 94 | }else{ 95 | label.textColor = self.titleColor; 96 | } 97 | if (_dataSource != nil && [_dataSource respondsToSelector:@selector(excelTitleView:titleAlignmentAtIndex:)]) { 98 | label.textAlignment = [_dataSource excelTitleView:self titleAlignmentAtIndex:index]; 99 | }else{ 100 | label.textAlignment = self.titleAlignment; 101 | } 102 | [self addSubview:label]; 103 | } 104 | 105 | - (void)layoutSubviews { 106 | [super layoutSubviews]; 107 | BOOL isCustomItemWidth = NO ; 108 | if (_dataSource != nil && [_dataSource respondsToSelector:@selector(excelTitleView:widthForItemAtIndex:)]) { 109 | isCustomItemWidth = YES ; 110 | } 111 | CGFloat defaultWidth = self.yh_width / _itemCount; 112 | for (NSInteger i = 0 ; i < self.subviews.count ; i++) { 113 | UILabel *label = self.subviews[i]; 114 | if (![label isKindOfClass:[UILabel class]]) { 115 | continue; 116 | } 117 | NSInteger index = label.tag; 118 | label.yh_height = self.yh_height; 119 | if (isCustomItemWidth){ 120 | label.yh_width = [_dataSource excelTitleView:self widthForItemAtIndex:index]; 121 | CGFloat x = 0; 122 | for (NSInteger j = 0 ; j < index; j ++) { 123 | x += [_dataSource excelTitleView:self widthForItemAtIndex:j]; 124 | } 125 | label.yh_x = x; 126 | }else{ 127 | label.yh_width = defaultWidth; 128 | label.yh_x = index * defaultWidth; 129 | } 130 | } 131 | 132 | } 133 | 134 | 135 | 136 | @end 137 | -------------------------------------------------------------------------------- /ExcelView/YHExcelView.h: -------------------------------------------------------------------------------- 1 | // 2 | // YHExcelView.h 3 | // 4 | // Created by Yahui on 16/3/4. 5 | // Copyright © 2016年 Yahui. All rights reserved. 6 | // 7 | 8 | #import 9 | #import "YHExcelViewIndexPath.h" 10 | #import "YHExcelViewColumn.h" 11 | 12 | @class YHExcelView; 13 | @protocol YHExcelViewDataSource 14 | 15 | @required 16 | //行数 17 | - (NSInteger)excelView:(YHExcelView *)excelView numberOfRowsInSection:(NSInteger)section; 18 | //某行的列数量 19 | - (NSInteger)excelView:(YHExcelView *)excelView columnCountAtIndexPath:(NSIndexPath *)indexPath; 20 | //colView 21 | - (YHExcelViewColumn *)excelView:(YHExcelView *)excelView columnForRowAtIndexPath:(YHExcelViewIndexPath *)indexPath; 22 | @optional 23 | //组数 24 | - (NSInteger)numberOfSectionsInExcelView:(YHExcelView *)excelView; 25 | //列宽,默认按照列数等分 26 | - (CGFloat)excelView:(YHExcelView *)excelView widthForColumnAtIndex:(YHExcelViewIndexPath *)indexPath; 27 | 28 | @end 29 | 30 | @interface YHExcelView : UIView 31 | 32 | @property (nonatomic, weak) id dataSource; 33 | //不要设置tableView的dataSource,YHExcelViewDataSource继承自UITableViewDataSource 34 | @property (nonatomic, readonly, strong) UIScrollView *scrollView; 35 | @property (nonatomic, readonly, strong) UITableView *tableView; 36 | @property (nonatomic, assign) BOOL showBorder;//default YES 37 | @property (nonatomic, strong) UIColor *borderColor;//default #eeeeee 38 | @property (nonatomic, assign) CGFloat borderWidth;//default 1.0 39 | @property (nonatomic, assign) CGRect tableViewFrame;//如果需要横向滚动,则需要设置 40 | 41 | - (YHExcelViewColumn *)dequeueReusableColumnWithIdentifier:(NSString *)identifier; 42 | - (void)reload; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /ExcelView/YHExcelView.m: -------------------------------------------------------------------------------- 1 | // 2 | // YHExcelView.m 3 | // 4 | // Created by Yahui on 16/3/4. 5 | // Copyright © 2016年 Yahui. All rights reserved. 6 | // 7 | 8 | #import "YHExcelView.h" 9 | #import "UIView+YHCategory.h" 10 | 11 | @interface YHExcelViewCell : UITableViewCell 12 | 13 | - (void)setupViewWithexcelView:(YHExcelView *)excelView indexPath:(NSIndexPath *)indexPath colViewPool:(NSMutableArray *) colViewPool; 14 | 15 | @end 16 | 17 | @interface YHExcelViewCell() 18 | @property (nonatomic,weak)YHExcelView *excelView; 19 | @property (nonatomic,weak)NSIndexPath *indexPath; 20 | @end 21 | 22 | @implementation YHExcelViewCell 23 | 24 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { 25 | if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { 26 | [self setup]; 27 | } 28 | return self; 29 | } 30 | 31 | - (void)setup { 32 | } 33 | 34 | - (void)setupViewWithexcelView:(YHExcelView *)excelView indexPath:(NSIndexPath *)indexPath colViewPool:(NSMutableArray *)colViewPool{ 35 | if (self.excelView == nil ) { 36 | self.excelView = excelView; 37 | } 38 | _indexPath = indexPath; 39 | [self.contentView.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 40 | if ([obj isKindOfClass:[YHExcelViewColumn class]]) { 41 | [colViewPool addObject:obj]; 42 | [obj removeFromSuperview]; 43 | } 44 | }]; 45 | NSInteger columnCount = [excelView.dataSource excelView:excelView columnCountAtIndexPath:indexPath]; 46 | for (NSInteger i = 0 ; i < columnCount ; i ++) { 47 | YHExcelViewColumn *column = [excelView.dataSource excelView:excelView columnForRowAtIndexPath:[YHExcelViewIndexPath indexPathForCol:i atIndexPath:indexPath]]; 48 | column.index = i ; 49 | 50 | [self.contentView addSubview:column]; 51 | } 52 | 53 | [self setNeedsLayout]; 54 | } 55 | 56 | 57 | - (void)layoutSubviews { 58 | [super layoutSubviews]; 59 | NSInteger columnCount = [self.excelView.dataSource excelView:self.excelView columnCountAtIndexPath:self.indexPath]; 60 | NSMutableArray *colViewArray = [NSMutableArray array]; 61 | for (YHExcelViewColumn *colView in self.contentView.subviews) { 62 | if ([colView isKindOfClass:[YHExcelViewColumn class]]) { 63 | if (colView.index < columnCount) { 64 | colView.hidden = NO; 65 | [colViewArray addObject:colView]; 66 | }else { 67 | colView.hidden = YES; 68 | } 69 | 70 | } 71 | } 72 | NSArray *sortColArray = [colViewArray sortedArrayUsingComparator:^NSComparisonResult(YHExcelViewColumn *obj1, YHExcelViewColumn *obj2) { 73 | return [[NSNumber numberWithInteger:obj1.index] compare:[NSNumber numberWithInteger:obj2.index]]; 74 | }]; 75 | 76 | BOOL isCustomColWidth = NO ; 77 | if (self.excelView && [self.excelView.dataSource respondsToSelector:@selector(excelView:widthForColumnAtIndex:)]){ 78 | isCustomColWidth = YES; 79 | } 80 | 81 | if (self.excelView.showBorder) { 82 | 83 | } 84 | 85 | CGFloat borderW = self.excelView.borderWidth ; 86 | if (!self.excelView.showBorder) { 87 | borderW = 0; 88 | } 89 | 90 | YHExcelViewColumn *tmpColView = nil ; 91 | for (YHExcelViewColumn *col in sortColArray) { 92 | col.yh_y = borderW; 93 | col.yh_height = self.yh_height - borderW; 94 | if (!isCustomColWidth) { 95 | col.yh_width = (self.yh_width / columnCount) - borderW - (borderW / columnCount); 96 | }else{ 97 | col.yh_width = [self.excelView.dataSource excelView:self.excelView widthForColumnAtIndex:[YHExcelViewIndexPath indexPathForCol:col.index atIndexPath:self.indexPath]] - borderW - (borderW / columnCount); 98 | } 99 | if (tmpColView == nil) { 100 | col.yh_x = borderW; 101 | }else { 102 | col.yh_x = CGRectGetMaxX(tmpColView.frame) + borderW; 103 | } 104 | tmpColView = col; 105 | 106 | }; 107 | 108 | 109 | } 110 | 111 | @end 112 | 113 | @interface YHExcelView() 114 | @property (nonatomic,strong)NSMutableArray *colViewPool; 115 | @property (nonatomic,strong)UIView *bottomBorder; 116 | @end 117 | 118 | @implementation YHExcelView 119 | 120 | #pragma mark - init 121 | - (instancetype)initWithFrame:(CGRect)frame { 122 | if (self = [super initWithFrame:frame]) { 123 | [self setup]; 124 | } 125 | return self; 126 | } 127 | 128 | - (void)awakeFromNib { 129 | // Initialization code 130 | [self setup]; 131 | } 132 | 133 | - (void)setup { 134 | _showBorder = YES; 135 | _borderColor = [UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1]; 136 | _borderWidth = 1.0; 137 | _bottomBorder = [UIView new]; 138 | } 139 | 140 | - (void)setShowBorder:(BOOL)showBorder { 141 | _showBorder = showBorder; 142 | _bottomBorder.hidden = !showBorder; 143 | [self reload]; 144 | } 145 | 146 | - (void)setBorderColor:(UIColor *)borderColor { 147 | _borderColor = borderColor; 148 | [self reload]; 149 | } 150 | 151 | - (void)setBorderWidth:(CGFloat)borderWidth { 152 | _borderWidth = borderWidth ; 153 | [self reload]; 154 | } 155 | 156 | - (void)setTableViewFrame:(CGRect)tableViewFrame { 157 | _tableViewFrame = tableViewFrame; 158 | [self reload]; 159 | } 160 | 161 | - (void)setDataSource:(id)dataSource { 162 | [self.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 163 | [obj removeFromSuperview]; 164 | }]; 165 | _scrollView = [[UIScrollView alloc] init]; 166 | _scrollView.showsHorizontalScrollIndicator = NO; 167 | _scrollView.showsVerticalScrollIndicator = NO; 168 | [self addSubview:_scrollView]; 169 | _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; 170 | [self.scrollView addSubview:_tableView]; 171 | [self.tableView addSubview:_bottomBorder]; 172 | _dataSource = dataSource; 173 | [self.tableView registerClass:[YHExcelViewCell class] forCellReuseIdentifier:@"YHExcelViewCell"]; 174 | self.tableView.dataSource = self; 175 | self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone ; 176 | } 177 | 178 | #pragma mark - UITableViewDataSource 179 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 180 | return [self.dataSource excelView:self numberOfRowsInSection:section]; 181 | } 182 | 183 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 184 | YHExcelViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YHExcelViewCell"]; 185 | if (self.showBorder) { 186 | cell.contentView.backgroundColor = self.borderColor; 187 | }else{ 188 | cell.contentView.backgroundColor = nil; 189 | } 190 | 191 | [cell setupViewWithexcelView:self indexPath:indexPath colViewPool:self.colViewPool]; 192 | return cell; 193 | } 194 | 195 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 196 | if ([self.dataSource respondsToSelector:@selector(numberOfSectionsInExcelView:)]) { 197 | return [self.dataSource numberOfSectionsInExcelView:self]; 198 | }else { 199 | return 1; 200 | } 201 | } 202 | 203 | 204 | #pragma mark - public 205 | - (YHExcelViewColumn *)dequeueReusableColumnWithIdentifier:(NSString *)identifier { 206 | YHExcelViewColumn *colView = nil; 207 | for (YHExcelViewColumn *tmpView in self.colViewPool) { 208 | if ([tmpView.reuseIdentifier isEqualToString:identifier]) { 209 | colView = tmpView; 210 | break; 211 | } 212 | } 213 | if (colView != nil) { 214 | [self.colViewPool removeObject:colView]; 215 | } 216 | return colView; 217 | } 218 | - (void)reload { 219 | if (self.tableView != nil) { 220 | [self.tableView reloadData]; 221 | [self setNeedsLayout]; 222 | } 223 | } 224 | 225 | #pragma mark - layoutSubviews 226 | - (void)layoutSubviews { 227 | [super layoutSubviews]; 228 | _scrollView.frame = self.bounds; 229 | _scrollView.contentSize = CGSizeMake(self.tableView.yh_width, self.yh_height); 230 | if (_tableViewFrame.size.width == 0) { 231 | _tableView.frame = self.bounds; 232 | }else{ 233 | _tableView.frame = _tableViewFrame; 234 | } 235 | _bottomBorder.yh_x = 0 ; 236 | _bottomBorder.yh_y = self.tableView.contentSize.height ; 237 | _bottomBorder.yh_width = self.tableView.yh_width; 238 | _bottomBorder.yh_height = _borderWidth ; 239 | _bottomBorder.backgroundColor = _borderColor; 240 | [self.tableView bringSubviewToFront:_bottomBorder]; 241 | } 242 | 243 | #pragma mark - getter 244 | - (NSMutableArray *)colViewPool { 245 | if (_colViewPool == nil) { 246 | _colViewPool = [NSMutableArray array]; 247 | } 248 | return _colViewPool; 249 | } 250 | 251 | @end 252 | -------------------------------------------------------------------------------- /ExcelView/YHExcelViewColumn.h: -------------------------------------------------------------------------------- 1 | // 2 | // YHExcelViewColumn.h 3 | // 4 | // Created by Yahui on 16/3/4. 5 | // Copyright © 2016年 Yahui. All rights reserved. 6 | // column 7 | 8 | #import 9 | 10 | @interface YHExcelViewColumn : UIView 11 | 12 | - (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier; 13 | @property (nonatomic, readonly, strong) UILabel *textLabel; 14 | @property (nonatomic, readonly, strong) UIView *contentView; 15 | @property (nonatomic, readonly, copy) NSString *reuseIdentifier; 16 | @property (nonatomic, assign)NSInteger index; 17 | @end 18 | -------------------------------------------------------------------------------- /ExcelView/YHExcelViewColumn.m: -------------------------------------------------------------------------------- 1 | // 2 | // YHExcelViewColumn.m 3 | // 4 | // Created by Yahui on 16/3/4. 5 | // Copyright © 2016年 Yahui. All rights reserved. 6 | // column 7 | 8 | #import "YHExcelViewColumn.h" 9 | #import "UIView+YHCategory.h" 10 | 11 | @interface YHExcelViewColumn() 12 | 13 | @end 14 | 15 | @implementation YHExcelViewColumn 16 | 17 | - (instancetype)initWithFrame:(CGRect)frame { 18 | return [self initWithReuseIdentifier:@"default"]; 19 | } 20 | 21 | - (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier { 22 | if (self = [super initWithFrame:CGRectZero]) { 23 | _reuseIdentifier = [reuseIdentifier copy]; 24 | [self setup]; 25 | } 26 | return self; 27 | } 28 | 29 | - (void)setup { 30 | self.backgroundColor = [UIColor whiteColor]; 31 | _textLabel = [UILabel new]; 32 | _textLabel.textAlignment = NSTextAlignmentCenter; 33 | [self addSubview:_textLabel]; 34 | _contentView = [UIView new]; 35 | [self addSubview:_contentView]; 36 | } 37 | 38 | - (void)layoutSubviews { 39 | [super layoutSubviews]; 40 | _textLabel.frame = self.bounds; 41 | _contentView.frame = self.bounds; 42 | } 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /ExcelView/YHExcelViewIndexPath.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBFPeportViewIndexPath.h 3 | // 4 | // Created by Yahui on 16/3/4. 5 | // Copyright © 2016年 Yahui. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | 11 | @interface YHExcelViewIndexPath : NSObject 12 | 13 | + (instancetype)indexPathForCol:(NSInteger)col inRow:(NSInteger)row inSection:(NSInteger)section; 14 | 15 | + (instancetype)indexPathForCol:(NSInteger)col atIndexPath:(NSIndexPath *)indexPath; 16 | 17 | 18 | @property (nonatomic, readonly ,assign) NSInteger section; 19 | @property (nonatomic, readonly ,assign) NSInteger row; 20 | @property (nonatomic, readonly ,assign) NSInteger col; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /ExcelView/YHExcelViewIndexPath.m: -------------------------------------------------------------------------------- 1 | // 2 | // YBFPeportViewIndexPath.m 3 | // 4 | // Created by Yahui on 16/3/4. 5 | // Copyright © 2016年 Yahui. All rights reserved. 6 | // 7 | 8 | #import "YHExcelViewIndexPath.h" 9 | 10 | @implementation YHExcelViewIndexPath 11 | 12 | - (instancetype)initWithCol:(NSInteger)col inRow:(NSInteger)row inSection:(NSInteger)section { 13 | if (self = [super init]) { 14 | _col = col; 15 | _row = row; 16 | _section = section; 17 | } 18 | return self; 19 | } 20 | 21 | 22 | + (instancetype)indexPathForCol:(NSInteger)col inRow:(NSInteger)row inSection:(NSInteger)section { 23 | YHExcelViewIndexPath *indexpath = [[YHExcelViewIndexPath alloc] initWithCol:col inRow:row inSection:section]; 24 | return indexpath; 25 | } 26 | 27 | + (instancetype)indexPathForCol:(NSInteger)col atIndexPath:(NSIndexPath *)indexPath { 28 | YHExcelViewIndexPath *indexpath = [[YHExcelViewIndexPath alloc] initWithCol:col inRow:indexPath.row inSection:indexPath.section]; 29 | return indexpath; 30 | } 31 | 32 | - (NSString *)description { 33 | return [NSString stringWithFormat:@"%@-%@-%@",@(self.section),@(self.row),@(self.col)]; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /ExcelViewDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 180563F11C8914DD00066034 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 180563F01C8914DD00066034 /* main.m */; }; 11 | 180563F41C8914DD00066034 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 180563F31C8914DD00066034 /* AppDelegate.m */; }; 12 | 180563F71C8914DD00066034 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 180563F61C8914DD00066034 /* ViewController.m */; }; 13 | 180563FA1C8914DD00066034 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 180563F81C8914DD00066034 /* Main.storyboard */; }; 14 | 180563FC1C8914DD00066034 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 180563FB1C8914DD00066034 /* Assets.xcassets */; }; 15 | 180563FF1C8914DD00066034 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 180563FD1C8914DD00066034 /* LaunchScreen.storyboard */; }; 16 | 1805640A1C8914DD00066034 /* ExcelViewDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 180564091C8914DD00066034 /* ExcelViewDemoTests.m */; }; 17 | 180564151C8914DD00066034 /* ExcelViewDemoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 180564141C8914DD00066034 /* ExcelViewDemoUITests.m */; }; 18 | 1805642F1C89151400066034 /* UIView+YHCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 180564241C89151400066034 /* UIView+YHCategory.m */; }; 19 | 180564301C89151400066034 /* YHExcelViewIndexPath.m in Sources */ = {isa = PBXBuildFile; fileRef = 180564261C89151400066034 /* YHExcelViewIndexPath.m */; }; 20 | 180564311C89151400066034 /* YHExcelTitleView.m in Sources */ = {isa = PBXBuildFile; fileRef = 180564281C89151400066034 /* YHExcelTitleView.m */; }; 21 | 180564321C89151400066034 /* YHExcelView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1805642A1C89151400066034 /* YHExcelView.m */; }; 22 | 180564341C89151400066034 /* YHExcelViewColumn.m in Sources */ = {isa = PBXBuildFile; fileRef = 1805642E1C89151400066034 /* YHExcelViewColumn.m */; }; 23 | /* End PBXBuildFile section */ 24 | 25 | /* Begin PBXContainerItemProxy section */ 26 | 180564061C8914DD00066034 /* PBXContainerItemProxy */ = { 27 | isa = PBXContainerItemProxy; 28 | containerPortal = 180563E41C8914DD00066034 /* Project object */; 29 | proxyType = 1; 30 | remoteGlobalIDString = 180563EB1C8914DD00066034; 31 | remoteInfo = ExcelViewDemo; 32 | }; 33 | 180564111C8914DD00066034 /* PBXContainerItemProxy */ = { 34 | isa = PBXContainerItemProxy; 35 | containerPortal = 180563E41C8914DD00066034 /* Project object */; 36 | proxyType = 1; 37 | remoteGlobalIDString = 180563EB1C8914DD00066034; 38 | remoteInfo = ExcelViewDemo; 39 | }; 40 | /* End PBXContainerItemProxy section */ 41 | 42 | /* Begin PBXFileReference section */ 43 | 180563EC1C8914DD00066034 /* ExcelViewDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ExcelViewDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | 180563F01C8914DD00066034 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 45 | 180563F21C8914DD00066034 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 46 | 180563F31C8914DD00066034 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 47 | 180563F51C8914DD00066034 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 48 | 180563F61C8914DD00066034 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 49 | 180563F91C8914DD00066034 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 50 | 180563FB1C8914DD00066034 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 51 | 180563FE1C8914DD00066034 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 52 | 180564001C8914DD00066034 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 53 | 180564051C8914DD00066034 /* ExcelViewDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ExcelViewDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | 180564091C8914DD00066034 /* ExcelViewDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ExcelViewDemoTests.m; sourceTree = ""; }; 55 | 1805640B1C8914DD00066034 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | 180564101C8914DD00066034 /* ExcelViewDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ExcelViewDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 57 | 180564141C8914DD00066034 /* ExcelViewDemoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ExcelViewDemoUITests.m; sourceTree = ""; }; 58 | 180564161C8914DD00066034 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 59 | 180564231C89151400066034 /* UIView+YHCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+YHCategory.h"; sourceTree = ""; }; 60 | 180564241C89151400066034 /* UIView+YHCategory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+YHCategory.m"; sourceTree = ""; }; 61 | 180564251C89151400066034 /* YHExcelViewIndexPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YHExcelViewIndexPath.h; sourceTree = ""; }; 62 | 180564261C89151400066034 /* YHExcelViewIndexPath.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YHExcelViewIndexPath.m; sourceTree = ""; }; 63 | 180564271C89151400066034 /* YHExcelTitleView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YHExcelTitleView.h; sourceTree = ""; }; 64 | 180564281C89151400066034 /* YHExcelTitleView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YHExcelTitleView.m; sourceTree = ""; }; 65 | 180564291C89151400066034 /* YHExcelView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YHExcelView.h; sourceTree = ""; }; 66 | 1805642A1C89151400066034 /* YHExcelView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YHExcelView.m; sourceTree = ""; }; 67 | 1805642D1C89151400066034 /* YHExcelViewColumn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YHExcelViewColumn.h; sourceTree = ""; }; 68 | 1805642E1C89151400066034 /* YHExcelViewColumn.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YHExcelViewColumn.m; sourceTree = ""; }; 69 | 180564351C89191100066034 /* YHExcel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YHExcel.h; sourceTree = ""; }; 70 | /* End PBXFileReference section */ 71 | 72 | /* Begin PBXFrameworksBuildPhase section */ 73 | 180563E91C8914DD00066034 /* Frameworks */ = { 74 | isa = PBXFrameworksBuildPhase; 75 | buildActionMask = 2147483647; 76 | files = ( 77 | ); 78 | runOnlyForDeploymentPostprocessing = 0; 79 | }; 80 | 180564021C8914DD00066034 /* Frameworks */ = { 81 | isa = PBXFrameworksBuildPhase; 82 | buildActionMask = 2147483647; 83 | files = ( 84 | ); 85 | runOnlyForDeploymentPostprocessing = 0; 86 | }; 87 | 1805640D1C8914DD00066034 /* Frameworks */ = { 88 | isa = PBXFrameworksBuildPhase; 89 | buildActionMask = 2147483647; 90 | files = ( 91 | ); 92 | runOnlyForDeploymentPostprocessing = 0; 93 | }; 94 | /* End PBXFrameworksBuildPhase section */ 95 | 96 | /* Begin PBXGroup section */ 97 | 180563E31C8914DD00066034 = { 98 | isa = PBXGroup; 99 | children = ( 100 | 180563EE1C8914DD00066034 /* ExcelViewDemo */, 101 | 180564081C8914DD00066034 /* ExcelViewDemoTests */, 102 | 180564131C8914DD00066034 /* ExcelViewDemoUITests */, 103 | 180563ED1C8914DD00066034 /* Products */, 104 | ); 105 | sourceTree = ""; 106 | }; 107 | 180563ED1C8914DD00066034 /* Products */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | 180563EC1C8914DD00066034 /* ExcelViewDemo.app */, 111 | 180564051C8914DD00066034 /* ExcelViewDemoTests.xctest */, 112 | 180564101C8914DD00066034 /* ExcelViewDemoUITests.xctest */, 113 | ); 114 | name = Products; 115 | sourceTree = ""; 116 | }; 117 | 180563EE1C8914DD00066034 /* ExcelViewDemo */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | 180564221C89151400066034 /* ExcelView */, 121 | 180563F21C8914DD00066034 /* AppDelegate.h */, 122 | 180563F31C8914DD00066034 /* AppDelegate.m */, 123 | 180563F51C8914DD00066034 /* ViewController.h */, 124 | 180563F61C8914DD00066034 /* ViewController.m */, 125 | 180563F81C8914DD00066034 /* Main.storyboard */, 126 | 180563FB1C8914DD00066034 /* Assets.xcassets */, 127 | 180563FD1C8914DD00066034 /* LaunchScreen.storyboard */, 128 | 180564001C8914DD00066034 /* Info.plist */, 129 | 180563EF1C8914DD00066034 /* Supporting Files */, 130 | ); 131 | path = ExcelViewDemo; 132 | sourceTree = ""; 133 | }; 134 | 180563EF1C8914DD00066034 /* Supporting Files */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | 180563F01C8914DD00066034 /* main.m */, 138 | ); 139 | name = "Supporting Files"; 140 | sourceTree = ""; 141 | }; 142 | 180564081C8914DD00066034 /* ExcelViewDemoTests */ = { 143 | isa = PBXGroup; 144 | children = ( 145 | 180564091C8914DD00066034 /* ExcelViewDemoTests.m */, 146 | 1805640B1C8914DD00066034 /* Info.plist */, 147 | ); 148 | path = ExcelViewDemoTests; 149 | sourceTree = ""; 150 | }; 151 | 180564131C8914DD00066034 /* ExcelViewDemoUITests */ = { 152 | isa = PBXGroup; 153 | children = ( 154 | 180564141C8914DD00066034 /* ExcelViewDemoUITests.m */, 155 | 180564161C8914DD00066034 /* Info.plist */, 156 | ); 157 | path = ExcelViewDemoUITests; 158 | sourceTree = ""; 159 | }; 160 | 180564221C89151400066034 /* ExcelView */ = { 161 | isa = PBXGroup; 162 | children = ( 163 | 180564231C89151400066034 /* UIView+YHCategory.h */, 164 | 180564241C89151400066034 /* UIView+YHCategory.m */, 165 | 180564251C89151400066034 /* YHExcelViewIndexPath.h */, 166 | 180564261C89151400066034 /* YHExcelViewIndexPath.m */, 167 | 180564271C89151400066034 /* YHExcelTitleView.h */, 168 | 180564281C89151400066034 /* YHExcelTitleView.m */, 169 | 180564291C89151400066034 /* YHExcelView.h */, 170 | 1805642A1C89151400066034 /* YHExcelView.m */, 171 | 1805642D1C89151400066034 /* YHExcelViewColumn.h */, 172 | 1805642E1C89151400066034 /* YHExcelViewColumn.m */, 173 | 180564351C89191100066034 /* YHExcel.h */, 174 | ); 175 | path = ExcelView; 176 | sourceTree = SOURCE_ROOT; 177 | }; 178 | /* End PBXGroup section */ 179 | 180 | /* Begin PBXNativeTarget section */ 181 | 180563EB1C8914DD00066034 /* ExcelViewDemo */ = { 182 | isa = PBXNativeTarget; 183 | buildConfigurationList = 180564191C8914DD00066034 /* Build configuration list for PBXNativeTarget "ExcelViewDemo" */; 184 | buildPhases = ( 185 | 180563E81C8914DD00066034 /* Sources */, 186 | 180563E91C8914DD00066034 /* Frameworks */, 187 | 180563EA1C8914DD00066034 /* Resources */, 188 | ); 189 | buildRules = ( 190 | ); 191 | dependencies = ( 192 | ); 193 | name = ExcelViewDemo; 194 | productName = ExcelViewDemo; 195 | productReference = 180563EC1C8914DD00066034 /* ExcelViewDemo.app */; 196 | productType = "com.apple.product-type.application"; 197 | }; 198 | 180564041C8914DD00066034 /* ExcelViewDemoTests */ = { 199 | isa = PBXNativeTarget; 200 | buildConfigurationList = 1805641C1C8914DD00066034 /* Build configuration list for PBXNativeTarget "ExcelViewDemoTests" */; 201 | buildPhases = ( 202 | 180564011C8914DD00066034 /* Sources */, 203 | 180564021C8914DD00066034 /* Frameworks */, 204 | 180564031C8914DD00066034 /* Resources */, 205 | ); 206 | buildRules = ( 207 | ); 208 | dependencies = ( 209 | 180564071C8914DD00066034 /* PBXTargetDependency */, 210 | ); 211 | name = ExcelViewDemoTests; 212 | productName = ExcelViewDemoTests; 213 | productReference = 180564051C8914DD00066034 /* ExcelViewDemoTests.xctest */; 214 | productType = "com.apple.product-type.bundle.unit-test"; 215 | }; 216 | 1805640F1C8914DD00066034 /* ExcelViewDemoUITests */ = { 217 | isa = PBXNativeTarget; 218 | buildConfigurationList = 1805641F1C8914DD00066034 /* Build configuration list for PBXNativeTarget "ExcelViewDemoUITests" */; 219 | buildPhases = ( 220 | 1805640C1C8914DD00066034 /* Sources */, 221 | 1805640D1C8914DD00066034 /* Frameworks */, 222 | 1805640E1C8914DD00066034 /* Resources */, 223 | ); 224 | buildRules = ( 225 | ); 226 | dependencies = ( 227 | 180564121C8914DD00066034 /* PBXTargetDependency */, 228 | ); 229 | name = ExcelViewDemoUITests; 230 | productName = ExcelViewDemoUITests; 231 | productReference = 180564101C8914DD00066034 /* ExcelViewDemoUITests.xctest */; 232 | productType = "com.apple.product-type.bundle.ui-testing"; 233 | }; 234 | /* End PBXNativeTarget section */ 235 | 236 | /* Begin PBXProject section */ 237 | 180563E41C8914DD00066034 /* Project object */ = { 238 | isa = PBXProject; 239 | attributes = { 240 | LastUpgradeCheck = 0720; 241 | ORGANIZATIONNAME = Yahui; 242 | TargetAttributes = { 243 | 180563EB1C8914DD00066034 = { 244 | CreatedOnToolsVersion = 7.2.1; 245 | }; 246 | 180564041C8914DD00066034 = { 247 | CreatedOnToolsVersion = 7.2.1; 248 | TestTargetID = 180563EB1C8914DD00066034; 249 | }; 250 | 1805640F1C8914DD00066034 = { 251 | CreatedOnToolsVersion = 7.2.1; 252 | TestTargetID = 180563EB1C8914DD00066034; 253 | }; 254 | }; 255 | }; 256 | buildConfigurationList = 180563E71C8914DD00066034 /* Build configuration list for PBXProject "ExcelViewDemo" */; 257 | compatibilityVersion = "Xcode 3.2"; 258 | developmentRegion = English; 259 | hasScannedForEncodings = 0; 260 | knownRegions = ( 261 | en, 262 | Base, 263 | ); 264 | mainGroup = 180563E31C8914DD00066034; 265 | productRefGroup = 180563ED1C8914DD00066034 /* Products */; 266 | projectDirPath = ""; 267 | projectRoot = ""; 268 | targets = ( 269 | 180563EB1C8914DD00066034 /* ExcelViewDemo */, 270 | 180564041C8914DD00066034 /* ExcelViewDemoTests */, 271 | 1805640F1C8914DD00066034 /* ExcelViewDemoUITests */, 272 | ); 273 | }; 274 | /* End PBXProject section */ 275 | 276 | /* Begin PBXResourcesBuildPhase section */ 277 | 180563EA1C8914DD00066034 /* Resources */ = { 278 | isa = PBXResourcesBuildPhase; 279 | buildActionMask = 2147483647; 280 | files = ( 281 | 180563FF1C8914DD00066034 /* LaunchScreen.storyboard in Resources */, 282 | 180563FC1C8914DD00066034 /* Assets.xcassets in Resources */, 283 | 180563FA1C8914DD00066034 /* Main.storyboard in Resources */, 284 | ); 285 | runOnlyForDeploymentPostprocessing = 0; 286 | }; 287 | 180564031C8914DD00066034 /* Resources */ = { 288 | isa = PBXResourcesBuildPhase; 289 | buildActionMask = 2147483647; 290 | files = ( 291 | ); 292 | runOnlyForDeploymentPostprocessing = 0; 293 | }; 294 | 1805640E1C8914DD00066034 /* Resources */ = { 295 | isa = PBXResourcesBuildPhase; 296 | buildActionMask = 2147483647; 297 | files = ( 298 | ); 299 | runOnlyForDeploymentPostprocessing = 0; 300 | }; 301 | /* End PBXResourcesBuildPhase section */ 302 | 303 | /* Begin PBXSourcesBuildPhase section */ 304 | 180563E81C8914DD00066034 /* Sources */ = { 305 | isa = PBXSourcesBuildPhase; 306 | buildActionMask = 2147483647; 307 | files = ( 308 | 180564321C89151400066034 /* YHExcelView.m in Sources */, 309 | 180563F71C8914DD00066034 /* ViewController.m in Sources */, 310 | 180564311C89151400066034 /* YHExcelTitleView.m in Sources */, 311 | 180563F41C8914DD00066034 /* AppDelegate.m in Sources */, 312 | 180564301C89151400066034 /* YHExcelViewIndexPath.m in Sources */, 313 | 1805642F1C89151400066034 /* UIView+YHCategory.m in Sources */, 314 | 180563F11C8914DD00066034 /* main.m in Sources */, 315 | 180564341C89151400066034 /* YHExcelViewColumn.m in Sources */, 316 | ); 317 | runOnlyForDeploymentPostprocessing = 0; 318 | }; 319 | 180564011C8914DD00066034 /* Sources */ = { 320 | isa = PBXSourcesBuildPhase; 321 | buildActionMask = 2147483647; 322 | files = ( 323 | 1805640A1C8914DD00066034 /* ExcelViewDemoTests.m in Sources */, 324 | ); 325 | runOnlyForDeploymentPostprocessing = 0; 326 | }; 327 | 1805640C1C8914DD00066034 /* Sources */ = { 328 | isa = PBXSourcesBuildPhase; 329 | buildActionMask = 2147483647; 330 | files = ( 331 | 180564151C8914DD00066034 /* ExcelViewDemoUITests.m in Sources */, 332 | ); 333 | runOnlyForDeploymentPostprocessing = 0; 334 | }; 335 | /* End PBXSourcesBuildPhase section */ 336 | 337 | /* Begin PBXTargetDependency section */ 338 | 180564071C8914DD00066034 /* PBXTargetDependency */ = { 339 | isa = PBXTargetDependency; 340 | target = 180563EB1C8914DD00066034 /* ExcelViewDemo */; 341 | targetProxy = 180564061C8914DD00066034 /* PBXContainerItemProxy */; 342 | }; 343 | 180564121C8914DD00066034 /* PBXTargetDependency */ = { 344 | isa = PBXTargetDependency; 345 | target = 180563EB1C8914DD00066034 /* ExcelViewDemo */; 346 | targetProxy = 180564111C8914DD00066034 /* PBXContainerItemProxy */; 347 | }; 348 | /* End PBXTargetDependency section */ 349 | 350 | /* Begin PBXVariantGroup section */ 351 | 180563F81C8914DD00066034 /* Main.storyboard */ = { 352 | isa = PBXVariantGroup; 353 | children = ( 354 | 180563F91C8914DD00066034 /* Base */, 355 | ); 356 | name = Main.storyboard; 357 | sourceTree = ""; 358 | }; 359 | 180563FD1C8914DD00066034 /* LaunchScreen.storyboard */ = { 360 | isa = PBXVariantGroup; 361 | children = ( 362 | 180563FE1C8914DD00066034 /* Base */, 363 | ); 364 | name = LaunchScreen.storyboard; 365 | sourceTree = ""; 366 | }; 367 | /* End PBXVariantGroup section */ 368 | 369 | /* Begin XCBuildConfiguration section */ 370 | 180564171C8914DD00066034 /* Debug */ = { 371 | isa = XCBuildConfiguration; 372 | buildSettings = { 373 | ALWAYS_SEARCH_USER_PATHS = NO; 374 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 375 | CLANG_CXX_LIBRARY = "libc++"; 376 | CLANG_ENABLE_MODULES = YES; 377 | CLANG_ENABLE_OBJC_ARC = YES; 378 | CLANG_WARN_BOOL_CONVERSION = YES; 379 | CLANG_WARN_CONSTANT_CONVERSION = YES; 380 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 381 | CLANG_WARN_EMPTY_BODY = YES; 382 | CLANG_WARN_ENUM_CONVERSION = YES; 383 | CLANG_WARN_INT_CONVERSION = YES; 384 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 385 | CLANG_WARN_UNREACHABLE_CODE = YES; 386 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 387 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 388 | COPY_PHASE_STRIP = NO; 389 | DEBUG_INFORMATION_FORMAT = dwarf; 390 | ENABLE_STRICT_OBJC_MSGSEND = YES; 391 | ENABLE_TESTABILITY = YES; 392 | GCC_C_LANGUAGE_STANDARD = gnu99; 393 | GCC_DYNAMIC_NO_PIC = NO; 394 | GCC_NO_COMMON_BLOCKS = YES; 395 | GCC_OPTIMIZATION_LEVEL = 0; 396 | GCC_PREPROCESSOR_DEFINITIONS = ( 397 | "DEBUG=1", 398 | "$(inherited)", 399 | ); 400 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 401 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 402 | GCC_WARN_UNDECLARED_SELECTOR = YES; 403 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 404 | GCC_WARN_UNUSED_FUNCTION = YES; 405 | GCC_WARN_UNUSED_VARIABLE = YES; 406 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 407 | MTL_ENABLE_DEBUG_INFO = YES; 408 | ONLY_ACTIVE_ARCH = YES; 409 | SDKROOT = iphoneos; 410 | }; 411 | name = Debug; 412 | }; 413 | 180564181C8914DD00066034 /* Release */ = { 414 | isa = XCBuildConfiguration; 415 | buildSettings = { 416 | ALWAYS_SEARCH_USER_PATHS = NO; 417 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 418 | CLANG_CXX_LIBRARY = "libc++"; 419 | CLANG_ENABLE_MODULES = YES; 420 | CLANG_ENABLE_OBJC_ARC = YES; 421 | CLANG_WARN_BOOL_CONVERSION = YES; 422 | CLANG_WARN_CONSTANT_CONVERSION = YES; 423 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 424 | CLANG_WARN_EMPTY_BODY = YES; 425 | CLANG_WARN_ENUM_CONVERSION = YES; 426 | CLANG_WARN_INT_CONVERSION = YES; 427 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 428 | CLANG_WARN_UNREACHABLE_CODE = YES; 429 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 430 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 431 | COPY_PHASE_STRIP = NO; 432 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 433 | ENABLE_NS_ASSERTIONS = NO; 434 | ENABLE_STRICT_OBJC_MSGSEND = YES; 435 | GCC_C_LANGUAGE_STANDARD = gnu99; 436 | GCC_NO_COMMON_BLOCKS = YES; 437 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 438 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 439 | GCC_WARN_UNDECLARED_SELECTOR = YES; 440 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 441 | GCC_WARN_UNUSED_FUNCTION = YES; 442 | GCC_WARN_UNUSED_VARIABLE = YES; 443 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 444 | MTL_ENABLE_DEBUG_INFO = NO; 445 | SDKROOT = iphoneos; 446 | VALIDATE_PRODUCT = YES; 447 | }; 448 | name = Release; 449 | }; 450 | 1805641A1C8914DD00066034 /* Debug */ = { 451 | isa = XCBuildConfiguration; 452 | buildSettings = { 453 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 454 | INFOPLIST_FILE = ExcelViewDemo/Info.plist; 455 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 456 | PRODUCT_BUNDLE_IDENTIFIER = com.yahui.ExcelViewDemo; 457 | PRODUCT_NAME = "$(TARGET_NAME)"; 458 | }; 459 | name = Debug; 460 | }; 461 | 1805641B1C8914DD00066034 /* Release */ = { 462 | isa = XCBuildConfiguration; 463 | buildSettings = { 464 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 465 | INFOPLIST_FILE = ExcelViewDemo/Info.plist; 466 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 467 | PRODUCT_BUNDLE_IDENTIFIER = com.yahui.ExcelViewDemo; 468 | PRODUCT_NAME = "$(TARGET_NAME)"; 469 | }; 470 | name = Release; 471 | }; 472 | 1805641D1C8914DD00066034 /* Debug */ = { 473 | isa = XCBuildConfiguration; 474 | buildSettings = { 475 | BUNDLE_LOADER = "$(TEST_HOST)"; 476 | INFOPLIST_FILE = ExcelViewDemoTests/Info.plist; 477 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 478 | PRODUCT_BUNDLE_IDENTIFIER = com.yahui.ExcelViewDemoTests; 479 | PRODUCT_NAME = "$(TARGET_NAME)"; 480 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ExcelViewDemo.app/ExcelViewDemo"; 481 | }; 482 | name = Debug; 483 | }; 484 | 1805641E1C8914DD00066034 /* Release */ = { 485 | isa = XCBuildConfiguration; 486 | buildSettings = { 487 | BUNDLE_LOADER = "$(TEST_HOST)"; 488 | INFOPLIST_FILE = ExcelViewDemoTests/Info.plist; 489 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 490 | PRODUCT_BUNDLE_IDENTIFIER = com.yahui.ExcelViewDemoTests; 491 | PRODUCT_NAME = "$(TARGET_NAME)"; 492 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ExcelViewDemo.app/ExcelViewDemo"; 493 | }; 494 | name = Release; 495 | }; 496 | 180564201C8914DD00066034 /* Debug */ = { 497 | isa = XCBuildConfiguration; 498 | buildSettings = { 499 | INFOPLIST_FILE = ExcelViewDemoUITests/Info.plist; 500 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 501 | PRODUCT_BUNDLE_IDENTIFIER = com.yahui.ExcelViewDemoUITests; 502 | PRODUCT_NAME = "$(TARGET_NAME)"; 503 | TEST_TARGET_NAME = ExcelViewDemo; 504 | USES_XCTRUNNER = YES; 505 | }; 506 | name = Debug; 507 | }; 508 | 180564211C8914DD00066034 /* Release */ = { 509 | isa = XCBuildConfiguration; 510 | buildSettings = { 511 | INFOPLIST_FILE = ExcelViewDemoUITests/Info.plist; 512 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 513 | PRODUCT_BUNDLE_IDENTIFIER = com.yahui.ExcelViewDemoUITests; 514 | PRODUCT_NAME = "$(TARGET_NAME)"; 515 | TEST_TARGET_NAME = ExcelViewDemo; 516 | USES_XCTRUNNER = YES; 517 | }; 518 | name = Release; 519 | }; 520 | /* End XCBuildConfiguration section */ 521 | 522 | /* Begin XCConfigurationList section */ 523 | 180563E71C8914DD00066034 /* Build configuration list for PBXProject "ExcelViewDemo" */ = { 524 | isa = XCConfigurationList; 525 | buildConfigurations = ( 526 | 180564171C8914DD00066034 /* Debug */, 527 | 180564181C8914DD00066034 /* Release */, 528 | ); 529 | defaultConfigurationIsVisible = 0; 530 | defaultConfigurationName = Release; 531 | }; 532 | 180564191C8914DD00066034 /* Build configuration list for PBXNativeTarget "ExcelViewDemo" */ = { 533 | isa = XCConfigurationList; 534 | buildConfigurations = ( 535 | 1805641A1C8914DD00066034 /* Debug */, 536 | 1805641B1C8914DD00066034 /* Release */, 537 | ); 538 | defaultConfigurationIsVisible = 0; 539 | }; 540 | 1805641C1C8914DD00066034 /* Build configuration list for PBXNativeTarget "ExcelViewDemoTests" */ = { 541 | isa = XCConfigurationList; 542 | buildConfigurations = ( 543 | 1805641D1C8914DD00066034 /* Debug */, 544 | 1805641E1C8914DD00066034 /* Release */, 545 | ); 546 | defaultConfigurationIsVisible = 0; 547 | }; 548 | 1805641F1C8914DD00066034 /* Build configuration list for PBXNativeTarget "ExcelViewDemoUITests" */ = { 549 | isa = XCConfigurationList; 550 | buildConfigurations = ( 551 | 180564201C8914DD00066034 /* Debug */, 552 | 180564211C8914DD00066034 /* Release */, 553 | ); 554 | defaultConfigurationIsVisible = 0; 555 | }; 556 | /* End XCConfigurationList section */ 557 | }; 558 | rootObject = 180563E41C8914DD00066034 /* Project object */; 559 | } 560 | -------------------------------------------------------------------------------- /ExcelViewDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ExcelViewDemo.xcodeproj/project.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShenYahui/YHExcelView/bf6cf9e8bba26deb19c9d637c7f2e35083f44991/ExcelViewDemo.xcodeproj/project.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ExcelViewDemo.xcodeproj/xcuserdata/apple.xcuserdatad/xcschemes/ExcelViewDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /ExcelViewDemo.xcodeproj/xcuserdata/apple.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ExcelViewDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 180563EB1C8914DD00066034 16 | 17 | primary 18 | 19 | 20 | 180564041C8914DD00066034 21 | 22 | primary 23 | 24 | 25 | 1805640F1C8914DD00066034 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /ExcelViewDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ExcelViewDemo 4 | // 5 | // Created by Yahui on 16/3/4. 6 | // Copyright © 2016年 Yahui. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /ExcelViewDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ExcelViewDemo 4 | // 5 | // Created by Yahui on 16/3/4. 6 | // Copyright © 2016年 Yahui. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /ExcelViewDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /ExcelViewDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ExcelViewDemo/Assets.xcassets/icon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "icon.jpeg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ExcelViewDemo/Assets.xcassets/icon.imageset/icon.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShenYahui/YHExcelView/bf6cf9e8bba26deb19c9d637c7f2e35083f44991/ExcelViewDemo/Assets.xcassets/icon.imageset/icon.jpeg -------------------------------------------------------------------------------- /ExcelViewDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ExcelViewDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /ExcelViewDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /ExcelViewDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // ExcelViewDemo 4 | // 5 | // Created by Yahui on 16/3/4. 6 | // Copyright © 2016年 Yahui. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /ExcelViewDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // ExcelViewDemo 4 | // 5 | // Created by Yahui on 16/3/4. 6 | // Copyright © 2016年 Yahui. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "YHExcel.h" 11 | #import "UIView+YHCategory.h" 12 | 13 | @interface ViewController () 14 | 15 | @property (weak, nonatomic) IBOutlet YHExcelTitleView *titleView;//表头 16 | @property (weak, nonatomic) IBOutlet YHExcelView *excelView;//表内容 17 | @property (strong, nonatomic) NSArray *titleArray; 18 | @property (strong, nonatomic) NSArray *colWidthArray; 19 | 20 | @end 21 | 22 | @implementation ViewController 23 | 24 | - (void)viewDidLoad { 25 | [super viewDidLoad]; 26 | self.excelView.showBorder = YES; 27 | self.excelView.borderWidth = 1; 28 | // self.excelView.borderColor = [UIColor blueColor]; 29 | self.titleArray = @[@"一",@"二",@"三",@"四",@"五",@"六",@"七",@"八",@"九",@"一",@"二",@"三",@"四",@"五",@"六",@"七",@"八",@"九"]; 30 | self.colWidthArray = @[@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(40.0),@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(40.0)]; 31 | self.excelView.tableViewFrame = CGRectMake(0, 0, 750, self.excelView.yh_height);//设置可横向滚动 32 | self.titleView.contentSize = CGSizeMake(750, 0); 33 | // self.titleArray = @[@"一",@"二",@"三",@"四",@"五",@"六",@"七",@"八",@"九"]; 34 | // self.colWidthArray = @[@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(40.0)]; 35 | self.titleView.dataSource = self; 36 | self.excelView.dataSource = self; 37 | self.excelView.backgroundColor = [UIColor whiteColor]; 38 | 39 | //表头 与 表内容 同时滚动 40 | [self.titleView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew |NSKeyValueObservingOptionOld context:nil]; 41 | [self.excelView.scrollView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil]; 42 | } 43 | #pragma mark - YHExcelTitleViewDataSource 44 | - (NSInteger)excelTitleViewItemCount:(YHExcelTitleView *)titleView { 45 | return self.titleArray.count; 46 | } 47 | 48 | - (NSString *)excelTitleView:(YHExcelTitleView *)titleView titleNameAtIndex:(NSInteger)index { 49 | return self.titleArray[index]; 50 | } 51 | 52 | - (CGFloat)excelTitleView:(YHExcelTitleView *)titleView widthForItemAtIndex:(NSInteger)index 53 | { 54 | return [self.colWidthArray[index] doubleValue] * ([UIScreen mainScreen].bounds.size.width/320); 55 | } 56 | 57 | #pragma mark - YHExcelViewDataSource 58 | - (NSInteger)excelView:(YHExcelView *)excelView columnCountAtIndexPath:(NSIndexPath *)indexPath { 59 | return self.titleArray.count; 60 | // return ((indexPath.row) % 9 ) + 1; 61 | } 62 | 63 | - (CGFloat)excelView:(YHExcelView *)excelView widthForColumnAtIndex:(YHExcelViewIndexPath *)indexPath { 64 | return [self.colWidthArray[indexPath.col] doubleValue] * ([UIScreen mainScreen].bounds.size.width/320); 65 | } 66 | 67 | - (YHExcelViewColumn *)excelView:(YHExcelView *)excelView columnForRowAtIndexPath:(YHExcelViewIndexPath *)indexPath { 68 | YHExcelViewColumn *col = [excelView dequeueReusableColumnWithIdentifier:@"col"]; 69 | if (col == nil) { 70 | col = [[YHExcelViewColumn alloc] initWithReuseIdentifier:@"col"]; 71 | col.textLabel.font = [UIFont systemFontOfSize:10]; 72 | } 73 | NSString *text = [NSString stringWithFormat:@"%@行%@列",@(indexPath.row),@(indexPath.col)]; 74 | col.textLabel.text = text; 75 | return col; 76 | } 77 | 78 | - (NSInteger)numberOfSectionsInExcelView:(YHExcelView *)excelView { 79 | return 1; 80 | } 81 | 82 | - (NSInteger)excelView:(YHExcelView *)excelView numberOfRowsInSection:(NSInteger)section { 83 | return 20; 84 | } 85 | 86 | #pragma mark - kvo 87 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 88 | CGPoint old = [change[@"old"] CGPointValue]; 89 | CGPoint new = [change[@"new"] CGPointValue]; 90 | if (old.x == new.x) { 91 | return; 92 | } 93 | if (object == self.titleView) { 94 | self.excelView.scrollView.contentOffset = CGPointMake(new.x, 0); 95 | }else if(object == self.excelView.scrollView){ 96 | self.titleView.contentOffset = CGPointMake(new.x, 0); 97 | } 98 | } 99 | 100 | - (void)dealloc { 101 | [self.titleView removeObserver:self forKeyPath:@"contentOffset"]; 102 | [self.excelView.scrollView removeObserver:self forKeyPath:@"contentOffset"]; 103 | } 104 | 105 | @end 106 | -------------------------------------------------------------------------------- /ExcelViewDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ExcelViewDemo 4 | // 5 | // Created by Yahui on 16/3/4. 6 | // Copyright © 2016年 Yahui. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ExcelViewDemoTests/ExcelViewDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ExcelViewDemoTests.m 3 | // ExcelViewDemoTests 4 | // 5 | // Created by Yahui on 16/3/4. 6 | // Copyright © 2016年 Yahui. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ExcelViewDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation ExcelViewDemoTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /ExcelViewDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /ExcelViewDemoUITests/ExcelViewDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ExcelViewDemoUITests.m 3 | // ExcelViewDemoUITests 4 | // 5 | // Created by Yahui on 16/3/4. 6 | // Copyright © 2016年 Yahui. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ExcelViewDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation ExcelViewDemoUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /ExcelViewDemoUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2015 YHExcelView (https://github.com/ShenYahui/YHExcelView) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # YHExcelView 2 | ##类似于excel的View 3 | ![](https://github.com/ShenYahui/YHExcelView/blob/master/1.png) 4 | ![](https://github.com/ShenYahui/YHExcelView/blob/master/2.png) 5 | ![](https://github.com/ShenYahui/YHExcelView/blob/master/3.png) 6 | ![](https://github.com/ShenYahui/YHExcelView/blob/master/4.png) 7 | ![](https://github.com/ShenYahui/YHExcelView/blob/master/5.png) 8 | ![](https://github.com/ShenYahui/YHExcelView/blob/master/6.png) 9 | ![image](https://github.com/ShenYahui/YHExcelView/blob/master/8.png) 10 | #使用方法 11 | ##CocoaPods 12 | ```objc 13 | pod 'YHExcelView' 14 | #import 15 | ``` 16 | #demo 17 | ##使用tableView类似,初始化YHExcelView 并设置dataSource 18 | ```objc 19 | #import "ViewController.h" 20 | #import "YHExcel.h" 21 | #import "UIView+YHCategory.h" 22 | 23 | @interface ViewController () 24 | 25 | @property (weak, nonatomic) IBOutlet YHExcelTitleView *titleView;//表头 26 | @property (weak, nonatomic) IBOutlet YHExcelView *excelView;//表内容 27 | @property (strong, nonatomic) NSArray *titleArray; 28 | @property (strong, nonatomic) NSArray *colWidthArray; 29 | 30 | @end 31 | 32 | @implementation ViewController 33 | 34 | - (void)viewDidLoad { 35 | [super viewDidLoad]; 36 | self.excelView.showBorder = YES; 37 | self.excelView.borderWidth = 1; 38 | // self.excelView.borderColor = [UIColor blueColor]; 39 | self.titleArray = @[@"一",@"二",@"三",@"四",@"五",@"六",@"七",@"八",@"九",@"一",@"二",@"三",@"四",@"五",@"六",@"七",@"八",@"九"]; 40 | self.colWidthArray = @[@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(40.0),@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(40.0)]; 41 | self.excelView.tableViewFrame = CGRectMake(0, 0, 750, self.excelView.yh_height);//设置可横向滚动 42 | self.titleView.contentSize = CGSizeMake(750, 0); 43 | // self.titleArray = @[@"一",@"二",@"三",@"四",@"五",@"六",@"七",@"八",@"九"]; 44 | // self.colWidthArray = @[@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(35.0),@(40.0)]; 45 | self.titleView.dataSource = self; 46 | self.excelView.dataSource = self; 47 | self.excelView.backgroundColor = [UIColor whiteColor]; 48 | 49 | //表头 与 表内容 同时滚动 50 | [self.titleView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew |NSKeyValueObservingOptionOld context:nil]; 51 | [self.excelView.scrollView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil]; 52 | } 53 | #pragma mark - YHExcelTitleViewDataSource 54 | - (NSInteger)excelTitleViewItemCount:(YHExcelTitleView *)titleView { 55 | return self.titleArray.count; 56 | } 57 | 58 | - (NSString *)excelTitleView:(YHExcelTitleView *)titleView titleNameAtIndex:(NSInteger)index { 59 | return self.titleArray[index]; 60 | } 61 | 62 | - (CGFloat)excelTitleView:(YHExcelTitleView *)titleView widthForItemAtIndex:(NSInteger)index 63 | { 64 | return [self.colWidthArray[index] doubleValue] * ([UIScreen mainScreen].bounds.size.width/320); 65 | } 66 | 67 | #pragma mark - YHExcelViewDataSource 68 | - (NSInteger)excelView:(YHExcelView *)excelView columnCountAtIndexPath:(NSIndexPath *)indexPath { 69 | return self.titleArray.count; 70 | // return ((indexPath.row) % 9 ) + 1; 71 | } 72 | 73 | - (CGFloat)excelView:(YHExcelView *)excelView widthForColumnAtIndex:(YHExcelViewIndexPath *)indexPath { 74 | return [self.colWidthArray[indexPath.col] doubleValue] * ([UIScreen mainScreen].bounds.size.width/320); 75 | } 76 | 77 | - (YHExcelViewColumn *)excelView:(YHExcelView *)excelView columnForRowAtIndexPath:(YHExcelViewIndexPath *)indexPath { 78 | YHExcelViewColumn *col = [excelView dequeueReusableColumnWithIdentifier:@"col"]; 79 | if (col == nil) { 80 | col = [[YHExcelViewColumn alloc] initWithReuseIdentifier:@"col"]; 81 | col.textLabel.font = [UIFont systemFontOfSize:10]; 82 | } 83 | NSString *text = [NSString stringWithFormat:@"%@行%@列",@(indexPath.row),@(indexPath.col)]; 84 | col.textLabel.text = text; 85 | return col; 86 | } 87 | 88 | - (NSInteger)numberOfSectionsInExcelView:(YHExcelView *)excelView { 89 | return 1; 90 | } 91 | 92 | - (NSInteger)excelView:(YHExcelView *)excelView numberOfRowsInSection:(NSInteger)section { 93 | return 20; 94 | } 95 | 96 | #pragma mark - kvo 97 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 98 | CGPoint old = [change[@"old"] CGPointValue]; 99 | CGPoint new = [change[@"new"] CGPointValue]; 100 | if (old.x == new.x) { 101 | return; 102 | } 103 | if (object == self.titleView) { 104 | self.excelView.scrollView.contentOffset = CGPointMake(new.x, 0); 105 | }else if(object == self.excelView.scrollView){ 106 | self.titleView.contentOffset = CGPointMake(new.x, 0); 107 | } 108 | } 109 | 110 | - (void)dealloc { 111 | [self.titleView removeObserver:self forKeyPath:@"contentOffset"]; 112 | [self.excelView.scrollView removeObserver:self forKeyPath:@"contentOffset"]; 113 | } 114 | 115 | @end 116 | ``` 117 | -------------------------------------------------------------------------------- /YHExcelView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'YHExcelView' 3 | s.version = '0.11' 4 | s.summary = 'iOS Similar to excel the rows and columns of tableview 类似于excel多行多列的tableview OC ExcelView GridView' 5 | s.homepage = 'https://github.com/ShenYahui/YHExcelView' 6 | s.license = 'MIT' 7 | s.authors = {'JohnShen' => '472325216@qq.com'} 8 | s.platform = :ios, '6.0' 9 | s.source = {:git => 'https://github.com/ShenYahui/YHExcelView.git', :tag => s.version} 10 | s.source_files = 'ExcelView/**/*.{h,m}' 11 | s.requires_arc = true 12 | end --------------------------------------------------------------------------------