axlsx 1.0.17 → 1.1.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.
Files changed (167) hide show
  1. data/CHANGELOG.md +11 -3
  2. data/README.md +159 -51
  3. data/examples/example.csv +1000 -0
  4. data/examples/example.rb +255 -150
  5. data/examples/example.xlsx +0 -0
  6. data/examples/example_streamed.xlsx +0 -0
  7. data/examples/no-use_autowidth.xlsx +0 -0
  8. data/examples/shared_strings_example.xlsx +0 -0
  9. data/lib/axlsx/content_type/content_type.rb +12 -12
  10. data/lib/axlsx/content_type/default.rb +9 -6
  11. data/lib/axlsx/content_type/override.rb +12 -8
  12. data/lib/axlsx/doc_props/app.rb +37 -40
  13. data/lib/axlsx/doc_props/core.rb +12 -17
  14. data/lib/axlsx/drawing/axis.rb +38 -19
  15. data/lib/axlsx/drawing/bar_3D_chart.rb +33 -32
  16. data/lib/axlsx/drawing/bar_series.rb +13 -14
  17. data/lib/axlsx/drawing/cat_axis.rb +15 -14
  18. data/lib/axlsx/drawing/cat_axis_data.rb +16 -18
  19. data/lib/axlsx/drawing/chart.rb +39 -40
  20. data/lib/axlsx/drawing/drawing.rb +15 -12
  21. data/lib/axlsx/drawing/graphic_frame.rb +21 -21
  22. data/lib/axlsx/drawing/hyperlink.rb +12 -11
  23. data/lib/axlsx/drawing/line_3D_chart.rb +30 -28
  24. data/lib/axlsx/drawing/line_series.rb +11 -11
  25. data/lib/axlsx/drawing/marker.rb +10 -8
  26. data/lib/axlsx/drawing/named_axis_data.rb +36 -0
  27. data/lib/axlsx/drawing/one_cell_anchor.rb +17 -16
  28. data/lib/axlsx/drawing/pic.rb +25 -37
  29. data/lib/axlsx/drawing/picture_locking.rb +21 -18
  30. data/lib/axlsx/drawing/pie_3D_chart.rb +10 -8
  31. data/lib/axlsx/drawing/pie_series.rb +15 -12
  32. data/lib/axlsx/drawing/scaling.rb +10 -10
  33. data/lib/axlsx/drawing/scatter_chart.rb +69 -0
  34. data/lib/axlsx/drawing/scatter_series.rb +39 -0
  35. data/lib/axlsx/drawing/ser_axis.rb +10 -10
  36. data/lib/axlsx/drawing/series.rb +15 -15
  37. data/lib/axlsx/drawing/series_title.rb +14 -14
  38. data/lib/axlsx/drawing/title.rb +26 -26
  39. data/lib/axlsx/drawing/two_cell_anchor.rb +18 -20
  40. data/lib/axlsx/drawing/val_axis.rb +8 -7
  41. data/lib/axlsx/drawing/val_axis_data.rb +17 -17
  42. data/lib/axlsx/drawing/view_3D.rb +22 -20
  43. data/lib/axlsx/package.rb +60 -43
  44. data/lib/axlsx/rels/relationship.rb +11 -8
  45. data/lib/axlsx/rels/relationships.rb +7 -1
  46. data/lib/axlsx/stylesheet/#num_fmt.rb# +69 -0
  47. data/lib/axlsx/stylesheet/border.rb +27 -23
  48. data/lib/axlsx/stylesheet/border_pr.rb +16 -15
  49. data/lib/axlsx/stylesheet/cell_alignment.rb +23 -21
  50. data/lib/axlsx/stylesheet/cell_protection.rb +10 -7
  51. data/lib/axlsx/stylesheet/cell_style.rb +8 -5
  52. data/lib/axlsx/stylesheet/color.rb +20 -14
  53. data/lib/axlsx/stylesheet/fill.rb +7 -5
  54. data/lib/axlsx/stylesheet/font.rb +21 -14
  55. data/lib/axlsx/stylesheet/gradient_fill.rb +19 -16
  56. data/lib/axlsx/stylesheet/gradient_stop.rb +9 -5
  57. data/lib/axlsx/stylesheet/num_fmt.rb +12 -6
  58. data/lib/axlsx/stylesheet/pattern_fill.rb +25 -10
  59. data/lib/axlsx/stylesheet/styles.rb +47 -35
  60. data/lib/axlsx/stylesheet/table_style.rb +9 -4
  61. data/lib/axlsx/stylesheet/table_style_element.rb +10 -7
  62. data/lib/axlsx/stylesheet/table_styles.rb +11 -8
  63. data/lib/axlsx/stylesheet/xf.rb +29 -25
  64. data/lib/axlsx/util/constants.rb +20 -14
  65. data/lib/axlsx/util/simple_typed_list.rb +18 -9
  66. data/lib/axlsx/util/validators.rb +13 -6
  67. data/lib/axlsx/version.rb +1 -1
  68. data/lib/axlsx/workbook/shared_strings_table.rb +19 -21
  69. data/lib/axlsx/workbook/workbook.rb +58 -34
  70. data/lib/axlsx/workbook/worksheet/cell.rb +149 -132
  71. data/lib/axlsx/workbook/worksheet/col.rb +114 -0
  72. data/lib/axlsx/workbook/worksheet/col.rb~ +0 -0
  73. data/lib/axlsx/workbook/worksheet/date_time_converter.rb +29 -0
  74. data/lib/axlsx/workbook/worksheet/page_margins.rb +97 -0
  75. data/lib/axlsx/workbook/worksheet/row.rb +40 -23
  76. data/lib/axlsx/workbook/worksheet/table.rb +96 -0
  77. data/lib/axlsx/workbook/worksheet/table.rb~ +97 -0
  78. data/lib/axlsx/workbook/worksheet/worksheet.rb +243 -127
  79. data/lib/axlsx.rb +30 -9
  80. data/lib/schema/dc.xsd +5 -5
  81. data/lib/schema/dcmitype.xsd +5 -3
  82. data/lib/schema/dcterms.xsd +15 -15
  83. data/lib/schema/opc-coreProperties.xsd +6 -2
  84. data/lib/schema/xml.xsd +7 -8
  85. data/test/#benchmark.txt# +7 -0
  86. data/test/#tc_helper.rb# +3 -0
  87. data/test/benchmark.rb +81 -0
  88. data/test/benchmark.rb~ +0 -0
  89. data/test/benchmark.txt +6 -0
  90. data/test/benchmark.txt~ +6 -0
  91. data/test/content_type/tc_content_type.rb +30 -32
  92. data/test/content_type/tc_default.rb +8 -23
  93. data/test/content_type/tc_override.rb +7 -21
  94. data/test/doc_props/tc_app.rb +2 -8
  95. data/test/doc_props/tc_core.rb +6 -7
  96. data/test/drawing/tc_axis.rb +7 -3
  97. data/test/drawing/tc_bar_3D_chart.rb +6 -7
  98. data/test/drawing/tc_bar_series.rb +4 -5
  99. data/test/drawing/tc_cat_axis.rb +2 -3
  100. data/test/drawing/tc_cat_axis_data.rb +2 -3
  101. data/test/drawing/tc_chart.rb +13 -14
  102. data/test/drawing/tc_drawing.rb +7 -8
  103. data/test/drawing/tc_graphic_frame.rb +3 -4
  104. data/test/drawing/tc_hyperlink.rb +2 -3
  105. data/test/drawing/tc_line_3d_chart.rb +5 -6
  106. data/test/drawing/tc_line_series.rb +3 -4
  107. data/test/drawing/tc_marker.rb +3 -4
  108. data/test/drawing/tc_one_cell_anchor.rb +6 -7
  109. data/test/drawing/tc_pic.rb +8 -9
  110. data/test/drawing/tc_picture_locking.rb +2 -3
  111. data/test/drawing/tc_pie_3D_chart.rb +5 -6
  112. data/test/drawing/tc_pie_series.rb +4 -5
  113. data/test/drawing/tc_scaling.rb +3 -4
  114. data/test/drawing/tc_scatter_chart.rb +43 -0
  115. data/test/drawing/tc_scatter_series.rb +20 -0
  116. data/test/drawing/tc_ser_axis.rb +2 -3
  117. data/test/drawing/tc_series.rb +4 -5
  118. data/test/drawing/tc_series_title.rb +4 -5
  119. data/test/drawing/tc_title.rb +4 -5
  120. data/test/drawing/tc_two_cell_anchor.rb +4 -5
  121. data/test/drawing/tc_val_axis.rb +2 -3
  122. data/test/drawing/tc_val_axis_data.rb +2 -3
  123. data/test/drawing/tc_view_3D.rb +6 -7
  124. data/test/example.csv +1000 -0
  125. data/test/example.xlsx +0 -0
  126. data/test/example_streamed.xlsx +0 -0
  127. data/test/profile.rb +33 -0
  128. data/test/rels/tc_relationship.rb +5 -6
  129. data/test/rels/tc_relationships.rb +4 -5
  130. data/test/stylesheet/tc_border.rb +3 -4
  131. data/test/stylesheet/tc_border_pr.rb +3 -4
  132. data/test/stylesheet/tc_cell_alignment.rb +10 -6
  133. data/test/stylesheet/tc_cell_protection.rb +2 -3
  134. data/test/stylesheet/tc_cell_style.rb +2 -3
  135. data/test/stylesheet/tc_color.rb +2 -3
  136. data/test/stylesheet/tc_fill.rb +1 -2
  137. data/test/stylesheet/tc_font.rb +12 -5
  138. data/test/stylesheet/tc_gradient_fill.rb +1 -2
  139. data/test/stylesheet/tc_gradient_stop.rb +1 -2
  140. data/test/stylesheet/tc_num_fmt.rb +1 -2
  141. data/test/stylesheet/tc_pattern_fill.rb +3 -4
  142. data/test/stylesheet/tc_styles.rb +16 -6
  143. data/test/stylesheet/tc_table_style.rb +2 -3
  144. data/test/stylesheet/tc_table_style_element.rb +2 -3
  145. data/test/stylesheet/tc_table_styles.rb +3 -4
  146. data/test/stylesheet/tc_xf.rb +16 -17
  147. data/test/tc_axlsx.rb +39 -0
  148. data/test/tc_axlsx.rb~ +0 -0
  149. data/test/tc_helper.rb +3 -0
  150. data/test/tc_helper.rb~ +3 -0
  151. data/test/tc_package.rb +13 -10
  152. data/test/util/tc_simple_typed_list.rb +8 -9
  153. data/test/util/tc_validators.rb +7 -8
  154. data/test/workbook/tc_shared_strings_table.rb +5 -6
  155. data/test/workbook/tc_workbook.rb +24 -6
  156. data/test/workbook/worksheet/table/tc_table.rb +71 -0
  157. data/test/workbook/worksheet/table/tc_table.rb~ +72 -0
  158. data/test/workbook/worksheet/tc_cell.rb +62 -18
  159. data/test/workbook/worksheet/tc_col.rb +59 -0
  160. data/test/workbook/worksheet/tc_col.rb~ +10 -0
  161. data/test/workbook/worksheet/tc_date_time_converter.rb +126 -0
  162. data/test/workbook/worksheet/tc_page_margins.rb +97 -0
  163. data/test/workbook/worksheet/tc_row.rb +54 -4
  164. data/test/workbook/worksheet/tc_worksheet.rb +177 -34
  165. metadata +69 -41
  166. data/test/drawing/tc_hyperlink.rb~ +0 -71
  167. data/test/workbook/tc_shared_strings_table.rb~ +0 -8
@@ -1,5 +1,4 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
1
+ require 'tc_helper.rb'
3
2
 
4
3
  class TestChart < Test::Unit::TestCase
5
4
 
@@ -16,7 +15,7 @@ class TestChart < Test::Unit::TestCase
16
15
  def test_initialization
17
16
  assert_equal(@p.workbook.charts.last,@chart, "the chart is in the workbook")
18
17
  assert_equal(@chart.title.text, "fishery", "the title option has been applied")
19
- assert((@chart.series.is_a?(Axlsx::SimpleTypedList) && @chart.series.empty?), "The series is initialized and empty")
18
+ assert((@chart.series.is_a?(Axlsx::SimpleTypedList) && @chart.series.empty?), "The series is initialized and empty")
20
19
  end
21
20
 
22
21
  def test_title
@@ -41,33 +40,33 @@ class TestChart < Test::Unit::TestCase
41
40
 
42
41
  end
43
42
 
44
- def end_at
43
+ def test_end_at
45
44
  @chart.end_at 25, 90
46
- assert_equal(@chart.graphic_frame.anchor.from.col, 25)
45
+ assert_equal(@chart.graphic_frame.anchor.to.col, 25)
47
46
  assert_equal(@chart.graphic_frame.anchor.to.row, 90)
48
47
  end
49
48
 
50
- def test_add_series
49
+ def test_add_series
51
50
  s = @chart.add_series :data=>[0,1,2,3], :labels => ["one", 1, "anything"], :title=>"bob"
52
51
  assert_equal(@chart.series.last, s, "series has been added to chart series collection")
53
52
  assert_equal(s.title.text, "bob", "series title has been applied")
54
53
  assert_equal(s.data, [0,1,2,3], "data option applied")
55
- assert_equal(s.labels, ["one",1,"anything"], "labels option applied")
56
- end
57
-
54
+ assert_equal(s.labels, ["one",1,"anything"], "labels option applied")
55
+ end
56
+
58
57
  def test_pn
59
58
  assert_equal(@chart.pn, "charts/chart1.xml")
60
59
  end
61
-
62
- def test_to_xml
60
+
61
+ def test_to_xml_string
63
62
  schema = Nokogiri::XML::Schema(File.open(Axlsx::DRAWING_XSD))
64
- doc = Nokogiri::XML(@chart.to_xml)
63
+ doc = Nokogiri::XML(@chart.to_xml_string)
65
64
  errors = []
66
65
  schema.validate(doc).each do |error|
67
66
  errors.push error
68
67
  puts error.message
69
68
  end
70
69
  assert(errors.empty?, "error free validation")
71
- end
72
-
70
+ end
71
+
73
72
  end
@@ -1,8 +1,7 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
1
+ require 'tc_helper.rb'
3
2
 
4
3
  class TestDrawing < Test::Unit::TestCase
5
- def setup
4
+ def setup
6
5
  p = Axlsx::Package.new
7
6
  @ws = p.workbook.add_worksheet
8
7
 
@@ -24,14 +23,14 @@ class TestDrawing < Test::Unit::TestCase
24
23
  assert_equal([anchor.to.row, anchor.to.col], [1,1], "options for start at are applied")
25
24
  assert_equal(chart.title.text, "bob", "option for title is applied")
26
25
  end
27
-
26
+
28
27
  def test_add_image
29
28
  src = File.dirname(__FILE__) + "/../../examples/image1.jpeg"
30
29
  image = @ws.add_image(:image_src => src, :start_at=>[0,0], :width=>600, :height=>400)
31
30
  assert(@ws.drawing.anchors.last.is_a?(Axlsx::OneCellAnchor))
32
31
  assert(image.is_a?(Axlsx::Pic))
33
32
  assert_equal(600, image.width)
34
- assert_equal(400, image.height)
33
+ assert_equal(400, image.height)
35
34
  end
36
35
 
37
36
  def test_charts
@@ -39,7 +38,7 @@ class TestDrawing < Test::Unit::TestCase
39
38
  chart = @ws.add_chart(Axlsx::Pie3DChart, :title=>"bob", :start_at=>[0,0], :end_at=>[1,1])
40
39
  assert_equal(@ws.drawing.charts.last, chart, "add chart is returned")
41
40
  chart = @ws.add_chart(Axlsx::Pie3DChart, :title=>"nancy", :start_at=>[1,5], :end_at=>[5,10])
42
- assert_equal(@ws.drawing.charts.last, chart, "add chart is returned")
41
+ assert_equal(@ws.drawing.charts.last, chart, "add chart is returned")
43
42
  end
44
43
 
45
44
  def test_pn
@@ -53,7 +52,7 @@ class TestDrawing < Test::Unit::TestCase
53
52
  def test_rId
54
53
  assert_equal(@ws.drawing.rId, "rId1")
55
54
  end
56
-
55
+
57
56
  def test_index
58
57
  assert_equal(@ws.drawing.index, @ws.workbook.drawings.index(@ws.drawing))
59
58
  end
@@ -68,7 +67,7 @@ class TestDrawing < Test::Unit::TestCase
68
67
 
69
68
  def test_to_xml
70
69
  schema = Nokogiri::XML::Schema(File.open(Axlsx::DRAWING_XSD))
71
- doc = Nokogiri::XML(@ws.drawing.to_xml)
70
+ doc = Nokogiri::XML(@ws.drawing.to_xml_string)
72
71
  errors = []
73
72
  schema.validate(doc).each do |error|
74
73
  errors.push error
@@ -1,8 +1,7 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
1
+ require 'tc_helper.rb'
3
2
 
4
3
  class TestGraphicFrame < Test::Unit::TestCase
5
- def setup
4
+ def setup
6
5
  p = Axlsx::Package.new
7
6
  @ws = p.workbook.add_worksheet
8
7
  @chart = @ws.add_chart Axlsx::Chart
@@ -20,7 +19,7 @@ class TestGraphicFrame < Test::Unit::TestCase
20
19
  def test_rId
21
20
  assert_equal(@frame.rId, "rId1")
22
21
  chart = @ws.add_chart Axlsx::Chart
23
- assert_equal(chart.graphic_frame.rId, "rId2")
22
+ assert_equal(chart.graphic_frame.rId, "rId2")
24
23
  end
25
24
 
26
25
  end
@@ -1,5 +1,4 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
1
+ require 'tc_helper.rb'
3
2
 
4
3
  class TestHyperlink < Test::Unit::TestCase
5
4
 
@@ -66,5 +65,5 @@ class TestHyperlink < Test::Unit::TestCase
66
65
  assert_raise(ArgumentError) {@hyperlink.history = "bob"}
67
66
  assert_equal(@hyperlink.history, false )
68
67
  end
69
-
68
+
70
69
  end
@@ -1,5 +1,4 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
1
+ require 'tc_helper.rb'
3
2
 
4
3
  class TestLine3DChart < Test::Unit::TestCase
5
4
 
@@ -13,7 +12,7 @@ class TestLine3DChart < Test::Unit::TestCase
13
12
  def teardown
14
13
  end
15
14
 
16
- def test_initialization
15
+ def test_initialization
17
16
  assert_equal(@chart.grouping, :standard, "grouping defualt incorrect")
18
17
  assert_equal(@chart.series_type, Axlsx::LineSeries, "series type incorrect")
19
18
  assert(@chart.catAxis.is_a?(Axlsx::CatAxis), "category axis not created")
@@ -36,13 +35,13 @@ class TestLine3DChart < Test::Unit::TestCase
36
35
 
37
36
  def test_to_xml
38
37
  schema = Nokogiri::XML::Schema(File.open(Axlsx::DRAWING_XSD))
39
- doc = Nokogiri::XML(@chart.to_xml)
38
+ doc = Nokogiri::XML(@chart.to_xml_string)
40
39
  errors = []
41
40
  schema.validate(doc).each do |error|
42
41
  errors.push error
43
42
  puts error.message
44
43
  end
45
44
  assert(errors.empty?, "error free validation")
46
- end
47
-
45
+ end
46
+
48
47
  end
@@ -1,5 +1,4 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
1
+ require 'tc_helper.rb'
3
2
 
4
3
  class TestLineSeries < Test::Unit::TestCase
5
4
 
@@ -9,11 +8,11 @@ class TestLineSeries < Test::Unit::TestCase
9
8
  chart = @ws.drawing.add_chart Axlsx::Line3DChart, :title => "fishery"
10
9
  @series = chart.add_series :data=>[0,1,2], :labels=>["zero", "one", "two"], :title=>"bob"
11
10
  end
12
-
11
+
13
12
  def test_initialize
14
13
  assert_equal(@series.title.text, "bob", "series title has been applied")
15
14
  assert_equal(@series.data, [0,1,2], "data option applied")
16
- assert_equal(@series.labels, ["zero", "one","two"], "labels option applied")
15
+ assert_equal(@series.labels, ["zero", "one","two"], "labels option applied")
17
16
  end
18
17
 
19
18
  def test_data
@@ -1,8 +1,7 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
1
+ require 'tc_helper.rb'
3
2
 
4
3
  class TestMarker < Test::Unit::TestCase
5
- def setup
4
+ def setup
6
5
  @marker = Axlsx::Marker.new
7
6
  end
8
7
 
@@ -41,5 +40,5 @@ class TestMarker < Test::Unit::TestCase
41
40
  assert_equal(@marker.col, 5)
42
41
  assert_equal(@marker.row, 10)
43
42
  end
44
-
43
+
45
44
  end
@@ -1,9 +1,8 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
1
+ require 'tc_helper.rb'
3
2
 
4
3
  class TestOneCellAnchor < Test::Unit::TestCase
5
4
 
6
- def setup
5
+ def setup
7
6
  @p = Axlsx::Package.new
8
7
  @ws = @p.workbook.add_worksheet
9
8
  @test_img = File.dirname(__FILE__) + "/../../examples/image1.jpeg"
@@ -22,7 +21,7 @@ class TestOneCellAnchor < Test::Unit::TestCase
22
21
  end
23
22
 
24
23
  def test_from
25
- assert(@anchor.from.is_a?(Axlsx::Marker))
24
+ assert(@anchor.from.is_a?(Axlsx::Marker))
26
25
  end
27
26
 
28
27
  def test_object
@@ -36,13 +35,13 @@ class TestOneCellAnchor < Test::Unit::TestCase
36
35
  def test_width
37
36
  assert_raise(ArgumentError) { @anchor.width = "a" }
38
37
  assert_nothing_raised { @anchor.width = 600 }
39
- assert_equal(@anchor.width, 600)
38
+ assert_equal(@anchor.width, 600)
40
39
  end
41
40
 
42
41
  def test_height
43
42
  assert_raise(ArgumentError) { @anchor.height = "a" }
44
43
  assert_nothing_raised { @anchor.height = 400 }
45
- assert_equal(400, @anchor.height)
44
+ assert_equal(400, @anchor.height)
46
45
  end
47
46
 
48
47
  def test_ext
@@ -63,5 +62,5 @@ class TestOneCellAnchor < Test::Unit::TestCase
63
62
  assert_equal(2, i.anchor.from.row)
64
63
  assert_equal(@test_img, i.image_src)
65
64
  end
66
-
65
+
67
66
  end
@@ -1,5 +1,4 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
1
+ require 'tc_helper.rb'
3
2
 
4
3
  class TestPic < Test::Unit::TestCase
5
4
 
@@ -17,7 +16,7 @@ class TestPic < Test::Unit::TestCase
17
16
  assert_equal(@p.workbook.images.first, @image)
18
17
  assert_equal(@image.image_src, @test_img)
19
18
  end
20
-
19
+
21
20
  def test_hyperlink
22
21
  assert_equal(@image.hyperlink, nil)
23
22
  @image.hyperlink = "http://axlsx.blogspot.com"
@@ -40,13 +39,13 @@ class TestPic < Test::Unit::TestCase
40
39
  def test_width
41
40
  assert_raise(ArgumentError) { @image.width = "a" }
42
41
  assert_nothing_raised { @image.width = 600 }
43
- assert_equal(@image.width, 600)
42
+ assert_equal(@image.width, 600)
44
43
  end
45
44
 
46
45
  def test_height
47
46
  assert_raise(ArgumentError) { @image.height = "a" }
48
47
  assert_nothing_raised { @image.height = 600 }
49
- assert_equal(600, @image.height)
48
+ assert_equal(600, @image.height)
50
49
  end
51
50
 
52
51
  def test_image_src
@@ -62,16 +61,16 @@ class TestPic < Test::Unit::TestCase
62
61
  assert_nothing_raised { @image.descr = "test" }
63
62
  assert_equal(@image.descr, "test")
64
63
  end
65
-
64
+
66
65
  def test_to_xml
67
66
  schema = Nokogiri::XML::Schema(File.open(Axlsx::DRAWING_XSD))
68
- doc = Nokogiri::XML(@image.anchor.drawing.to_xml)
67
+ doc = Nokogiri::XML(@image.anchor.drawing.to_xml_string)
69
68
  errors = []
70
69
  schema.validate(doc).each do |error|
71
70
  errors.push error
72
71
  puts error.message
73
72
  end
74
73
  assert(errors.empty?, "error free validation")
75
- end
76
-
74
+ end
75
+
77
76
  end
@@ -1,8 +1,7 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
1
+ require 'tc_helper.rb'
3
2
 
4
3
  class TestPictureLocking < Test::Unit::TestCase
5
- def setup
4
+ def setup
6
5
  @item = Axlsx::PictureLocking.new
7
6
  end
8
7
  def teardown
@@ -1,5 +1,4 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
1
+ require 'tc_helper.rb'
3
2
 
4
3
  class TestPie3DChart < Test::Unit::TestCase
5
4
 
@@ -18,16 +17,16 @@ class TestPie3DChart < Test::Unit::TestCase
18
17
  assert_equal(@chart.view3D.perspective, 30, "view 3d default perspective incorrect")
19
18
  assert_equal(@chart.series_type, Axlsx::PieSeries, "series type incorrect")
20
19
  end
21
-
20
+
22
21
  def test_to_xml
23
22
  schema = Nokogiri::XML::Schema(File.open(Axlsx::DRAWING_XSD))
24
- doc = Nokogiri::XML(@chart.to_xml)
23
+ doc = Nokogiri::XML(@chart.to_xml_string)
25
24
  errors = []
26
25
  schema.validate(doc).each do |error|
27
26
  errors.push error
28
27
  puts error.message
29
28
  end
30
29
  assert(errors.empty?, "error free validation")
31
- end
32
-
30
+ end
31
+
33
32
  end
@@ -1,5 +1,4 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
1
+ require 'tc_helper.rb'
3
2
 
4
3
  class TestPieSeries < Test::Unit::TestCase
5
4
 
@@ -9,12 +8,12 @@ class TestPieSeries < Test::Unit::TestCase
9
8
  chart = @ws.drawing.add_chart Axlsx::Pie3DChart, :title => "fishery"
10
9
  @series = chart.add_series :data=>[0,1,2], :labels=>["zero", "one", "two"], :title=>"bob"
11
10
  end
12
-
11
+
13
12
  def test_initialize
14
13
  assert_equal(@series.title.text, "bob", "series title has been applied")
15
14
  assert_equal(@series.data, [0,1,2], "data option applied")
16
- assert_equal(@series.labels, ["zero", "one","two"], "labels option applied")
17
- assert_equal(@series.explosion, nil, "series shape has been applied")
15
+ assert_equal(@series.labels, ["zero", "one","two"], "labels option applied")
16
+ assert_equal(@series.explosion, nil, "series shape has been applied")
18
17
  end
19
18
 
20
19
  def test_data
@@ -1,8 +1,7 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
1
+ require 'tc_helper.rb'
3
2
 
4
3
  class TestScaling < Test::Unit::TestCase
5
- def setup
4
+ def setup
6
5
  @scaling = Axlsx::Scaling.new
7
6
  end
8
7
 
@@ -33,5 +32,5 @@ class TestScaling < Test::Unit::TestCase
33
32
  assert_raise(ArgumentError) { @scaling.min = 1}
34
33
  assert_nothing_raised {@scaling.min = 10.5}
35
34
  end
36
-
35
+
37
36
  end
@@ -0,0 +1,43 @@
1
+ require 'tc_helper.rb'
2
+
3
+ class TestScatterChart < Test::Unit::TestCase
4
+ def setup
5
+ @p = Axlsx::Package.new
6
+ @chart = nil
7
+ ws = @p.workbook.add_worksheet do |sheet|
8
+ sheet.add_row ["First", 1, 5, 7, 9]
9
+ sheet.add_row ["", 1, 25, 49, 81]
10
+ sheet.add_row ["Second", 5, 2, 14, 9]
11
+ sheet.add_row ["", 5, 10, 15, 20]
12
+ sheet.add_chart(Axlsx::ScatterChart, :title => "example 7: Scatter Chart") do |chart|
13
+ chart.start_at 0, 4
14
+ chart.end_at 10, 19
15
+ chart.add_series :xData => sheet["B1:E1"], :yData => sheet["B2:E2"], :title => sheet["A1"]
16
+ chart.add_series :xData => sheet["B3:E3"], :yData => sheet["B4:E4"], :title => sheet["A3"]
17
+ @chart = chart
18
+ end
19
+ end
20
+ end
21
+
22
+ def teardown
23
+ end
24
+
25
+ def test_initialization
26
+ assert_equal(@chart.scatterStyle, :lineMarker, "scatterStyle defualt incorrect")
27
+ assert_equal(@chart.series_type, Axlsx::ScatterSeries, "series type incorrect")
28
+ assert(@chart.xValAxis.is_a?(Axlsx::ValAxis), "independant value axis not created")
29
+ assert(@chart.yValAxis.is_a?(Axlsx::ValAxis), "dependant value axis not created")
30
+ end
31
+
32
+ def test_to_xml_string
33
+ schema = Nokogiri::XML::Schema(File.open(Axlsx::DRAWING_XSD))
34
+ doc = Nokogiri::XML(@chart.to_xml_string)
35
+ errors = []
36
+ schema.validate(doc).each do |error|
37
+ errors.push error
38
+ puts error.message
39
+ end
40
+ assert(errors.empty?, "error free validation")
41
+ end
42
+
43
+ end
@@ -0,0 +1,20 @@
1
+ require 'tc_helper.rb'
2
+
3
+ class TestScatterSeries < Test::Unit::TestCase
4
+
5
+ def setup
6
+ p = Axlsx::Package.new
7
+ @ws = p.workbook.add_worksheet :name=>"hmmm"
8
+ chart = @ws.drawing.add_chart Axlsx::ScatterChart, :title => "Scatter Chart"
9
+ @series = chart.add_series :xData=>[1,2,4], :yData=>[1,3,9], :title=>"exponents"
10
+ end
11
+
12
+ def test_initialize
13
+ assert_equal(@series.title.text, "exponents", "series title has been applied")
14
+ end
15
+
16
+ def test_data
17
+ assert_equal(@series.xData, [1,2,4])
18
+ assert_equal(@series.yData, [1,3,9])
19
+ end
20
+ end
@@ -1,8 +1,7 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
1
+ require 'tc_helper.rb'
3
2
 
4
3
  class TestSerAxis < Test::Unit::TestCase
5
- def setup
4
+ def setup
6
5
  @axis = Axlsx::SerAxis.new 12345, 54321
7
6
  end
8
7
  def teardown
@@ -1,5 +1,4 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
1
+ require 'tc_helper.rb'
3
2
 
4
3
  class TestSeries < Test::Unit::TestCase
5
4
 
@@ -9,16 +8,16 @@ class TestSeries < Test::Unit::TestCase
9
8
  chart = @ws.drawing.add_chart Axlsx::Chart, :title => "fishery"
10
9
  @series = chart.add_series :title=>"bob"
11
10
  end
12
-
11
+
13
12
  def test_initialize
14
13
  assert_equal(@series.title.text, "bob", "series title has been applied")
15
14
  assert_equal(@series.order, @series.index, "order is index by default")
16
- assert_equal(@series.index, @series.chart.series.index(@series), "index is applied")
15
+ assert_equal(@series.index, @series.chart.series.index(@series), "index is applied")
17
16
  end
18
17
 
19
18
  def test_order
20
19
  @series.order = 2
21
20
  assert_equal(@series.order, 2)
22
21
  end
23
-
22
+
24
23
  end
@@ -1,8 +1,7 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
1
+ require 'tc_helper.rb'
3
2
 
4
3
  class TestSeriesTitle < Test::Unit::TestCase
5
- def setup
4
+ def setup
6
5
  @p = Axlsx::Package.new
7
6
  ws = @p.workbook.add_worksheet
8
7
  @row = ws.add_row ["one", 1, Time.now]
@@ -21,7 +20,7 @@ class TestSeriesTitle < Test::Unit::TestCase
21
20
  def test_text
22
21
  assert_raise(ArgumentError, "text must be a string") { @title.text = 123 }
23
22
  @title.cell = @row.cells.first
24
- @title.text = "bob"
23
+ @title.text = "bob"
25
24
  assert(@title.cell == nil, "setting title with text clears the cell")
26
25
  end
27
26
 
@@ -30,5 +29,5 @@ class TestSeriesTitle < Test::Unit::TestCase
30
29
  @title.cell = @row.cells.first
31
30
  assert(@title.text == "one")
32
31
  end
33
-
32
+
34
33
  end
@@ -1,8 +1,7 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
1
+ require 'tc_helper.rb'
3
2
 
4
3
  class TestTitle < Test::Unit::TestCase
5
- def setup
4
+ def setup
6
5
  @p = Axlsx::Package.new
7
6
  ws = @p.workbook.add_worksheet
8
7
  @row = ws.add_row ["one", 1, Time.now]
@@ -21,7 +20,7 @@ class TestTitle < Test::Unit::TestCase
21
20
  def test_text
22
21
  assert_raise(ArgumentError, "text must be a string") { @title.text = 123 }
23
22
  @title.cell = @row.cells.first
24
- @title.text = "bob"
23
+ @title.text = "bob"
25
24
  assert(@title.cell == nil, "setting title with text clears the cell")
26
25
  end
27
26
 
@@ -30,5 +29,5 @@ class TestTitle < Test::Unit::TestCase
30
29
  @title.cell = @row.cells.first
31
30
  assert(@title.text == "one")
32
31
  end
33
-
32
+
34
33
  end
@@ -1,9 +1,8 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
1
+ require 'tc_helper.rb'
3
2
 
4
3
  class TestTwoCellAnchor < Test::Unit::TestCase
5
4
 
6
- def setup
5
+ def setup
7
6
  p = Axlsx::Package.new
8
7
  @ws = p.workbook.add_worksheet
9
8
  row = @ws.add_row ["one", 1, Time.now]
@@ -22,7 +21,7 @@ class TestTwoCellAnchor < Test::Unit::TestCase
22
21
  assert(@anchor.to.row == 10)
23
22
  end
24
23
 
25
-
24
+
26
25
  def test_options
27
26
  assert_raise(ArgumentError, 'invalid start_at') { @ws.add_chart Axlsx::Chart, :start_at=>[1] }
28
27
  assert_raise(ArgumentError, 'invalid end_at') { @ws.add_chart Axlsx::Chart, :start_at=>[1,2], :end_at => ["a", 4] }
@@ -34,5 +33,5 @@ class TestTwoCellAnchor < Test::Unit::TestCase
34
33
  assert_equal(a.graphic_frame.anchor.to.col, 90)
35
34
  assert_equal(a.graphic_frame.anchor.to.row, 45)
36
35
  end
37
-
36
+
38
37
  end
@@ -1,8 +1,7 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
1
+ require 'tc_helper.rb'
3
2
 
4
3
  class TestValAxis < Test::Unit::TestCase
5
- def setup
4
+ def setup
6
5
  @axis = Axlsx::ValAxis.new 12345, 54321
7
6
  end
8
7
  def teardown
@@ -1,5 +1,4 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
1
+ require 'tc_helper.rb'
3
2
 
4
3
  class TestValAxisData < Test::Unit::TestCase
5
4
 
@@ -9,7 +8,7 @@ class TestValAxisData < Test::Unit::TestCase
9
8
  chart = @ws.drawing.add_chart Axlsx::Line3DChart
10
9
  @series = chart.add_series :data=>[0,1,2]
11
10
  end
12
-
11
+
13
12
  def test_initialize
14
13
  assert(@series.data.is_a?Axlsx::SimpleTypedList)
15
14
  assert_equal(@series.data, [0,1,2])
@@ -1,14 +1,13 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
1
+ require 'tc_helper.rb'
3
2
 
4
3
  class TestView3D < Test::Unit::TestCase
5
- def setup
4
+ def setup
6
5
  @view = Axlsx::View3D.new
7
6
  end
8
7
 
9
8
  def teardown
10
9
  end
11
-
10
+
12
11
  def test_options
13
12
  v = Axlsx::View3D.new :rotX => 10, :rotY => 5, :hPercent => "30%", :depthPercent => "45%", :rAngAx => false, :perspective => 10
14
13
  assert_equal(v.rotX, 10)
@@ -18,7 +17,7 @@ class TestView3D < Test::Unit::TestCase
18
17
  assert_equal(v.rAngAx, false)
19
18
  assert_equal(v.perspective, 10)
20
19
  end
21
-
20
+
22
21
  def test_rotX
23
22
  assert_raise(ArgumentError) {@view.rotX = "bob"}
24
23
  assert_nothing_raised {@view.rotX = -90}
@@ -44,12 +43,12 @@ class TestView3D < Test::Unit::TestCase
44
43
  assert_raise(ArgumentError) {@view.rAngAx = "bob"}
45
44
  assert_nothing_raised {@view.rAngAx = true}
46
45
  end
47
-
46
+
48
47
  def test_perspective
49
48
  assert_raise(ArgumentError) {@view.perspective = "bob"}
50
49
  assert_nothing_raised {@view.perspective = 30}
51
50
  end
52
51
 
53
52
 
54
-
53
+
55
54
  end