caxlsx 2.0.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/README.md +41 -33
  4. data/Rakefile +9 -11
  5. data/examples/auto_filter.rb +10 -1
  6. data/examples/conditional_formatting/example_conditional_formatting.rb +18 -3
  7. data/examples/data_validation.rb +57 -40
  8. data/examples/example.rb +115 -7
  9. data/examples/merge_cells.rb +17 -0
  10. data/examples/no_grid_with_borders.rb +18 -0
  11. data/examples/pivot_test.rb +63 -0
  12. data/examples/split.rb +16 -0
  13. data/lib/axlsx.rb +34 -15
  14. data/lib/axlsx/content_type/abstract_content_type.rb +1 -1
  15. data/lib/axlsx/content_type/content_type.rb +1 -1
  16. data/lib/axlsx/doc_props/app.rb +1 -1
  17. data/lib/axlsx/doc_props/core.rb +5 -5
  18. data/lib/axlsx/drawing/area_chart.rb +99 -0
  19. data/lib/axlsx/drawing/area_series.rb +110 -0
  20. data/lib/axlsx/drawing/axes.rb +1 -1
  21. data/lib/axlsx/drawing/axis.rb +12 -9
  22. data/lib/axlsx/drawing/bar_3D_chart.rb +13 -13
  23. data/lib/axlsx/drawing/bar_chart.rb +143 -0
  24. data/lib/axlsx/drawing/bar_series.rb +9 -9
  25. data/lib/axlsx/drawing/bubble_chart.rb +59 -0
  26. data/lib/axlsx/drawing/bubble_series.rb +63 -0
  27. data/lib/axlsx/drawing/cat_axis.rb +5 -5
  28. data/lib/axlsx/drawing/chart.rb +52 -8
  29. data/lib/axlsx/drawing/d_lbls.rb +3 -3
  30. data/lib/axlsx/drawing/drawing.rb +6 -1
  31. data/lib/axlsx/drawing/graphic_frame.rb +3 -3
  32. data/lib/axlsx/drawing/hyperlink.rb +1 -3
  33. data/lib/axlsx/drawing/line_3D_chart.rb +2 -2
  34. data/lib/axlsx/drawing/line_chart.rb +10 -10
  35. data/lib/axlsx/drawing/line_series.rb +32 -3
  36. data/lib/axlsx/drawing/marker.rb +1 -1
  37. data/lib/axlsx/drawing/num_data.rb +4 -4
  38. data/lib/axlsx/drawing/num_data_source.rb +6 -6
  39. data/lib/axlsx/drawing/num_val.rb +3 -1
  40. data/lib/axlsx/drawing/one_cell_anchor.rb +3 -2
  41. data/lib/axlsx/drawing/pic.rb +25 -19
  42. data/lib/axlsx/drawing/picture_locking.rb +1 -3
  43. data/lib/axlsx/drawing/pie_3D_chart.rb +5 -6
  44. data/lib/axlsx/drawing/pie_series.rb +6 -6
  45. data/lib/axlsx/drawing/scaling.rb +6 -6
  46. data/lib/axlsx/drawing/scatter_chart.rb +10 -10
  47. data/lib/axlsx/drawing/scatter_series.rb +40 -7
  48. data/lib/axlsx/drawing/ser_axis.rb +2 -2
  49. data/lib/axlsx/drawing/series.rb +3 -3
  50. data/lib/axlsx/drawing/series_title.rb +2 -2
  51. data/lib/axlsx/drawing/str_data.rb +3 -3
  52. data/lib/axlsx/drawing/str_val.rb +3 -1
  53. data/lib/axlsx/drawing/title.rb +22 -4
  54. data/lib/axlsx/drawing/two_cell_anchor.rb +6 -1
  55. data/lib/axlsx/drawing/val_axis.rb +1 -1
  56. data/lib/axlsx/drawing/view_3D.rb +2 -2
  57. data/lib/axlsx/drawing/vml_drawing.rb +1 -1
  58. data/lib/axlsx/package.rb +33 -31
  59. data/lib/axlsx/rels/relationship.rb +1 -1
  60. data/lib/axlsx/rels/relationships.rb +7 -4
  61. data/lib/axlsx/stylesheet/border_pr.rb +2 -2
  62. data/lib/axlsx/stylesheet/cell_alignment.rb +1 -3
  63. data/lib/axlsx/stylesheet/cell_protection.rb +1 -3
  64. data/lib/axlsx/stylesheet/cell_style.rb +1 -3
  65. data/lib/axlsx/stylesheet/color.rb +1 -3
  66. data/lib/axlsx/stylesheet/font.rb +1 -1
  67. data/lib/axlsx/stylesheet/gradient_stop.rb +1 -1
  68. data/lib/axlsx/stylesheet/num_fmt.rb +10 -3
  69. data/lib/axlsx/stylesheet/pattern_fill.rb +1 -1
  70. data/lib/axlsx/stylesheet/styles.rb +7 -7
  71. data/lib/axlsx/stylesheet/table_style_element.rb +1 -3
  72. data/lib/axlsx/util/accessors.rb +6 -6
  73. data/lib/axlsx/util/constants.rb +107 -99
  74. data/lib/axlsx/util/mime_type_utils.rb +11 -0
  75. data/lib/axlsx/util/options_parser.rb +2 -1
  76. data/lib/axlsx/util/parser.rb +4 -4
  77. data/lib/axlsx/util/serialized_attributes.rb +16 -6
  78. data/lib/axlsx/util/simple_typed_list.rb +28 -52
  79. data/lib/axlsx/util/storage.rb +4 -4
  80. data/lib/axlsx/util/validators.rb +29 -17
  81. data/lib/axlsx/version.rb +1 -1
  82. data/lib/axlsx/workbook/defined_name.rb +11 -12
  83. data/lib/axlsx/workbook/defined_names.rb +2 -2
  84. data/lib/axlsx/workbook/shared_strings_table.rb +5 -5
  85. data/lib/axlsx/workbook/workbook.rb +36 -11
  86. data/lib/axlsx/workbook/workbook_view.rb +80 -0
  87. data/lib/axlsx/workbook/workbook_views.rb +22 -0
  88. data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +2 -2
  89. data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +1 -3
  90. data/lib/axlsx/workbook/worksheet/break.rb +1 -3
  91. data/lib/axlsx/workbook/worksheet/cell.rb +136 -74
  92. data/lib/axlsx/workbook/worksheet/cell_serializer.rb +63 -43
  93. data/lib/axlsx/workbook/worksheet/cfvo.rb +1 -3
  94. data/lib/axlsx/workbook/worksheet/cfvos.rb +4 -1
  95. data/lib/axlsx/workbook/worksheet/col.rb +7 -10
  96. data/lib/axlsx/workbook/worksheet/col_breaks.rb +2 -2
  97. data/lib/axlsx/workbook/worksheet/cols.rb +5 -2
  98. data/lib/axlsx/workbook/worksheet/comment.rb +5 -6
  99. data/lib/axlsx/workbook/worksheet/comments.rb +9 -12
  100. data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +1 -1
  101. data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +1 -1
  102. data/lib/axlsx/workbook/worksheet/data_bar.rb +4 -6
  103. data/lib/axlsx/workbook/worksheet/data_validation.rb +6 -4
  104. data/lib/axlsx/workbook/worksheet/dimension.rb +2 -2
  105. data/lib/axlsx/workbook/worksheet/header_footer.rb +6 -8
  106. data/lib/axlsx/workbook/worksheet/icon_set.rb +3 -5
  107. data/lib/axlsx/workbook/worksheet/merged_cells.rb +4 -2
  108. data/lib/axlsx/workbook/worksheet/outline_pr.rb +33 -0
  109. data/lib/axlsx/workbook/worksheet/page_margins.rb +1 -3
  110. data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +1 -1
  111. data/lib/axlsx/workbook/worksheet/page_setup.rb +21 -23
  112. data/lib/axlsx/workbook/worksheet/pane.rb +1 -3
  113. data/lib/axlsx/workbook/worksheet/pivot_table.rb +44 -28
  114. data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +4 -4
  115. data/lib/axlsx/workbook/worksheet/print_options.rb +1 -3
  116. data/lib/axlsx/workbook/worksheet/protected_range.rb +1 -3
  117. data/lib/axlsx/workbook/worksheet/protected_ranges.rb +5 -2
  118. data/lib/axlsx/workbook/worksheet/rich_text.rb +55 -0
  119. data/lib/axlsx/workbook/worksheet/rich_text_run.rb +250 -0
  120. data/lib/axlsx/workbook/worksheet/row.rb +40 -51
  121. data/lib/axlsx/workbook/worksheet/row_breaks.rb +2 -2
  122. data/lib/axlsx/workbook/worksheet/selection.rb +1 -3
  123. data/lib/axlsx/workbook/worksheet/sheet_data.rb +3 -1
  124. data/lib/axlsx/workbook/worksheet/sheet_pr.rb +21 -3
  125. data/lib/axlsx/workbook/worksheet/sheet_protection.rb +1 -3
  126. data/lib/axlsx/workbook/worksheet/table.rb +6 -6
  127. data/lib/axlsx/workbook/worksheet/table_style_info.rb +1 -3
  128. data/lib/axlsx/workbook/worksheet/tables.rb +4 -1
  129. data/lib/axlsx/workbook/worksheet/worksheet.rb +64 -78
  130. data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +10 -10
  131. data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +3 -3
  132. data/test/drawing/tc_area_chart.rb +39 -0
  133. data/test/drawing/tc_area_series.rb +71 -0
  134. data/test/drawing/tc_axis.rb +27 -0
  135. data/test/drawing/tc_bar_chart.rb +71 -0
  136. data/test/drawing/tc_bubble_chart.rb +44 -0
  137. data/test/drawing/tc_bubble_series.rb +21 -0
  138. data/test/drawing/tc_chart.rb +23 -10
  139. data/test/drawing/tc_data_source.rb +6 -0
  140. data/test/drawing/tc_drawing.rb +2 -2
  141. data/test/drawing/tc_line_chart.rb +5 -5
  142. data/test/drawing/tc_line_series.rb +47 -6
  143. data/test/drawing/tc_pic.rb +11 -15
  144. data/test/drawing/tc_scatter_series.rb +36 -1
  145. data/test/drawing/tc_str_val.rb +9 -0
  146. data/test/drawing/tc_title.rb +5 -0
  147. data/test/stylesheet/tc_styles.rb +2 -2
  148. data/test/tc_axlsx.rb +31 -0
  149. data/test/tc_helper.rb +2 -0
  150. data/test/tc_package.rb +19 -1
  151. data/test/util/tc_mime_type_utils.rb +13 -0
  152. data/test/util/tc_simple_typed_list.rb +2 -3
  153. data/test/util/tc_validators.rb +34 -10
  154. data/test/workbook/tc_defined_name.rb +12 -4
  155. data/test/workbook/tc_shared_strings_table.rb +16 -1
  156. data/test/workbook/tc_workbook.rb +38 -3
  157. data/test/workbook/tc_workbook_view.rb +50 -0
  158. data/test/workbook/worksheet/auto_filter/tc_filters.rb +1 -1
  159. data/test/workbook/worksheet/tc_break.rb +1 -1
  160. data/test/workbook/worksheet/tc_cell.rb +76 -8
  161. data/test/workbook/worksheet/tc_col.rb +2 -2
  162. data/test/workbook/worksheet/tc_conditional_formatting.rb +2 -2
  163. data/test/workbook/worksheet/tc_data_bar.rb +1 -1
  164. data/test/workbook/worksheet/tc_data_validation.rb +11 -11
  165. data/test/workbook/worksheet/tc_header_footer.rb +2 -2
  166. data/test/workbook/worksheet/tc_icon_set.rb +1 -1
  167. data/test/workbook/worksheet/tc_outline_pr.rb +19 -0
  168. data/test/workbook/worksheet/tc_page_setup.rb +3 -3
  169. data/test/workbook/worksheet/tc_pivot_table.rb +21 -6
  170. data/test/workbook/worksheet/tc_print_options.rb +1 -1
  171. data/test/workbook/worksheet/tc_rich_text.rb +44 -0
  172. data/test/workbook/worksheet/tc_rich_text_run.rb +172 -0
  173. data/test/workbook/worksheet/tc_row.rb +7 -2
  174. data/test/workbook/worksheet/tc_sheet_calc_pr.rb +1 -1
  175. data/test/workbook/worksheet/tc_sheet_format_pr.rb +4 -4
  176. data/test/workbook/worksheet/tc_sheet_pr.rb +26 -4
  177. data/test/workbook/worksheet/tc_sheet_protection.rb +5 -5
  178. data/test/workbook/worksheet/tc_sheet_view.rb +4 -4
  179. data/test/workbook/worksheet/tc_table.rb +2 -3
  180. data/test/workbook/worksheet/tc_worksheet.rb +99 -45
  181. metadata +89 -16
@@ -197,11 +197,11 @@ class TestSheetView < Test::Unit::TestCase
197
197
 
198
198
  doc = Nokogiri::XML.parse(@ws.sheet_view.to_xml_string)
199
199
 
200
- assert_equal(1, doc.xpath("//sheetView[@tabSelected='false']").size)
200
+ assert_equal(1, doc.xpath("//sheetView[@tabSelected=0]").size)
201
201
 
202
- assert_equal(1, doc.xpath("//sheetView[@tabSelected='false'][@showWhiteSpace='false'][@showOutlineSymbols='false'][@showFormulas='false']
203
- [@rightToLeft='false'][@windowProtection='false'][@showZeros='true'][@showRuler='true']
204
- [@showRowColHeaders='true'][@showGridLines='true'][@defaultGridColor='true']
202
+ assert_equal(1, doc.xpath("//sheetView[@tabSelected=0][@showWhiteSpace=0][@showOutlineSymbols=0][@showFormulas=0]
203
+ [@rightToLeft=0][@windowProtection=0][@showZeros=1][@showRuler=1]
204
+ [@showRowColHeaders=1][@showGridLines=1][@defaultGridColor=1]
205
205
  [@zoomScale='100'][@workbookViewId='0'][@zoomScaleSheetLayoutView='0'][@zoomScalePageLayoutView='0']
206
206
  [@zoomScaleNormal='0'][@view='pageBreakPreview']").size)
207
207
  end
@@ -47,9 +47,9 @@ class TestTable < Test::Unit::TestCase
47
47
 
48
48
  def test_relationships
49
49
  assert(@ws.relationships.empty?)
50
- table = @ws.add_table("A1:D5")
50
+ @ws.add_table("A1:D5")
51
51
  assert_equal(@ws.relationships.size, 1, "adding a table adds a relationship")
52
- table = @ws.add_table("F1:J5")
52
+ @ws.add_table("F1:J5")
53
53
  assert_equal(@ws.relationships.size, 2, "adding a table adds a relationship")
54
54
  end
55
55
 
@@ -64,5 +64,4 @@ class TestTable < Test::Unit::TestCase
64
64
  end
65
65
  assert(errors.empty?, "error free validation")
66
66
  end
67
-
68
67
  end
@@ -73,6 +73,15 @@ class TestWorksheet < Test::Unit::TestCase
73
73
  end
74
74
  end
75
75
 
76
+ def test_state
77
+ assert_equal(:visible, @ws.state)
78
+ end
79
+
80
+ def test_state_validation
81
+ assert_raise(ArgumentError) { @ws.state = :dead }
82
+ assert_nothing_raised { @ws.state = :very_hidden }
83
+ end
84
+
76
85
  def test_no_autowidth
77
86
  @ws.workbook.use_autowidth = false
78
87
  @ws.add_row [1,2,3,4]
@@ -84,7 +93,7 @@ class TestWorksheet < Test::Unit::TestCase
84
93
  page_setup = {:fit_to_height => 1, :fit_to_width => 1, :orientation => :landscape, :paper_width => "210mm", :paper_height => "297mm", :scale => 80}
85
94
  print_options = {:grid_lines => true, :headings => true, :horizontal_centered => true, :vertical_centered => true}
86
95
  header_footer = {:different_first => false, :different_odd_even => false, :odd_header => 'Header'}
87
- optioned = @ws.workbook.add_worksheet(:name => 'bob', :page_margins => page_margins, :page_setup => page_setup, :print_options => print_options, :header_footer => header_footer, :selected => true, :show_gridlines => false)
96
+ optioned = @ws.workbook.add_worksheet(:name => 'bob', :page_margins => page_margins, :page_setup => page_setup, :print_options => print_options, :header_footer => header_footer)
88
97
  page_margins.keys.each do |key|
89
98
  assert_equal(page_margins[key], optioned.page_margins.send(key))
90
99
  end
@@ -98,23 +107,21 @@ class TestWorksheet < Test::Unit::TestCase
98
107
  assert_equal(header_footer[key], optioned.header_footer.send(key))
99
108
  end
100
109
  assert_equal(optioned.name, 'bob')
101
- assert_equal(optioned.selected, true)
102
- assert_equal(optioned.show_gridlines, false)
103
110
 
104
111
  end
105
112
 
106
113
 
107
- def test_use_gridlines
108
- assert_raise(ArgumentError) { @ws.show_gridlines = -1.1 }
109
- assert_nothing_raised { @ws.show_gridlines = false }
110
- assert_equal(@ws.show_gridlines, false)
111
- end
114
+ # def test_use_gridlines
115
+ # assert_raise(ArgumentError) { @ws.show_gridlines = -1.1 }
116
+ # assert_nothing_raised { @ws.show_gridlines = false }
117
+ # assert_equal(@ws.show_gridlines, false)
118
+ # end
112
119
 
113
- def test_selected
114
- assert_raise(ArgumentError) { @ws.selected = -1.1 }
115
- assert_nothing_raised { @ws.selected = true }
116
- assert_equal(@ws.selected, true)
117
- end
120
+ # def test_selected
121
+ # assert_raise(ArgumentError) { @ws.selected = -1.1 }
122
+ # assert_nothing_raised { @ws.selected = true }
123
+ # assert_equal(@ws.selected, true)
124
+ # end
118
125
 
119
126
  def test_rels_pn
120
127
  assert_equal(@ws.rels_pn, "worksheets/_rels/sheet1.xml.rels")
@@ -257,11 +264,11 @@ class TestWorksheet < Test::Unit::TestCase
257
264
  end
258
265
  end
259
266
 
260
- def test_to_xml_string_fit_to_page
261
- @ws.page_setup.fit_to_width = 1
262
- doc = Nokogiri::XML(@ws.to_xml_string)
263
- assert_equal(doc.xpath('//xmlns:worksheet/xmlns:sheetPr/xmlns:pageSetUpPr[@fitToPage="true"]').size, 1)
264
- end
267
+ # def test_to_xml_string_fit_to_page
268
+ # @ws.page_setup.fit_to_width = 1
269
+ # doc = Nokogiri::XML(@ws.to_xml_string)
270
+ # assert_equal(doc.xpath('//xmlns:worksheet/xmlns:sheetPr/xmlns:pageSetUpPr[@fitToPage=1]').size, 1)
271
+ # end
265
272
 
266
273
  def test_to_xml_string_dimensions
267
274
  @ws.add_row [1,2,3]
@@ -269,22 +276,22 @@ class TestWorksheet < Test::Unit::TestCase
269
276
  assert_equal(doc.xpath('//xmlns:worksheet/xmlns:dimension[@ref="A1:C1"]').size, 1)
270
277
  end
271
278
 
272
- def test_fit_to_page_assignation_does_nothing
273
- @ws.fit_to_page = true
274
- assert_equal(@ws.fit_to_page?, false)
275
- end
279
+ # def test_fit_to_page_assignation_does_nothing
280
+ # @ws.fit_to_page = true
281
+ # assert_equal(@ws.fit_to_page?, false)
282
+ # end
276
283
 
277
- def test_to_xml_string_selected
278
- @ws.selected = true
279
- doc = Nokogiri::XML(@ws.to_xml_string)
280
- assert_equal(doc.xpath('//xmlns:worksheet/xmlns:sheetViews/xmlns:sheetView[@tabSelected="true"]').size, 1)
281
- end
284
+ # def test_to_xml_string_selected
285
+ # @ws.selected = true
286
+ # doc = Nokogiri::XML(@ws.to_xml_string)
287
+ # assert_equal(doc.xpath('//xmlns:worksheet/xmlns:sheetViews/xmlns:sheetView[@tabSelected=1]').size, 1)
288
+ # end
282
289
 
283
- def test_to_xml_string_show_gridlines
284
- @ws.show_gridlines = false
285
- doc = Nokogiri::XML(@ws.to_xml_string)
286
- assert_equal(doc.xpath('//xmlns:worksheet/xmlns:sheetViews/xmlns:sheetView[@showGridLines="false"]').size, 1)
287
- end
290
+ # def test_to_xml_string_show_gridlines
291
+ # @ws.show_gridlines = false
292
+ # doc = Nokogiri::XML(@ws.to_xml_string)
293
+ # assert_equal(doc.xpath('//xmlns:worksheet/xmlns:sheetViews/xmlns:sheetView[@showGridLines=0]').size, 1)
294
+ # end
288
295
 
289
296
  def test_to_xml_string_auto_fit_data
290
297
  @ws.add_row [1, "two"]
@@ -314,6 +321,13 @@ class TestWorksheet < Test::Unit::TestCase
314
321
  assert_equal(doc.xpath('//xmlns:worksheet/xmlns:mergeCells/xmlns:mergeCell[@ref="E1:F1"]').size, 1)
315
322
  end
316
323
 
324
+ def test_to_xml_string_merge_cells_row
325
+ row = @ws.add_row [1, "two"]
326
+ @ws.merge_cells row
327
+ doc = Nokogiri::XML(@ws.to_xml_string)
328
+ assert_equal(doc.xpath('//xmlns:worksheet/xmlns:mergeCells/xmlns:mergeCell[@ref="A1:B1"]').size, 1)
329
+ end
330
+
317
331
  def test_to_xml_string_row_breaks
318
332
  @ws.add_page_break("A1")
319
333
  doc = Nokogiri::XML(@ws.to_xml_string)
@@ -350,7 +364,7 @@ class TestWorksheet < Test::Unit::TestCase
350
364
  po.horizontal_centered = true
351
365
  end
352
366
  doc = Nokogiri::XML(@ws.to_xml_string)
353
- assert_equal(doc.xpath('//xmlns:worksheet/xmlns:printOptions[@gridLines="true"][@horizontalCentered="true"]').size, 1)
367
+ assert_equal(doc.xpath('//xmlns:worksheet/xmlns:printOptions[@gridLines=1][@horizontalCentered=1]').size, 1)
354
368
  end
355
369
 
356
370
  def test_to_xml_string_header_footer
@@ -360,7 +374,7 @@ class TestWorksheet < Test::Unit::TestCase
360
374
  hf.odd_header = 'Test Header'
361
375
  end
362
376
  doc = Nokogiri::XML(@ws.to_xml_string)
363
- assert_equal(doc.xpath('//xmlns:worksheet/xmlns:headerFooter[@differentFirst="false"][@differentOddEven="false"]').size, 1)
377
+ assert_equal(doc.xpath('//xmlns:worksheet/xmlns:headerFooter[@differentFirst=0][@differentOddEven=0]').size, 1)
364
378
  end
365
379
 
366
380
  def test_to_xml_string_drawing
@@ -389,10 +403,13 @@ class TestWorksheet < Test::Unit::TestCase
389
403
  end
390
404
 
391
405
  def test_to_xml_string_with_illegal_chars
406
+ old = Axlsx::trust_input
407
+ Axlsx::trust_input = false
392
408
  nasties = "\v\u2028\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u001f"
393
409
  @ws.add_row [nasties]
394
410
  assert_equal(0, @ws.rows.last.cells.last.value.index("\v"))
395
- assert_equal(nil,@ws.to_xml_string.index("\v"))
411
+ assert_equal(nil, @ws.to_xml_string.index("\v"))
412
+ Axlsx::trust_input = old
396
413
  end
397
414
 
398
415
  def test_to_xml_string_with_newlines
@@ -420,16 +437,16 @@ class TestWorksheet < Test::Unit::TestCase
420
437
  def test_relationships
421
438
  @ws.add_row [1,2,3]
422
439
  assert(@ws.relationships.empty?, "No Drawing relationship until you add a chart")
423
- c = @ws.add_chart Axlsx::Pie3DChart
440
+ @ws.add_chart Axlsx::Pie3DChart
424
441
  assert_equal(@ws.relationships.size, 1, "adding a chart creates the relationship")
425
- c = @ws.add_chart Axlsx::Pie3DChart
442
+ @ws.add_chart Axlsx::Pie3DChart
426
443
  assert_equal(@ws.relationships.size, 1, "multiple charts still only result in one relationship")
427
- c = @ws.add_comment :text => 'builder', :author => 'bob', :ref => @ws.rows.last.cells.last
428
- assert_equal(@ws.relationships.size, 4, "adding a comment adds 3 relationships")
429
- c = @ws.add_comment :text => 'not that is a comment!', :author => 'travis', :ref => "A1"
430
- assert_equal(@ws.relationships.size, 4, "adding multiple comments in the same worksheet should not add any additional comment relationships")
431
- c = @ws.add_pivot_table 'G5:G6', 'A1:D10'
432
- assert_equal(@ws.relationships.size, 5, "adding a pivot table adds 1 relationship")
444
+ @ws.add_comment :text => 'builder', :author => 'bob', :ref => @ws.rows.last.cells.last
445
+ assert_equal(@ws.relationships.size, 3, "adding a comment adds 2 relationships")
446
+ @ws.add_comment :text => 'not that is a comment!', :author => 'travis', :ref => "A1"
447
+ assert_equal(@ws.relationships.size, 3, "adding multiple comments in the same worksheet should not add any additional comment relationships")
448
+ @ws.add_pivot_table 'G5:G6', 'A1:D10'
449
+ assert_equal(@ws.relationships.size, 4, "adding a pivot table adds 1 relationship")
433
450
  end
434
451
 
435
452
 
@@ -464,7 +481,7 @@ class TestWorksheet < Test::Unit::TestCase
464
481
  @ws.column_widths nil, 0.5
465
482
  assert_equal(@ws.column_info[1].width, 0.5, 'eat my width')
466
483
  assert_raise(ArgumentError, 'only accept unsigned ints') { @ws.column_widths 2, 7, -1 }
467
- assert_raise(ArgumentError, 'only accept Integer, Float or Fixnum') { @ws.column_widths 2, 7, "-1" }
484
+ assert_raise(ArgumentError, 'only accept Integer or Float') { @ws.column_widths 2, 7, "-1" }
468
485
  end
469
486
 
470
487
  def test_protect_range
@@ -501,16 +518,43 @@ class TestWorksheet < Test::Unit::TestCase
501
518
 
502
519
  def test_auto_filter
503
520
  assert(@ws.auto_filter.range.nil?)
521
+ assert(@wb.defined_names.none?{|defined_name| defined_name.name=='_xlnm._FilterDatabase'})
504
522
  assert_raise(ArgumentError) { @ws.auto_filter = 123 }
505
523
  @ws.auto_filter.range = "A1:D9"
506
524
  assert_equal(@ws.auto_filter.range, "A1:D9")
525
+ @ws.to_xml_string
526
+ assert(@wb.defined_names.any?{|defined_name| defined_name.name=='_xlnm._FilterDatabase'})
527
+ end
528
+
529
+ def test_auto_filter_assign
530
+ other_ws = @wb.add_worksheet
531
+
532
+ assert(@ws.auto_filter.range.nil?)
533
+ assert(other_ws.auto_filter.range.nil?)
534
+ assert(@wb.defined_names.none?{|defined_name| defined_name.name=='_xlnm._FilterDatabase'})
535
+ assert_raise(ArgumentError) { @ws.auto_filter = 123 }
536
+
537
+ @ws.auto_filter = "A1:D9"
538
+ assert_equal(@ws.auto_filter.range, "A1:D9")
539
+
540
+ other_ws.auto_filter = "A1:D2"
541
+ assert_equal(other_ws.auto_filter.range, "A1:D2")
542
+
543
+ @ws.to_xml_string
544
+ other_ws.to_xml_string
545
+
546
+ filter_database = @wb.defined_names.select{|defined_name| defined_name.name=='_xlnm._FilterDatabase'}
547
+ assert_equal(2, filter_database.size)
548
+ assert_equal(@ws.index, filter_database[0].local_sheet_id)
549
+ assert_equal(other_ws.index, filter_database[1].local_sheet_id)
507
550
  end
508
551
 
552
+
509
553
  def test_sheet_pr_for_auto_filter
510
554
  @ws.auto_filter.range = 'A1:D9'
511
555
  @ws.auto_filter.add_column 0, :filters, :filter_items => [1]
512
556
  doc = Nokogiri::XML(@ws.to_xml_string)
513
- assert(doc.xpath('//sheetPr[@filterMode="true"]'))
557
+ assert(doc.xpath('//sheetPr[@filterMode=1]'))
514
558
  end
515
559
 
516
560
  def test_outline_level_rows
@@ -535,4 +579,14 @@ class TestWorksheet < Test::Unit::TestCase
535
579
  assert_equal(1, @wb.worksheets.size)
536
580
  end
537
581
 
582
+ def test_worksheet_only_includes_outline_pr_when_set
583
+ doc = Nokogiri::XML(@ws.to_xml_string)
584
+ assert_equal(doc.xpath('//xmlns:worksheet/xmlns:sheetPr/xmlns:outlinePr').size, 0)
585
+
586
+ @ws.sheet_pr.outline_pr.summary_below = false
587
+ @ws.sheet_pr.outline_pr.summary_right = true
588
+ doc = Nokogiri::XML(@ws.to_xml_string)
589
+ assert_equal(doc.xpath('//xmlns:worksheet/xmlns:sheetPr/xmlns:outlinePr').size, 1)
590
+ assert_equal(doc.xpath('//xmlns:worksheet/xmlns:sheetPr/xmlns:outlinePr[@summaryBelow=0][@summaryRight=1]').size, 1)
591
+ end
538
592
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caxlsx
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Randy Morgan
@@ -10,22 +10,28 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-10-04 00:00:00.000000000 Z
13
+ date: 2019-09-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.8'
19
22
  - - ">="
20
23
  - !ruby/object:Gem::Version
21
- version: 1.4.1
24
+ version: 1.8.2
22
25
  type: :runtime
23
26
  prerelease: false
24
27
  version_requirements: !ruby/object:Gem::Requirement
25
28
  requirements:
29
+ - - "~>"
30
+ - !ruby/object:Gem::Version
31
+ version: '1.8'
26
32
  - - ">="
27
33
  - !ruby/object:Gem::Version
28
- version: 1.4.1
34
+ version: 1.8.2
29
35
  - !ruby/object:Gem::Dependency
30
36
  name: rubyzip
31
37
  requirement: !ruby/object:Gem::Requirement
@@ -33,6 +39,9 @@ dependencies:
33
39
  - - "~>"
34
40
  - !ruby/object:Gem::Version
35
41
  version: '1.2'
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 1.2.1
36
45
  type: :runtime
37
46
  prerelease: false
38
47
  version_requirements: !ruby/object:Gem::Requirement
@@ -40,62 +49,91 @@ dependencies:
40
49
  - - "~>"
41
50
  - !ruby/object:Gem::Version
42
51
  version: '1.2'
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.2.1
43
55
  - !ruby/object:Gem::Dependency
44
56
  name: htmlentities
45
57
  requirement: !ruby/object:Gem::Requirement
46
58
  requirements:
47
59
  - - "~>"
48
60
  - !ruby/object:Gem::Version
49
- version: 4.3.1
61
+ version: '4.3'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 4.3.4
50
65
  type: :runtime
51
66
  prerelease: false
52
67
  version_requirements: !ruby/object:Gem::Requirement
53
68
  requirements:
54
69
  - - "~>"
55
70
  - !ruby/object:Gem::Version
56
- version: 4.3.1
71
+ version: '4.3'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 4.3.4
75
+ - !ruby/object:Gem::Dependency
76
+ name: mimemagic
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '0.3'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '0.3'
57
89
  - !ruby/object:Gem::Dependency
58
90
  name: yard
59
91
  requirement: !ruby/object:Gem::Requirement
60
92
  requirements:
61
- - - ">="
93
+ - - "~>"
62
94
  - !ruby/object:Gem::Version
63
- version: '0'
95
+ version: 0.9.8
64
96
  type: :development
65
97
  prerelease: false
66
98
  version_requirements: !ruby/object:Gem::Requirement
67
99
  requirements:
68
- - - ">="
100
+ - - "~>"
69
101
  - !ruby/object:Gem::Version
70
- version: '0'
102
+ version: 0.9.8
71
103
  - !ruby/object:Gem::Dependency
72
104
  name: kramdown
73
105
  requirement: !ruby/object:Gem::Requirement
74
106
  requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '1.16'
75
110
  - - ">="
76
111
  - !ruby/object:Gem::Version
77
- version: '0'
112
+ version: 1.16.2
78
113
  type: :development
79
114
  prerelease: false
80
115
  version_requirements: !ruby/object:Gem::Requirement
81
116
  requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '1.16'
82
120
  - - ">="
83
121
  - !ruby/object:Gem::Version
84
- version: '0'
122
+ version: 1.16.2
85
123
  - !ruby/object:Gem::Dependency
86
124
  name: timecop
87
125
  requirement: !ruby/object:Gem::Requirement
88
126
  requirements:
89
127
  - - "~>"
90
128
  - !ruby/object:Gem::Version
91
- version: 0.6.1
129
+ version: 0.8.1
92
130
  type: :development
93
131
  prerelease: false
94
132
  version_requirements: !ruby/object:Gem::Requirement
95
133
  requirements:
96
134
  - - "~>"
97
135
  - !ruby/object:Gem::Version
98
- version: 0.6.1
136
+ version: 0.8.1
99
137
  description: " xlsx spreadsheet generation with charts, images, automated column
100
138
  width, customizable styles and full schema validation. Axlsx helps you create beautiful
101
139
  Office Open XML Spreadsheet documents ( Excel, Google Spreadsheets, Numbers, LibreOffice)
@@ -130,10 +168,14 @@ files:
130
168
  - examples/extractive.rb
131
169
  - examples/image1.jpeg
132
170
  - examples/ios_preview.rb
171
+ - examples/merge_cells.rb
172
+ - examples/no_grid_with_borders.rb
133
173
  - examples/page_setup.rb
134
174
  - examples/pivot_table.rb
175
+ - examples/pivot_test.rb
135
176
  - examples/sheet_protection.rb
136
177
  - examples/skydrive/real_example.rb
178
+ - examples/split.rb
137
179
  - examples/styles.rb
138
180
  - examples/underline.rb
139
181
  - examples/wrap_text.rb
@@ -144,11 +186,16 @@ files:
144
186
  - lib/axlsx/content_type/override.rb
145
187
  - lib/axlsx/doc_props/app.rb
146
188
  - lib/axlsx/doc_props/core.rb
189
+ - lib/axlsx/drawing/area_chart.rb
190
+ - lib/axlsx/drawing/area_series.rb
147
191
  - lib/axlsx/drawing/ax_data_source.rb
148
192
  - lib/axlsx/drawing/axes.rb
149
193
  - lib/axlsx/drawing/axis.rb
150
194
  - lib/axlsx/drawing/bar_3D_chart.rb
195
+ - lib/axlsx/drawing/bar_chart.rb
151
196
  - lib/axlsx/drawing/bar_series.rb
197
+ - lib/axlsx/drawing/bubble_chart.rb
198
+ - lib/axlsx/drawing/bubble_series.rb
152
199
  - lib/axlsx/drawing/cat_axis.rb
153
200
  - lib/axlsx/drawing/chart.rb
154
201
  - lib/axlsx/drawing/d_lbls.rb
@@ -204,6 +251,7 @@ files:
204
251
  - lib/axlsx/stylesheet/xf.rb
205
252
  - lib/axlsx/util/accessors.rb
206
253
  - lib/axlsx/util/constants.rb
254
+ - lib/axlsx/util/mime_type_utils.rb
207
255
  - lib/axlsx/util/options_parser.rb
208
256
  - lib/axlsx/util/parser.rb
209
257
  - lib/axlsx/util/serialized_attributes.rb
@@ -215,6 +263,8 @@ files:
215
263
  - lib/axlsx/workbook/defined_names.rb
216
264
  - lib/axlsx/workbook/shared_strings_table.rb
217
265
  - lib/axlsx/workbook/workbook.rb
266
+ - lib/axlsx/workbook/workbook_view.rb
267
+ - lib/axlsx/workbook/workbook_views.rb
218
268
  - lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb
219
269
  - lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb
220
270
  - lib/axlsx/workbook/worksheet/auto_filter/filters.rb
@@ -240,6 +290,7 @@ files:
240
290
  - lib/axlsx/workbook/worksheet/header_footer.rb
241
291
  - lib/axlsx/workbook/worksheet/icon_set.rb
242
292
  - lib/axlsx/workbook/worksheet/merged_cells.rb
293
+ - lib/axlsx/workbook/worksheet/outline_pr.rb
243
294
  - lib/axlsx/workbook/worksheet/page_margins.rb
244
295
  - lib/axlsx/workbook/worksheet/page_set_up_pr.rb
245
296
  - lib/axlsx/workbook/worksheet/page_setup.rb
@@ -250,6 +301,8 @@ files:
250
301
  - lib/axlsx/workbook/worksheet/print_options.rb
251
302
  - lib/axlsx/workbook/worksheet/protected_range.rb
252
303
  - lib/axlsx/workbook/worksheet/protected_ranges.rb
304
+ - lib/axlsx/workbook/worksheet/rich_text.rb
305
+ - lib/axlsx/workbook/worksheet/rich_text_run.rb
253
306
  - lib/axlsx/workbook/worksheet/row.rb
254
307
  - lib/axlsx/workbook/worksheet/row_breaks.rb
255
308
  - lib/axlsx/workbook/worksheet/selection.rb
@@ -308,10 +361,15 @@ files:
308
361
  - test/content_type/tc_override.rb
309
362
  - test/doc_props/tc_app.rb
310
363
  - test/doc_props/tc_core.rb
364
+ - test/drawing/tc_area_chart.rb
365
+ - test/drawing/tc_area_series.rb
311
366
  - test/drawing/tc_axes.rb
312
367
  - test/drawing/tc_axis.rb
313
368
  - test/drawing/tc_bar_3D_chart.rb
369
+ - test/drawing/tc_bar_chart.rb
314
370
  - test/drawing/tc_bar_series.rb
371
+ - test/drawing/tc_bubble_chart.rb
372
+ - test/drawing/tc_bubble_series.rb
315
373
  - test/drawing/tc_cat_axis.rb
316
374
  - test/drawing/tc_cat_axis_data.rb
317
375
  - test/drawing/tc_chart.rb
@@ -370,12 +428,14 @@ files:
370
428
  - test/tc_axlsx.rb
371
429
  - test/tc_helper.rb
372
430
  - test/tc_package.rb
431
+ - test/util/tc_mime_type_utils.rb
373
432
  - test/util/tc_serialized_attributes.rb
374
433
  - test/util/tc_simple_typed_list.rb
375
434
  - test/util/tc_validators.rb
376
435
  - test/workbook/tc_defined_name.rb
377
436
  - test/workbook/tc_shared_strings_table.rb
378
437
  - test/workbook/tc_workbook.rb
438
+ - test/workbook/tc_workbook_view.rb
379
439
  - test/workbook/worksheet/auto_filter/tc_auto_filter.rb
380
440
  - test/workbook/worksheet/auto_filter/tc_filter_column.rb
381
441
  - test/workbook/worksheet/auto_filter/tc_filters.rb
@@ -392,6 +452,7 @@ files:
392
452
  - test/workbook/worksheet/tc_date_time_converter.rb
393
453
  - test/workbook/worksheet/tc_header_footer.rb
394
454
  - test/workbook/worksheet/tc_icon_set.rb
455
+ - test/workbook/worksheet/tc_outline_pr.rb
395
456
  - test/workbook/worksheet/tc_page_margins.rb
396
457
  - test/workbook/worksheet/tc_page_set_up_pr.rb
397
458
  - test/workbook/worksheet/tc_page_setup.rb
@@ -400,6 +461,8 @@ files:
400
461
  - test/workbook/worksheet/tc_pivot_table_cache_definition.rb
401
462
  - test/workbook/worksheet/tc_print_options.rb
402
463
  - test/workbook/worksheet/tc_protected_range.rb
464
+ - test/workbook/worksheet/tc_rich_text.rb
465
+ - test/workbook/worksheet/tc_rich_text_run.rb
403
466
  - test/workbook/worksheet/tc_row.rb
404
467
  - test/workbook/worksheet/tc_selection.rb
405
468
  - test/workbook/worksheet/tc_sheet_calc_pr.rb
@@ -411,7 +474,7 @@ files:
411
474
  - test/workbook/worksheet/tc_table_style_info.rb
412
475
  - test/workbook/worksheet/tc_worksheet.rb
413
476
  - test/workbook/worksheet/tc_worksheet_hyperlink.rb
414
- homepage: https://github.com/caxlsx/caxlsx
477
+ homepage: https://github.com/caxlsx/axlsx
415
478
  licenses:
416
479
  - MIT
417
480
  metadata: {}
@@ -433,7 +496,7 @@ requirements: []
433
496
  rubygems_version: 3.0.4
434
497
  signing_key:
435
498
  specification_version: 4
436
- summary: excel OOXML (xlsx) with charts, styles, images and autowidth columns.
499
+ summary: Excel OOXML (xlsx) with charts, styles, images and autowidth columns.
437
500
  test_files:
438
501
  - test/drawing/tc_num_data.rb
439
502
  - test/drawing/tc_two_cell_anchor.rb
@@ -445,16 +508,20 @@ test_files:
445
508
  - test/drawing/tc_axis.rb
446
509
  - test/drawing/tc_line_chart.rb
447
510
  - test/drawing/tc_marker.rb
511
+ - test/drawing/tc_bubble_series.rb
448
512
  - test/drawing/tc_d_lbls.rb
449
513
  - test/drawing/tc_str_val.rb
514
+ - test/drawing/tc_bar_chart.rb
450
515
  - test/drawing/tc_line_3d_chart.rb
451
516
  - test/drawing/tc_cat_axis_data.rb
517
+ - test/drawing/tc_area_chart.rb
452
518
  - test/drawing/tc_line_series.rb
453
519
  - test/drawing/tc_scatter_series.rb
454
520
  - test/drawing/tc_bar_series.rb
455
521
  - test/drawing/tc_hyperlink.rb
456
522
  - test/drawing/tc_pic.rb
457
523
  - test/drawing/tc_named_axis_data.rb
524
+ - test/drawing/tc_bubble_chart.rb
458
525
  - test/drawing/tc_str_data.rb
459
526
  - test/drawing/tc_drawing.rb
460
527
  - test/drawing/tc_scatter_chart.rb
@@ -467,6 +534,7 @@ test_files:
467
534
  - test/drawing/tc_axes.rb
468
535
  - test/drawing/tc_vml_drawing.rb
469
536
  - test/drawing/tc_pie_3D_chart.rb
537
+ - test/drawing/tc_area_series.rb
470
538
  - test/drawing/tc_graphic_frame.rb
471
539
  - test/drawing/tc_one_cell_anchor.rb
472
540
  - test/drawing/tc_data_source.rb
@@ -474,6 +542,7 @@ test_files:
474
542
  - test/drawing/tc_scaling.rb
475
543
  - test/drawing/tc_bar_3D_chart.rb
476
544
  - test/util/tc_simple_typed_list.rb
545
+ - test/util/tc_mime_type_utils.rb
477
546
  - test/util/tc_validators.rb
478
547
  - test/util/tc_serialized_attributes.rb
479
548
  - test/tc_axlsx.rb
@@ -506,6 +575,7 @@ test_files:
506
575
  - test/profile.rb
507
576
  - test/benchmark.rb
508
577
  - test/tc_package.rb
578
+ - test/workbook/tc_workbook_view.rb
509
579
  - test/workbook/tc_defined_name.rb
510
580
  - test/workbook/worksheet/tc_data_bar.rb
511
581
  - test/workbook/worksheet/tc_worksheet_hyperlink.rb
@@ -513,6 +583,7 @@ test_files:
513
583
  - test/workbook/worksheet/tc_pivot_table_cache_definition.rb
514
584
  - test/workbook/worksheet/tc_protected_range.rb
515
585
  - test/workbook/worksheet/tc_selection.rb
586
+ - test/workbook/worksheet/tc_rich_text.rb
516
587
  - test/workbook/worksheet/tc_date_time_converter.rb
517
588
  - test/workbook/worksheet/tc_table_style_info.rb
518
589
  - test/workbook/worksheet/tc_conditional_formatting.rb
@@ -522,6 +593,7 @@ test_files:
522
593
  - test/workbook/worksheet/tc_sheet_calc_pr.rb
523
594
  - test/workbook/worksheet/tc_color_scale.rb
524
595
  - test/workbook/worksheet/tc_worksheet.rb
596
+ - test/workbook/worksheet/tc_rich_text_run.rb
525
597
  - test/workbook/worksheet/tc_sheet_pr.rb
526
598
  - test/workbook/worksheet/auto_filter/tc_filters.rb
527
599
  - test/workbook/worksheet/auto_filter/tc_auto_filter.rb
@@ -539,6 +611,7 @@ test_files:
539
611
  - test/workbook/worksheet/tc_sheet_format_pr.rb
540
612
  - test/workbook/worksheet/tc_print_options.rb
541
613
  - test/workbook/worksheet/tc_comment.rb
614
+ - test/workbook/worksheet/tc_outline_pr.rb
542
615
  - test/workbook/worksheet/tc_row.rb
543
616
  - test/workbook/worksheet/tc_icon_set.rb
544
617
  - test/workbook/worksheet/tc_page_set_up_pr.rb