forked from andreac/RSSheet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRSworkSheetRow.m
159 lines (119 loc) · 3.9 KB
/
RSworkSheetRow.m
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
//
// workSheetRow.m
// excelWriterExample
//
// Created by andrea cappellotto on 14/09/11.
// Copyright 2011 Università degli studi di Trento. All rights reserved.
//
#import "RSworkSheetRow.h"
@implementation RSworkSheetRow
@synthesize style, height, cellArray;
- (id)init
{
self = [super init];
if (self) {
// Initialization code here.
}
return self;
}
- (id)initWithHeight:(NSInteger)heightRow
{
self = [super init];
if (self) {
height = heightRow;
style = [[RSStyle alloc] init];
style.font = [UIFont systemFontOfSize:14];
style.size = 14;
style.color = [UIColor blackColor];
style.alignmentH = RSStyleMiddleAlign;
style.alignmentV = RSStyleCenterAlign;
cellArray = [[NSMutableArray alloc] init];
}
return self;
}
- (id) initWithHeight:(NSInteger)heightRow andStyle:(RSStyle *)styleRow
{
self = [super init];
if (self) {
style = styleRow;
height = heightRow;
cellArray = [[NSMutableArray alloc] init];
}
return self;
}
- (void)addCellString:(NSString *)contentRow
{
RSStyle * styleDefault = [[RSStyle alloc] init];
styleDefault.font = [UIFont systemFontOfSize:14];
styleDefault.size = 14;
styleDefault.color = [UIColor blackColor];
styleDefault.alignmentH = RSStyleMiddleAlign;
styleDefault.alignmentV = RSStyleCenterAlign;
RSCell * newCell = [[RSCell alloc] init];
newCell.content = contentRow;
newCell.type = cellTypeString;
newCell.style = styleDefault;
[cellArray addObject:newCell];
}
- (void)addCellString:(NSString *)contentRow withStyle:(RSStyle *)styleRow
{
RSCell * newCell = [[RSCell alloc] init];
newCell.content = contentRow;
newCell.type = cellTypeString;
newCell.style = styleRow;
[cellArray addObject:newCell];
}
- (void)addCellNumber:(float)contentRow
{
RSStyle * styleDefault = [[RSStyle alloc] init];
styleDefault.font = [UIFont systemFontOfSize:14];
styleDefault.size = 14;
styleDefault.color = [UIColor blackColor];
styleDefault.alignmentH = RSStyleMiddleAlign;
styleDefault.alignmentV = RSStyleCenterAlign;
RSCell * newCell = [[RSCell alloc] init];
newCell.content = [NSString stringWithFormat:@"%.2f", contentRow];
newCell.type = cellTypeNumber;
newCell.style = styleDefault;
[cellArray addObject:newCell];
}
- (void)addCellNumber:(float)contentRow withStyle:(RSStyle *)styleRow
{
RSCell * newCell = [[RSCell alloc] init];
newCell.content = [NSString stringWithFormat:@"%.2f", contentRow];
newCell.type = cellTypeNumber;
newCell.style = styleRow;
[cellArray addObject:newCell];
}
- (void)addCellData:(NSDate *)contentRow
{
NSDateFormatter *format = [[NSDateFormatter alloc] init];
[format setDateFormat:@"yyyy-MM-ddTHH:mm:ss"];
NSString *dateString = [format stringFromDate:contentRow];
RSStyle * styleDefault = [[RSStyle alloc] init];
styleDefault.font = [UIFont systemFontOfSize:14];
styleDefault.size = 14;
styleDefault.color = [UIColor blackColor];
styleDefault.alignmentH = RSStyleMiddleAlign;
styleDefault.alignmentV = RSStyleCenterAlign;
RSCell * newCell = [[RSCell alloc] init];
newCell.content = dateString;
newCell.type = cellTypeDate;
newCell.style = styleDefault;
[cellArray addObject:newCell];
}
- (void)addCellData:(NSDate *)contentRow withStyle:(RSStyle *)styleRow
{
NSDateFormatter *format = [[NSDateFormatter alloc] init];
[format setDateFormat:@"yyyy-MM-ddTHH:mm:ss"];
NSString *dateString = [format stringFromDate:contentRow];
RSCell * newCell = [[RSCell alloc] init];
newCell.content = dateString;
newCell.type = cellTypeDate;
newCell.style = styleRow;
[cellArray addObject:newCell];
}
-(void)dealloc
{
}
@end