axlsx 1.0.12 → 1.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -3
- data/lib/axlsx.rb +57 -0
- data/lib/axlsx/content_type/content_type.rb +23 -0
- data/lib/axlsx/content_type/default.rb +37 -0
- data/lib/axlsx/content_type/override.rb +37 -0
- data/lib/axlsx/doc_props/app.rb +178 -0
- data/lib/axlsx/doc_props/core.rb +34 -0
- data/lib/axlsx/drawing/axis.rb +90 -0
- data/lib/axlsx/drawing/bar_3D_chart.rb +128 -0
- data/lib/axlsx/drawing/bar_series.rb +64 -0
- data/lib/axlsx/drawing/cat_axis.rb +63 -0
- data/lib/axlsx/drawing/cat_axis_data.rb +35 -0
- data/lib/axlsx/drawing/chart.rb +179 -0
- data/lib/axlsx/drawing/drawing.rb +137 -0
- data/lib/axlsx/drawing/graphic_frame.rb +52 -0
- data/lib/axlsx/drawing/line_3D_chart.rb +106 -0
- data/lib/axlsx/drawing/line_series.rb +46 -0
- data/lib/axlsx/drawing/marker.rb +61 -0
- data/lib/axlsx/drawing/one_cell_anchor.rb +89 -0
- data/lib/axlsx/drawing/pic.rb +153 -0
- data/lib/axlsx/drawing/picture_locking.rb +72 -0
- data/lib/axlsx/drawing/picture_locking.rb~ +36 -0
- data/lib/axlsx/drawing/pie_3D_chart.rb +41 -0
- data/lib/axlsx/drawing/pie_series.rb +56 -0
- data/lib/axlsx/drawing/scaling.rb +59 -0
- data/lib/axlsx/drawing/ser_axis.rb +45 -0
- data/lib/axlsx/drawing/series.rb +71 -0
- data/lib/axlsx/drawing/series_title.rb +22 -0
- data/lib/axlsx/drawing/title.rb +61 -0
- data/lib/axlsx/drawing/two_cell_anchor.rb +76 -0
- data/lib/axlsx/drawing/val_axis.rb +34 -0
- data/lib/axlsx/drawing/val_axis_data.rb +28 -0
- data/lib/axlsx/drawing/view_3D.rb +85 -0
- data/lib/axlsx/package.rb +215 -0
- data/lib/axlsx/rels/relationship.rb +44 -0
- data/lib/axlsx/rels/relationships.rb +25 -0
- data/lib/axlsx/stylesheet/border.rb +57 -0
- data/lib/axlsx/stylesheet/border_pr.rb +68 -0
- data/lib/axlsx/stylesheet/cell_alignment.rb +105 -0
- data/lib/axlsx/stylesheet/cell_protection.rb +36 -0
- data/lib/axlsx/stylesheet/cell_style.rb +65 -0
- data/lib/axlsx/stylesheet/color.rb +69 -0
- data/lib/axlsx/stylesheet/fill.rb +32 -0
- data/lib/axlsx/stylesheet/font.rb +139 -0
- data/lib/axlsx/stylesheet/gradient_fill.rb +76 -0
- data/lib/axlsx/stylesheet/gradient_stop.rb +33 -0
- data/lib/axlsx/stylesheet/num_fmt.rb +63 -0
- data/lib/axlsx/stylesheet/pattern_fill.rb +66 -0
- data/lib/axlsx/stylesheet/styles.rb +298 -0
- data/lib/axlsx/stylesheet/table_style.rb +47 -0
- data/lib/axlsx/stylesheet/table_style_element.rb +71 -0
- data/lib/axlsx/stylesheet/table_styles.rb +39 -0
- data/lib/axlsx/stylesheet/xf.rb +138 -0
- data/lib/axlsx/util/constants.rb +220 -0
- data/lib/axlsx/util/parser.rb +43 -0
- data/lib/axlsx/util/parser.rb~ +6 -0
- data/lib/axlsx/util/simple_typed_list.rb +160 -0
- data/lib/axlsx/util/validators.rb +132 -0
- data/lib/axlsx/version.rb +4 -0
- data/lib/axlsx/workbook/#workbook.rb# +165 -0
- data/lib/axlsx/workbook/workbook.rb +160 -0
- data/lib/axlsx/workbook/worksheet/cell.rb +337 -0
- data/lib/axlsx/workbook/worksheet/row.rb +107 -0
- data/lib/axlsx/workbook/worksheet/worksheet.rb +279 -0
- metadata +93 -141
- data/examples/follow_20111202.xlsx +0 -0
- data/test/content_type/tc_content_type.rb +0 -81
- data/test/content_type/tc_default.rb +0 -40
- data/test/content_type/tc_override.rb +0 -40
- data/test/doc_props/tc_app.rb +0 -19
- data/test/doc_props/tc_core.rb +0 -34
- data/test/drawing/tc_axis.rb +0 -40
- data/test/drawing/tc_bar_3D_chart.rb +0 -66
- data/test/drawing/tc_bar_series.rb +0 -34
- data/test/drawing/tc_cat_axis.rb +0 -32
- data/test/drawing/tc_cat_axis_data.rb +0 -18
- data/test/drawing/tc_chart.rb +0 -73
- data/test/drawing/tc_drawing.rb +0 -80
- data/test/drawing/tc_graphic_frame.rb +0 -26
- data/test/drawing/tc_line_3d_chart.rb +0 -48
- data/test/drawing/tc_line_series.rb +0 -27
- data/test/drawing/tc_marker.rb +0 -45
- data/test/drawing/tc_one_cell_anchor.rb +0 -67
- data/test/drawing/tc_pic.rb +0 -71
- data/test/drawing/tc_picture_locking.rb +0 -73
- data/test/drawing/tc_pie_3D_chart.rb +0 -33
- data/test/drawing/tc_pie_series.rb +0 -35
- data/test/drawing/tc_scaling.rb +0 -37
- data/test/drawing/tc_ser_axis.rb +0 -31
- data/test/drawing/tc_series.rb +0 -24
- data/test/drawing/tc_series_title.rb +0 -34
- data/test/drawing/tc_title.rb +0 -34
- data/test/drawing/tc_two_cell_anchor.rb +0 -38
- data/test/drawing/tc_val_axis.rb +0 -25
- data/test/drawing/tc_val_axis_data.rb +0 -18
- data/test/drawing/tc_view_3D.rb +0 -55
- data/test/rels/tc_relationship.rb +0 -16
- data/test/rels/tc_relationships.rb +0 -27
- data/test/stylesheet/tc_border.rb +0 -38
- data/test/stylesheet/tc_border_pr.rb +0 -33
- data/test/stylesheet/tc_cell_alignment.rb +0 -77
- data/test/stylesheet/tc_cell_protection.rb +0 -30
- data/test/stylesheet/tc_cell_style.rb +0 -58
- data/test/stylesheet/tc_color.rb +0 -38
- data/test/stylesheet/tc_fill.rb +0 -19
- data/test/stylesheet/tc_font.rb +0 -114
- data/test/stylesheet/tc_gradient_fill.rb +0 -65
- data/test/stylesheet/tc_gradient_stop.rb +0 -32
- data/test/stylesheet/tc_num_fmt.rb +0 -31
- data/test/stylesheet/tc_pattern_fill.rb +0 -38
- data/test/stylesheet/tc_styles.rb +0 -52
- data/test/stylesheet/tc_table_style.rb +0 -37
- data/test/stylesheet/tc_table_style_element.rb +0 -37
- data/test/stylesheet/tc_table_styles.rb +0 -30
- data/test/stylesheet/tc_xf.rb +0 -121
- data/test/tc_package.rb +0 -68
- data/test/util/tc_simple_typed_list.rb +0 -66
- data/test/util/tc_validators.rb +0 -76
- data/test/workbook/tc_workbook.rb +0 -60
- data/test/workbook/worksheet/tc_cell.rb +0 -179
- data/test/workbook/worksheet/tc_row.rb +0 -36
- data/test/workbook/worksheet/tc_worksheet.rb +0 -138
Binary file
|
@@ -1,81 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'axlsx.rb'
|
3
|
-
|
4
|
-
class TestContentType < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
@package = Axlsx::Package.new
|
7
|
-
@doc = Nokogiri::XML(@package.send(:content_types).to_xml)
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_valid_document
|
11
|
-
schema = Nokogiri::XML::Schema(File.open(Axlsx::CONTENT_TYPES_XSD))
|
12
|
-
errors = []
|
13
|
-
schema.validate(@doc).each do |error|
|
14
|
-
puts error.message
|
15
|
-
errors << error
|
16
|
-
end
|
17
|
-
assert_equal(errors.size, 0, "[Content Types].xml Invalid" + errors.map{ |e| e.message }.to_s)
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_pre_built_types
|
21
|
-
|
22
|
-
o_path = "Types Override [@ContentType='%s']"
|
23
|
-
d_path = "Types Default [@ContentType='%s']"
|
24
|
-
|
25
|
-
#default
|
26
|
-
assert_equal(@doc.css("Types Default").size, 2, "There should be 2 default types")
|
27
|
-
|
28
|
-
node = @doc.css(d_path % Axlsx::XML_CT).first
|
29
|
-
assert_equal(node["Extension"], "#{Axlsx::XML_EX}", "xml content type invalid")
|
30
|
-
|
31
|
-
node = @doc.css(d_path % Axlsx::RELS_CT).first
|
32
|
-
assert_equal(node["Extension"],"#{Axlsx::RELS_EX}", "relationships content type invalid")
|
33
|
-
|
34
|
-
#overrride
|
35
|
-
assert_equal(@doc.css("Types Override").size, 4, "There should be 4 Override types")
|
36
|
-
|
37
|
-
node = @doc.css(o_path % Axlsx::APP_CT).first
|
38
|
-
assert_equal(node["PartName"], "/#{Axlsx::APP_PN}", "App part name invalid")
|
39
|
-
|
40
|
-
node = @doc.css(o_path % Axlsx::CORE_CT).first
|
41
|
-
assert_equal(node["PartName"], "/#{Axlsx::CORE_PN}", "Core part name invalid")
|
42
|
-
|
43
|
-
node = @doc.css(o_path % Axlsx::STYLES_CT).first
|
44
|
-
assert_equal(node["PartName"], "/xl/#{Axlsx::STYLES_PN}", "Styles part name invalid")
|
45
|
-
|
46
|
-
node = @doc.css(o_path % Axlsx::WORKBOOK_CT).first
|
47
|
-
assert_equal(node["PartName"], "/#{Axlsx::WORKBOOK_PN}", "Workbook part invalid")
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_should_get_worksheet_for_worksheets
|
51
|
-
o_path = "Types Override [@ContentType='%s']"
|
52
|
-
|
53
|
-
ws = @package.workbook.add_worksheet
|
54
|
-
doc = Nokogiri::XML(@package.send(:content_types).to_xml)
|
55
|
-
assert_equal(doc.css("Types Override").size, 5, "adding a worksheet should add another type")
|
56
|
-
assert_equal(doc.css(o_path % Axlsx::WORKSHEET_CT).last["PartName"], "/xl/#{ws.pn}", "Worksheet part invalid")
|
57
|
-
|
58
|
-
ws = @package.workbook.add_worksheet
|
59
|
-
doc = Nokogiri::XML(@package.send(:content_types).to_xml)
|
60
|
-
assert_equal(doc.css("Types Override").size, 6, "adding workship should add another type")
|
61
|
-
assert_equal(doc.css(o_path % Axlsx::WORKSHEET_CT).last["PartName"], "/xl/#{ws.pn}", "Worksheet part invalid")
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_drawings_and_charts_need_content_types
|
66
|
-
o_path = "Types Override [@ContentType='%s']"
|
67
|
-
ws = @package.workbook.add_worksheet
|
68
|
-
|
69
|
-
c = ws.add_chart Axlsx::Pie3DChart
|
70
|
-
doc = Nokogiri::XML(@package.send(:content_types).to_xml)
|
71
|
-
assert_equal(doc.css("Types Override").size, 7, "expected 7 types got #{doc.css("Types Override").size}")
|
72
|
-
assert_equal(doc.css(o_path % Axlsx::DRAWING_CT).first["PartName"], "/xl/#{ws.drawing.pn}", "Drawing part name invlid")
|
73
|
-
assert_equal(doc.css(o_path % Axlsx::CHART_CT).last["PartName"], "/xl/#{c.pn}", "Chart part name invlid")
|
74
|
-
|
75
|
-
c = ws.add_chart Axlsx::Pie3DChart
|
76
|
-
doc = Nokogiri::XML(@package.send(:content_types).to_xml)
|
77
|
-
assert_equal(doc.css("Types Override").size, 8, "expected 7 types got #{doc.css("Types Override").size}")
|
78
|
-
assert_equal(doc.css(o_path % Axlsx::CHART_CT).last["PartName"], "/xl/#{c.pn}", "Chart part name invlid")
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'axlsx.rb'
|
3
|
-
|
4
|
-
class TestDefault < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
end
|
7
|
-
def teardown
|
8
|
-
end
|
9
|
-
def test_initialization_requires_Extension_and_ContentType
|
10
|
-
assert_raise(ArgumentError, "raises argument error if Extension and/or ContentType are not specified") { Axlsx::Default.new }
|
11
|
-
assert_raise(ArgumentError, "raises argument error if Extension and/or ContentType are not specified") { Axlsx::Default.new :Extension=>"xml" }
|
12
|
-
assert_raise(ArgumentError, "raises argument error if Extension and/or ContentType are not specified") { Axlsx::Default.new :ContentType=>"asdf" }
|
13
|
-
|
14
|
-
assert_nothing_raised {Axlsx::Default.new :Extension=>"foo", :ContentType=>Axlsx::XML_CT}
|
15
|
-
|
16
|
-
end
|
17
|
-
def test_content_type_restriction
|
18
|
-
assert_raise(ArgumentError, "raises argument error if invlalid ContentType is") { Axlsx::Default.new :ContentType=>"asdf" }
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_to_xml
|
22
|
-
schema = Nokogiri::XML::Schema(File.open(Axlsx::CONTENT_TYPES_XSD))
|
23
|
-
type = Axlsx::Default.new :Extension=>"xml", :ContentType=>Axlsx::XML_CT
|
24
|
-
builder = Nokogiri::XML::Builder.new(:encoding => Axlsx::ENCODING) do |xml|
|
25
|
-
xml.Types(:xmlns => Axlsx::XML_NS_T) {
|
26
|
-
type.to_xml(xml)
|
27
|
-
}
|
28
|
-
end
|
29
|
-
doc = Nokogiri::XML(builder.to_xml)
|
30
|
-
errors = []
|
31
|
-
schema.validate(doc).each do |error|
|
32
|
-
puts error.message
|
33
|
-
errors << error
|
34
|
-
end
|
35
|
-
assert_equal(errors.size, 0, "[Content Types].xml Invalid" + errors.map{ |e| e.message }.to_s)
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'axlsx.rb'
|
3
|
-
|
4
|
-
class TestOverride < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
end
|
7
|
-
def teardown
|
8
|
-
end
|
9
|
-
def test_initialization_requires_Extension_and_ContentType
|
10
|
-
err = "requires PartName and ContentType options"
|
11
|
-
assert_raise(ArgumentError, err) { Axlsx::Override.new }
|
12
|
-
assert_raise(ArgumentError, err) { Axlsx::Override.new :PartName=>"xml" }
|
13
|
-
assert_raise(ArgumentError, err) { Axlsx::Override.new :ContentType=>"asdf" }
|
14
|
-
assert_nothing_raised {Axlsx::Override.new :PartName=>"foo", :ContentType=>Axlsx::CHART_CT}
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_content_type_restriction
|
18
|
-
assert_raise(ArgumentError, "requires known content type") { Axlsx::Override.new :ContentType=>"asdf" }
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_to_xml
|
22
|
-
schema = Nokogiri::XML::Schema(File.open(Axlsx::CONTENT_TYPES_XSD))
|
23
|
-
type = Axlsx::Override.new :PartName=>"somechart.xml", :ContentType=>Axlsx::CHART_CT
|
24
|
-
builder = Nokogiri::XML::Builder.new(:encoding => Axlsx::ENCODING) do |xml|
|
25
|
-
xml.Types(:xmlns => Axlsx::XML_NS_T) {
|
26
|
-
type.to_xml(xml)
|
27
|
-
}
|
28
|
-
end
|
29
|
-
doc = Nokogiri::XML(builder.to_xml)
|
30
|
-
errors = []
|
31
|
-
schema.validate(doc).each do |error|
|
32
|
-
puts error.message
|
33
|
-
errors << error
|
34
|
-
end
|
35
|
-
assert_equal(errors.size, 0, "Override content type caused invalid content_type doc" + errors.map{ |e| e.message }.to_s)
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
end
|
data/test/doc_props/tc_app.rb
DELETED
@@ -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(Axlsx::APP_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
|
data/test/doc_props/tc_core.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'axlsx.rb'
|
3
|
-
|
4
|
-
class TestCore < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@core = Axlsx::Core.new
|
8
|
-
@doc = Nokogiri::XML(@core.to_xml)
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_valid_document
|
12
|
-
schema = Nokogiri::XML::Schema(File.open(Axlsx::CORE_XSD))
|
13
|
-
errors = []
|
14
|
-
schema.validate(@doc).each do |error|
|
15
|
-
puts error.message
|
16
|
-
errors << error
|
17
|
-
end
|
18
|
-
assert_equal(errors.size, 0, "core.xml Invalid" + errors.map{ |e| e.message }.to_s)
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_populates_created
|
22
|
-
assert_equal(@doc.xpath('//dcterms:created').text, Time.now.strftime('%Y-%m-%dT%H:%M:%S'), "dcterms:created incorrect")
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_populates_default_name
|
26
|
-
assert_equal(@doc.xpath('//dc:creator').text, "axlsx", "Default name not populated")
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_creator_as_option
|
30
|
-
c = Axlsx::Core.new :creator => "some guy"
|
31
|
-
doc = Nokogiri::XML(c.to_xml)
|
32
|
-
assert(doc.xpath('//dc:creator').text == "some guy")
|
33
|
-
end
|
34
|
-
end
|
data/test/drawing/tc_axis.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'axlsx.rb'
|
3
|
-
|
4
|
-
class TestAxis < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
@axis = Axlsx::Axis.new 12345, 54321
|
7
|
-
end
|
8
|
-
def teardown
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_initialization
|
12
|
-
assert_equal(@axis.axPos, :l, "axis position default incorrect")
|
13
|
-
assert_equal(@axis.tickLblPos, :nextTo, "tick label position default incorrect")
|
14
|
-
assert_equal(@axis.tickLblPos, :nextTo, "tick label position default incorrect")
|
15
|
-
assert_equal(@axis.crosses, :autoZero, "tick label position default incorrect")
|
16
|
-
assert(@axis.scaling.is_a?(Axlsx::Scaling) && @axis.scaling.orientation == :minMax, "scaling default incorrect")
|
17
|
-
assert_raise(ArgumentError) { Axlsx::Axis.new -1234, 'abcd' }
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_axis_position
|
21
|
-
assert_raise(ArgumentError, "requires valid axis position") { @axis.axPos = :nowhere }
|
22
|
-
assert_nothing_raised("accepts valid axis position") { @axis.axPos = :r }
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_tick_label_position
|
26
|
-
assert_raise(ArgumentError, "requires valid tick label position") { @axis.tickLblPos = :nowhere }
|
27
|
-
assert_nothing_raised("accepts valid tick label position") { @axis.tickLblPos = :high }
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_format_code
|
31
|
-
assert_raise(ArgumentError, "requires valid format code") { @axis.format_code = 1 }
|
32
|
-
assert_nothing_raised("accepts valid format code") { @axis.tickLblPos = :high }
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_crosses
|
36
|
-
assert_raise(ArgumentError, "requires valid crosses") { @axis.crosses = 1 }
|
37
|
-
assert_nothing_raised("accepts valid crosses") { @axis.crosses = :min }
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'axlsx.rb'
|
3
|
-
|
4
|
-
class TestBar3DChart < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@p = Axlsx::Package.new
|
8
|
-
ws = @p.workbook.add_worksheet
|
9
|
-
@row = ws.add_row ["one", 1, Time.now]
|
10
|
-
@chart = ws.add_chart Axlsx::Bar3DChart, :title => "fishery"
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_initialization
|
17
|
-
assert_equal(@chart.grouping, :clustered, "grouping defualt incorrect")
|
18
|
-
assert_equal(@chart.series_type, Axlsx::BarSeries, "series type incorrect")
|
19
|
-
assert_equal(@chart.barDir, :bar, " bar direction incorrect")
|
20
|
-
assert(@chart.catAxis.is_a?(Axlsx::CatAxis), "category axis not created")
|
21
|
-
assert(@chart.valAxis.is_a?(Axlsx::ValAxis), "value access not created")
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_bar_direction
|
25
|
-
assert_raise(ArgumentError, "require valid bar direction") { @chart.barDir = :left }
|
26
|
-
assert_nothing_raised("allow valid bar direction") { @chart.barDir = :col }
|
27
|
-
assert(@chart.barDir == :col)
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_grouping
|
31
|
-
assert_raise(ArgumentError, "require valid grouping") { @chart.grouping = :inverted }
|
32
|
-
assert_nothing_raised("allow valid grouping") { @chart.grouping = :standard }
|
33
|
-
assert(@chart.grouping == :standard)
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
def test_gapWidth
|
38
|
-
assert_raise(ArgumentError, "require valid gap width") { @chart.gapWidth = 200 }
|
39
|
-
assert_nothing_raised("allow valid gapWidth") { @chart.gapWidth = "200%" }
|
40
|
-
assert(@chart.gapWidth == "200%")
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_gapDepth
|
44
|
-
assert_raise(ArgumentError, "require valid gapDepth") { @chart.gapDepth = 200 }
|
45
|
-
assert_nothing_raised("allow valid gapDepth") { @chart.gapDepth = "200%" }
|
46
|
-
assert(@chart.gapDepth == "200%")
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_shape
|
50
|
-
assert_raise(ArgumentError, "require valid shape") { @chart.shape = :star }
|
51
|
-
assert_nothing_raised("allow valid shape") { @chart.shape = :cone }
|
52
|
-
assert(@chart.shape == :cone)
|
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,34 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'axlsx.rb'
|
3
|
-
|
4
|
-
class TestBarSeries < 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::Bar3DChart, :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.text, "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
|
-
assert_equal(@series.shape, :box, "series shape has been applied")
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_data
|
21
|
-
assert_equal(@series.data, [0,1,2])
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_labels
|
25
|
-
assert_equal(@series.labels, ["zero", "one", "two"])
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_shape
|
29
|
-
assert_raise(ArgumentError, "require valid shape") { @series.shape = :teardropt }
|
30
|
-
assert_nothing_raised("allow valid shape") { @series.shape = :cone }
|
31
|
-
assert(@series.shape == :cone)
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
data/test/drawing/tc_cat_axis.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'axlsx.rb'
|
3
|
-
|
4
|
-
class TestCatAxis < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
@axis = Axlsx::CatAxis.new 12345, 54321
|
7
|
-
end
|
8
|
-
def teardown
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_initialization
|
12
|
-
assert_equal(@axis.auto, true, "axis auto default incorrect")
|
13
|
-
assert_equal(@axis.lblAlgn, :ctr, "label align default incorrect")
|
14
|
-
assert_equal(@axis.lblOffset, "100%", "label offset default incorrect")
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_auto
|
18
|
-
assert_raise(ArgumentError, "requires valid auto") { @axis.auto = :nowhere }
|
19
|
-
assert_nothing_raised("accepts valid auto") { @axis.auto = false }
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_lblAlgn
|
23
|
-
assert_raise(ArgumentError, "requires valid label alignment") { @axis.lblAlgn = :nowhere }
|
24
|
-
assert_nothing_raised("accepts valid label alignment") { @axis.lblAlgn = :r }
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_lblOffset
|
28
|
-
assert_raise(ArgumentError, "requires valid label offset") { @axis.lblOffset = 100 }
|
29
|
-
assert_nothing_raised("accepts valid label offset") { @axis.lblOffset = "20%" }
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'axlsx.rb'
|
3
|
-
|
4
|
-
class TestCatAxisData < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
p = Axlsx::Package.new
|
8
|
-
@ws = p.workbook.add_worksheet
|
9
|
-
chart = @ws.drawing.add_chart Axlsx::Bar3DChart
|
10
|
-
@series = chart.add_series :labels=>["zero", "one", "two"]
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_initialize
|
14
|
-
assert(@series.labels.is_a?Axlsx::SimpleTypedList)
|
15
|
-
assert_equal(@series.labels, ["zero", "one", "two"])
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
data/test/drawing/tc_chart.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'axlsx.rb'
|
3
|
-
|
4
|
-
class TestChart < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@p = Axlsx::Package.new
|
8
|
-
ws = @p.workbook.add_worksheet
|
9
|
-
@row = ws.add_row ["one", 1, Time.now]
|
10
|
-
@chart = ws.add_chart Axlsx::Bar3DChart, :title => "fishery"
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_initialization
|
17
|
-
assert_equal(@p.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_style
|
32
|
-
assert_raise(ArgumentError) { @chart.style = 49 }
|
33
|
-
assert_nothing_raised { @chart.style = 2 }
|
34
|
-
assert_equal(@chart.style, 2)
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_start_at
|
38
|
-
@chart.start_at 15,25
|
39
|
-
assert_equal(@chart.graphic_frame.anchor.from.col, 15)
|
40
|
-
assert_equal(@chart.graphic_frame.anchor.from.row, 25)
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
def end_at
|
45
|
-
@chart.end_at 25, 90
|
46
|
-
assert_equal(@chart.graphic_frame.anchor.from.col, 25)
|
47
|
-
assert_equal(@chart.graphic_frame.anchor.to.row, 90)
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_add_series
|
51
|
-
s = @chart.add_series :data=>[0,1,2,3], :labels => ["one", 1, "anything"], :title=>"bob"
|
52
|
-
assert_equal(@chart.series.last, s, "series has been added to chart series collection")
|
53
|
-
assert_equal(s.title.text, "bob", "series title has been applied")
|
54
|
-
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
|
-
|
58
|
-
def test_pn
|
59
|
-
assert_equal(@chart.pn, "charts/chart1.xml")
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_to_xml
|
63
|
-
schema = Nokogiri::XML::Schema(File.open(Axlsx::DRAWING_XSD))
|
64
|
-
doc = Nokogiri::XML(@chart.to_xml)
|
65
|
-
errors = []
|
66
|
-
schema.validate(doc).each do |error|
|
67
|
-
errors.push error
|
68
|
-
puts error.message
|
69
|
-
end
|
70
|
-
assert(errors.empty?, "error free validation")
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|