rubyXL-git-ref-6002046 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +20 -0
- data/Gemfile.lock +63 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +197 -0
- data/Rakefile +58 -0
- data/VERSION +1 -0
- data/lib/rubyXL.rb +21 -0
- data/lib/rubyXL/cell.rb +325 -0
- data/lib/rubyXL/generic_storage.rb +40 -0
- data/lib/rubyXL/objects/border.rb +53 -0
- data/lib/rubyXL/objects/cell_style.rb +73 -0
- data/lib/rubyXL/objects/color.rb +23 -0
- data/lib/rubyXL/objects/column_range.rb +88 -0
- data/lib/rubyXL/objects/data_validation.rb +31 -0
- data/lib/rubyXL/objects/defined_name.rb +27 -0
- data/lib/rubyXL/objects/fill.rb +42 -0
- data/lib/rubyXL/objects/font.rb +109 -0
- data/lib/rubyXL/objects/formula.rb +8 -0
- data/lib/rubyXL/objects/ooxml_object.rb +177 -0
- data/lib/rubyXL/objects/reference.rb +98 -0
- data/lib/rubyXL/objects/sheet_view.rb +62 -0
- data/lib/rubyXL/objects/worksheet.rb +11 -0
- data/lib/rubyXL/parser.rb +307 -0
- data/lib/rubyXL/private_class.rb +95 -0
- data/lib/rubyXL/shared_strings.rb +35 -0
- data/lib/rubyXL/workbook.rb +342 -0
- data/lib/rubyXL/worksheet.rb +1118 -0
- data/lib/rubyXL/writer/app_writer.rb +51 -0
- data/lib/rubyXL/writer/calc_chain_writer.rb +18 -0
- data/lib/rubyXL/writer/content_types_writer.rb +113 -0
- data/lib/rubyXL/writer/core_writer.rb +34 -0
- data/lib/rubyXL/writer/generic_writer.rb +33 -0
- data/lib/rubyXL/writer/root_rels_writer.rb +17 -0
- data/lib/rubyXL/writer/shared_strings_writer.rb +21 -0
- data/lib/rubyXL/writer/styles_writer.rb +64 -0
- data/lib/rubyXL/writer/theme_writer.rb +337 -0
- data/lib/rubyXL/writer/workbook_rels_writer.rb +43 -0
- data/lib/rubyXL/writer/workbook_writer.rb +73 -0
- data/lib/rubyXL/writer/worksheet_writer.rb +164 -0
- data/lib/rubyXL/zip.rb +20 -0
- data/rdoc/created.rid +36 -0
- data/rdoc/fonts.css +167 -0
- data/rdoc/fonts/Lato-Light.ttf +0 -0
- data/rdoc/fonts/Lato-LightItalic.ttf +0 -0
- data/rdoc/fonts/Lato-Regular.ttf +0 -0
- data/rdoc/fonts/Lato-RegularItalic.ttf +0 -0
- data/rdoc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/rdoc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/rdoc/images/add.png +0 -0
- data/rdoc/images/arrow_up.png +0 -0
- data/rdoc/images/brick.png +0 -0
- data/rdoc/images/brick_link.png +0 -0
- data/rdoc/images/bug.png +0 -0
- data/rdoc/images/bullet_black.png +0 -0
- data/rdoc/images/bullet_toggle_minus.png +0 -0
- data/rdoc/images/bullet_toggle_plus.png +0 -0
- data/rdoc/images/date.png +0 -0
- data/rdoc/images/delete.png +0 -0
- data/rdoc/images/find.png +0 -0
- data/rdoc/images/loadingAnimation.gif +0 -0
- data/rdoc/images/macFFBgHack.png +0 -0
- data/rdoc/images/package.png +0 -0
- data/rdoc/images/page_green.png +0 -0
- data/rdoc/images/page_white_text.png +0 -0
- data/rdoc/images/page_white_width.png +0 -0
- data/rdoc/images/plugin.png +0 -0
- data/rdoc/images/ruby.png +0 -0
- data/rdoc/images/tag_blue.png +0 -0
- data/rdoc/images/tag_green.png +0 -0
- data/rdoc/images/transparent.png +0 -0
- data/rdoc/images/wrench.png +0 -0
- data/rdoc/images/wrench_orange.png +0 -0
- data/rdoc/images/zoom.png +0 -0
- data/rdoc/js/darkfish.js +140 -0
- data/rdoc/js/jquery.js +18 -0
- data/rdoc/js/navigation.js +142 -0
- data/rdoc/js/search.js +109 -0
- data/rdoc/js/search_index.js +1 -0
- data/rdoc/js/searcher.js +228 -0
- data/rdoc/rdoc.css +580 -0
- data/rubyXL-git-ref-6002046.gemspec +143 -0
- data/spec/lib/cell_spec.rb +407 -0
- data/spec/lib/color_spec.rb +14 -0
- data/spec/lib/parser_spec.rb +80 -0
- data/spec/lib/workbook_spec.rb +73 -0
- data/spec/lib/worksheet_spec.rb +1789 -0
- metadata +231 -0
@@ -0,0 +1,143 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "rubyXL-git-ref-6002046"
|
8
|
+
s.version = "2.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Vivek Bhagwat"]
|
12
|
+
s.date = "2014-01-16"
|
13
|
+
s.description = "rubyXL is a gem which allows the parsing, creation, and manipulation of Microsoft Excel (.xlsx/.xlsm) Documents"
|
14
|
+
s.email = "bhagwat.vivek@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
"Gemfile",
|
21
|
+
"Gemfile.lock",
|
22
|
+
"LICENSE.txt",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/rubyXL.rb",
|
27
|
+
"lib/rubyXL/cell.rb",
|
28
|
+
"lib/rubyXL/generic_storage.rb",
|
29
|
+
"lib/rubyXL/objects/border.rb",
|
30
|
+
"lib/rubyXL/objects/cell_style.rb",
|
31
|
+
"lib/rubyXL/objects/color.rb",
|
32
|
+
"lib/rubyXL/objects/column_range.rb",
|
33
|
+
"lib/rubyXL/objects/data_validation.rb",
|
34
|
+
"lib/rubyXL/objects/defined_name.rb",
|
35
|
+
"lib/rubyXL/objects/fill.rb",
|
36
|
+
"lib/rubyXL/objects/font.rb",
|
37
|
+
"lib/rubyXL/objects/formula.rb",
|
38
|
+
"lib/rubyXL/objects/ooxml_object.rb",
|
39
|
+
"lib/rubyXL/objects/reference.rb",
|
40
|
+
"lib/rubyXL/objects/sheet_view.rb",
|
41
|
+
"lib/rubyXL/objects/worksheet.rb",
|
42
|
+
"lib/rubyXL/parser.rb",
|
43
|
+
"lib/rubyXL/private_class.rb",
|
44
|
+
"lib/rubyXL/shared_strings.rb",
|
45
|
+
"lib/rubyXL/workbook.rb",
|
46
|
+
"lib/rubyXL/worksheet.rb",
|
47
|
+
"lib/rubyXL/writer/app_writer.rb",
|
48
|
+
"lib/rubyXL/writer/calc_chain_writer.rb",
|
49
|
+
"lib/rubyXL/writer/content_types_writer.rb",
|
50
|
+
"lib/rubyXL/writer/core_writer.rb",
|
51
|
+
"lib/rubyXL/writer/generic_writer.rb",
|
52
|
+
"lib/rubyXL/writer/root_rels_writer.rb",
|
53
|
+
"lib/rubyXL/writer/shared_strings_writer.rb",
|
54
|
+
"lib/rubyXL/writer/styles_writer.rb",
|
55
|
+
"lib/rubyXL/writer/theme_writer.rb",
|
56
|
+
"lib/rubyXL/writer/workbook_rels_writer.rb",
|
57
|
+
"lib/rubyXL/writer/workbook_writer.rb",
|
58
|
+
"lib/rubyXL/writer/worksheet_writer.rb",
|
59
|
+
"lib/rubyXL/zip.rb",
|
60
|
+
"rdoc/created.rid",
|
61
|
+
"rdoc/fonts.css",
|
62
|
+
"rdoc/fonts/Lato-Light.ttf",
|
63
|
+
"rdoc/fonts/Lato-LightItalic.ttf",
|
64
|
+
"rdoc/fonts/Lato-Regular.ttf",
|
65
|
+
"rdoc/fonts/Lato-RegularItalic.ttf",
|
66
|
+
"rdoc/fonts/SourceCodePro-Bold.ttf",
|
67
|
+
"rdoc/fonts/SourceCodePro-Regular.ttf",
|
68
|
+
"rdoc/images/add.png",
|
69
|
+
"rdoc/images/arrow_up.png",
|
70
|
+
"rdoc/images/brick.png",
|
71
|
+
"rdoc/images/brick_link.png",
|
72
|
+
"rdoc/images/bug.png",
|
73
|
+
"rdoc/images/bullet_black.png",
|
74
|
+
"rdoc/images/bullet_toggle_minus.png",
|
75
|
+
"rdoc/images/bullet_toggle_plus.png",
|
76
|
+
"rdoc/images/date.png",
|
77
|
+
"rdoc/images/delete.png",
|
78
|
+
"rdoc/images/find.png",
|
79
|
+
"rdoc/images/loadingAnimation.gif",
|
80
|
+
"rdoc/images/macFFBgHack.png",
|
81
|
+
"rdoc/images/package.png",
|
82
|
+
"rdoc/images/page_green.png",
|
83
|
+
"rdoc/images/page_white_text.png",
|
84
|
+
"rdoc/images/page_white_width.png",
|
85
|
+
"rdoc/images/plugin.png",
|
86
|
+
"rdoc/images/ruby.png",
|
87
|
+
"rdoc/images/tag_blue.png",
|
88
|
+
"rdoc/images/tag_green.png",
|
89
|
+
"rdoc/images/transparent.png",
|
90
|
+
"rdoc/images/wrench.png",
|
91
|
+
"rdoc/images/wrench_orange.png",
|
92
|
+
"rdoc/images/zoom.png",
|
93
|
+
"rdoc/js/darkfish.js",
|
94
|
+
"rdoc/js/jquery.js",
|
95
|
+
"rdoc/js/navigation.js",
|
96
|
+
"rdoc/js/search.js",
|
97
|
+
"rdoc/js/search_index.js",
|
98
|
+
"rdoc/js/searcher.js",
|
99
|
+
"rdoc/rdoc.css",
|
100
|
+
"rubyXL-git-ref-6002046.gemspec",
|
101
|
+
"spec/lib/cell_spec.rb",
|
102
|
+
"spec/lib/color_spec.rb",
|
103
|
+
"spec/lib/parser_spec.rb",
|
104
|
+
"spec/lib/workbook_spec.rb",
|
105
|
+
"spec/lib/worksheet_spec.rb"
|
106
|
+
]
|
107
|
+
s.homepage = "http://github.com/gilt/rubyXL"
|
108
|
+
s.licenses = ["MIT"]
|
109
|
+
s.require_paths = ["lib"]
|
110
|
+
s.rubygems_version = "1.8.23"
|
111
|
+
s.summary = "rubyXL is a gem which allows the parsing, creation, and manipulation of Microsoft Excel (.xlsx/.xlsm) Documents"
|
112
|
+
|
113
|
+
if s.respond_to? :specification_version then
|
114
|
+
s.specification_version = 3
|
115
|
+
|
116
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
117
|
+
s.add_runtime_dependency(%q<nokogiri>, [">= 1.4.4"])
|
118
|
+
s.add_runtime_dependency(%q<rubyzip>, [">= 1.0.0"])
|
119
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
120
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
121
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
122
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
123
|
+
s.add_development_dependency(%q<rspec>, [">= 1.3.4"])
|
124
|
+
else
|
125
|
+
s.add_dependency(%q<nokogiri>, [">= 1.4.4"])
|
126
|
+
s.add_dependency(%q<rubyzip>, [">= 1.0.0"])
|
127
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
128
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
129
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
130
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
131
|
+
s.add_dependency(%q<rspec>, [">= 1.3.4"])
|
132
|
+
end
|
133
|
+
else
|
134
|
+
s.add_dependency(%q<nokogiri>, [">= 1.4.4"])
|
135
|
+
s.add_dependency(%q<rubyzip>, [">= 1.0.0"])
|
136
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
137
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
138
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
139
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
140
|
+
s.add_dependency(%q<rspec>, [">= 1.3.4"])
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
@@ -0,0 +1,407 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rubyXL'
|
3
|
+
|
4
|
+
describe RubyXL::Cell do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@workbook = RubyXL::Workbook.new
|
8
|
+
@worksheet = RubyXL::Worksheet.new(@workbook)
|
9
|
+
@workbook.worksheets << @worksheet
|
10
|
+
(0..10).each do |i|
|
11
|
+
(0..10).each do |j|
|
12
|
+
@worksheet.add_cell(i, j, "#{i}:#{j}")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
@cell = @worksheet[0][0]
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.change_fill' do
|
19
|
+
it 'should cause an error if hex color code not passed' do
|
20
|
+
lambda {
|
21
|
+
@cell.change_fill('G')
|
22
|
+
}.should raise_error
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should make cell fill color equal to hex color code passed' do
|
26
|
+
@cell.change_fill('0f0f0f')
|
27
|
+
@cell.fill_color.should == '0f0f0f'
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should cause an error if hex color code includes # character' do
|
31
|
+
lambda {
|
32
|
+
@cell.change_fill('#0f0f0f')
|
33
|
+
}.should raise_error
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '.change_font_name' do
|
38
|
+
it 'should make font name match font name passed' do
|
39
|
+
@cell.change_font_name('Arial')
|
40
|
+
@cell.font_name.should == 'Arial'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '.change_font_size' do
|
45
|
+
it 'should make font size match number passed' do
|
46
|
+
@cell.change_font_size(30)
|
47
|
+
@cell.font_size.should == 30
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should cause an error if a string passed' do
|
51
|
+
lambda {
|
52
|
+
@cell.change_font_size('20')
|
53
|
+
}.should raise_error
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '.change_font_color' do
|
58
|
+
it 'should cause an error if hex color code not passed' do
|
59
|
+
lambda {
|
60
|
+
@cell.change_font_color('G')
|
61
|
+
}.should raise_error
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should make cell font color equal to hex color code passed' do
|
65
|
+
@cell.change_font_color('0f0f0f')
|
66
|
+
@cell.font_color.should == '0f0f0f'
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should cause an error if hex color code includes # character' do
|
70
|
+
lambda {
|
71
|
+
@cell.change_font_color('#0f0f0f')
|
72
|
+
}.should raise_error
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '.change_font_italics' do
|
77
|
+
it 'should make cell font italicized when true is passed' do
|
78
|
+
@cell.change_font_italics(true)
|
79
|
+
@cell.is_italicized.should == true
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '.change_font_bold' do
|
84
|
+
it 'should make cell font bolded when true is passed' do
|
85
|
+
@cell.change_font_bold(true)
|
86
|
+
@cell.is_bolded.should == true
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '.change_font_underline' do
|
91
|
+
it 'should make cell font underlined when true is passed' do
|
92
|
+
@cell.change_font_underline(true)
|
93
|
+
@cell.is_underlined.should == true
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe '.change_font_strikethrough' do
|
98
|
+
it 'should make cell font struckthrough when true is passed' do
|
99
|
+
@cell.change_font_strikethrough(true)
|
100
|
+
@cell.is_struckthrough.should == true
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe '.change_horizontal_alignment' do
|
105
|
+
it 'should cause cell to horizontally align as specified by the passed in string' do
|
106
|
+
@cell.change_horizontal_alignment('center')
|
107
|
+
@cell.horizontal_alignment.should == 'center'
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'should cause error if nil, "center", "justify", "left", "right", or "distributed" is not passed' do
|
111
|
+
lambda {
|
112
|
+
@cell.change_horizontal_alignment('TEST')
|
113
|
+
}.should raise_error
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe '.change_vertical_alignment' do
|
118
|
+
it 'should cause cell to vertically align as specified by the passed in string' do
|
119
|
+
@cell.change_vertical_alignment('center')
|
120
|
+
@cell.vertical_alignment.should == 'center'
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'should cause error if nil, "center", "justify", "left", "right", or "distributed" is not passed' do
|
124
|
+
lambda {
|
125
|
+
@cell.change_vertical_alignment('TEST')
|
126
|
+
}.should raise_error
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe '.change_wrap' do
|
131
|
+
it 'should cause cell to wrap align as specified by the passed in value' do
|
132
|
+
@cell.change_text_wrap(true)
|
133
|
+
@cell.text_wrap.should == true
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'should cause error if nil, "center", "justify", "left", "right", or "distributed" is not passed' do
|
137
|
+
lambda {
|
138
|
+
@cell.change_vertical_alignment('TEST')
|
139
|
+
}.should raise_error
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe '.change_border_top' do
|
144
|
+
it 'should cause cell to have border at top with specified weight' do
|
145
|
+
@cell.change_border_top('thin')
|
146
|
+
@cell.border_top.should == 'thin'
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'should cause error if nil, "thin", "thick", "hairline", or "medium" is not passed' do
|
150
|
+
lambda {
|
151
|
+
@cell.change_border_top('TEST')
|
152
|
+
}.should raise_error
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe '.change_border_left' do
|
157
|
+
it 'should cause cell to have border at left with specified weight' do
|
158
|
+
@cell.change_border_left('thin')
|
159
|
+
@cell.border_left.should == 'thin'
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'should cause error if nil, "thin", "thick", "hairline", or "medium" is not passed' do
|
163
|
+
lambda {
|
164
|
+
@cell.change_border_left('TEST')
|
165
|
+
}.should raise_error
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
describe '.change_border_right' do
|
170
|
+
it 'should cause cell to have border at right with specified weight' do
|
171
|
+
@cell.change_border_right('thin')
|
172
|
+
@cell.border_right.should == 'thin'
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'should cause error if nil, "thin", "thick", "hairline", or "medium" is not passed' do
|
176
|
+
lambda {
|
177
|
+
@cell.change_border_right('TEST')
|
178
|
+
}.should raise_error
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
describe '.change_border_bottom' do
|
183
|
+
it 'should cause cell to have border at bottom with specified weight' do
|
184
|
+
@cell.change_border_bottom('thin')
|
185
|
+
@cell.border_bottom.should == 'thin'
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'should cause error if nil, "thin", "thick", "hairline", or "medium" is not passed' do
|
189
|
+
lambda {
|
190
|
+
@cell.change_border_bottom('TEST')
|
191
|
+
}.should raise_error
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
describe '.change_border_diagonal' do
|
196
|
+
it 'should cause cell to have border at diagonal with specified weight' do
|
197
|
+
@cell.change_border_diagonal('thin')
|
198
|
+
@cell.border_diagonal.should == 'thin'
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'should cause error if nil, "thin", "thick", "hairline", or "medium" is not passed' do
|
202
|
+
lambda {
|
203
|
+
@cell.change_border_diagonal('TEST')
|
204
|
+
}.should raise_error
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
describe '.value' do
|
209
|
+
it 'should return the value of a date' do
|
210
|
+
date = Date.parse('January 1, 2011')
|
211
|
+
@cell.change_contents(date)
|
212
|
+
@cell.should_receive(:is_date?).at_least(1).and_return(true)
|
213
|
+
@cell.value.should == date
|
214
|
+
end
|
215
|
+
|
216
|
+
context '1900-based dates' do
|
217
|
+
before(:each) { @workbook.date1904 = false }
|
218
|
+
it 'should convert date numbers correctly' do
|
219
|
+
date = 41019
|
220
|
+
@cell.change_contents(date)
|
221
|
+
@cell.should_receive(:is_date?).at_least(1).and_return(true)
|
222
|
+
# puts @cell.value
|
223
|
+
# puts Date.parse('April 20, 2012')
|
224
|
+
@cell.value.should == Date.parse('April 20, 2012')
|
225
|
+
@cell.change_contents(35981)
|
226
|
+
@cell.value.should == Date.parse('July 5, 1998')
|
227
|
+
end
|
228
|
+
end
|
229
|
+
context '1904-based dates' do
|
230
|
+
before(:each) { @workbook.date1904 = true }
|
231
|
+
it 'should convert date numbers correctly' do
|
232
|
+
date = 39557
|
233
|
+
@cell.change_contents(date)
|
234
|
+
@cell.should_receive(:is_date?).at_least(1).and_return(true)
|
235
|
+
# puts @cell.value
|
236
|
+
# puts Date.parse('April 20, 2012')
|
237
|
+
@cell.value.should == Date.parse('April 20, 2012')
|
238
|
+
@cell.change_contents(34519)
|
239
|
+
@cell.value.should == Date.parse('July 5, 1998')
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
describe '.change_contents' do
|
245
|
+
it 'should cause cell value to match string or number that is passed in' do
|
246
|
+
@cell.change_contents('TEST')
|
247
|
+
@cell.value.should == 'TEST'
|
248
|
+
@cell.formula.should == nil
|
249
|
+
end
|
250
|
+
|
251
|
+
it 'should cause cell value to match a date that is passed in' do
|
252
|
+
date = Date.parse('January 1, 2011')
|
253
|
+
@cell.change_contents(date)
|
254
|
+
@cell.should_receive(:is_date?).at_least(1).and_return(true)
|
255
|
+
@cell.value.should == date
|
256
|
+
@cell.formula.should == nil
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'should cause cell value and formula to match what is passed in' do
|
260
|
+
@cell.change_contents(nil, 'SUM(A2:A4)')
|
261
|
+
@cell.value.should == nil
|
262
|
+
@cell.formula.should == 'SUM(A2:A4)'
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
describe '.is_italicized' do
|
267
|
+
it 'should correctly return whether or not the cell\'s font is italicized' do
|
268
|
+
@cell.change_font_italics(true)
|
269
|
+
@cell.is_italicized.should == true
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
describe '.is_bolded' do
|
274
|
+
it 'should correctly return whether or not the cell\'s font is bolded' do
|
275
|
+
@cell.change_font_bold(true)
|
276
|
+
@cell.is_bolded.should == true
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
describe '.is_underlined' do
|
281
|
+
it 'should correctly return whether or not the cell\'s font is underlined' do
|
282
|
+
@cell.change_font_underline(true)
|
283
|
+
@cell.is_underlined.should == true
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
describe '.is_struckthrough' do
|
288
|
+
it 'should correctly return whether or not the cell\'s font is struckthrough' do
|
289
|
+
@cell.change_font_strikethrough(true)
|
290
|
+
@cell.is_struckthrough.should == true
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
describe '.font_name' do
|
295
|
+
it 'should correctly return the name of the cell\'s font' do
|
296
|
+
@cell.change_font_name('Verdana')
|
297
|
+
@cell.font_name.should == 'Verdana'
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
describe '.font_size' do
|
302
|
+
it 'should correctly return the size of the cell\'s font' do
|
303
|
+
@cell.change_font_size(20)
|
304
|
+
@cell.font_size.should == 20
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
describe '.font_color' do
|
309
|
+
it 'should correctly return the color of the cell\'s font' do
|
310
|
+
@cell.change_font_color('0f0f0f')
|
311
|
+
@cell.font_color.should == '0f0f0f'
|
312
|
+
end
|
313
|
+
|
314
|
+
it 'should return 000000 (black) if no font color has been specified for this cell' do
|
315
|
+
@cell.font_color.should == '000000'
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
describe '.fill_color' do
|
320
|
+
it 'should correctly return the color of the cell\'s fill' do
|
321
|
+
@cell.change_fill('000000')
|
322
|
+
@cell.fill_color.should == '000000'
|
323
|
+
end
|
324
|
+
|
325
|
+
it 'should return ffffff (white) if no fill color has been specified for this cell' do
|
326
|
+
@cell.fill_color.should == 'ffffff'
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
describe '.horizontal_alignment' do
|
331
|
+
it 'should correctly return the type of horizontal alignment of this cell' do
|
332
|
+
@cell.change_horizontal_alignment('center')
|
333
|
+
@cell.horizontal_alignment.should == 'center'
|
334
|
+
end
|
335
|
+
|
336
|
+
it 'should return nil if no horizontal alignment has been specified for this cell' do
|
337
|
+
@cell.horizontal_alignment.should == nil
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
describe '.vertical_alignment' do
|
342
|
+
it 'should correctly return the type of vertical alignment of this cell' do
|
343
|
+
@cell.change_vertical_alignment('center')
|
344
|
+
@cell.vertical_alignment.should == 'center'
|
345
|
+
end
|
346
|
+
|
347
|
+
it 'should return nil if no vertical alignment has been specified for this cell' do
|
348
|
+
@cell.vertical_alignment.should be_nil
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
describe '.border_top' do
|
353
|
+
it 'should correctly return the weight of the border on top for this cell' do
|
354
|
+
@cell.change_border_top('thin')
|
355
|
+
@cell.border_top.should == 'thin'
|
356
|
+
end
|
357
|
+
|
358
|
+
it 'should return nil if no top border has been specified for this cell' do
|
359
|
+
@cell.border_top.should be_nil
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
describe '.border_left' do
|
364
|
+
it 'should correctly return the weight of the border on left for this cell' do
|
365
|
+
@cell.change_border_left('thin')
|
366
|
+
@cell.border_left.should == 'thin'
|
367
|
+
end
|
368
|
+
|
369
|
+
it 'should return nil if no left border has been specified for this cell' do
|
370
|
+
@cell.border_left.should be_nil
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
describe '.border_right' do
|
375
|
+
it 'should correctly return the weight of the border on right for this cell' do
|
376
|
+
@cell.change_border_right('thin')
|
377
|
+
@cell.border_right.should == 'thin'
|
378
|
+
end
|
379
|
+
|
380
|
+
it 'should return nil if no right border has been specified for this cell' do
|
381
|
+
@cell.border_right.should be_nil
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
describe '.border_bottom' do
|
386
|
+
it 'should correctly return the weight of the border on bottom for this cell' do
|
387
|
+
@cell.change_border_bottom('thin')
|
388
|
+
@cell.border_bottom.should == 'thin'
|
389
|
+
end
|
390
|
+
|
391
|
+
it 'should return nil if no bottom border has been specified for this cell' do
|
392
|
+
@cell.border_bottom.should be_nil
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
396
|
+
describe '.border_diagonal' do
|
397
|
+
it 'should correctly return the weight of the diagonal border for this cell' do
|
398
|
+
@cell.change_border_diagonal('thin')
|
399
|
+
@cell.border_diagonal.should == 'thin'
|
400
|
+
end
|
401
|
+
|
402
|
+
it 'should return nil if no diagonal border has been specified for this cell' do
|
403
|
+
@cell.border_diagonal.should be_nil
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
end
|