axlsx 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +21 -3
- data/doc/Axlsx.html +150 -6
- data/doc/Axlsx/App.html +1 -1
- data/doc/Axlsx/Axis.html +1 -1
- data/doc/Axlsx/Bar3DChart.html +1 -1
- data/doc/Axlsx/BarSeries.html +1 -1
- data/doc/Axlsx/Border.html +1 -1
- data/doc/Axlsx/BorderPr.html +1 -1
- data/doc/Axlsx/CatAxis.html +1 -1
- data/doc/Axlsx/CatAxisData.html +7 -5
- data/doc/Axlsx/Cell.html +1 -1
- data/doc/Axlsx/CellAlignment.html +1 -1
- data/doc/Axlsx/CellProtection.html +1 -1
- data/doc/Axlsx/CellStyle.html +1 -1
- data/doc/Axlsx/Chart.html +16 -16
- data/doc/Axlsx/Color.html +1 -1
- data/doc/Axlsx/ContentType.html +1 -1
- data/doc/Axlsx/Core.html +1 -1
- data/doc/Axlsx/DataTypeValidator.html +1 -1
- data/doc/Axlsx/Default.html +1 -1
- data/doc/Axlsx/Drawing.html +243 -65
- data/doc/Axlsx/Fill.html +1 -1
- data/doc/Axlsx/Font.html +1 -1
- data/doc/Axlsx/GradientFill.html +1 -1
- data/doc/Axlsx/GradientStop.html +1 -1
- data/doc/Axlsx/GraphicFrame.html +21 -21
- data/doc/Axlsx/Line3DChart.html +1 -1
- data/doc/Axlsx/LineSeries.html +6 -8
- data/doc/Axlsx/Marker.html +1 -1
- data/doc/Axlsx/NumFmt.html +1 -1
- data/doc/Axlsx/OneCellAnchor.html +988 -0
- data/doc/Axlsx/Override.html +1 -1
- data/doc/Axlsx/Package.html +127 -75
- data/doc/Axlsx/PatternFill.html +1 -1
- data/doc/Axlsx/Pic.html +1532 -0
- data/doc/Axlsx/Pie3DChart.html +5 -7
- data/doc/Axlsx/PieSeries.html +1 -1
- data/doc/Axlsx/RegexValidator.html +1 -1
- data/doc/Axlsx/Relationship.html +6 -6
- data/doc/Axlsx/Relationships.html +1 -1
- data/doc/Axlsx/RestrictionValidator.html +1 -1
- data/doc/Axlsx/Row.html +1 -1
- data/doc/Axlsx/Scaling.html +1 -1
- data/doc/Axlsx/SerAxis.html +1 -1
- data/doc/Axlsx/Series.html +1 -1
- data/doc/Axlsx/SeriesTitle.html +1 -1
- data/doc/Axlsx/SimpleTypedList.html +1 -1
- data/doc/Axlsx/Styles.html +1 -1
- data/doc/Axlsx/TableStyle.html +1 -1
- data/doc/Axlsx/TableStyleElement.html +1 -1
- data/doc/Axlsx/TableStyles.html +1 -1
- data/doc/Axlsx/Title.html +1 -1
- data/doc/Axlsx/TwoCellAnchor.html +165 -61
- data/doc/Axlsx/ValAxis.html +1 -1
- data/doc/Axlsx/ValAxisData.html +1 -1
- data/doc/Axlsx/View3D.html +1 -1
- data/doc/Axlsx/Workbook.html +151 -47
- data/doc/Axlsx/Worksheet.html +172 -35
- data/doc/Axlsx/Xf.html +1 -1
- data/doc/_index.html +15 -1
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +29 -4
- data/doc/index.html +29 -4
- data/doc/method_list.html +571 -363
- data/doc/top-level-namespace.html +1 -1
- data/examples/example.rb +13 -0
- data/examples/image1.gif +0 -0
- data/examples/image1.jpeg +0 -0
- data/examples/image1.jpg +0 -0
- data/examples/image1.png +0 -0
- data/lib/axlsx/drawing/bar_series.rb +0 -1
- data/lib/axlsx/drawing/cat_axis_data.rb +1 -0
- data/lib/axlsx/drawing/chart.rb +0 -1
- data/lib/axlsx/drawing/drawing.rb +31 -7
- data/lib/axlsx/drawing/graphic_frame.rb +0 -2
- data/lib/axlsx/drawing/line_series.rb +0 -1
- data/lib/axlsx/drawing/one_cell_anchor.rb +89 -0
- data/lib/axlsx/drawing/pic.rb +158 -0
- data/lib/axlsx/drawing/pie_3D_chart.rb +0 -1
- data/lib/axlsx/drawing/two_cell_anchor.rb +17 -4
- data/lib/axlsx/package.rb +31 -5
- data/lib/axlsx/rels/relationship.rb +1 -2
- data/lib/axlsx/util/constants.rb +24 -0
- data/lib/axlsx/util/validators.rb +2 -2
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/workbook.rb +8 -0
- data/lib/axlsx/workbook/worksheet/worksheet.rb +10 -1
- data/test/drawing/tc_drawing.rb +10 -1
- data/test/drawing/tc_one_cell_anchor.rb +67 -0
- data/test/drawing/tc_pic.rb +71 -0
- data/test/tc_package.rb +0 -2
- metadata +13 -118
- data/examples/#example.rb# +0 -87
- data/examples/example.rb~ +0 -79
- data/examples/multi_chart.xlsx +0 -0
- data/lib/axlsx.rb~ +0 -67
- data/lib/axlsx/content_type/content_type.rb~ +0 -20
- data/lib/axlsx/content_type/default.rb~ +0 -32
- data/lib/axlsx/content_type/override.rb~ +0 -30
- data/lib/axlsx/doc_props/app.rb~ +0 -127
- data/lib/axlsx/doc_props/core.rb~ +0 -25
- data/lib/axlsx/drawing/#bar_series.rb# +0 -62
- data/lib/axlsx/drawing/axis.rb~ +0 -0
- data/lib/axlsx/drawing/bar_3D_chart.rb~ +0 -64
- data/lib/axlsx/drawing/bar_series.rb~ +0 -92
- data/lib/axlsx/drawing/cat_axis.rb~ +0 -32
- data/lib/axlsx/drawing/cat_axis_data.rb~ +0 -28
- data/lib/axlsx/drawing/chart.rb~ +0 -0
- data/lib/axlsx/drawing/drawing.rb~ +0 -102
- data/lib/axlsx/drawing/graphic_frame.rb~ +0 -40
- data/lib/axlsx/drawing/line_3D_chart.rb~ +0 -138
- data/lib/axlsx/drawing/line_series.rb~ +0 -91
- data/lib/axlsx/drawing/marker.rb~ +0 -50
- data/lib/axlsx/drawing/pie_3D_chart.rb~ +0 -132
- data/lib/axlsx/drawing/pie_series.rb~ +0 -0
- data/lib/axlsx/drawing/scaling.rb~ +0 -0
- data/lib/axlsx/drawing/ser_axis.rb~ +0 -48
- data/lib/axlsx/drawing/series.rb~ +0 -114
- data/lib/axlsx/drawing/series_title.rb~ +0 -18
- data/lib/axlsx/drawing/title.rb~ +0 -69
- data/lib/axlsx/drawing/two_cell_anchor.rb~ +0 -70
- data/lib/axlsx/drawing/val_axis.rb~ +0 -34
- data/lib/axlsx/drawing/val_axis_data.rb~ +0 -29
- data/lib/axlsx/drawing/view_3D.rb~ +0 -21
- data/lib/axlsx/package.rb~ +0 -181
- data/lib/axlsx/rels/relationship.rb~ +0 -18
- data/lib/axlsx/rels/relationships.rb~ +0 -23
- data/lib/axlsx/stylesheet/border.rb~ +0 -24
- data/lib/axlsx/stylesheet/border_pr.rb~ +0 -64
- data/lib/axlsx/stylesheet/cell_alignment.rb~ +0 -93
- data/lib/axlsx/stylesheet/cell_protection.rb~ +0 -16
- data/lib/axlsx/stylesheet/cell_style.rb~ +0 -61
- data/lib/axlsx/stylesheet/color.rb~ +0 -56
- data/lib/axlsx/stylesheet/fill.rb~ +0 -31
- data/lib/axlsx/stylesheet/font.rb~ +0 -33
- data/lib/axlsx/stylesheet/gradient_fill.rb~ +0 -70
- data/lib/axlsx/stylesheet/gradient_stop.rb~ +0 -15
- data/lib/axlsx/stylesheet/num_fmt.rb~ +0 -60
- data/lib/axlsx/stylesheet/pattern_fill.rb~ +0 -63
- data/lib/axlsx/stylesheet/styles.rb~ +0 -279
- data/lib/axlsx/stylesheet/table_style.rb~ +0 -43
- data/lib/axlsx/stylesheet/table_style_element.rb~ +0 -66
- data/lib/axlsx/stylesheet/table_styles.rb~ +0 -36
- data/lib/axlsx/stylesheet/xf.rb~ +0 -37
- data/lib/axlsx/util/constants.rb~ +0 -187
- data/lib/axlsx/util/monkey_patches_for_true_zip_stream.rb~ +0 -61
- data/lib/axlsx/util/simple_typed_list.rb~ +0 -79
- data/lib/axlsx/util/validators.rb~ +0 -132
- data/lib/axlsx/util/xml_escape.rb~ +0 -6
- data/lib/axlsx/workbook/workbook.rb~ +0 -130
- data/lib/axlsx/workbook/worksheet/cell.rb~ +0 -185
- data/lib/axlsx/workbook/worksheet/row.rb~ +0 -92
- data/lib/axlsx/workbook/worksheet/worksheet.rb~ +0 -194
- 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/drawing/tc_axis.rb~ +0 -0
- data/test/drawing/tc_bar_3D_chart.rb~ +0 -66
- data/test/drawing/tc_bar_series.rb~ +0 -31
- data/test/drawing/tc_cat_axis.rb~ +0 -39
- data/test/drawing/tc_cat_axis_data.rb~ +0 -32
- data/test/drawing/tc_chart.rb~ +0 -59
- data/test/drawing/tc_graphic_frame.rb~ +0 -21
- data/test/drawing/tc_line_3d_chart.rb~ +0 -48
- data/test/drawing/tc_line_series.rb~ +0 -34
- data/test/drawing/tc_marker.rb~ +0 -26
- data/test/drawing/tc_pie_3D_chart.rb~ +0 -33
- data/test/drawing/tc_pie_series.rb~ +0 -26
- data/test/drawing/tc_scaling.rb~ +0 -45
- data/test/drawing/tc_ser_axis.rb~ +0 -20
- data/test/drawing/tc_series.rb~ +0 -31
- 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 -37
- data/test/drawing/tc_val_axis.rb~ +0 -32
- data/test/drawing/tc_val_axis_data.rb~ +0 -18
- data/test/drawing/tc_view_3D.rb~ +0 -37
- data/test/rels/tc_relationship.rb~ +0 -39
- data/test/rels/tc_relationships.rb~ +0 -37
- data/test/stylesheet/tc_border.rb~ +0 -31
- data/test/stylesheet/tc_border_pr.rb~ +0 -31
- data/test/stylesheet/tc_cell_alignment.rb~ +0 -38
- data/test/stylesheet/tc_cell_protection.rb~ +0 -77
- data/test/stylesheet/tc_cell_style.rb~ +0 -30
- data/test/stylesheet/tc_color.rb~ +0 -38
- data/test/stylesheet/tc_fill.rb~ +0 -19
- data/test/stylesheet/tc_font.rb~ +0 -19
- data/test/stylesheet/tc_gradient_fill.rb~ +0 -114
- data/test/stylesheet/tc_gradient_stop.rb~ +0 -65
- data/test/stylesheet/tc_num_fmt.rb~ +0 -32
- data/test/stylesheet/tc_pattern_fill.rb~ +0 -31
- data/test/stylesheet/tc_table_style.rb~ +0 -38
- data/test/stylesheet/tc_table_style_element.rb~ +0 -37
- data/test/stylesheet/tc_table_styles.rb~ +0 -37
- data/test/stylesheet/tc_xf.rb~ +0 -30
- data/test/tc_app.rb~ +0 -19
- data/test/tc_border_pr.rb~ +0 -21
- data/test/tc_package.rb~ +0 -64
- data/test/tc_pie_3D_chart.rb~ +0 -66
- data/test/tc_relationships.rb~ +0 -37
- data/test/tc_series.rb~ +0 -31
- data/test/tc_styles.rb~ +0 -64
- data/test/tc_validators.rb~ +0 -77
- data/test/tc_worksheet.rb~ +0 -85
- data/test/workbook/worksheet/tc_row.rb~ +0 -30
- 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
|
data/test/stylesheet/tc_xf.rb~
DELETED
@@ -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
|
data/test/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("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
|
data/test/tc_border_pr.rb~
DELETED
@@ -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
|
-
|
data/test/tc_package.rb~
DELETED
@@ -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
|
data/test/tc_pie_3D_chart.rb~
DELETED
@@ -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
|
data/test/tc_relationships.rb~
DELETED
@@ -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
|
data/test/tc_series.rb~
DELETED
@@ -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
|
data/test/tc_styles.rb~
DELETED
@@ -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
|
data/test/tc_validators.rb~
DELETED
@@ -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
|
-
|