axlsx 1.0.18 → 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.
- data/CHANGELOG.md +11 -3
- data/README.md +93 -18
- data/examples/example.csv +1000 -0
- data/examples/example.rb +97 -5
- data/examples/example.xlsx +0 -0
- data/examples/example_streamed.xlsx +0 -0
- data/examples/no-use_autowidth.xlsx +0 -0
- data/examples/shared_strings_example.xlsx +0 -0
- data/lib/axlsx.rb +30 -9
- data/lib/axlsx/content_type/content_type.rb +9 -9
- data/lib/axlsx/content_type/default.rb +9 -6
- data/lib/axlsx/content_type/override.rb +12 -8
- data/lib/axlsx/doc_props/app.rb +37 -40
- data/lib/axlsx/doc_props/core.rb +12 -17
- data/lib/axlsx/drawing/axis.rb +38 -19
- data/lib/axlsx/drawing/bar_3D_chart.rb +33 -32
- data/lib/axlsx/drawing/bar_series.rb +13 -14
- data/lib/axlsx/drawing/cat_axis.rb +15 -14
- data/lib/axlsx/drawing/cat_axis_data.rb +16 -18
- data/lib/axlsx/drawing/chart.rb +37 -38
- data/lib/axlsx/drawing/drawing.rb +15 -12
- data/lib/axlsx/drawing/graphic_frame.rb +21 -21
- data/lib/axlsx/drawing/hyperlink.rb +12 -11
- data/lib/axlsx/drawing/line_3D_chart.rb +30 -28
- data/lib/axlsx/drawing/line_series.rb +11 -11
- data/lib/axlsx/drawing/marker.rb +10 -8
- data/lib/axlsx/drawing/named_axis_data.rb +36 -0
- data/lib/axlsx/drawing/one_cell_anchor.rb +17 -16
- data/lib/axlsx/drawing/pic.rb +24 -37
- data/lib/axlsx/drawing/picture_locking.rb +21 -18
- data/lib/axlsx/drawing/pie_3D_chart.rb +10 -8
- data/lib/axlsx/drawing/pie_series.rb +15 -12
- data/lib/axlsx/drawing/scaling.rb +10 -10
- data/lib/axlsx/drawing/scatter_chart.rb +69 -0
- data/lib/axlsx/drawing/scatter_series.rb +39 -0
- data/lib/axlsx/drawing/ser_axis.rb +10 -10
- data/lib/axlsx/drawing/series.rb +15 -15
- data/lib/axlsx/drawing/series_title.rb +14 -14
- data/lib/axlsx/drawing/title.rb +26 -26
- data/lib/axlsx/drawing/two_cell_anchor.rb +18 -20
- data/lib/axlsx/drawing/val_axis.rb +8 -7
- data/lib/axlsx/drawing/val_axis_data.rb +17 -17
- data/lib/axlsx/drawing/view_3D.rb +22 -20
- data/lib/axlsx/package.rb +32 -15
- data/lib/axlsx/rels/relationship.rb +9 -6
- data/lib/axlsx/rels/relationships.rb +7 -1
- data/lib/axlsx/stylesheet/#num_fmt.rb# +69 -0
- data/lib/axlsx/stylesheet/border.rb +27 -23
- data/lib/axlsx/stylesheet/border_pr.rb +16 -15
- data/lib/axlsx/stylesheet/cell_alignment.rb +23 -21
- data/lib/axlsx/stylesheet/cell_protection.rb +10 -7
- data/lib/axlsx/stylesheet/cell_style.rb +8 -5
- data/lib/axlsx/stylesheet/color.rb +20 -14
- data/lib/axlsx/stylesheet/fill.rb +7 -5
- data/lib/axlsx/stylesheet/font.rb +14 -14
- data/lib/axlsx/stylesheet/gradient_fill.rb +19 -16
- data/lib/axlsx/stylesheet/gradient_stop.rb +9 -5
- data/lib/axlsx/stylesheet/num_fmt.rb +12 -6
- data/lib/axlsx/stylesheet/pattern_fill.rb +25 -10
- data/lib/axlsx/stylesheet/styles.rb +41 -32
- data/lib/axlsx/stylesheet/table_style.rb +9 -4
- data/lib/axlsx/stylesheet/table_style_element.rb +10 -7
- data/lib/axlsx/stylesheet/table_styles.rb +11 -8
- data/lib/axlsx/stylesheet/xf.rb +29 -25
- data/lib/axlsx/util/constants.rb +4 -0
- data/lib/axlsx/util/simple_typed_list.rb +18 -9
- data/lib/axlsx/util/validators.rb +13 -6
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/shared_strings_table.rb +19 -21
- data/lib/axlsx/workbook/workbook.rb +43 -19
- data/lib/axlsx/workbook/worksheet/cell.rb +93 -91
- data/lib/axlsx/workbook/worksheet/col.rb +114 -0
- data/lib/axlsx/workbook/worksheet/col.rb~ +0 -0
- data/lib/axlsx/workbook/worksheet/page_margins.rb +16 -13
- data/lib/axlsx/workbook/worksheet/row.rb +13 -13
- data/lib/axlsx/workbook/worksheet/table.rb +96 -0
- data/lib/axlsx/workbook/worksheet/table.rb~ +97 -0
- data/lib/axlsx/workbook/worksheet/worksheet.rb +152 -118
- data/lib/schema/dc.xsd +5 -5
- data/lib/schema/dcmitype.xsd +5 -3
- data/lib/schema/dcterms.xsd +15 -15
- data/lib/schema/opc-coreProperties.xsd +6 -2
- data/lib/schema/xml.xsd +7 -8
- data/test/#benchmark.txt# +7 -0
- data/test/#tc_helper.rb# +3 -0
- data/test/benchmark.rb +81 -0
- data/test/benchmark.rb~ +0 -0
- data/test/benchmark.txt +6 -0
- data/test/benchmark.txt~ +6 -0
- data/test/content_type/tc_content_type.rb +30 -32
- data/test/content_type/tc_default.rb +8 -23
- data/test/content_type/tc_override.rb +7 -21
- data/test/doc_props/tc_app.rb +2 -8
- data/test/doc_props/tc_core.rb +6 -7
- data/test/drawing/tc_axis.rb +7 -3
- data/test/drawing/tc_bar_3D_chart.rb +6 -7
- data/test/drawing/tc_bar_series.rb +4 -5
- data/test/drawing/tc_cat_axis.rb +2 -3
- data/test/drawing/tc_cat_axis_data.rb +2 -3
- data/test/drawing/tc_chart.rb +11 -12
- data/test/drawing/tc_drawing.rb +7 -8
- data/test/drawing/tc_graphic_frame.rb +3 -4
- data/test/drawing/tc_hyperlink.rb +2 -3
- data/test/drawing/tc_line_3d_chart.rb +5 -6
- data/test/drawing/tc_line_series.rb +3 -4
- data/test/drawing/tc_marker.rb +3 -4
- data/test/drawing/tc_one_cell_anchor.rb +6 -7
- data/test/drawing/tc_pic.rb +8 -9
- data/test/drawing/tc_picture_locking.rb +2 -3
- data/test/drawing/tc_pie_3D_chart.rb +5 -6
- data/test/drawing/tc_pie_series.rb +4 -5
- data/test/drawing/tc_scaling.rb +3 -4
- data/test/drawing/tc_scatter_chart.rb +43 -0
- data/test/drawing/tc_scatter_series.rb +20 -0
- data/test/drawing/tc_ser_axis.rb +2 -3
- data/test/drawing/tc_series.rb +4 -5
- data/test/drawing/tc_series_title.rb +4 -5
- data/test/drawing/tc_title.rb +4 -5
- data/test/drawing/tc_two_cell_anchor.rb +4 -5
- data/test/drawing/tc_val_axis.rb +2 -3
- data/test/drawing/tc_val_axis_data.rb +2 -3
- data/test/drawing/tc_view_3D.rb +6 -7
- data/test/example.csv +1000 -0
- data/test/example.xlsx +0 -0
- data/test/example_streamed.xlsx +0 -0
- data/test/profile.rb +33 -0
- data/test/rels/tc_relationship.rb +5 -6
- data/test/rels/tc_relationships.rb +4 -5
- data/test/stylesheet/tc_border.rb +3 -4
- data/test/stylesheet/tc_border_pr.rb +3 -4
- data/test/stylesheet/tc_cell_alignment.rb +4 -5
- data/test/stylesheet/tc_cell_protection.rb +2 -3
- data/test/stylesheet/tc_cell_style.rb +2 -3
- data/test/stylesheet/tc_color.rb +2 -3
- data/test/stylesheet/tc_fill.rb +1 -2
- data/test/stylesheet/tc_font.rb +5 -6
- data/test/stylesheet/tc_gradient_fill.rb +1 -2
- data/test/stylesheet/tc_gradient_stop.rb +1 -2
- data/test/stylesheet/tc_num_fmt.rb +1 -2
- data/test/stylesheet/tc_pattern_fill.rb +3 -4
- data/test/stylesheet/tc_styles.rb +15 -9
- data/test/stylesheet/tc_table_style.rb +2 -3
- data/test/stylesheet/tc_table_style_element.rb +2 -3
- data/test/stylesheet/tc_table_styles.rb +3 -4
- data/test/stylesheet/tc_xf.rb +16 -17
- data/test/tc_axlsx.rb +39 -0
- data/test/tc_axlsx.rb~ +0 -0
- data/test/tc_helper.rb +3 -0
- data/test/tc_helper.rb~ +3 -0
- data/test/tc_package.rb +13 -10
- data/test/util/tc_simple_typed_list.rb +8 -9
- data/test/util/tc_validators.rb +7 -8
- data/test/workbook/tc_shared_strings_table.rb +5 -6
- data/test/workbook/tc_workbook.rb +24 -6
- data/test/workbook/worksheet/table/tc_table.rb +71 -0
- data/test/workbook/worksheet/table/tc_table.rb~ +72 -0
- data/test/workbook/worksheet/tc_cell.rb +24 -10
- data/test/workbook/worksheet/tc_col.rb +59 -0
- data/test/workbook/worksheet/tc_col.rb~ +10 -0
- data/test/workbook/worksheet/tc_date_time_converter.rb +1 -2
- data/test/workbook/worksheet/tc_page_margins.rb +6 -9
- data/test/workbook/worksheet/tc_row.rb +26 -12
- data/test/workbook/worksheet/tc_worksheet.rb +134 -68
- metadata +150 -90
- data/test/drawing/tc_hyperlink.rb~ +0 -71
- data/test/workbook/tc_shared_strings_table.rb~ +0 -8
- data/test/workbook/worksheet/tc_date_time_converter.rb~ +0 -69
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
|
-
|
|
3
|
-
require 'test/unit'
|
|
4
|
-
require 'axlsx.rb'
|
|
2
|
+
require 'tc_helper.rb'
|
|
5
3
|
|
|
6
4
|
class TestDefault < Test::Unit::TestCase
|
|
7
|
-
|
|
8
|
-
end
|
|
9
|
-
def teardown
|
|
10
|
-
end
|
|
5
|
+
|
|
11
6
|
def test_initialization_requires_Extension_and_ContentType
|
|
12
7
|
assert_raise(ArgumentError, "raises argument error if Extension and/or ContentType are not specified") { Axlsx::Default.new }
|
|
13
8
|
assert_raise(ArgumentError, "raises argument error if Extension and/or ContentType are not specified") { Axlsx::Default.new :Extension=>"xml" }
|
|
@@ -19,23 +14,13 @@ class TestDefault < Test::Unit::TestCase
|
|
|
19
14
|
def test_content_type_restriction
|
|
20
15
|
assert_raise(ArgumentError, "raises argument error if invlalid ContentType is") { Axlsx::Default.new :ContentType=>"asdf" }
|
|
21
16
|
end
|
|
22
|
-
|
|
23
|
-
def
|
|
24
|
-
schema = Nokogiri::XML::Schema(File.open(Axlsx::CONTENT_TYPES_XSD))
|
|
17
|
+
|
|
18
|
+
def test_to_xml_string
|
|
25
19
|
type = Axlsx::Default.new :Extension=>"xml", :ContentType=>Axlsx::XML_CT
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
end
|
|
31
|
-
doc = Nokogiri::XML(builder.to_xml)
|
|
32
|
-
errors = []
|
|
33
|
-
schema.validate(doc).each do |error|
|
|
34
|
-
puts error.message
|
|
35
|
-
errors << error
|
|
36
|
-
end
|
|
37
|
-
assert_equal(errors.size, 0, "[Content Types].xml Invalid" + errors.map{ |e| e.message }.to_s)
|
|
38
|
-
|
|
20
|
+
doc = Nokogiri::XML(type.to_xml_string)
|
|
21
|
+
assert_equal(doc.xpath("Default[@ContentType='#{Axlsx::XML_CT}']").size, 1)
|
|
22
|
+
assert_equal(doc.xpath("Default[@Extension='xml']").size, 1)
|
|
23
|
+
|
|
39
24
|
end
|
|
40
25
|
|
|
41
26
|
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
require '
|
|
3
|
-
require 'axlsx.rb'
|
|
2
|
+
require 'tc_helper.rb'
|
|
4
3
|
|
|
5
4
|
class TestOverride < Test::Unit::TestCase
|
|
6
|
-
|
|
7
|
-
end
|
|
8
|
-
def teardown
|
|
9
|
-
end
|
|
5
|
+
|
|
10
6
|
def test_initialization_requires_Extension_and_ContentType
|
|
11
7
|
err = "requires PartName and ContentType options"
|
|
12
8
|
assert_raise(ArgumentError, err) { Axlsx::Override.new }
|
|
@@ -18,23 +14,13 @@ class TestOverride < Test::Unit::TestCase
|
|
|
18
14
|
def test_content_type_restriction
|
|
19
15
|
assert_raise(ArgumentError, "requires known content type") { Axlsx::Override.new :ContentType=>"asdf" }
|
|
20
16
|
end
|
|
21
|
-
|
|
17
|
+
|
|
22
18
|
def test_to_xml
|
|
23
|
-
schema = Nokogiri::XML::Schema(File.open(Axlsx::CONTENT_TYPES_XSD))
|
|
24
19
|
type = Axlsx::Override.new :PartName=>"somechart.xml", :ContentType=>Axlsx::CHART_CT
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
end
|
|
30
|
-
doc = Nokogiri::XML(builder.to_xml)
|
|
31
|
-
errors = []
|
|
32
|
-
schema.validate(doc).each do |error|
|
|
33
|
-
puts error.message
|
|
34
|
-
errors << error
|
|
35
|
-
end
|
|
36
|
-
assert_equal(errors.size, 0, "Override content type caused invalid content_type doc" + errors.map{ |e| e.message }.to_s)
|
|
37
|
-
|
|
20
|
+
doc = Nokogiri::XML(type.to_xml_string)
|
|
21
|
+
assert_equal(doc.xpath("Override[@ContentType='#{Axlsx::CHART_CT}']").size, 1)
|
|
22
|
+
assert_equal(doc.xpath("Override[@PartName='somechart.xml']").size, 1)
|
|
23
|
+
|
|
38
24
|
end
|
|
39
25
|
|
|
40
26
|
|
data/test/doc_props/tc_app.rb
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
require '
|
|
2
|
-
require 'axlsx.rb'
|
|
1
|
+
require 'tc_helper.rb'
|
|
3
2
|
|
|
4
3
|
class TestApp < Test::Unit::TestCase
|
|
5
|
-
def setup
|
|
6
|
-
end
|
|
7
|
-
def teardown
|
|
8
|
-
end
|
|
9
|
-
|
|
10
4
|
def test_valid_document
|
|
11
5
|
schema = Nokogiri::XML::Schema(File.open(Axlsx::APP_XSD))
|
|
12
|
-
doc = Nokogiri::XML(Axlsx::App.new.
|
|
6
|
+
doc = Nokogiri::XML(Axlsx::App.new.to_xml_string)
|
|
13
7
|
errors = []
|
|
14
8
|
schema.validate(doc).each do |error|
|
|
15
9
|
errors << error
|
data/test/doc_props/tc_core.rb
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
require '
|
|
2
|
-
require 'axlsx.rb'
|
|
1
|
+
require 'tc_helper.rb'
|
|
3
2
|
|
|
4
3
|
class TestCore < Test::Unit::TestCase
|
|
5
|
-
|
|
6
|
-
def setup
|
|
4
|
+
|
|
5
|
+
def setup
|
|
7
6
|
@core = Axlsx::Core.new
|
|
8
|
-
@doc = Nokogiri::XML(@core.
|
|
7
|
+
@doc = Nokogiri::XML(@core.to_xml_string)
|
|
9
8
|
end
|
|
10
9
|
|
|
11
10
|
def test_valid_document
|
|
@@ -21,14 +20,14 @@ class TestCore < Test::Unit::TestCase
|
|
|
21
20
|
def test_populates_created
|
|
22
21
|
assert_equal(@doc.xpath('//dcterms:created').text, Time.now.strftime('%Y-%m-%dT%H:%M:%S'), "dcterms:created incorrect")
|
|
23
22
|
end
|
|
24
|
-
|
|
23
|
+
|
|
25
24
|
def test_populates_default_name
|
|
26
25
|
assert_equal(@doc.xpath('//dc:creator').text, "axlsx", "Default name not populated")
|
|
27
26
|
end
|
|
28
27
|
|
|
29
28
|
def test_creator_as_option
|
|
30
29
|
c = Axlsx::Core.new :creator => "some guy"
|
|
31
|
-
doc = Nokogiri::XML(c.
|
|
30
|
+
doc = Nokogiri::XML(c.to_xml_string)
|
|
32
31
|
assert(doc.xpath('//dc:creator').text == "some guy")
|
|
33
32
|
end
|
|
34
33
|
end
|
data/test/drawing/tc_axis.rb
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
require '
|
|
2
|
-
require 'axlsx.rb'
|
|
1
|
+
require 'tc_helper.rb'
|
|
3
2
|
|
|
4
3
|
class TestAxis < Test::Unit::TestCase
|
|
5
|
-
def setup
|
|
4
|
+
def setup
|
|
6
5
|
@axis = Axlsx::Axis.new 12345, 54321
|
|
7
6
|
end
|
|
8
7
|
def teardown
|
|
@@ -37,4 +36,9 @@ class TestAxis < Test::Unit::TestCase
|
|
|
37
36
|
assert_nothing_raised("accepts valid crosses") { @axis.crosses = :min }
|
|
38
37
|
end
|
|
39
38
|
|
|
39
|
+
def test_gridlines
|
|
40
|
+
assert_raise(ArgumentError, "requires valid gridlines") { @axis.gridlines = 'alice' }
|
|
41
|
+
assert_nothing_raised("accepts valid crosses") { @axis.gridlines = false }
|
|
42
|
+
end
|
|
43
|
+
|
|
40
44
|
end
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
require '
|
|
2
|
-
require 'axlsx.rb'
|
|
1
|
+
require 'tc_helper.rb'
|
|
3
2
|
|
|
4
3
|
class TestBar3DChart < Test::Unit::TestCase
|
|
5
4
|
|
|
@@ -13,7 +12,7 @@ class TestBar3DChart < 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, :clustered, "grouping defualt incorrect")
|
|
18
17
|
assert_equal(@chart.series_type, Axlsx::BarSeries, "series type incorrect")
|
|
19
18
|
assert_equal(@chart.barDir, :bar, " bar direction incorrect")
|
|
@@ -52,15 +51,15 @@ class TestBar3DChart < Test::Unit::TestCase
|
|
|
52
51
|
assert(@chart.shape == :cone)
|
|
53
52
|
end
|
|
54
53
|
|
|
55
|
-
def
|
|
54
|
+
def test_to_xml_string
|
|
56
55
|
schema = Nokogiri::XML::Schema(File.open(Axlsx::DRAWING_XSD))
|
|
57
|
-
doc = Nokogiri::XML(@chart.
|
|
56
|
+
doc = Nokogiri::XML(@chart.to_xml_string)
|
|
58
57
|
errors = []
|
|
59
58
|
schema.validate(doc).each do |error|
|
|
60
59
|
errors.push error
|
|
61
60
|
puts error.message
|
|
62
61
|
end
|
|
63
62
|
assert(errors.empty?, "error free validation")
|
|
64
|
-
end
|
|
65
|
-
|
|
63
|
+
end
|
|
64
|
+
|
|
66
65
|
end
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
require '
|
|
2
|
-
require 'axlsx.rb'
|
|
1
|
+
require 'tc_helper.rb'
|
|
3
2
|
|
|
4
3
|
class TestBarSeries < Test::Unit::TestCase
|
|
5
4
|
|
|
@@ -9,12 +8,12 @@ class TestBarSeries < Test::Unit::TestCase
|
|
|
9
8
|
chart = @ws.drawing.add_chart Axlsx::Bar3DChart, :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.shape, :box, "series shape has been applied")
|
|
15
|
+
assert_equal(@series.labels, ["zero", "one","two"], "labels option applied")
|
|
16
|
+
assert_equal(@series.shape, :box, "series shape has been applied")
|
|
18
17
|
end
|
|
19
18
|
|
|
20
19
|
def test_data
|
data/test/drawing/tc_cat_axis.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
require '
|
|
2
|
-
require 'axlsx.rb'
|
|
1
|
+
require 'tc_helper.rb'
|
|
3
2
|
|
|
4
3
|
class TestCatAxisData < Test::Unit::TestCase
|
|
5
4
|
|
|
@@ -9,7 +8,7 @@ class TestCatAxisData < Test::Unit::TestCase
|
|
|
9
8
|
chart = @ws.drawing.add_chart Axlsx::Bar3DChart
|
|
10
9
|
@series = chart.add_series :labels=>["zero", "one", "two"]
|
|
11
10
|
end
|
|
12
|
-
|
|
11
|
+
|
|
13
12
|
def test_initialize
|
|
14
13
|
assert(@series.labels.is_a?Axlsx::SimpleTypedList)
|
|
15
14
|
assert_equal(@series.labels, ["zero", "one", "two"])
|
data/test/drawing/tc_chart.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
require '
|
|
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
|
|
@@ -47,27 +46,27 @@ class TestChart < Test::Unit::TestCase
|
|
|
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
|
|
60
|
+
|
|
61
|
+
def test_to_xml_string
|
|
63
62
|
schema = Nokogiri::XML::Schema(File.open(Axlsx::DRAWING_XSD))
|
|
64
|
-
doc = Nokogiri::XML(@chart.
|
|
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
|
data/test/drawing/tc_drawing.rb
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
require '
|
|
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.
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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.
|
|
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 '
|
|
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
|
data/test/drawing/tc_marker.rb
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
require '
|
|
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
|