axlsx 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +13 -0
- data/lib/axlsx.rb +38 -0
- data/lib/axlsx/content_type/content_type.rb +23 -0
- data/lib/axlsx/content_type/default.rb +32 -0
- data/lib/axlsx/content_type/override.rb +30 -0
- data/lib/axlsx/doc_props/app.rb +148 -0
- data/lib/axlsx/doc_props/core.rb +34 -0
- data/lib/axlsx/drawing/axis.rb +78 -0
- data/lib/axlsx/drawing/bar_3D_chart.rb +138 -0
- data/lib/axlsx/drawing/bar_series.rb +91 -0
- data/lib/axlsx/drawing/cat_axis.rb +58 -0
- data/lib/axlsx/drawing/chart.rb +120 -0
- data/lib/axlsx/drawing/drawing.rb +121 -0
- data/lib/axlsx/drawing/graphic_frame.rb +55 -0
- data/lib/axlsx/drawing/marker.rb +57 -0
- data/lib/axlsx/drawing/pie_3D_chart.rb +59 -0
- data/lib/axlsx/drawing/pie_series.rb +88 -0
- data/lib/axlsx/drawing/scaling.rb +53 -0
- data/lib/axlsx/drawing/series.rb +70 -0
- data/lib/axlsx/drawing/title.rb +69 -0
- data/lib/axlsx/drawing/two_cell_anchor.rb +88 -0
- data/lib/axlsx/drawing/val_axis.rb +34 -0
- data/lib/axlsx/drawing/view_3D.rb +72 -0
- data/lib/axlsx/package.rb +181 -0
- data/lib/axlsx/rels/relationship.rb +43 -0
- data/lib/axlsx/rels/relationships.rb +25 -0
- data/lib/axlsx/stylesheet/border.rb +52 -0
- data/lib/axlsx/stylesheet/border_pr.rb +65 -0
- data/lib/axlsx/stylesheet/cell_alignment.rb +96 -0
- data/lib/axlsx/stylesheet/cell_protection.rb +33 -0
- data/lib/axlsx/stylesheet/cell_style.rb +60 -0
- data/lib/axlsx/stylesheet/color.rb +57 -0
- data/lib/axlsx/stylesheet/fill.rb +31 -0
- data/lib/axlsx/stylesheet/font.rb +128 -0
- data/lib/axlsx/stylesheet/gradient_fill.rb +70 -0
- data/lib/axlsx/stylesheet/gradient_stop.rb +31 -0
- data/lib/axlsx/stylesheet/num_fmt.rb +61 -0
- data/lib/axlsx/stylesheet/pattern_fill.rb +64 -0
- data/lib/axlsx/stylesheet/styles.rb +296 -0
- data/lib/axlsx/stylesheet/table_style.rb +44 -0
- data/lib/axlsx/stylesheet/table_style_element.rb +66 -0
- data/lib/axlsx/stylesheet/table_styles.rb +39 -0
- data/lib/axlsx/stylesheet/xf.rb +117 -0
- data/lib/axlsx/util/constants.rb +189 -0
- data/lib/axlsx/util/simple_typed_list.rb +150 -0
- data/lib/axlsx/util/validators.rb +132 -0
- data/lib/axlsx/workbook/workbook.rb +130 -0
- data/lib/axlsx/workbook/worksheet/cell.rb +184 -0
- data/lib/axlsx/workbook/worksheet/row.rb +92 -0
- data/lib/axlsx/workbook/worksheet/worksheet.rb +194 -0
- data/lib/schema/dc.xsd +118 -0
- data/lib/schema/dcmitype.xsd +50 -0
- data/lib/schema/dcterms.xsd +331 -0
- data/lib/schema/dml-chart.xsd +1499 -0
- data/lib/schema/dml-chartDrawing.xsd +146 -0
- data/lib/schema/dml-compatibility.xsd +14 -0
- data/lib/schema/dml-diagram.xsd +1091 -0
- data/lib/schema/dml-lockedCanvas.xsd +11 -0
- data/lib/schema/dml-main.xsd +3048 -0
- data/lib/schema/dml-picture.xsd +23 -0
- data/lib/schema/dml-spreadsheetDrawing.xsd +185 -0
- data/lib/schema/dml-wordprocessingDrawing.xsd +185 -0
- data/lib/schema/opc-contentTypes.xsd +42 -0
- data/lib/schema/opc-coreProperties.xsd +50 -0
- data/lib/schema/opc-digSig.xsd +49 -0
- data/lib/schema/opc-relationships.xsd +33 -0
- data/lib/schema/pml.xsd +1676 -0
- data/lib/schema/shared-additionalCharacteristics.xsd +28 -0
- data/lib/schema/shared-bibliography.xsd +144 -0
- data/lib/schema/shared-commonSimpleTypes.xsd +166 -0
- data/lib/schema/shared-customXmlDataProperties.xsd +25 -0
- data/lib/schema/shared-customXmlSchemaProperties.xsd +18 -0
- data/lib/schema/shared-documentPropertiesCustom.xsd +59 -0
- data/lib/schema/shared-documentPropertiesExtended.xsd +56 -0
- data/lib/schema/shared-documentPropertiesVariantTypes.xsd +195 -0
- data/lib/schema/shared-math.xsd +582 -0
- data/lib/schema/shared-relationshipReference.xsd +25 -0
- data/lib/schema/sml.xsd +4430 -0
- data/lib/schema/vml-main.xsd +569 -0
- data/lib/schema/vml-officeDrawing.xsd +509 -0
- data/lib/schema/vml-presentationDrawing.xsd +12 -0
- data/lib/schema/vml-spreadsheetDrawing.xsd +108 -0
- data/lib/schema/vml-wordprocessingDrawing.xsd +96 -0
- data/lib/schema/wml.xsd +3644 -0
- data/lib/schema/xml.xsd +117 -0
- data/test/content_type/tc_content_type.rb +81 -0
- data/test/content_type/tc_content_type.rb~ +81 -0
- data/test/content_type/tc_default.rb +40 -0
- data/test/content_type/tc_default.rb~ +40 -0
- data/test/content_type/tc_override.rb +40 -0
- data/test/content_type/tc_override.rb~ +40 -0
- data/test/doc_props/tc_app.rb +19 -0
- data/test/doc_props/tc_app.rb~ +19 -0
- data/test/doc_props/tc_core.rb +34 -0
- data/test/drawing/tc_axis.rb +39 -0
- data/test/drawing/tc_axis.rb~ +0 -0
- data/test/drawing/tc_bar_3D_chart.rb +66 -0
- data/test/drawing/tc_bar_3D_chart.rb~ +4 -0
- data/test/drawing/tc_bar_series.rb +34 -0
- data/test/drawing/tc_bar_series.rb~ +31 -0
- data/test/drawing/tc_cat_axis.rb +32 -0
- data/test/drawing/tc_cat_axis.rb~ +39 -0
- data/test/drawing/tc_chart.rb +59 -0
- data/test/drawing/tc_chart.rb~ +58 -0
- data/test/drawing/tc_drawing.rb +71 -0
- data/test/drawing/tc_graphic_frame.rb +26 -0
- data/test/drawing/tc_graphic_frame.rb~ +21 -0
- data/test/drawing/tc_marker.rb +45 -0
- data/test/drawing/tc_marker.rb~ +26 -0
- data/test/drawing/tc_pie_3D_chart.rb +33 -0
- data/test/drawing/tc_pie_3D_chart.rb~ +58 -0
- data/test/drawing/tc_pie_series.rb +35 -0
- data/test/drawing/tc_pie_series.rb~ +26 -0
- data/test/drawing/tc_scaling.rb +37 -0
- data/test/drawing/tc_scaling.rb~ +45 -0
- data/test/drawing/tc_series.rb +24 -0
- data/test/drawing/tc_series.rb~ +31 -0
- data/test/drawing/tc_title.rb +34 -0
- data/test/drawing/tc_title.rb~ +37 -0
- data/test/drawing/tc_two_cell_anchor.rb +37 -0
- data/test/drawing/tc_two_cell_anchor.rb~ +35 -0
- data/test/drawing/tc_val_axis.rb +20 -0
- data/test/drawing/tc_val_axis.rb~ +32 -0
- data/test/drawing/tc_view_3D.rb +46 -0
- data/test/drawing/tc_view_3D.rb~ +37 -0
- data/test/rels/tc_relationship.rb +16 -0
- data/test/rels/tc_relationship.rb~ +39 -0
- data/test/rels/tc_relationships.rb +32 -0
- data/test/rels/tc_relationships.rb~ +37 -0
- data/test/stylesheet/tc_border.rb +38 -0
- data/test/stylesheet/tc_border.rb~ +31 -0
- data/test/stylesheet/tc_border_pr.rb +33 -0
- data/test/stylesheet/tc_border_pr.rb~ +31 -0
- data/test/stylesheet/tc_cell_alignment.rb +77 -0
- data/test/stylesheet/tc_cell_alignment.rb~ +38 -0
- data/test/stylesheet/tc_cell_protection.rb +30 -0
- data/test/stylesheet/tc_cell_protection.rb~ +77 -0
- data/test/stylesheet/tc_cell_style.rb +58 -0
- data/test/stylesheet/tc_cell_style.rb~ +30 -0
- data/test/stylesheet/tc_color.rb +38 -0
- data/test/stylesheet/tc_color.rb~ +38 -0
- data/test/stylesheet/tc_fill.rb +19 -0
- data/test/stylesheet/tc_fill.rb~ +19 -0
- data/test/stylesheet/tc_font.rb +114 -0
- data/test/stylesheet/tc_font.rb~ +19 -0
- data/test/stylesheet/tc_gradient_fill.rb +65 -0
- data/test/stylesheet/tc_gradient_fill.rb~ +114 -0
- data/test/stylesheet/tc_gradient_stop.rb +32 -0
- data/test/stylesheet/tc_gradient_stop.rb~ +65 -0
- data/test/stylesheet/tc_num_fmt.rb +31 -0
- data/test/stylesheet/tc_num_fmt.rb~ +32 -0
- data/test/stylesheet/tc_pattern_fill.rb +38 -0
- data/test/stylesheet/tc_pattern_fill.rb~ +31 -0
- data/test/stylesheet/tc_styles.rb +64 -0
- data/test/stylesheet/tc_table_style.rb +37 -0
- data/test/stylesheet/tc_table_style.rb~ +38 -0
- data/test/stylesheet/tc_table_style_element.rb +37 -0
- data/test/stylesheet/tc_table_style_element.rb~ +37 -0
- data/test/stylesheet/tc_table_styles.rb +30 -0
- data/test/stylesheet/tc_table_styles.rb~ +37 -0
- data/test/stylesheet/tc_xf.rb +121 -0
- data/test/stylesheet/tc_xf.rb~ +30 -0
- data/test/tc_app.rb~ +19 -0
- data/test/tc_border_pr.rb~ +21 -0
- data/test/tc_package.rb +70 -0
- data/test/tc_package.rb~ +64 -0
- data/test/tc_pie_3D_chart.rb~ +66 -0
- data/test/tc_relationships.rb~ +37 -0
- data/test/tc_series.rb~ +31 -0
- data/test/tc_styles.rb~ +64 -0
- data/test/tc_validators.rb~ +77 -0
- data/test/tc_worksheet.rb~ +85 -0
- data/test/util/tc_simple_typed_list.rb +66 -0
- data/test/util/tc_validators.rb +76 -0
- data/test/workbook/tc_workbook.rb +53 -0
- data/test/workbook/worksheet/tc_cell.rb +78 -0
- data/test/workbook/worksheet/tc_row.rb +30 -0
- data/test/workbook/worksheet/tc_worksheet.rb +85 -0
- metadata +378 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'axlsx.rb'
|
3
|
+
|
4
|
+
class TestNumFmt < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@item = Axlsx::NumFmt.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def test_initialiation
|
15
|
+
assert_equal(@item.numFmtId, 0)
|
16
|
+
assert_equal(@item.formatCode, "")
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_numFmtId
|
20
|
+
assert_raise(ArgumentError) { @item.numFmtId = -1.1 }
|
21
|
+
assert_nothing_raised { @item.numFmtId = 2 }
|
22
|
+
assert_equal(@item.numFmtId, 2)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_fomatCode
|
26
|
+
assert_raise(ArgumentError) { @item.formatCode = -1.1 }
|
27
|
+
assert_nothing_raised { @item.formatCode = "0" }
|
28
|
+
assert_equal(@item.formatCode, "0")
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'axlsx.rb'
|
3
|
+
|
4
|
+
class TestNumFmt < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@item = Axlsx::NumFmt.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def test_initialiation
|
15
|
+
assert_equal(@item.color.rgb, "FFFF0000")
|
16
|
+
assert_equal(@item.position, 1.0)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_position
|
20
|
+
assert_raise(ArgumentError) { @item.position = -1.1 }
|
21
|
+
assert_nothing_raised { @item.position = 0.0 }
|
22
|
+
assert_equal(@item.position, 0.0)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_color
|
26
|
+
assert_raise(ArgumentError) { @item.color = nil }
|
27
|
+
color = Axlsx::Color.new(:rgb=>"FF0000FF")
|
28
|
+
@item.color = color
|
29
|
+
assert_equal(@item.color.rgb, "FF0000FF")
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'axlsx.rb'
|
3
|
+
|
4
|
+
class TestPatternFill < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@item = Axlsx::PatternFill.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def test_initialiation
|
15
|
+
assert_equal(@item.patternType, :none)
|
16
|
+
assert_equal(@item.bgColor, nil)
|
17
|
+
assert_equal(@item.fgColor, nil)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_bgColor
|
21
|
+
assert_raise(ArgumentError) { @item.bgColor = -1.1 }
|
22
|
+
assert_nothing_raised { @item.bgColor = Axlsx::Color.new }
|
23
|
+
assert_equal(@item.bgColor.rgb, "FF000000")
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_fgColor
|
27
|
+
assert_raise(ArgumentError) { @item.fgColor = -1.1 }
|
28
|
+
assert_nothing_raised { @item.fgColor = Axlsx::Color.new }
|
29
|
+
assert_equal(@item.fgColor.rgb, "FF000000")
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_pattern_type
|
33
|
+
assert_raise(ArgumentError) { @item.patternType = -1.1 }
|
34
|
+
assert_nothing_raised { @item.patternType = :lightUp }
|
35
|
+
assert_equal(@item.patternType, :lightUp)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'axlsx.rb'
|
3
|
+
|
4
|
+
class TestPatternFill < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@item = Axlsx::PatternFill.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def test_initialiation
|
15
|
+
assert_equal(@item.numFmtId, 0)
|
16
|
+
assert_equal(@item.formatCode, "")
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_numFmtId
|
20
|
+
assert_raise(ArgumentError) { @item.numFmtId = -1.1 }
|
21
|
+
assert_nothing_raised { @item.numFmtId = 2 }
|
22
|
+
assert_equal(@item.numFmtId, 2)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_fomatCode
|
26
|
+
assert_raise(ArgumentError) { @item.formatCode = -1.1 }
|
27
|
+
assert_nothing_raised { @item.formatCode = "0" }
|
28
|
+
assert_equal(@item.formatCode, "0")
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,64 @@
|
|
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, :num_fmt=>Axlsx::NUM_FMT_PERCENT, :alignment=>{:horizontal=>:left}, :border=>Axlsx::STYLE_THIN_BORDER, :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::STYLE_THIN_BORDER, "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 :border => 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, 2, "cellXfs should be locked at 2" )
|
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
|
@@ -0,0 +1,37 @@
|
|
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
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'axlsx.rb'
|
3
|
+
|
4
|
+
class TestTableStyle < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@item = Axlsx::TableStyle.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def test_initialiation
|
15
|
+
assert_equal(@item.patternType, :none)
|
16
|
+
assert_equal(@item.bgColor, nil)
|
17
|
+
assert_equal(@item.fgColor, nil)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_bgColor
|
21
|
+
assert_raise(ArgumentError) { @item.bgColor = -1.1 }
|
22
|
+
assert_nothing_raised { @item.bgColor = Axlsx::Color.new }
|
23
|
+
assert_equal(@item.bgColor.rgb, "FF000000")
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_fgColor
|
27
|
+
assert_raise(ArgumentError) { @item.fgColor = -1.1 }
|
28
|
+
assert_nothing_raised { @item.fgColor = Axlsx::Color.new }
|
29
|
+
assert_equal(@item.fgColor.rgb, "FF000000")
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_pattern_type
|
33
|
+
assert_raise(ArgumentError) { @item.patternType = -1.1 }
|
34
|
+
assert_nothing_raised { @item.patternType = :lightUp }
|
35
|
+
assert_equal(@item.patternType, :lightUp)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'axlsx.rb'
|
3
|
+
|
4
|
+
class TestTableStyleElement < 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
|
@@ -0,0 +1,37 @@
|
|
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
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'axlsx.rb'
|
3
|
+
|
4
|
+
class TestTableStyles < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@item = Axlsx::TableStyles.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
|
@@ -0,0 +1,37 @@
|
|
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
|
@@ -0,0 +1,121 @@
|
|
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.alignment, nil)
|
15
|
+
assert_equal(@item.protection, nil)
|
16
|
+
assert_equal(@item.numFmtId, nil)
|
17
|
+
assert_equal(@item.fontId, nil)
|
18
|
+
assert_equal(@item.fillId, nil)
|
19
|
+
assert_equal(@item.borderId, nil)
|
20
|
+
assert_equal(@item.xfId, nil)
|
21
|
+
assert_equal(@item.quotePrefix, nil)
|
22
|
+
assert_equal(@item.pivotButton, nil)
|
23
|
+
assert_equal(@item.applyNumberFormat, nil)
|
24
|
+
assert_equal(@item.applyFont, nil)
|
25
|
+
assert_equal(@item.applyFill, nil)
|
26
|
+
assert_equal(@item.applyBorder, nil)
|
27
|
+
assert_equal(@item.applyAlignment, nil)
|
28
|
+
assert_equal(@item.applyProtection, nil)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_alignment
|
32
|
+
assert_raise(ArgumentError) { @item.alignment = -1.1 }
|
33
|
+
assert_nothing_raised { @item.alignment = Axlsx::CellAlignment.new }
|
34
|
+
assert(@item.alignment.is_a?(Axlsx::CellAlignment))
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_protection
|
38
|
+
assert_raise(ArgumentError) { @item.protection = -1.1 }
|
39
|
+
assert_nothing_raised { @item.protection = Axlsx::CellProtection.new }
|
40
|
+
assert(@item.protection.is_a?(Axlsx::CellProtection))
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_numFmtId
|
44
|
+
assert_raise(ArgumentError) { @item.numFmtId = -1.1 }
|
45
|
+
assert_nothing_raised { @item.numFmtId = 0 }
|
46
|
+
assert_equal(@item.numFmtId, 0)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_fillId
|
50
|
+
assert_raise(ArgumentError) { @item.fillId = -1.1 }
|
51
|
+
assert_nothing_raised { @item.fillId = 0 }
|
52
|
+
assert_equal(@item.fillId, 0)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_fontId
|
56
|
+
assert_raise(ArgumentError) { @item.fontId = -1.1 }
|
57
|
+
assert_nothing_raised { @item.fontId = 0 }
|
58
|
+
assert_equal(@item.fontId, 0)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_borderId
|
62
|
+
assert_raise(ArgumentError) { @item.borderId = -1.1 }
|
63
|
+
assert_nothing_raised { @item.borderId = 0 }
|
64
|
+
assert_equal(@item.borderId, 0)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_xfId
|
68
|
+
assert_raise(ArgumentError) { @item.xfId = -1.1 }
|
69
|
+
assert_nothing_raised { @item.xfId = 0 }
|
70
|
+
assert_equal(@item.xfId, 0)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_quotePrefix
|
74
|
+
assert_raise(ArgumentError) { @item.quotePrefix = -1.1 }
|
75
|
+
assert_nothing_raised { @item.quotePrefix = false }
|
76
|
+
assert_equal(@item.quotePrefix, false)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_pivotButton
|
80
|
+
assert_raise(ArgumentError) { @item.pivotButton = -1.1 }
|
81
|
+
assert_nothing_raised { @item.pivotButton = false }
|
82
|
+
assert_equal(@item.pivotButton, false)
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_applyNumberFormat
|
86
|
+
assert_raise(ArgumentError) { @item.applyNumberFormat = -1.1 }
|
87
|
+
assert_nothing_raised { @item.applyNumberFormat = false }
|
88
|
+
assert_equal(@item.applyNumberFormat, false)
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_applyFont
|
92
|
+
assert_raise(ArgumentError) { @item.applyFont = -1.1 }
|
93
|
+
assert_nothing_raised { @item.applyFont = false }
|
94
|
+
assert_equal(@item.applyFont, false)
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_applyFill
|
98
|
+
assert_raise(ArgumentError) { @item.applyFill = -1.1 }
|
99
|
+
assert_nothing_raised { @item.applyFill = false }
|
100
|
+
assert_equal(@item.applyFill, false)
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_applyBorder
|
104
|
+
assert_raise(ArgumentError) { @item.applyBorder = -1.1 }
|
105
|
+
assert_nothing_raised { @item.applyBorder = false }
|
106
|
+
assert_equal(@item.applyBorder, false)
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_applyAlignment
|
110
|
+
assert_raise(ArgumentError) { @item.applyAlignment = -1.1 }
|
111
|
+
assert_nothing_raised { @item.applyAlignment = false }
|
112
|
+
assert_equal(@item.applyAlignment, false)
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_applyProtection
|
116
|
+
assert_raise(ArgumentError) { @item.applyProtection = -1.1 }
|
117
|
+
assert_nothing_raised { @item.applyProtection = false }
|
118
|
+
assert_equal(@item.applyProtection, false)
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|