axlsx 1.1.8 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +5 -2
- data/CHANGELOG.md +39 -0
- data/README.md +48 -46
- data/Rakefile +3 -3
- data/examples/basic_charts.rb +8 -0
- data/examples/example.rb +7 -1
- data/examples/example.xlsx +0 -0
- data/examples/example_streamed.xlsx +0 -0
- data/examples/no-use_autowidth.xlsx +0 -0
- data/examples/scraping_html.rb +91 -0
- data/examples/shared_strings_example.xlsx +0 -0
- data/lib/axlsx.rb +14 -8
- data/lib/axlsx/drawing/bar_3D_chart.rb +2 -8
- data/lib/axlsx/drawing/chart.rb +29 -25
- data/lib/axlsx/drawing/d_lbls.rb +100 -0
- data/lib/axlsx/drawing/drawing.rb +2 -0
- data/lib/axlsx/drawing/line_3D_chart.rb +2 -9
- data/lib/axlsx/drawing/pie_3D_chart.rb +3 -0
- data/lib/axlsx/drawing/scatter_chart.rb +2 -8
- data/lib/axlsx/drawing/two_cell_anchor.rb +38 -1
- data/lib/axlsx/util/simple_typed_list.rb +13 -6
- data/lib/axlsx/version.rb +2 -7
- data/lib/axlsx/workbook/defined_name.rb +174 -0
- data/lib/axlsx/workbook/defined_names.rb +21 -0
- data/lib/axlsx/workbook/workbook.rb +39 -13
- data/lib/axlsx/workbook/worksheet/auto_filter.rb +34 -0
- data/lib/axlsx/workbook/worksheet/cell.rb +24 -1
- data/lib/axlsx/workbook/worksheet/col.rb +15 -0
- data/lib/axlsx/workbook/worksheet/cols.rb +20 -0
- data/lib/axlsx/workbook/worksheet/comments.rb +8 -0
- data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +25 -0
- data/lib/axlsx/workbook/worksheet/data_validations.rb +28 -0
- data/lib/axlsx/workbook/worksheet/dimension.rb +65 -0
- data/lib/axlsx/workbook/worksheet/merged_cells.rb +35 -0
- data/lib/axlsx/workbook/worksheet/protected_ranges.rb +34 -0
- data/lib/axlsx/workbook/worksheet/row.rb +1 -1
- data/lib/axlsx/workbook/worksheet/sheet_data.rb +25 -0
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +24 -0
- data/lib/axlsx/workbook/worksheet/tables.rb +31 -0
- data/lib/axlsx/workbook/worksheet/worksheet.rb +263 -380
- data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +57 -0
- data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +64 -0
- data/test/drawing/tc_bar_series.rb +1 -1
- data/test/drawing/tc_chart.rb +7 -1
- data/test/drawing/tc_d_lbls.rb +47 -0
- data/test/drawing/tc_drawing.rb +5 -4
- data/test/drawing/tc_line_series.rb +1 -1
- data/test/drawing/tc_pie_3D_chart.rb +1 -1
- data/test/drawing/tc_pie_series.rb +1 -1
- data/test/drawing/tc_scatter_series.rb +1 -1
- data/test/drawing/tc_series.rb +1 -1
- data/test/tc_package.rb +16 -1
- data/test/workbook/tc_defined_name.rb +41 -0
- data/test/workbook/tc_workbook.rb +5 -3
- data/test/workbook/worksheet/table/tc_table.rb +0 -8
- data/test/workbook/worksheet/tc_cell.rb +2 -4
- data/test/workbook/worksheet/tc_protected_range.rb +0 -1
- data/test/workbook/worksheet/tc_row.rb +2 -2
- data/test/workbook/worksheet/tc_worksheet.rb +19 -21
- metadata +48 -7
@@ -38,8 +38,8 @@ class TestRow < Test::Unit::TestCase
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_add_cell_autowidth_info
|
41
|
-
|
42
|
-
|
41
|
+
cell = @row.add_cell("this is the cell of cells")
|
42
|
+
width = cell.send(:autowidth)
|
43
43
|
assert_equal(@ws.column_info.last.width, width)
|
44
44
|
end
|
45
45
|
|
@@ -113,12 +113,12 @@ class TestWorksheet < Test::Unit::TestCase
|
|
113
113
|
def test_dimension
|
114
114
|
@ws.add_row [1, 2, 3]
|
115
115
|
@ws.add_row [4, 5, 6]
|
116
|
-
assert_equal @ws.dimension, "A1:C2"
|
116
|
+
assert_equal @ws.dimension.sqref, "A1:C2"
|
117
117
|
end
|
118
118
|
|
119
119
|
def test_dimension_with_empty_row
|
120
120
|
@ws.add_row
|
121
|
-
assert_equal "A1:AA200", @ws.dimension
|
121
|
+
assert_equal "A1:AA200", @ws.dimension.sqref
|
122
122
|
end
|
123
123
|
|
124
124
|
def test_referencing
|
@@ -148,7 +148,9 @@ class TestWorksheet < Test::Unit::TestCase
|
|
148
148
|
end
|
149
149
|
|
150
150
|
def test_drawing
|
151
|
-
assert @ws.drawing
|
151
|
+
assert @ws.drawing == nil
|
152
|
+
@ws.add_chart(Axlsx::Pie3DChart)
|
153
|
+
assert @ws.drawing.is_a?(Axlsx::Drawing)
|
152
154
|
end
|
153
155
|
|
154
156
|
def test_col_style
|
@@ -306,18 +308,16 @@ class TestWorksheet < Test::Unit::TestCase
|
|
306
308
|
assert_equal(doc.xpath('//xmlns:worksheet/xmlns:tableParts/xmlns:tablePart[@r:id="rId1"]').size, 1)
|
307
309
|
end
|
308
310
|
|
309
|
-
def test_abs_auto_filter
|
310
|
-
@ws.add_row [1, "two", 3]
|
311
|
-
@ws.auto_filter = "A1:C1"
|
312
|
-
assert_equal(@ws.abs_auto_filter, "'Sheet1'!$A$1:$C$1")
|
313
|
-
end
|
314
|
-
|
315
311
|
def test_to_xml_string
|
316
312
|
schema = Nokogiri::XML::Schema(File.open(Axlsx::SML_XSD))
|
317
313
|
doc = Nokogiri::XML(@ws.to_xml_string)
|
318
314
|
assert(schema.validate(doc).map{ |e| puts e.message; e }.empty?, "error free validation")
|
319
315
|
end
|
320
316
|
|
317
|
+
def test_styles
|
318
|
+
assert(@ws.styles.is_a?(Axlsx::Styles), 'worksheet provides access to styles')
|
319
|
+
end
|
320
|
+
|
321
321
|
def test_to_xml_string_with_illegal_chars
|
322
322
|
nasties = "\v\u2028\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u001f"
|
323
323
|
@ws.add_row [nasties]
|
@@ -365,7 +365,7 @@ class TestWorksheet < Test::Unit::TestCase
|
|
365
365
|
def test_set_fixed_width_column
|
366
366
|
@ws.add_row ["mule", "donkey", "horse"], :widths => [20, :ignore, nil]
|
367
367
|
assert(@ws.column_info.size == 3, "a data item for each column")
|
368
|
-
assert_equal(@ws.column_info[0].width,
|
368
|
+
assert_equal(20, @ws.column_info[0].width, "adding a row with fixed width updates :fixed attribute")
|
369
369
|
assert_equal(@ws.column_info[1].width, nil, ":ignore does not set any data")
|
370
370
|
end
|
371
371
|
|
@@ -383,29 +383,27 @@ class TestWorksheet < Test::Unit::TestCase
|
|
383
383
|
end
|
384
384
|
|
385
385
|
def test_protect_range
|
386
|
-
assert(@ws.protected_ranges.is_a?(Axlsx::SimpleTypedList))
|
387
|
-
assert_equal(0, @ws.protected_ranges.size)
|
386
|
+
assert(@ws.send(:protected_ranges).is_a?(Axlsx::SimpleTypedList))
|
387
|
+
assert_equal(0, @ws.send(:protected_ranges).size)
|
388
388
|
@ws.protect_range('A1:A3')
|
389
|
-
assert_equal('A1:A3', @ws.protected_ranges.last.sqref)
|
389
|
+
assert_equal('A1:A3', @ws.send(:protected_ranges).last.sqref)
|
390
390
|
end
|
391
391
|
|
392
392
|
def test_protect_range_with_cells
|
393
393
|
@ws.add_row [1, 2, 3]
|
394
394
|
assert_nothing_raised {@ws.protect_range(@ws.rows.first.cells) }
|
395
|
-
assert_equal('A1:C1', @ws.protected_ranges.last.sqref)
|
395
|
+
assert_equal('A1:C1', @ws.send(:protected_ranges).last.sqref)
|
396
396
|
|
397
397
|
end
|
398
398
|
def test_merge_cells
|
399
|
-
assert(@ws.merged_cells.is_a?(Array))
|
400
|
-
assert_equal(@ws.merged_cells.size, 0)
|
401
399
|
@ws.add_row [1,2,3]
|
402
400
|
@ws.add_row [4,5,6]
|
403
401
|
@ws.add_row [7,8,9]
|
404
402
|
@ws.merge_cells "A1:A2"
|
405
403
|
@ws.merge_cells "B2:C3"
|
406
404
|
@ws.merge_cells @ws.rows.last.cells[(0..1)]
|
407
|
-
assert_equal(@ws.merged_cells.size, 3)
|
408
|
-
assert_equal(@ws.merged_cells.last, "A3:B3")
|
405
|
+
assert_equal(@ws.send(:merged_cells).size, 3)
|
406
|
+
assert_equal(@ws.send(:merged_cells).last, "A3:B3")
|
409
407
|
end
|
410
408
|
|
411
409
|
def test_merge_cells_sorts_correctly_by_row_when_given_array
|
@@ -413,13 +411,13 @@ class TestWorksheet < Test::Unit::TestCase
|
|
413
411
|
@ws.add_row [i]
|
414
412
|
end
|
415
413
|
@ws.merge_cells [@ws.rows[8].cells.first, @ws.rows[9].cells.first]
|
416
|
-
assert_equal "A9:A10", @ws.merged_cells.first
|
414
|
+
assert_equal "A9:A10", @ws.send(:merged_cells).first
|
417
415
|
end
|
418
416
|
|
419
417
|
def test_auto_filter
|
420
|
-
assert(@ws.auto_filter.nil?)
|
418
|
+
assert(@ws.auto_filter.range.nil?)
|
421
419
|
assert_raise(ArgumentError) { @ws.auto_filter = 123 }
|
422
420
|
@ws.auto_filter = "A1:D9"
|
423
|
-
assert_equal(@ws.auto_filter, "A1:D9")
|
421
|
+
assert_equal(@ws.auto_filter.range, "A1:D9")
|
424
422
|
end
|
425
423
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: axlsx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -60,21 +60,37 @@ dependencies:
|
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 4.3.1
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
63
|
+
name: yard
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
67
|
- - ! '>='
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0
|
70
|
-
type: :
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: 0
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: kramdown
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
78
94
|
- !ruby/object:Gem::Dependency
|
79
95
|
name: cover_me
|
80
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,6 +131,7 @@ files:
|
|
115
131
|
- lib/axlsx/drawing/bar_series.rb
|
116
132
|
- lib/axlsx/drawing/cat_axis.rb
|
117
133
|
- lib/axlsx/drawing/chart.rb
|
134
|
+
- lib/axlsx/drawing/d_lbls.rb
|
118
135
|
- lib/axlsx/drawing/drawing.rb
|
119
136
|
- lib/axlsx/drawing/graphic_frame.rb
|
120
137
|
- lib/axlsx/drawing/hyperlink.rb
|
@@ -170,31 +187,45 @@ files:
|
|
170
187
|
- lib/axlsx/util/storage.rb
|
171
188
|
- lib/axlsx/util/validators.rb
|
172
189
|
- lib/axlsx/version.rb
|
190
|
+
- lib/axlsx/workbook/defined_name.rb
|
191
|
+
- lib/axlsx/workbook/defined_names.rb
|
173
192
|
- lib/axlsx/workbook/shared_strings_table.rb
|
174
193
|
- lib/axlsx/workbook/workbook.rb
|
194
|
+
- lib/axlsx/workbook/worksheet/auto_filter.rb
|
175
195
|
- lib/axlsx/workbook/worksheet/cell.rb
|
176
196
|
- lib/axlsx/workbook/worksheet/cfvo.rb
|
177
197
|
- lib/axlsx/workbook/worksheet/col.rb
|
178
198
|
- lib/axlsx/workbook/worksheet/color_scale.rb
|
199
|
+
- lib/axlsx/workbook/worksheet/cols.rb
|
179
200
|
- lib/axlsx/workbook/worksheet/comment.rb
|
180
201
|
- lib/axlsx/workbook/worksheet/comments.rb
|
181
202
|
- lib/axlsx/workbook/worksheet/conditional_formatting.rb
|
182
203
|
- lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb
|
204
|
+
- lib/axlsx/workbook/worksheet/conditional_formattings.rb
|
183
205
|
- lib/axlsx/workbook/worksheet/data_bar.rb
|
184
206
|
- lib/axlsx/workbook/worksheet/data_validation.rb
|
207
|
+
- lib/axlsx/workbook/worksheet/data_validations.rb
|
185
208
|
- lib/axlsx/workbook/worksheet/date_time_converter.rb
|
209
|
+
- lib/axlsx/workbook/worksheet/dimension.rb
|
186
210
|
- lib/axlsx/workbook/worksheet/icon_set.rb
|
211
|
+
- lib/axlsx/workbook/worksheet/merged_cells.rb
|
187
212
|
- lib/axlsx/workbook/worksheet/page_margins.rb
|
188
213
|
- lib/axlsx/workbook/worksheet/page_setup.rb
|
189
214
|
- lib/axlsx/workbook/worksheet/pane.rb
|
190
215
|
- lib/axlsx/workbook/worksheet/print_options.rb
|
191
216
|
- lib/axlsx/workbook/worksheet/protected_range.rb
|
217
|
+
- lib/axlsx/workbook/worksheet/protected_ranges.rb
|
192
218
|
- lib/axlsx/workbook/worksheet/row.rb
|
193
219
|
- lib/axlsx/workbook/worksheet/selection.rb
|
220
|
+
- lib/axlsx/workbook/worksheet/sheet_data.rb
|
221
|
+
- lib/axlsx/workbook/worksheet/sheet_pr.rb
|
194
222
|
- lib/axlsx/workbook/worksheet/sheet_protection.rb
|
195
223
|
- lib/axlsx/workbook/worksheet/sheet_view.rb
|
196
224
|
- lib/axlsx/workbook/worksheet/table.rb
|
225
|
+
- lib/axlsx/workbook/worksheet/tables.rb
|
197
226
|
- lib/axlsx/workbook/worksheet/worksheet.rb
|
227
|
+
- lib/axlsx/workbook/worksheet/worksheet_comments.rb
|
228
|
+
- lib/axlsx/workbook/worksheet/worksheet_drawing.rb
|
198
229
|
- lib/axlsx.rb
|
199
230
|
- lib/schema/dc.xsd
|
200
231
|
- lib/schema/dcmitype.xsd
|
@@ -240,13 +271,18 @@ files:
|
|
240
271
|
- examples/conditional_formatting/stop_and_go.rb
|
241
272
|
- examples/data_validation.rb
|
242
273
|
- examples/example.rb
|
274
|
+
- examples/example.xlsx
|
275
|
+
- examples/example_streamed.xlsx
|
243
276
|
- examples/extractive.pdf
|
244
277
|
- examples/extractive.rb
|
245
278
|
- examples/image1.gif
|
246
279
|
- examples/image1.jpeg
|
247
280
|
- examples/image1.jpg
|
248
281
|
- examples/image1.png
|
282
|
+
- examples/no-use_autowidth.xlsx
|
249
283
|
- examples/sample.png
|
284
|
+
- examples/scraping_html.rb
|
285
|
+
- examples/shared_strings_example.xlsx
|
250
286
|
- examples/sheet_protection.rb
|
251
287
|
- examples/sheet_view.rb
|
252
288
|
- examples/skydrive/real_example.rb
|
@@ -268,6 +304,7 @@ files:
|
|
268
304
|
- test/drawing/tc_cat_axis.rb
|
269
305
|
- test/drawing/tc_cat_axis_data.rb
|
270
306
|
- test/drawing/tc_chart.rb
|
307
|
+
- test/drawing/tc_d_lbls.rb
|
271
308
|
- test/drawing/tc_data_source.rb
|
272
309
|
- test/drawing/tc_drawing.rb
|
273
310
|
- test/drawing/tc_graphic_frame.rb
|
@@ -323,6 +360,7 @@ files:
|
|
323
360
|
- test/tc_package.rb
|
324
361
|
- test/util/tc_simple_typed_list.rb
|
325
362
|
- test/util/tc_validators.rb
|
363
|
+
- test/workbook/tc_defined_name.rb
|
326
364
|
- test/workbook/tc_shared_strings_table.rb
|
327
365
|
- test/workbook/tc_workbook.rb
|
328
366
|
- test/workbook/worksheet/table/tc_table.rb
|
@@ -367,7 +405,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
367
405
|
version: '0'
|
368
406
|
segments:
|
369
407
|
- 0
|
370
|
-
hash:
|
408
|
+
hash: 2125383540867602531
|
371
409
|
requirements: []
|
372
410
|
rubyforge_project:
|
373
411
|
rubygems_version: 1.8.24
|
@@ -387,6 +425,7 @@ test_files:
|
|
387
425
|
- test/drawing/tc_cat_axis.rb
|
388
426
|
- test/drawing/tc_cat_axis_data.rb
|
389
427
|
- test/drawing/tc_chart.rb
|
428
|
+
- test/drawing/tc_d_lbls.rb
|
390
429
|
- test/drawing/tc_data_source.rb
|
391
430
|
- test/drawing/tc_drawing.rb
|
392
431
|
- test/drawing/tc_graphic_frame.rb
|
@@ -442,6 +481,7 @@ test_files:
|
|
442
481
|
- test/tc_package.rb
|
443
482
|
- test/util/tc_simple_typed_list.rb
|
444
483
|
- test/util/tc_validators.rb
|
484
|
+
- test/workbook/tc_defined_name.rb
|
445
485
|
- test/workbook/tc_shared_strings_table.rb
|
446
486
|
- test/workbook/tc_workbook.rb
|
447
487
|
- test/workbook/worksheet/table/tc_table.rb
|
@@ -466,3 +506,4 @@ test_files:
|
|
466
506
|
- test/workbook/worksheet/tc_sheet_protection.rb
|
467
507
|
- test/workbook/worksheet/tc_sheet_view.rb
|
468
508
|
- test/workbook/worksheet/tc_worksheet.rb
|
509
|
+
has_rdoc: axlsx
|