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
data/test/drawing/tc_drawing.rb
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'axlsx.rb'
|
3
|
-
|
4
|
-
class TestDrawing < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
p = Axlsx::Package.new
|
7
|
-
@ws = p.workbook.add_worksheet
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_initialization
|
12
|
-
assert(@ws.workbook.drawings.empty?)
|
13
|
-
assert_equal(@ws.drawing, @ws.workbook.drawings.last, "drawing is added to workbook")
|
14
|
-
assert(@ws.drawing.anchors.is_a?(Axlsx::SimpleTypedList) && @ws.drawing.anchors.empty?, "anchor list is created and empty")
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_add_chart
|
18
|
-
chart = @ws.add_chart(Axlsx::Pie3DChart, :title=>"bob", :start_at=>[0,0], :end_at=>[1,1])
|
19
|
-
assert(chart.is_a?(Axlsx::Pie3DChart), "must create a chart")
|
20
|
-
assert_equal(@ws.workbook.charts.last, chart, "must be added to workbook charts collection")
|
21
|
-
assert_equal(@ws.drawing.anchors.last.object.chart, chart, "an anchor has been created and holds a reference to this chart")
|
22
|
-
anchor = @ws.drawing.anchors.last
|
23
|
-
assert_equal([anchor.from.row, anchor.from.col], [0,0], "options for start at are applied")
|
24
|
-
assert_equal([anchor.to.row, anchor.to.col], [1,1], "options for start at are applied")
|
25
|
-
assert_equal(chart.title.text, "bob", "option for title is applied")
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_add_image
|
29
|
-
src = File.dirname(__FILE__) + "/../../examples/image1.jpeg"
|
30
|
-
image = @ws.add_image(:image_src => src, :start_at=>[0,0], :width=>600, :height=>400)
|
31
|
-
assert(@ws.drawing.anchors.last.is_a?(Axlsx::OneCellAnchor))
|
32
|
-
assert(image.is_a?(Axlsx::Pic))
|
33
|
-
assert_equal(600, image.width)
|
34
|
-
assert_equal(400, image.height)
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_charts
|
38
|
-
assert(@ws.drawing.charts.empty?)
|
39
|
-
chart = @ws.add_chart(Axlsx::Pie3DChart, :title=>"bob", :start_at=>[0,0], :end_at=>[1,1])
|
40
|
-
assert_equal(@ws.drawing.charts.last, chart, "add chart is returned")
|
41
|
-
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")
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_pn
|
46
|
-
assert_equal(@ws.drawing.pn, "drawings/drawing1.xml")
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_rels_pn
|
50
|
-
assert_equal(@ws.drawing.rels_pn, "drawings/_rels/drawing1.xml.rels")
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_rId
|
54
|
-
assert_equal(@ws.drawing.rId, "rId1")
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_index
|
58
|
-
assert_equal(@ws.drawing.index, @ws.workbook.drawings.index(@ws.drawing))
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_relationships
|
62
|
-
assert(@ws.drawing.relationships.empty?)
|
63
|
-
chart = @ws.add_chart(Axlsx::Pie3DChart, :title=>"bob", :start_at=>[0,0], :end_at=>[1,1])
|
64
|
-
assert_equal(@ws.drawing.relationships.size, 1, "adding a chart adds a relationship")
|
65
|
-
chart = @ws.add_chart(Axlsx::Pie3DChart, :title=>"nancy", :start_at=>[1,5], :end_at=>[5,10])
|
66
|
-
assert_equal(@ws.drawing.relationships.size, 2, "adding a chart adds a relationship")
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_to_xml
|
70
|
-
schema = Nokogiri::XML::Schema(File.open(Axlsx::DRAWING_XSD))
|
71
|
-
doc = Nokogiri::XML(@ws.drawing.to_xml)
|
72
|
-
errors = []
|
73
|
-
schema.validate(doc).each do |error|
|
74
|
-
errors.push error
|
75
|
-
puts error.message
|
76
|
-
end
|
77
|
-
assert(errors.empty?, "error free validation")
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'axlsx.rb'
|
3
|
-
|
4
|
-
class TestGraphicFrame < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
p = Axlsx::Package.new
|
7
|
-
@ws = p.workbook.add_worksheet
|
8
|
-
@chart = @ws.add_chart Axlsx::Chart
|
9
|
-
@frame = @chart.graphic_frame
|
10
|
-
end
|
11
|
-
|
12
|
-
def teardown
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_initialization
|
16
|
-
assert(@frame.anchor.is_a?(Axlsx::TwoCellAnchor))
|
17
|
-
assert_equal(@frame.chart, @chart)
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_rId
|
21
|
-
assert_equal(@frame.rId, "rId1")
|
22
|
-
chart = @ws.add_chart Axlsx::Chart
|
23
|
-
assert_equal(chart.graphic_frame.rId, "rId2")
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'axlsx.rb'
|
3
|
-
|
4
|
-
class TestLine3DChart < 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::Line3DChart, :title => "fishery"
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_initialization
|
17
|
-
assert_equal(@chart.grouping, :standard, "grouping defualt incorrect")
|
18
|
-
assert_equal(@chart.series_type, Axlsx::LineSeries, "series type incorrect")
|
19
|
-
assert(@chart.catAxis.is_a?(Axlsx::CatAxis), "category axis not created")
|
20
|
-
assert(@chart.valAxis.is_a?(Axlsx::ValAxis), "value access not created")
|
21
|
-
assert(@chart.serAxis.is_a?(Axlsx::SerAxis), "value access not created")
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_grouping
|
25
|
-
assert_raise(ArgumentError, "require valid grouping") { @chart.grouping = :inverted }
|
26
|
-
assert_nothing_raised("allow valid grouping") { @chart.grouping = :stacked }
|
27
|
-
assert(@chart.grouping == :stacked)
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_gapDepth
|
31
|
-
assert_raise(ArgumentError, "require valid gapDepth") { @chart.gapDepth = 200 }
|
32
|
-
assert_nothing_raised("allow valid gapDepth") { @chart.gapDepth = "200%" }
|
33
|
-
assert(@chart.gapDepth == "200%")
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
def test_to_xml
|
38
|
-
schema = Nokogiri::XML::Schema(File.open(Axlsx::DRAWING_XSD))
|
39
|
-
doc = Nokogiri::XML(@chart.to_xml)
|
40
|
-
errors = []
|
41
|
-
schema.validate(doc).each do |error|
|
42
|
-
errors.push error
|
43
|
-
puts error.message
|
44
|
-
end
|
45
|
-
assert(errors.empty?, "error free validation")
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'axlsx.rb'
|
3
|
-
|
4
|
-
class TestLineSeries < 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::Line3DChart, :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
|
-
end
|
18
|
-
|
19
|
-
def test_data
|
20
|
-
assert_equal(@series.data, [0,1,2])
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_labels
|
24
|
-
assert_equal(@series.labels, ["zero", "one", "two"])
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
data/test/drawing/tc_marker.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'axlsx.rb'
|
3
|
-
|
4
|
-
class TestMarker < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
@marker = Axlsx::Marker.new
|
7
|
-
end
|
8
|
-
|
9
|
-
def teardown
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_initialization
|
13
|
-
assert(@marker.col == 0)
|
14
|
-
assert(@marker.colOff == 0)
|
15
|
-
assert(@marker.row == 0)
|
16
|
-
assert(@marker.rowOff == 0)
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_col
|
20
|
-
assert_raise(ArgumentError) { @marker.col = -1}
|
21
|
-
assert_nothing_raised {@marker.col = 10}
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_colOff
|
25
|
-
assert_raise(ArgumentError) { @marker.colOff = "1"}
|
26
|
-
assert_nothing_raised {@marker.colOff = -10}
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_row
|
30
|
-
assert_raise(ArgumentError) { @marker.row = -1}
|
31
|
-
assert_nothing_raised {@marker.row = 10}
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_rowOff
|
35
|
-
assert_raise(ArgumentError) { @marker.rowOff = "1"}
|
36
|
-
assert_nothing_raised {@marker.rowOff = -10}
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_coord
|
40
|
-
@marker.coord 5, 10
|
41
|
-
assert_equal(@marker.col, 5)
|
42
|
-
assert_equal(@marker.row, 10)
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'axlsx.rb'
|
3
|
-
|
4
|
-
class TestOneCellAnchor < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@p = Axlsx::Package.new
|
8
|
-
@ws = @p.workbook.add_worksheet
|
9
|
-
@test_img = File.dirname(__FILE__) + "/../../examples/image1.jpeg"
|
10
|
-
@image = @ws.add_image :image_src => @test_img
|
11
|
-
@anchor = @image.anchor
|
12
|
-
end
|
13
|
-
|
14
|
-
def teardown
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_initialization
|
18
|
-
assert(@anchor.from.col == 0)
|
19
|
-
assert(@anchor.from.row == 0)
|
20
|
-
assert(@anchor.width == 0)
|
21
|
-
assert(@anchor.height == 0)
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_from
|
25
|
-
assert(@anchor.from.is_a?(Axlsx::Marker))
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_object
|
29
|
-
assert(@anchor.object.is_a?(Axlsx::Pic))
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_index
|
33
|
-
assert_equal(@anchor.index, @anchor.drawing.anchors.index(@anchor))
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_width
|
37
|
-
assert_raise(ArgumentError) { @anchor.width = "a" }
|
38
|
-
assert_nothing_raised { @anchor.width = 600 }
|
39
|
-
assert_equal(@anchor.width, 600)
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_height
|
43
|
-
assert_raise(ArgumentError) { @anchor.height = "a" }
|
44
|
-
assert_nothing_raised { @anchor.height = 400 }
|
45
|
-
assert_equal(400, @anchor.height)
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_ext
|
49
|
-
ext = @anchor.send(:ext)
|
50
|
-
assert_equal(ext[:cx], (@anchor.width * 914400 / 96))
|
51
|
-
assert_equal(ext[:cy], (@anchor.height * 914400 / 96))
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_options
|
55
|
-
assert_raise(ArgumentError, 'invalid start_at') { @ws.add_image :image_src=>@test_img, :start_at=>[1] }
|
56
|
-
i = @ws.add_image :image_src=>@test_img, :start_at => [1,2], :width=>100, :height=>200, :name=>"someimage", :descr=>"a neat image"
|
57
|
-
|
58
|
-
assert_equal("a neat image", i.descr)
|
59
|
-
assert_equal("someimage", i.name)
|
60
|
-
assert_equal(200, i.height)
|
61
|
-
assert_equal(100, i.width)
|
62
|
-
assert_equal(1, i.anchor.from.col)
|
63
|
-
assert_equal(2, i.anchor.from.row)
|
64
|
-
assert_equal(@test_img, i.image_src)
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
data/test/drawing/tc_pic.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'axlsx.rb'
|
3
|
-
|
4
|
-
class TestPic < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@p = Axlsx::Package.new
|
8
|
-
ws = @p.workbook.add_worksheet
|
9
|
-
@test_img = File.dirname(__FILE__) + "/../../examples/image1.jpeg"
|
10
|
-
@image = ws.add_image :image_src => @test_img
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_initialization
|
17
|
-
assert_equal(@p.workbook.images.first, @image)
|
18
|
-
assert_equal(@image.image_src, @test_img)
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_name
|
22
|
-
assert_raise(ArgumentError) { @image.name = 49 }
|
23
|
-
assert_nothing_raised { @image.name = "unknown" }
|
24
|
-
assert_equal(@image.name, "unknown")
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_start_at
|
28
|
-
assert_raise(ArgumentError) { @image.start_at "a", 1 }
|
29
|
-
assert_nothing_raised { @image.start_at 6, 7 }
|
30
|
-
assert_equal(@image.anchor.from.col, 6)
|
31
|
-
assert_equal(@image.anchor.from.row, 7)
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_width
|
35
|
-
assert_raise(ArgumentError) { @image.width = "a" }
|
36
|
-
assert_nothing_raised { @image.width = 600 }
|
37
|
-
assert_equal(@image.width, 600)
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_height
|
41
|
-
assert_raise(ArgumentError) { @image.height = "a" }
|
42
|
-
assert_nothing_raised { @image.height = 600 }
|
43
|
-
assert_equal(600, @image.height)
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_image_src
|
47
|
-
assert_raise(ArgumentError) { @image.image_src = 49 }
|
48
|
-
assert_raise(ArgumentError) { @image.image_src = 'Unknown' }
|
49
|
-
assert_raise(ArgumentError) { @image.image_src = __FILE__ }
|
50
|
-
assert_nothing_raised { @image.image_src = @test_img }
|
51
|
-
assert_equal(@image.image_src, @test_img)
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_descr
|
55
|
-
assert_raise(ArgumentError) { @image.descr = 49 }
|
56
|
-
assert_nothing_raised { @image.descr = "test" }
|
57
|
-
assert_equal(@image.descr, "test")
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_to_xml
|
61
|
-
schema = Nokogiri::XML::Schema(File.open(Axlsx::DRAWING_XSD))
|
62
|
-
doc = Nokogiri::XML(@image.anchor.drawing.to_xml)
|
63
|
-
errors = []
|
64
|
-
schema.validate(doc).each do |error|
|
65
|
-
errors.push error
|
66
|
-
puts error.message
|
67
|
-
end
|
68
|
-
assert(errors.empty?, "error free validation")
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'axlsx.rb'
|
3
|
-
|
4
|
-
class TestPictureLocking < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
@item = Axlsx::PictureLocking.new
|
7
|
-
end
|
8
|
-
def teardown
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_initialiation
|
12
|
-
assert_equal(@item.instance_values.size, 1)
|
13
|
-
assert_equal(@item.noChangeAspect, true)
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_noGrp
|
17
|
-
assert_raise(ArgumentError) { @item.noGrp = -1 }
|
18
|
-
assert_nothing_raised { @item.noGrp = false }
|
19
|
-
assert_equal(@item.noGrp, false )
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_noRot
|
23
|
-
assert_raise(ArgumentError) { @item.noRot = -1 }
|
24
|
-
assert_nothing_raised { @item.noRot = false }
|
25
|
-
assert_equal(@item.noRot, false )
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_noChangeAspect
|
29
|
-
assert_raise(ArgumentError) { @item.noChangeAspect = -1 }
|
30
|
-
assert_nothing_raised { @item.noChangeAspect = false }
|
31
|
-
assert_equal(@item.noChangeAspect, false )
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_noMove
|
35
|
-
assert_raise(ArgumentError) { @item.noMove = -1 }
|
36
|
-
assert_nothing_raised { @item.noMove = false }
|
37
|
-
assert_equal(@item.noMove, false )
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_noResize
|
41
|
-
assert_raise(ArgumentError) { @item.noResize = -1 }
|
42
|
-
assert_nothing_raised { @item.noResize = false }
|
43
|
-
assert_equal(@item.noResize, false )
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_noEditPoints
|
47
|
-
assert_raise(ArgumentError) { @item.noEditPoints = -1 }
|
48
|
-
assert_nothing_raised { @item.noEditPoints = false }
|
49
|
-
assert_equal(@item.noEditPoints, false )
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_noAdjustHandles
|
53
|
-
assert_raise(ArgumentError) { @item.noAdjustHandles = -1 }
|
54
|
-
assert_nothing_raised { @item.noAdjustHandles = false }
|
55
|
-
assert_equal(@item.noAdjustHandles, false )
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_noChangeArrowheads
|
59
|
-
assert_raise(ArgumentError) { @item.noChangeArrowheads = -1 }
|
60
|
-
assert_nothing_raised { @item.noChangeArrowheads = false }
|
61
|
-
assert_equal(@item.noChangeArrowheads, false )
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_noChangeShapeType
|
65
|
-
assert_raise(ArgumentError) { @item.noChangeShapeType = -1 }
|
66
|
-
assert_nothing_raised { @item.noChangeShapeType = false }
|
67
|
-
assert_equal(@item.noChangeShapeType, false )
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
end
|
@@ -1,33 +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 ["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.view3D.rotX, 30, "view 3d default rotX incorrect")
|
18
|
-
assert_equal(@chart.view3D.perspective, 30, "view 3d default perspective incorrect")
|
19
|
-
assert_equal(@chart.series_type, Axlsx::PieSeries, "series type incorrect")
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_to_xml
|
23
|
-
schema = Nokogiri::XML::Schema(File.open(Axlsx::DRAWING_XSD))
|
24
|
-
doc = Nokogiri::XML(@chart.to_xml)
|
25
|
-
errors = []
|
26
|
-
schema.validate(doc).each do |error|
|
27
|
-
errors.push error
|
28
|
-
puts error.message
|
29
|
-
end
|
30
|
-
assert(errors.empty?, "error free validation")
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|