rubyXL 1.2.10 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. data/Gemfile +14 -10
  2. data/Gemfile.lock +80 -21
  3. data/LICENSE.txt +1 -1
  4. data/README.rdoc +88 -82
  5. data/Rakefile +7 -2
  6. data/VERSION +1 -1
  7. data/lib/rubyXL.rb +13 -7
  8. data/lib/rubyXL/cell.rb +108 -268
  9. data/lib/rubyXL/generic_storage.rb +40 -0
  10. data/lib/rubyXL/objects/border.rb +66 -0
  11. data/lib/rubyXL/objects/calculation_chain.rb +28 -0
  12. data/lib/rubyXL/objects/cell_style.rb +75 -0
  13. data/lib/rubyXL/objects/color.rb +25 -0
  14. data/lib/rubyXL/objects/column_range.rb +74 -0
  15. data/lib/rubyXL/objects/container_nodes.rb +122 -0
  16. data/lib/rubyXL/objects/data_validation.rb +43 -0
  17. data/lib/rubyXL/objects/document_properties.rb +76 -0
  18. data/lib/rubyXL/objects/extensions.rb +36 -0
  19. data/lib/rubyXL/objects/fill.rb +57 -0
  20. data/lib/rubyXL/objects/font.rb +111 -0
  21. data/lib/rubyXL/objects/formula.rb +24 -0
  22. data/lib/rubyXL/objects/ooxml_object.rb +295 -0
  23. data/lib/rubyXL/objects/reference.rb +110 -0
  24. data/lib/rubyXL/objects/relationships.rb +59 -0
  25. data/lib/rubyXL/objects/shared_strings.rb +57 -0
  26. data/lib/rubyXL/objects/sheet_data.rb +149 -0
  27. data/lib/rubyXL/objects/sheet_view.rb +71 -0
  28. data/lib/rubyXL/objects/stylesheet.rb +200 -0
  29. data/lib/rubyXL/objects/text.rb +87 -0
  30. data/lib/rubyXL/objects/theme.rb +64 -0
  31. data/lib/rubyXL/objects/workbook.rb +233 -0
  32. data/lib/rubyXL/objects/worksheet.rb +485 -0
  33. data/lib/rubyXL/parser.rb +78 -442
  34. data/lib/rubyXL/workbook.rb +216 -385
  35. data/lib/rubyXL/worksheet.rb +509 -1062
  36. data/lib/rubyXL/writer/content_types_writer.rb +104 -68
  37. data/lib/rubyXL/writer/core_writer.rb +26 -43
  38. data/lib/rubyXL/writer/generic_writer.rb +43 -0
  39. data/lib/rubyXL/writer/root_rels_writer.rb +11 -19
  40. data/lib/rubyXL/writer/styles_writer.rb +6 -398
  41. data/lib/rubyXL/writer/theme_writer.rb +321 -327
  42. data/lib/rubyXL/writer/workbook_writer.rb +63 -67
  43. data/lib/rubyXL/writer/worksheet_writer.rb +29 -218
  44. data/rdoc/created.rid +39 -0
  45. data/rdoc/fonts.css +167 -0
  46. data/rdoc/fonts/Lato-Light.ttf +0 -0
  47. data/rdoc/fonts/Lato-LightItalic.ttf +0 -0
  48. data/rdoc/fonts/Lato-Regular.ttf +0 -0
  49. data/rdoc/fonts/Lato-RegularItalic.ttf +0 -0
  50. data/rdoc/fonts/SourceCodePro-Bold.ttf +0 -0
  51. data/rdoc/fonts/SourceCodePro-Regular.ttf +0 -0
  52. data/rdoc/images/add.png +0 -0
  53. data/rdoc/images/arrow_up.png +0 -0
  54. data/rdoc/images/brick.png +0 -0
  55. data/rdoc/images/brick_link.png +0 -0
  56. data/rdoc/images/bug.png +0 -0
  57. data/rdoc/images/bullet_black.png +0 -0
  58. data/rdoc/images/bullet_toggle_minus.png +0 -0
  59. data/rdoc/images/bullet_toggle_plus.png +0 -0
  60. data/rdoc/images/date.png +0 -0
  61. data/rdoc/images/delete.png +0 -0
  62. data/rdoc/images/find.png +0 -0
  63. data/rdoc/images/loadingAnimation.gif +0 -0
  64. data/rdoc/images/macFFBgHack.png +0 -0
  65. data/rdoc/images/package.png +0 -0
  66. data/rdoc/images/page_green.png +0 -0
  67. data/rdoc/images/page_white_text.png +0 -0
  68. data/rdoc/images/page_white_width.png +0 -0
  69. data/rdoc/images/plugin.png +0 -0
  70. data/rdoc/images/ruby.png +0 -0
  71. data/rdoc/images/tag_blue.png +0 -0
  72. data/rdoc/images/tag_green.png +0 -0
  73. data/rdoc/images/transparent.png +0 -0
  74. data/rdoc/images/wrench.png +0 -0
  75. data/rdoc/images/wrench_orange.png +0 -0
  76. data/rdoc/images/zoom.png +0 -0
  77. data/rdoc/js/darkfish.js +140 -0
  78. data/rdoc/js/jquery.js +18 -0
  79. data/rdoc/js/navigation.js +142 -0
  80. data/rdoc/js/search.js +109 -0
  81. data/rdoc/js/search_index.js +1 -0
  82. data/rdoc/js/searcher.js +228 -0
  83. data/rdoc/rdoc.css +580 -0
  84. data/rubyXL.gemspec +90 -34
  85. data/spec/lib/cell_spec.rb +29 -59
  86. data/spec/lib/parser_spec.rb +35 -19
  87. data/spec/lib/reference_spec.rb +29 -0
  88. data/spec/lib/stylesheet_spec.rb +29 -0
  89. data/spec/lib/workbook_spec.rb +22 -17
  90. data/spec/lib/worksheet_spec.rb +47 -202
  91. metadata +185 -148
  92. data/lib/.DS_Store +0 -0
  93. data/lib/rubyXL/Hash.rb +0 -60
  94. data/lib/rubyXL/color.rb +0 -14
  95. data/lib/rubyXL/private_class.rb +0 -265
  96. data/lib/rubyXL/writer/app_writer.rb +0 -62
  97. data/lib/rubyXL/writer/calc_chain_writer.rb +0 -33
  98. data/lib/rubyXL/writer/shared_strings_writer.rb +0 -30
  99. data/lib/rubyXL/writer/workbook_rels_writer.rb +0 -59
  100. data/lib/rubyXL/zip.rb +0 -20
  101. data/spec/lib/hash_spec.rb +0 -28
data/rubyXL.gemspec CHANGED
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{rubyXL}
8
- s.version = "1.2.10"
7
+ s.name = "rubyXL"
8
+ s.version = "2.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Vivek Bhagwat"]
12
- s.date = %q{2012-08-07}
13
- s.description = %q{rubyXL is a gem which allows the parsing, creation, and manipulation of Microsoft Excel (.xlsx/.xlsm) Documents}
14
- s.email = %q{bhagwat.vivek@gmail.com}
12
+ s.date = "2014-02-07"
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
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
17
  "README.rdoc"
@@ -23,69 +23,125 @@ Gem::Specification.new do |s|
23
23
  "README.rdoc",
24
24
  "Rakefile",
25
25
  "VERSION",
26
- "lib/.DS_Store",
27
26
  "lib/rubyXL.rb",
28
- "lib/rubyXL/Hash.rb",
29
27
  "lib/rubyXL/cell.rb",
30
- "lib/rubyXL/color.rb",
28
+ "lib/rubyXL/generic_storage.rb",
29
+ "lib/rubyXL/objects/border.rb",
30
+ "lib/rubyXL/objects/calculation_chain.rb",
31
+ "lib/rubyXL/objects/cell_style.rb",
32
+ "lib/rubyXL/objects/color.rb",
33
+ "lib/rubyXL/objects/column_range.rb",
34
+ "lib/rubyXL/objects/container_nodes.rb",
35
+ "lib/rubyXL/objects/data_validation.rb",
36
+ "lib/rubyXL/objects/document_properties.rb",
37
+ "lib/rubyXL/objects/extensions.rb",
38
+ "lib/rubyXL/objects/fill.rb",
39
+ "lib/rubyXL/objects/font.rb",
40
+ "lib/rubyXL/objects/formula.rb",
41
+ "lib/rubyXL/objects/ooxml_object.rb",
42
+ "lib/rubyXL/objects/reference.rb",
43
+ "lib/rubyXL/objects/relationships.rb",
44
+ "lib/rubyXL/objects/shared_strings.rb",
45
+ "lib/rubyXL/objects/sheet_data.rb",
46
+ "lib/rubyXL/objects/sheet_view.rb",
47
+ "lib/rubyXL/objects/stylesheet.rb",
48
+ "lib/rubyXL/objects/text.rb",
49
+ "lib/rubyXL/objects/theme.rb",
50
+ "lib/rubyXL/objects/workbook.rb",
51
+ "lib/rubyXL/objects/worksheet.rb",
31
52
  "lib/rubyXL/parser.rb",
32
- "lib/rubyXL/private_class.rb",
33
53
  "lib/rubyXL/workbook.rb",
34
54
  "lib/rubyXL/worksheet.rb",
35
- "lib/rubyXL/writer/app_writer.rb",
36
- "lib/rubyXL/writer/calc_chain_writer.rb",
37
55
  "lib/rubyXL/writer/content_types_writer.rb",
38
56
  "lib/rubyXL/writer/core_writer.rb",
57
+ "lib/rubyXL/writer/generic_writer.rb",
39
58
  "lib/rubyXL/writer/root_rels_writer.rb",
40
- "lib/rubyXL/writer/shared_strings_writer.rb",
41
59
  "lib/rubyXL/writer/styles_writer.rb",
42
60
  "lib/rubyXL/writer/theme_writer.rb",
43
- "lib/rubyXL/writer/workbook_rels_writer.rb",
44
61
  "lib/rubyXL/writer/workbook_writer.rb",
45
62
  "lib/rubyXL/writer/worksheet_writer.rb",
46
- "lib/rubyXL/zip.rb",
63
+ "rdoc/created.rid",
64
+ "rdoc/fonts.css",
65
+ "rdoc/fonts/Lato-Light.ttf",
66
+ "rdoc/fonts/Lato-LightItalic.ttf",
67
+ "rdoc/fonts/Lato-Regular.ttf",
68
+ "rdoc/fonts/Lato-RegularItalic.ttf",
69
+ "rdoc/fonts/SourceCodePro-Bold.ttf",
70
+ "rdoc/fonts/SourceCodePro-Regular.ttf",
71
+ "rdoc/images/add.png",
72
+ "rdoc/images/arrow_up.png",
73
+ "rdoc/images/brick.png",
74
+ "rdoc/images/brick_link.png",
75
+ "rdoc/images/bug.png",
76
+ "rdoc/images/bullet_black.png",
77
+ "rdoc/images/bullet_toggle_minus.png",
78
+ "rdoc/images/bullet_toggle_plus.png",
79
+ "rdoc/images/date.png",
80
+ "rdoc/images/delete.png",
81
+ "rdoc/images/find.png",
82
+ "rdoc/images/loadingAnimation.gif",
83
+ "rdoc/images/macFFBgHack.png",
84
+ "rdoc/images/package.png",
85
+ "rdoc/images/page_green.png",
86
+ "rdoc/images/page_white_text.png",
87
+ "rdoc/images/page_white_width.png",
88
+ "rdoc/images/plugin.png",
89
+ "rdoc/images/ruby.png",
90
+ "rdoc/images/tag_blue.png",
91
+ "rdoc/images/tag_green.png",
92
+ "rdoc/images/transparent.png",
93
+ "rdoc/images/wrench.png",
94
+ "rdoc/images/wrench_orange.png",
95
+ "rdoc/images/zoom.png",
96
+ "rdoc/js/darkfish.js",
97
+ "rdoc/js/jquery.js",
98
+ "rdoc/js/navigation.js",
99
+ "rdoc/js/search.js",
100
+ "rdoc/js/search_index.js",
101
+ "rdoc/js/searcher.js",
102
+ "rdoc/rdoc.css",
47
103
  "rubyXL.gemspec",
48
104
  "spec/lib/cell_spec.rb",
49
105
  "spec/lib/color_spec.rb",
50
- "spec/lib/hash_spec.rb",
51
106
  "spec/lib/parser_spec.rb",
107
+ "spec/lib/reference_spec.rb",
108
+ "spec/lib/stylesheet_spec.rb",
52
109
  "spec/lib/workbook_spec.rb",
53
110
  "spec/lib/worksheet_spec.rb"
54
111
  ]
55
- s.homepage = %q{http://github.com/gilt/rubyXL}
112
+ s.homepage = "http://github.com/gilt/rubyXL"
56
113
  s.licenses = ["MIT"]
57
114
  s.require_paths = ["lib"]
58
- s.rubygems_version = %q{1.3.7}
59
- s.summary = %q{rubyXL is a gem which allows the parsing, creation, and manipulation of Microsoft Excel (.xlsx/.xlsm) Documents}
115
+ s.rubygems_version = "1.8.23"
116
+ s.summary = "rubyXL is a gem which allows the parsing, creation, and manipulation of Microsoft Excel (.xlsx/.xlsm) Documents"
60
117
 
61
118
  if s.respond_to? :specification_version then
62
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
63
119
  s.specification_version = 3
64
120
 
65
121
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
122
+ s.add_runtime_dependency(%q<nokogiri>, [">= 1.4.4"])
123
+ s.add_runtime_dependency(%q<rubyzip>, [">= 1.0.0"])
66
124
  s.add_development_dependency(%q<shoulda>, [">= 0"])
67
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
68
- s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
69
- s.add_development_dependency(%q<rcov>, [">= 0"])
70
- s.add_development_dependency(%q<nokogiri>, [">= 1.4.4"])
71
- s.add_development_dependency(%q<rubyzip>, [">= 0.9.4"])
125
+ s.add_development_dependency(%q<bundler>, [">= 0"])
126
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
127
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
72
128
  s.add_development_dependency(%q<rspec>, [">= 1.3.4"])
73
129
  else
74
- s.add_dependency(%q<shoulda>, [">= 0"])
75
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
76
- s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
77
- s.add_dependency(%q<rcov>, [">= 0"])
78
130
  s.add_dependency(%q<nokogiri>, [">= 1.4.4"])
79
- s.add_dependency(%q<rubyzip>, [">= 0.9.4"])
131
+ s.add_dependency(%q<rubyzip>, [">= 1.0.0"])
132
+ s.add_dependency(%q<shoulda>, [">= 0"])
133
+ s.add_dependency(%q<bundler>, [">= 0"])
134
+ s.add_dependency(%q<jeweler>, [">= 0"])
135
+ s.add_dependency(%q<simplecov>, [">= 0"])
80
136
  s.add_dependency(%q<rspec>, [">= 1.3.4"])
81
137
  end
82
138
  else
83
- s.add_dependency(%q<shoulda>, [">= 0"])
84
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
85
- s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
86
- s.add_dependency(%q<rcov>, [">= 0"])
87
139
  s.add_dependency(%q<nokogiri>, [">= 1.4.4"])
88
- s.add_dependency(%q<rubyzip>, [">= 0.9.4"])
140
+ s.add_dependency(%q<rubyzip>, [">= 1.0.0"])
141
+ s.add_dependency(%q<shoulda>, [">= 0"])
142
+ s.add_dependency(%q<bundler>, [">= 0"])
143
+ s.add_dependency(%q<jeweler>, [">= 0"])
144
+ s.add_dependency(%q<simplecov>, [">= 0"])
89
145
  s.add_dependency(%q<rspec>, [">= 1.3.4"])
90
146
  end
91
147
  end
@@ -5,7 +5,7 @@ describe RubyXL::Cell do
5
5
 
6
6
  before do
7
7
  @workbook = RubyXL::Workbook.new
8
- @worksheet = RubyXL::Worksheet.new(@workbook)
8
+ @worksheet = @workbook.add_worksheet('Test Worksheet')
9
9
  @workbook.worksheets << @worksheet
10
10
  (0..10).each do |i|
11
11
  (0..10).each do |j|
@@ -106,12 +106,6 @@ describe RubyXL::Cell do
106
106
  @cell.change_horizontal_alignment('center')
107
107
  @cell.horizontal_alignment.should == 'center'
108
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
109
  end
116
110
 
117
111
  describe '.change_vertical_alignment' do
@@ -119,11 +113,12 @@ describe RubyXL::Cell do
119
113
  @cell.change_vertical_alignment('center')
120
114
  @cell.vertical_alignment.should == 'center'
121
115
  end
116
+ end
122
117
 
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
118
+ describe '.change_wrap' do
119
+ it 'should cause cell to wrap align as specified by the passed in value' do
120
+ @cell.change_text_wrap(true)
121
+ @cell.text_wrap.should == true
127
122
  end
128
123
  end
129
124
 
@@ -132,12 +127,6 @@ describe RubyXL::Cell do
132
127
  @cell.change_border_top('thin')
133
128
  @cell.border_top.should == 'thin'
134
129
  end
135
-
136
- it 'should cause error if nil, "thin", "thick", "hairline", or "medium" is not passed' do
137
- lambda {
138
- @cell.change_border_top('TEST')
139
- }.should raise_error
140
- end
141
130
  end
142
131
 
143
132
  describe '.change_border_left' do
@@ -145,12 +134,6 @@ describe RubyXL::Cell do
145
134
  @cell.change_border_left('thin')
146
135
  @cell.border_left.should == 'thin'
147
136
  end
148
-
149
- it 'should cause error if nil, "thin", "thick", "hairline", or "medium" is not passed' do
150
- lambda {
151
- @cell.change_border_left('TEST')
152
- }.should raise_error
153
- end
154
137
  end
155
138
 
156
139
  describe '.change_border_right' do
@@ -158,12 +141,6 @@ describe RubyXL::Cell do
158
141
  @cell.change_border_right('thin')
159
142
  @cell.border_right.should == 'thin'
160
143
  end
161
-
162
- it 'should cause error if nil, "thin", "thick", "hairline", or "medium" is not passed' do
163
- lambda {
164
- @cell.change_border_right('TEST')
165
- }.should raise_error
166
- end
167
144
  end
168
145
 
169
146
  describe '.change_border_bottom' do
@@ -171,12 +148,6 @@ describe RubyXL::Cell do
171
148
  @cell.change_border_bottom('thin')
172
149
  @cell.border_bottom.should == 'thin'
173
150
  end
174
-
175
- it 'should cause error if nil, "thin", "thick", "hairline", or "medium" is not passed' do
176
- lambda {
177
- @cell.change_border_bottom('TEST')
178
- }.should raise_error
179
- end
180
151
  end
181
152
 
182
153
  describe '.change_border_diagonal' do
@@ -184,29 +155,37 @@ describe RubyXL::Cell do
184
155
  @cell.change_border_diagonal('thin')
185
156
  @cell.border_diagonal.should == 'thin'
186
157
  end
187
-
188
- it 'should cause error if nil, "thin", "thick", "hairline", or "medium" is not passed' do
189
- lambda {
190
- @cell.change_border_diagonal('TEST')
191
- }.should raise_error
192
- end
193
158
  end
194
159
 
195
160
  describe '.value' do
196
161
  it 'should return the value of a date' do
197
162
  date = Date.parse('January 1, 2011')
198
163
  @cell.change_contents(date)
199
- @cell.should_receive(:is_date?).any_number_of_times.and_return(true)
164
+ @cell.should_receive(:is_date?).at_least(1).and_return(true)
200
165
  @cell.value.should == date
201
166
  end
202
167
 
203
- it 'should convert date numbers correctly' do
204
- date = 41019
205
- @cell.change_contents(date)
206
- @cell.should_receive(:is_date?).any_number_of_times.and_return(true)
207
- puts @cell.value
208
- puts Date.parse('April 20, 2012')
209
- @cell.value.should == Date.parse('April 20, 2012')
168
+ context '1900-based dates' do
169
+ before(:each) { @workbook.date1904 = false }
170
+ it 'should convert date numbers correctly' do
171
+ date = 41019
172
+ @cell.change_contents(date)
173
+ @cell.should_receive(:is_date?).at_least(1).and_return(true)
174
+ @cell.value.should == Date.parse('April 20, 2012')
175
+ @cell.change_contents(35981)
176
+ @cell.value.should == Date.parse('July 5, 1998')
177
+ end
178
+ end
179
+ context '1904-based dates' do
180
+ before(:each) { @workbook.date1904 = true }
181
+ it 'should convert date numbers correctly' do
182
+ date = 39557
183
+ @cell.change_contents(date)
184
+ @cell.should_receive(:is_date?).at_least(1).and_return(true)
185
+ @cell.value.should == Date.parse('April 20, 2012')
186
+ @cell.change_contents(34519)
187
+ @cell.value.should == Date.parse('July 5, 1998')
188
+ end
210
189
  end
211
190
  end
212
191
 
@@ -220,7 +199,7 @@ describe RubyXL::Cell do
220
199
  it 'should cause cell value to match a date that is passed in' do
221
200
  date = Date.parse('January 1, 2011')
222
201
  @cell.change_contents(date)
223
- @cell.should_receive(:is_date?).any_number_of_times.and_return(true)
202
+ @cell.should_receive(:is_date?).at_least(1).and_return(true)
224
203
  @cell.value.should == date
225
204
  @cell.formula.should == nil
226
205
  end
@@ -373,13 +352,4 @@ describe RubyXL::Cell do
373
352
  end
374
353
  end
375
354
 
376
- describe '.convert_to_cell' do
377
- it 'should correctly return the "Excel Style" description of cells when given a row/column number' do
378
- RubyXL::Cell.convert_to_cell(0,26).should == 'AA1'
379
- end
380
-
381
- it 'should cause an error if a negative argument is given' do
382
- lambda {RubyXL::Cell.convert_to_cell(-1,0)}.should raise_error
383
- end
384
- end
385
355
  end
@@ -2,21 +2,23 @@ require 'rubygems'
2
2
  require 'rubyXL'
3
3
 
4
4
  describe RubyXL::Parser do
5
+
5
6
  before do
6
- @workbook = (RubyXL::Workbook.new)
7
- @time_str = Time.now.to_s
8
- @file = @time_str + '.xlsx'
9
- @workbook.write(@file)
10
- end
7
+ @workbook = RubyXL::Workbook.new
8
+ @workbook.add_worksheet("Test Worksheet")
11
9
 
12
- describe '.convert_to_index' do
13
- it 'should convert a well-formed Excel index into a pair of array indices' do
14
- RubyXL::Parser.convert_to_index('AA1').should == [0, 26]
15
- end
10
+ ws = @workbook.add_worksheet("Escape Test")
11
+ ws.add_cell(0,0, "&")
12
+ ws.add_cell(0,1, "<")
13
+ ws.add_cell(0,2, ">")
16
14
 
17
- it 'should return [-1, -1] if the Excel index is not well-formed' do
18
- RubyXL::Parser.convert_to_index('A1B').should == [-1, -1]
19
- end
15
+ ws.add_cell(1,0, "&")#TODO#.datatype = RubyXL::Cell::SHARED_STRING
16
+ ws.add_cell(1,1, "<")#TODO#.datatype = RubyXL::Cell::SHARED_STRING
17
+ ws.add_cell(1,2, ">")#TODO#.datatype = RubyXL::Cell::SHARED_STRING
18
+
19
+ @time_str = Time.now.to_s
20
+ @file = "#{@time_str}.xlsx"
21
+ @workbook.write(@file)
20
22
  end
21
23
 
22
24
  describe '.parse' do
@@ -24,12 +26,13 @@ describe RubyXL::Parser do
24
26
  @workbook2 = RubyXL::Parser.parse(@file)
25
27
 
26
28
  @workbook2.worksheets.size.should == @workbook.worksheets.size
27
- @workbook2[0].sheet_data.should == @workbook[0].sheet_data
28
- @workbook2[0].sheet_name.should == @workbook[0].sheet_name
29
+ @workbook2.worksheets.each_index { |i|
30
+ @workbook2[i].extract_data.should == @workbook[i].extract_data
31
+ }
29
32
  end
30
33
 
31
34
  it 'should cause an error if an xlsx or xlsm workbook is not passed' do
32
- lambda {@workbook2 = RubyXL::Parser.parse(@time_str+".xls")}.should raise_error
35
+ lambda {@workbook2 = RubyXL::Parser.parse("nonexistent_file.tmp")}.should raise_error
33
36
  end
34
37
 
35
38
  it 'should not cause an error if an xlsx or xlsm workbook is not passed but the skip_filename_check option is used' do
@@ -46,16 +49,29 @@ describe RubyXL::Parser do
46
49
  @workbook2 = RubyXL::Parser.parse(@file, :data_only => true)
47
50
 
48
51
  @workbook2.worksheets.size.should == @workbook.worksheets.size
49
- @workbook2[0].sheet_data.should == @workbook[0].sheet_data
50
- @workbook2[0].sheet_name.should == @workbook[0].sheet_name
52
+ @workbook2[0].extract_data.should == @workbook[0].extract_data
53
+ @workbook2[0].extract_data.should == @workbook[0].extract_data
51
54
  end
52
55
 
56
+ =begin
53
57
  it 'should construct consistent number formats' do
54
58
  @workbook2 = RubyXL::Parser.parse(@file)
59
+ @workbook2.num_fmts.should be_an(Array)
60
+ @workbook2.num_fmts.size.should == @workbook2.num_fmts[:attributes][:count]
61
+ end
62
+ =end
63
+
64
+ it 'should unescape HTML entities properly' do
65
+ @workbook2 = RubyXL::Parser.parse(@file)
66
+ @workbook2["Escape Test"][0][0].value.should == "&"
67
+ @workbook2["Escape Test"][0][1].value.should == "<"
68
+ @workbook2["Escape Test"][0][2].value.should == ">"
55
69
 
56
- @workbook2.num_fmts[:numFmt].should be_an(Array)
57
- @workbook2.num_fmts[:numFmt].length.should == @workbook2.num_fmts[:attributes][:count]
70
+ @workbook2["Escape Test"][1][0].value.should == "&"
71
+ @workbook2["Escape Test"][1][1].value.should == "<"
72
+ @workbook2["Escape Test"][1][2].value.should == ">"
58
73
  end
74
+
59
75
  end
60
76
 
61
77
  after do
@@ -0,0 +1,29 @@
1
+ require 'rubygems'
2
+ require 'rubyXL'
3
+
4
+ describe RubyXL::Reference do
5
+
6
+ describe '.ind2ref + .ref2ind' do
7
+ it 'should correctly return the "Excel Style" description of cells when given a row/column number' do
8
+ RubyXL::Reference.ind2ref(0, 26).should == 'AA1'
9
+ RubyXL::Reference.ind2ref(99, 0).should == 'A100'
10
+ RubyXL::Reference.ind2ref(0, 26).should == 'AA1'
11
+ RubyXL::Reference.ind2ref(0, 51).should == 'AZ1'
12
+ RubyXL::Reference.ind2ref(0, 52).should == 'BA1'
13
+ RubyXL::Reference.ind2ref(0, 77).should == 'BZ1'
14
+ RubyXL::Reference.ind2ref(0, 78).should == 'CA1'
15
+ RubyXL::Reference.ind2ref(0, 16383).should == 'XFD1'
16
+ end
17
+
18
+ it 'should correctly convert back and forth between "Excel Style" and index style cell references' do
19
+ 0.upto(16383) do |n|
20
+ RubyXL::Reference.ref2ind(RubyXL::Reference.ind2ref(n, 16383 - n)).should == [ n, 16383 - n ]
21
+ end
22
+ end
23
+
24
+ it 'should return [-1, -1] if the Excel index is not well-formed' do
25
+ RubyXL::Reference.ref2ind('A1B').should == [-1, -1]
26
+ end
27
+ end
28
+
29
+ end