axlsx 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (207) hide show
  1. data/README.md +21 -3
  2. data/doc/Axlsx.html +150 -6
  3. data/doc/Axlsx/App.html +1 -1
  4. data/doc/Axlsx/Axis.html +1 -1
  5. data/doc/Axlsx/Bar3DChart.html +1 -1
  6. data/doc/Axlsx/BarSeries.html +1 -1
  7. data/doc/Axlsx/Border.html +1 -1
  8. data/doc/Axlsx/BorderPr.html +1 -1
  9. data/doc/Axlsx/CatAxis.html +1 -1
  10. data/doc/Axlsx/CatAxisData.html +7 -5
  11. data/doc/Axlsx/Cell.html +1 -1
  12. data/doc/Axlsx/CellAlignment.html +1 -1
  13. data/doc/Axlsx/CellProtection.html +1 -1
  14. data/doc/Axlsx/CellStyle.html +1 -1
  15. data/doc/Axlsx/Chart.html +16 -16
  16. data/doc/Axlsx/Color.html +1 -1
  17. data/doc/Axlsx/ContentType.html +1 -1
  18. data/doc/Axlsx/Core.html +1 -1
  19. data/doc/Axlsx/DataTypeValidator.html +1 -1
  20. data/doc/Axlsx/Default.html +1 -1
  21. data/doc/Axlsx/Drawing.html +243 -65
  22. data/doc/Axlsx/Fill.html +1 -1
  23. data/doc/Axlsx/Font.html +1 -1
  24. data/doc/Axlsx/GradientFill.html +1 -1
  25. data/doc/Axlsx/GradientStop.html +1 -1
  26. data/doc/Axlsx/GraphicFrame.html +21 -21
  27. data/doc/Axlsx/Line3DChart.html +1 -1
  28. data/doc/Axlsx/LineSeries.html +6 -8
  29. data/doc/Axlsx/Marker.html +1 -1
  30. data/doc/Axlsx/NumFmt.html +1 -1
  31. data/doc/Axlsx/OneCellAnchor.html +988 -0
  32. data/doc/Axlsx/Override.html +1 -1
  33. data/doc/Axlsx/Package.html +127 -75
  34. data/doc/Axlsx/PatternFill.html +1 -1
  35. data/doc/Axlsx/Pic.html +1532 -0
  36. data/doc/Axlsx/Pie3DChart.html +5 -7
  37. data/doc/Axlsx/PieSeries.html +1 -1
  38. data/doc/Axlsx/RegexValidator.html +1 -1
  39. data/doc/Axlsx/Relationship.html +6 -6
  40. data/doc/Axlsx/Relationships.html +1 -1
  41. data/doc/Axlsx/RestrictionValidator.html +1 -1
  42. data/doc/Axlsx/Row.html +1 -1
  43. data/doc/Axlsx/Scaling.html +1 -1
  44. data/doc/Axlsx/SerAxis.html +1 -1
  45. data/doc/Axlsx/Series.html +1 -1
  46. data/doc/Axlsx/SeriesTitle.html +1 -1
  47. data/doc/Axlsx/SimpleTypedList.html +1 -1
  48. data/doc/Axlsx/Styles.html +1 -1
  49. data/doc/Axlsx/TableStyle.html +1 -1
  50. data/doc/Axlsx/TableStyleElement.html +1 -1
  51. data/doc/Axlsx/TableStyles.html +1 -1
  52. data/doc/Axlsx/Title.html +1 -1
  53. data/doc/Axlsx/TwoCellAnchor.html +165 -61
  54. data/doc/Axlsx/ValAxis.html +1 -1
  55. data/doc/Axlsx/ValAxisData.html +1 -1
  56. data/doc/Axlsx/View3D.html +1 -1
  57. data/doc/Axlsx/Workbook.html +151 -47
  58. data/doc/Axlsx/Worksheet.html +172 -35
  59. data/doc/Axlsx/Xf.html +1 -1
  60. data/doc/_index.html +15 -1
  61. data/doc/class_list.html +1 -1
  62. data/doc/file.README.html +29 -4
  63. data/doc/index.html +29 -4
  64. data/doc/method_list.html +571 -363
  65. data/doc/top-level-namespace.html +1 -1
  66. data/examples/example.rb +13 -0
  67. data/examples/image1.gif +0 -0
  68. data/examples/image1.jpeg +0 -0
  69. data/examples/image1.jpg +0 -0
  70. data/examples/image1.png +0 -0
  71. data/lib/axlsx/drawing/bar_series.rb +0 -1
  72. data/lib/axlsx/drawing/cat_axis_data.rb +1 -0
  73. data/lib/axlsx/drawing/chart.rb +0 -1
  74. data/lib/axlsx/drawing/drawing.rb +31 -7
  75. data/lib/axlsx/drawing/graphic_frame.rb +0 -2
  76. data/lib/axlsx/drawing/line_series.rb +0 -1
  77. data/lib/axlsx/drawing/one_cell_anchor.rb +89 -0
  78. data/lib/axlsx/drawing/pic.rb +158 -0
  79. data/lib/axlsx/drawing/pie_3D_chart.rb +0 -1
  80. data/lib/axlsx/drawing/two_cell_anchor.rb +17 -4
  81. data/lib/axlsx/package.rb +31 -5
  82. data/lib/axlsx/rels/relationship.rb +1 -2
  83. data/lib/axlsx/util/constants.rb +24 -0
  84. data/lib/axlsx/util/validators.rb +2 -2
  85. data/lib/axlsx/version.rb +1 -1
  86. data/lib/axlsx/workbook/workbook.rb +8 -0
  87. data/lib/axlsx/workbook/worksheet/worksheet.rb +10 -1
  88. data/test/drawing/tc_drawing.rb +10 -1
  89. data/test/drawing/tc_one_cell_anchor.rb +67 -0
  90. data/test/drawing/tc_pic.rb +71 -0
  91. data/test/tc_package.rb +0 -2
  92. metadata +13 -118
  93. data/examples/#example.rb# +0 -87
  94. data/examples/example.rb~ +0 -79
  95. data/examples/multi_chart.xlsx +0 -0
  96. data/lib/axlsx.rb~ +0 -67
  97. data/lib/axlsx/content_type/content_type.rb~ +0 -20
  98. data/lib/axlsx/content_type/default.rb~ +0 -32
  99. data/lib/axlsx/content_type/override.rb~ +0 -30
  100. data/lib/axlsx/doc_props/app.rb~ +0 -127
  101. data/lib/axlsx/doc_props/core.rb~ +0 -25
  102. data/lib/axlsx/drawing/#bar_series.rb# +0 -62
  103. data/lib/axlsx/drawing/axis.rb~ +0 -0
  104. data/lib/axlsx/drawing/bar_3D_chart.rb~ +0 -64
  105. data/lib/axlsx/drawing/bar_series.rb~ +0 -92
  106. data/lib/axlsx/drawing/cat_axis.rb~ +0 -32
  107. data/lib/axlsx/drawing/cat_axis_data.rb~ +0 -28
  108. data/lib/axlsx/drawing/chart.rb~ +0 -0
  109. data/lib/axlsx/drawing/drawing.rb~ +0 -102
  110. data/lib/axlsx/drawing/graphic_frame.rb~ +0 -40
  111. data/lib/axlsx/drawing/line_3D_chart.rb~ +0 -138
  112. data/lib/axlsx/drawing/line_series.rb~ +0 -91
  113. data/lib/axlsx/drawing/marker.rb~ +0 -50
  114. data/lib/axlsx/drawing/pie_3D_chart.rb~ +0 -132
  115. data/lib/axlsx/drawing/pie_series.rb~ +0 -0
  116. data/lib/axlsx/drawing/scaling.rb~ +0 -0
  117. data/lib/axlsx/drawing/ser_axis.rb~ +0 -48
  118. data/lib/axlsx/drawing/series.rb~ +0 -114
  119. data/lib/axlsx/drawing/series_title.rb~ +0 -18
  120. data/lib/axlsx/drawing/title.rb~ +0 -69
  121. data/lib/axlsx/drawing/two_cell_anchor.rb~ +0 -70
  122. data/lib/axlsx/drawing/val_axis.rb~ +0 -34
  123. data/lib/axlsx/drawing/val_axis_data.rb~ +0 -29
  124. data/lib/axlsx/drawing/view_3D.rb~ +0 -21
  125. data/lib/axlsx/package.rb~ +0 -181
  126. data/lib/axlsx/rels/relationship.rb~ +0 -18
  127. data/lib/axlsx/rels/relationships.rb~ +0 -23
  128. data/lib/axlsx/stylesheet/border.rb~ +0 -24
  129. data/lib/axlsx/stylesheet/border_pr.rb~ +0 -64
  130. data/lib/axlsx/stylesheet/cell_alignment.rb~ +0 -93
  131. data/lib/axlsx/stylesheet/cell_protection.rb~ +0 -16
  132. data/lib/axlsx/stylesheet/cell_style.rb~ +0 -61
  133. data/lib/axlsx/stylesheet/color.rb~ +0 -56
  134. data/lib/axlsx/stylesheet/fill.rb~ +0 -31
  135. data/lib/axlsx/stylesheet/font.rb~ +0 -33
  136. data/lib/axlsx/stylesheet/gradient_fill.rb~ +0 -70
  137. data/lib/axlsx/stylesheet/gradient_stop.rb~ +0 -15
  138. data/lib/axlsx/stylesheet/num_fmt.rb~ +0 -60
  139. data/lib/axlsx/stylesheet/pattern_fill.rb~ +0 -63
  140. data/lib/axlsx/stylesheet/styles.rb~ +0 -279
  141. data/lib/axlsx/stylesheet/table_style.rb~ +0 -43
  142. data/lib/axlsx/stylesheet/table_style_element.rb~ +0 -66
  143. data/lib/axlsx/stylesheet/table_styles.rb~ +0 -36
  144. data/lib/axlsx/stylesheet/xf.rb~ +0 -37
  145. data/lib/axlsx/util/constants.rb~ +0 -187
  146. data/lib/axlsx/util/monkey_patches_for_true_zip_stream.rb~ +0 -61
  147. data/lib/axlsx/util/simple_typed_list.rb~ +0 -79
  148. data/lib/axlsx/util/validators.rb~ +0 -132
  149. data/lib/axlsx/util/xml_escape.rb~ +0 -6
  150. data/lib/axlsx/workbook/workbook.rb~ +0 -130
  151. data/lib/axlsx/workbook/worksheet/cell.rb~ +0 -185
  152. data/lib/axlsx/workbook/worksheet/row.rb~ +0 -92
  153. data/lib/axlsx/workbook/worksheet/worksheet.rb~ +0 -194
  154. data/test/content_type/tc_content_type.rb~ +0 -81
  155. data/test/content_type/tc_default.rb~ +0 -40
  156. data/test/content_type/tc_override.rb~ +0 -40
  157. data/test/doc_props/tc_app.rb~ +0 -19
  158. data/test/drawing/tc_axis.rb~ +0 -0
  159. data/test/drawing/tc_bar_3D_chart.rb~ +0 -66
  160. data/test/drawing/tc_bar_series.rb~ +0 -31
  161. data/test/drawing/tc_cat_axis.rb~ +0 -39
  162. data/test/drawing/tc_cat_axis_data.rb~ +0 -32
  163. data/test/drawing/tc_chart.rb~ +0 -59
  164. data/test/drawing/tc_graphic_frame.rb~ +0 -21
  165. data/test/drawing/tc_line_3d_chart.rb~ +0 -48
  166. data/test/drawing/tc_line_series.rb~ +0 -34
  167. data/test/drawing/tc_marker.rb~ +0 -26
  168. data/test/drawing/tc_pie_3D_chart.rb~ +0 -33
  169. data/test/drawing/tc_pie_series.rb~ +0 -26
  170. data/test/drawing/tc_scaling.rb~ +0 -45
  171. data/test/drawing/tc_ser_axis.rb~ +0 -20
  172. data/test/drawing/tc_series.rb~ +0 -31
  173. data/test/drawing/tc_series_title.rb~ +0 -34
  174. data/test/drawing/tc_title.rb~ +0 -34
  175. data/test/drawing/tc_two_cell_anchor.rb~ +0 -37
  176. data/test/drawing/tc_val_axis.rb~ +0 -32
  177. data/test/drawing/tc_val_axis_data.rb~ +0 -18
  178. data/test/drawing/tc_view_3D.rb~ +0 -37
  179. data/test/rels/tc_relationship.rb~ +0 -39
  180. data/test/rels/tc_relationships.rb~ +0 -37
  181. data/test/stylesheet/tc_border.rb~ +0 -31
  182. data/test/stylesheet/tc_border_pr.rb~ +0 -31
  183. data/test/stylesheet/tc_cell_alignment.rb~ +0 -38
  184. data/test/stylesheet/tc_cell_protection.rb~ +0 -77
  185. data/test/stylesheet/tc_cell_style.rb~ +0 -30
  186. data/test/stylesheet/tc_color.rb~ +0 -38
  187. data/test/stylesheet/tc_fill.rb~ +0 -19
  188. data/test/stylesheet/tc_font.rb~ +0 -19
  189. data/test/stylesheet/tc_gradient_fill.rb~ +0 -114
  190. data/test/stylesheet/tc_gradient_stop.rb~ +0 -65
  191. data/test/stylesheet/tc_num_fmt.rb~ +0 -32
  192. data/test/stylesheet/tc_pattern_fill.rb~ +0 -31
  193. data/test/stylesheet/tc_table_style.rb~ +0 -38
  194. data/test/stylesheet/tc_table_style_element.rb~ +0 -37
  195. data/test/stylesheet/tc_table_styles.rb~ +0 -37
  196. data/test/stylesheet/tc_xf.rb~ +0 -30
  197. data/test/tc_app.rb~ +0 -19
  198. data/test/tc_border_pr.rb~ +0 -21
  199. data/test/tc_package.rb~ +0 -64
  200. data/test/tc_pie_3D_chart.rb~ +0 -66
  201. data/test/tc_relationships.rb~ +0 -37
  202. data/test/tc_series.rb~ +0 -31
  203. data/test/tc_styles.rb~ +0 -64
  204. data/test/tc_validators.rb~ +0 -77
  205. data/test/tc_worksheet.rb~ +0 -85
  206. data/test/workbook/worksheet/tc_row.rb~ +0 -30
  207. data/test/workbook/worksheet/tc_worksheet.rb~ +0 -85
@@ -1,37 +0,0 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
3
-
4
- class TestTableStyle < Test::Unit::TestCase
5
-
6
- def setup
7
- @item = Axlsx::TableStyle.new "fisher"
8
- end
9
-
10
- def teardown
11
- end
12
-
13
- def test_initialiation
14
- assert_equal(@item.name, "fisher")
15
- assert_equal(@item.pivot, nil)
16
- assert_equal(@item.table, nil)
17
- end
18
-
19
- def test_name
20
- assert_raise(ArgumentError) { @item.name = -1.1 }
21
- assert_nothing_raised { @item.name = "lovely table style" }
22
- assert_equal(@item.name, "lovely table style")
23
- end
24
-
25
- def test_pivot
26
- assert_raise(ArgumentError) { @item.pivot = -1.1 }
27
- assert_nothing_raised { @item.pivot = true }
28
- assert_equal(@item.pivot, true)
29
- end
30
-
31
- def test_table
32
- assert_raise(ArgumentError) { @item.table = -1.1 }
33
- assert_nothing_raised { @item.table = true }
34
- assert_equal(@item.table, true)
35
- end
36
-
37
- end
@@ -1,37 +0,0 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
3
-
4
- class TestTableStyles < Test::Unit::TestCase
5
-
6
- def setup
7
- @item = Axlsx::TableStyleElement.new
8
- end
9
-
10
- def teardown
11
- end
12
-
13
- def test_initialiation
14
- assert_equal(@item.type, nil)
15
- assert_equal(@item.size, nil)
16
- assert_equal(@item.dxfId, nil)
17
- end
18
-
19
- def test_type
20
- assert_raise(ArgumentError) { @item.type = -1.1 }
21
- assert_nothing_raised { @item.type = :blankRow }
22
- assert_equal(@item.type, :blankRow)
23
- end
24
-
25
- def test_size
26
- assert_raise(ArgumentError) { @item.size = -1.1 }
27
- assert_nothing_raised { @item.size = 2 }
28
- assert_equal(@item.size, 2)
29
- end
30
-
31
- def test_dxfId
32
- assert_raise(ArgumentError) { @item.dxfId = -1.1 }
33
- assert_nothing_raised { @item.dxfId = 7 }
34
- assert_equal(@item.dxfId, 7)
35
- end
36
-
37
- end
@@ -1,30 +0,0 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
3
-
4
- class TestXf < Test::Unit::TestCase
5
-
6
- def setup
7
- @item = Axlsx::Xf.new
8
- end
9
-
10
- def teardown
11
- end
12
-
13
- def test_initialiation
14
- assert_equal(@item.defaultTableStyle, "TableStyleMedium9")
15
- assert_equal(@item.defaultPivotStyle, "PivotStyleLight16")
16
- end
17
-
18
- def test_defaultTableStyle
19
- assert_raise(ArgumentError) { @item.defaultTableStyle = -1.1 }
20
- assert_nothing_raised { @item.defaultTableStyle = "anyones guess" }
21
- assert_equal(@item.defaultTableStyle, "anyones guess")
22
- end
23
-
24
- def test_defaultPivotStyle
25
- assert_raise(ArgumentError) { @item.defaultPivotStyle = -1.1 }
26
- assert_nothing_raised { @item.defaultPivotStyle = "anyones guess" }
27
- assert_equal(@item.defaultPivotStyle, "anyones guess")
28
- end
29
-
30
- end
@@ -1,19 +0,0 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
3
-
4
- class TestApp < Test::Unit::TestCase
5
- def setup
6
- end
7
- def teardown
8
- end
9
-
10
- def test_valid_document
11
- schema = Nokogiri::XML::Schema(File.open("schema/shared-documentPropertiesExtended.xsd"))
12
- doc = Nokogiri::XML(Axlsx::App.new.to_xml)
13
- errors = []
14
- schema.validate(doc).each do |error|
15
- errors << error
16
- end
17
- assert_equal(errors.size, 0, "app.xml invalid" + errors.map{ |e| e.message }.to_s)
18
- end
19
- end
@@ -1,21 +0,0 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
3
-
4
- class TestBorderPr < Test::Unit::TestCase
5
- def setup
6
- @bpr = Axlsx::BorderPr.new
7
- end
8
- def teardown
9
- end
10
-
11
- def test_valid_document
12
- schema = Nokogiri::XML::Schema(File.open(Axlsx::SML_XSD))
13
- doc = Nokogiri::XML(@styles.to_xml)
14
- errors = []
15
- schema.validate(doc).each do |error|
16
- errors.push error
17
- puts error.message
18
- end
19
- assert(errors.size == 0)
20
- end
21
-
@@ -1,64 +0,0 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
3
-
4
- class TestPackage < Test::Unit::TestCase
5
- def setup
6
- @package = Axlsx::Package.new
7
- ws = @package.workbook.add_worksheet
8
- chart = ws.add_chart Axlsx::Pie3DChart
9
- chart.add_series :data=>[1,2,3], :labels=>["a", "b", "c"]
10
- end
11
-
12
- def test_default_objects_are_created
13
- assert(@package.instance_values["app"].is_a?(Axlsx::App), 'App object not created')
14
- assert(@package.instance_values["core"].is_a?(Axlsx::Core), 'Core object not created')
15
- assert(@package.workbook.is_a?(Axlsx::Workbook), 'Workbook object not created')
16
- assert(Axlsx::Package.new.workbook.worksheets.size == 0, 'Workbook should not have sheets by default')
17
- end
18
-
19
- def test_serialization
20
- fname = 'test_serialization.xlsx'
21
- assert_nothing_raised do
22
- f = File.open(fname, 'w')
23
- z= @package.serialize(f)
24
-
25
- zf = Zip::ZipFile.open(f.path)
26
- @package.send(:parts).each{ |part| zf.get_entry(part[:entry]) }
27
- File.delete(f.path)
28
- end
29
- end
30
-
31
- def test_validation
32
- assert_equal(@package.validate.size, 0, @package.validate)
33
- #how to test for failure? the internal validations on the models are so strict I cant break anthing.....
34
- end
35
-
36
- def test_parts
37
- p = @package.send(:parts)
38
- p.each do |part|
39
- #all parts must have :doc, :entry, :schema
40
- assert(part.keys.size == 3 && part.keys.reject{ |k| [:doc, :entry, :schema].include? k}.empty?)
41
- end
42
- #all parts have an entry
43
- assert_equal(p.select{ |part| part[:entry] =~ /_rels\/\.rels/ }.size, 1, "rels missing")
44
- assert_equal(p.select{ |part| part[:entry] =~ /docProps\/core\.xml/ }.size, 1, "core missing")
45
- assert_equal(p.select{ |part| part[:entry] =~ /docProps\/app\.xml/ }.size, 1, "app missing")
46
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/_rels\/workbook\.xml\.rels/ }.size, 1, "workbook rels missing")
47
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/workbook\.xml/ }.size, 1, "workbook missing")
48
- assert_equal(p.select{ |part| part[:entry] =~ /\[Content_Types\]\.xml/ }.size, 1, "content types missing")
49
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/styles\.xml/ }.size, 1, "styles missin")
50
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/drawings\/_rels\/drawing\d\.xml\.rels/ }.size, @package.workbook.drawings.size, "one or more drawing rels missing")
51
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/drawings\/drawing\d\.xml/ }.size, @package.workbook.drawings.size, "one or more drawings missing")
52
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/charts\/chart\d\.xml/ }.size, @package.workbook.charts.size, "one or more charts missing")
53
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/worksheets\/sheet\d\.xml/ }.size, @package.workbook.worksheets.size, "one or more sheet missing")
54
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/worksheets\/_rels\/sheet\d\.xml\.rels/ }.size, @package.workbook.worksheets.size, "one or more sheet rels missing")
55
-
56
- #no mystery parts
57
- assert_equal(p.size, 12)
58
-
59
- end
60
-
61
- def test_workbook_is_a_workbook
62
- assert @package.workbook.is_a? Axlsx::Workbook
63
- end
64
- end
@@ -1,66 +0,0 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
3
-
4
- class TestPie3DChart < Test::Unit::TestCase
5
-
6
- def setup
7
- p = Axlsx::Package.new
8
- ws = p.workbook.add_worksheet
9
- @row = ws.add_row :values=>["one", 1, Time.now]
10
- @chart = ws.drawing.add_chart Axlsx::Pie3DChart, :title => "fishery"
11
- end
12
-
13
- def teardown
14
- end
15
-
16
- def test_initialization
17
- assert_equal(@chart.workbook.charts.last,@chart, "the chart is in the workbook")
18
- 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")
20
- end
21
-
22
- def test_title
23
- @chart.title.text = 'wowzer'
24
- assert_equal(@chart.title.text, "wowzer", "the title text via a string")
25
- assert_equal(@chart.title.cell, nil, "the title cell is nil as we set the title with text.")
26
- @chart.title.cell = @row.cells.first
27
- assert_equal(@chart.title.text, "one", "the title text was set via cell reference")
28
- assert_equal(@chart.title.cell, @row.cells.first)
29
- end
30
-
31
- def test_add_series
32
- s = @chart.add_series :data=>[0,1,2,3], :labels => ["one", 1, "anything"], :title=>"bob"
33
- assert_equal(@chart.series.last, s, "series has been added to chart series collection")
34
- assert_equal(s.title, "bob", "series title has been applied")
35
- assert_equal(s.data, [0,1,2,3], "data option applied")
36
- assert_equal(s.labels, ["one",1,"anything"], "labels option applied")
37
- end
38
-
39
- def test_create_range
40
-
41
- end
42
-
43
- def test_pn
44
- assert_equal(@chart.pn, "charts/chart1.xml")
45
- end
46
-
47
- def test_rId
48
- assert_equal(@chart.rId, "rId1")
49
- end
50
-
51
- def test_index
52
- assert_equal(@chart.index, @chart.workbook.charts.index(@chart))
53
- end
54
-
55
- def test_to_xml
56
- schema = Nokogiri::XML::Schema(File.open(Axlsx::DRAWING_XSD))
57
- doc = Nokogiri::XML(@chart.to_xml)
58
- errors = []
59
- schema.validate(doc).each do |error|
60
- errors.push error
61
- puts error.message
62
- end
63
- assert(errors.empty?, "error free validation")
64
- end
65
-
66
- end
@@ -1,37 +0,0 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
3
-
4
- class TestRelationships < Test::Unit::TestCase
5
- def setup
6
- @rels = Axlsx::Relationships.new
7
- end
8
-
9
- def teardown
10
- end
11
-
12
- def test_valid_document
13
- schema = Nokogiri::XML::Schema(File.open("schema/opc-relationships.xsd"))
14
- doc = Nokogiri::XML(@rels.to_xml)
15
- errors = []
16
- schema.validate(doc).each do |error|
17
- puts error.message
18
- errors << error
19
- end
20
-
21
- @rels << Axlsx::Relationship.new(Axlsx::WORKSHEET_R, "bar")
22
- doc = Nokogiri::XML(@rels.to_xml)
23
- errors = []
24
- schema.validate(doc).each do |error|
25
- puts error.message
26
- errors << error
27
- end
28
-
29
- assert(errors.size == 0)
30
- end
31
-
32
- def test_require_valid_relationship_type
33
- assert_raise(ArgumentError) { Axlsx::Relationship.new("Unknown", "bar" ) }
34
- assert_nothing_raised { Axlsx::Relationship.new(Axlsx::CHART_R, "bar") }
35
- end
36
-
37
- end
@@ -1,31 +0,0 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
3
-
4
- class TestSeries < Test::Unit::TestCase
5
-
6
- def setup
7
- p = Axlsx::Package.new
8
- @ws = p.workbook.add_worksheet :name=>"hmmm"
9
- chart = @ws.drawing.add_chart Axlsx::Pie3DChart, :title => "fishery"
10
- @series = chart.add_series :data=>[0,1,2], :labels=>["zero", "one", "two"], :title=>"bob"
11
- end
12
-
13
- def test_initialize
14
- assert_equal(@series.title, "bob", "series title has been applied")
15
- assert_equal(@series.data, [0,1,2], "data option applied")
16
- assert_equal(@series.labels, ["zero", "one","two"], "labels option applied")
17
- end
18
-
19
- def test_range
20
- labels = @ws.add_row :values=>["one", "two", "three"]
21
- data = @ws.add_row :values=>[1,2,3]
22
- s = @series.chart.add_series :data=>data.cells, :labels=>labels.cells
23
- assert_equal(s.send(:range, s.data), "#{@ws.name}!$A$2:$C$2", "range is created created from cells")
24
- assert_equal(s.send(:range, s.labels), "#{@ws.name}!$A$1:$C$1", "range is created from cells")
25
- assert_equal(@series.send(:range, @series.data), "", "no range if the data is a simple array")
26
- end
27
-
28
- def test_index
29
- assert_equal(@series.index, @series.chart.series.index(@series))
30
- end
31
- end
@@ -1,64 +0,0 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
3
-
4
- class TestStyles < Test::Unit::TestCase
5
- def setup
6
- @styles = Axlsx::Styles.new
7
- end
8
- def teardown
9
- end
10
-
11
- def test_valid_document
12
- schema = Nokogiri::XML::Schema(File.open(Axlsx::SML_XSD))
13
- doc = Nokogiri::XML(@styles.to_xml)
14
- errors = []
15
- schema.validate(doc).each do |error|
16
- errors.push error
17
- puts error.message
18
- end
19
- assert(errors.size == 0)
20
- end
21
-
22
-
23
- def test_add_style
24
- fill_count = @styles.fills.size
25
- font_count = @styles.fonts.size
26
- xf_count = @styles.cellXfs.size
27
-
28
- @styles.add_style :bg_color=>"FF000000", :fg_color=>"FFFFFFFF", :sz=>13, :numFmt=>Axlsx::NUM_FMT_PERCENT, :alignment=>{:horizontal=>:left}, :borderId=>Axlsx::BORDER_ID_ALL, :hidden=>true, :locked=>true
29
- assert_equal(@styles.fills.size, fill_count+1)
30
- assert_equal(@styles.fonts.size, font_count+1)
31
- assert_equal(@styles.cellXfs.size, xf_count+1)
32
- xf = @styles.cellXfs.last
33
- assert_equal(xf.fillId, (@styles.fills.size-1), "points to the last created fill")
34
- assert_equal(@styles.fills.last.fill_type.fgColor.rgb, "FF000000", "fill created with color")
35
-
36
- assert_equal(xf.fontId, (@styles.fonts.size-1), "points to the last created font")
37
- assert_equal(@styles.fonts.last.sz, 13, "font sz applied")
38
- assert_equal(@styles.fonts.last.color.rgb, "FFFFFFFF", "font color applied")
39
-
40
- assert_equal(xf.borderId, Axlsx::BORDER_ID_ALL, "border id is set")
41
- assert_equal(xf.numFmtId, Axlsx::NUM_FMT_PERCENT, "number format id is set")
42
-
43
- assert(xf.alignment.is_a?(Axlsx::CellAlignment), "alignment was created")
44
- assert_equal(xf.alignment.horizontal, :left, "horizontal alignment applied")
45
- assert_equal(xf.applyProtection, 1, "protection applied")
46
- assert_equal(xf.protection.hidden, true, "hidden protection set")
47
- assert_equal(xf.protection.locked, true, "cell locking set")
48
- assert_raise(ArgumentError, "should reject invalid borderId") { @styles.add_style :borderId => 2 }
49
-
50
- end
51
-
52
-
53
- #:numFmts, :fonts, :fills, :borders, :cellStyleXfs, :cellXfs, :dxfs, :tableStyles
54
- def test_ensure_locking
55
- assert_equal(@styles.numFmts.locked_at, 2, "numFmts should be locked at 2")
56
- assert_equal(@styles.fonts.locked_at, 1, "fonts should be locked at 1" )
57
- assert_equal(@styles.fills.locked_at, 2, "fills should be locked at 2" )
58
- assert_equal(@styles.borders.locked_at, 2, "borders should be locked at two" )
59
- assert_equal(@styles.cellStyleXfs.locked_at, 1, "cellStyleXfs should be locked at two" )
60
- assert_equal(@styles.cellXfs.locked_at, 1, "cellXfs should be locked at 1" )
61
- assert_equal(@styles.dxfs.locked_at, 0, "dxfs should be locked at 0" )
62
- assert_equal(@styles.tableStyles.locked_at, 0, "tableStyles should be locked at 0" )
63
- end
64
- end
@@ -1,77 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'axlsx.rb'
4
- class TestValidators < Test::Unit::TestCase
5
- def setup
6
- end
7
- def teardown
8
- end
9
-
10
- def test_validators
11
- #unsigned_int
12
- assert_nothing_raised { Axlsx.validate_unsigned_int 1 }
13
- assert_nothing_raised { Axlsx.validate_unsigned_int +1 }
14
- assert_raise(ArgumentError) { Axlsx.validate_unsigned_int -1 }
15
- assert_raise(ArgumentError) { Axlsx.validate_unsigned_int '1' }
16
-
17
- #int
18
- assert_nothing_raised { Axlsx.validate_int 1 }
19
- assert_nothing_raised { Axlsx.validate_int -1 }
20
- assert_raise(ArgumentError) { Axlsx.validate_int 'a' }
21
- assert_raise(ArgumentError) { Axlsx.validate_int Array }
22
-
23
- #boolean (as 0 or 1)
24
- assert_nothing_raised { Axlsx.validate_boolean 0 }
25
- assert_nothing_raised { Axlsx.validate_boolean 1 }
26
- assert_raise(ArgumentError) { Axlsx.validate_boolean 2 }
27
- assert_raise(ArgumentError) { Axlsx.validate_boolean false }
28
-
29
- #string
30
- assert_nothing_raised { Axlsx.validate_string "1" }
31
- assert_raise(ArgumentError) { Axlsx.validate_string 2 }
32
- assert_raise(ArgumentError) { Axlsx.validate_string false }
33
-
34
- #float
35
- assert_nothing_raised { Axlsx.validate_float 1.0 }
36
- assert_raise(ArgumentError) { Axlsx.validate_float 2 }
37
- assert_raise(ArgumentError) { Axlsx.validate_float false }
38
-
39
- #pattern_type
40
- assert_nothing_raised { Axlsx.validate_pattern_type :none }
41
- assert_raise(ArgumentError) { Axlsx.validate_pattern_type "none" }
42
- assert_raise(ArgumentError) { Axlsx.validate_pattern_type "crazy_pattern" }
43
- assert_raise(ArgumentError) { Axlsx.validate_pattern_type false }
44
-
45
- #gradient_type
46
- assert_nothing_raised { Axlsx.validate_gradient_type :path }
47
- assert_raise(ArgumentError) { Axlsx.validate_gradient_type nil }
48
- assert_raise(ArgumentError) { Axlsx.validate_gradient_type "fractal" }
49
- assert_raise(ArgumentError) { Axlsx.validate_gradient_type false }
50
-
51
- #horizontal alignment
52
- assert_nothing_raised { Axlsx.validate_horizontal_alignment :general }
53
- assert_raise(ArgumentError) { Axlsx.validate_horizontal_alignment nil }
54
- assert_raise(ArgumentError) { Axlsx.validate_horizontal_alignment "wavy" }
55
- assert_raise(ArgumentError) { Axlsx.validate_horizontal_alignment false }
56
-
57
- #vertical alignment
58
- assert_nothing_raised { Axlsx.validate_vertical_alignment :top }
59
- assert_raise(ArgumentError) { Axlsx.validate_vertical_alignment nil }
60
- assert_raise(ArgumentError) { Axlsx.validate_vertical_alignment "dynamic" }
61
- assert_raise(ArgumentError) { Axlsx.validate_vertical_alignment false }
62
-
63
- #contentType
64
- assert_nothing_raised { Axlsx.validate_content_type Axlsx::WORKBOOK_CT }
65
- assert_raise(ArgumentError) { Axlsx.validate_content_type nil }
66
- assert_raise(ArgumentError) { Axlsx.validate_content_type "http://some.url" }
67
- assert_raise(ArgumentError) { Axlsx.validate_content_type false }
68
-
69
- #relationshipType
70
- assert_nothing_raised { Axlsx.validate_relationship_type Axlsx::WORKBOOK_R }
71
- assert_raise(ArgumentError) { Axlsx.validate_relationship_type nil }
72
- assert_raise(ArgumentError) { Axlsx.validate_relationship_type "http://some.url" }
73
- assert_raise(ArgumentError) { Axlsx.validate_relationship_type false }
74
-
75
- end
76
- end
77
-