axlsx 1.1.0 → 1.2.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/.yardopts +5 -2
- data/CHANGELOG.md +78 -0
- data/LICENSE +1 -1
- data/README.md +132 -331
- data/Rakefile +17 -5
- data/examples/basic_charts.rb +54 -0
- data/examples/chart_colors.rb +88 -0
- data/examples/conditional_formatting/example_conditional_formatting.rb +72 -0
- data/examples/conditional_formatting/getting_barred.rb +37 -0
- data/examples/conditional_formatting/hitting_the_high_notes.rb +37 -0
- data/examples/conditional_formatting/scaled_colors.rb +39 -0
- data/examples/conditional_formatting/stop_and_go.rb +37 -0
- data/examples/data_validation.rb +50 -0
- data/examples/example.rb +300 -152
- data/examples/example.xlsx +0 -0
- data/examples/example_streamed.xlsx +0 -0
- data/examples/extractive.pdf +0 -0
- data/examples/extractive.rb +45 -0
- data/examples/no-use_autowidth.xlsx +0 -0
- data/examples/sample.png +0 -0
- data/examples/scraping_html.rb +91 -0
- data/examples/shared_strings_example.xlsx +0 -0
- data/examples/sheet_protection.rb +10 -0
- data/examples/sheet_view.rb +34 -0
- data/examples/skydrive/real_example.rb +63 -0
- data/examples/two_cell_anchor_image.rb +11 -0
- data/lib/axlsx/content_type/content_type.rb +2 -0
- data/lib/axlsx/content_type/default.rb +30 -15
- data/lib/axlsx/content_type/override.rb +29 -14
- data/lib/axlsx/doc_props/app.rb +161 -104
- data/lib/axlsx/doc_props/core.rb +9 -5
- data/lib/axlsx/drawing/ax_data_source.rb +26 -0
- data/lib/axlsx/drawing/axis.rb +106 -35
- data/lib/axlsx/drawing/bar_3D_chart.rb +49 -45
- data/lib/axlsx/drawing/bar_series.rb +25 -7
- data/lib/axlsx/drawing/cat_axis.rb +50 -22
- data/lib/axlsx/drawing/chart.rb +69 -56
- data/lib/axlsx/drawing/d_lbls.rb +100 -0
- data/lib/axlsx/drawing/drawing.rb +28 -12
- data/lib/axlsx/drawing/graphic_frame.rb +2 -1
- data/lib/axlsx/drawing/line_3D_chart.rb +3 -10
- data/lib/axlsx/drawing/line_series.rb +20 -4
- data/lib/axlsx/drawing/num_data.rb +52 -0
- data/lib/axlsx/drawing/num_data_source.rb +61 -0
- data/lib/axlsx/drawing/num_val.rb +32 -0
- data/lib/axlsx/drawing/pic.rb +44 -4
- data/lib/axlsx/drawing/pie_3D_chart.rb +10 -7
- data/lib/axlsx/drawing/pie_series.rb +18 -4
- data/lib/axlsx/drawing/scatter_chart.rb +12 -18
- data/lib/axlsx/drawing/scatter_series.rb +28 -2
- data/lib/axlsx/drawing/ser_axis.rb +1 -1
- data/lib/axlsx/drawing/series.rb +1 -1
- data/lib/axlsx/drawing/str_data.rb +42 -0
- data/lib/axlsx/drawing/str_val.rb +33 -0
- data/lib/axlsx/drawing/title.rb +21 -9
- data/lib/axlsx/drawing/two_cell_anchor.rb +46 -9
- data/lib/axlsx/drawing/view_3D.rb +44 -31
- data/lib/axlsx/drawing/vml_drawing.rb +42 -0
- data/lib/axlsx/drawing/vml_shape.rb +125 -0
- data/lib/axlsx/package.rb +44 -16
- data/lib/axlsx/rels/relationship.rb +3 -3
- data/lib/axlsx/rels/relationships.rb +1 -11
- data/lib/axlsx/stylesheet/color.rb +0 -1
- data/lib/axlsx/stylesheet/dxf.rb +79 -0
- data/lib/axlsx/stylesheet/font.rb +2 -1
- data/lib/axlsx/stylesheet/gradient_fill.rb +1 -1
- data/lib/axlsx/stylesheet/styles.rb +143 -50
- data/lib/axlsx/stylesheet/table_style.rb +3 -3
- data/lib/axlsx/stylesheet/xf.rb +2 -0
- data/lib/axlsx/util/constants.rb +36 -0
- data/lib/axlsx/util/simple_typed_list.rb +15 -21
- data/lib/axlsx/util/validators.rb +122 -5
- data/lib/axlsx/version.rb +2 -7
- data/lib/axlsx/workbook/defined_name.rb +174 -0
- data/lib/axlsx/workbook/defined_names.rb +21 -0
- data/lib/axlsx/workbook/shared_strings_table.rb +12 -13
- data/lib/axlsx/workbook/workbook.rb +71 -13
- data/lib/axlsx/workbook/worksheet/auto_filter.rb +34 -0
- data/lib/axlsx/workbook/worksheet/cell.rb +45 -36
- data/lib/axlsx/workbook/worksheet/cfvo.rb +62 -0
- data/lib/axlsx/workbook/worksheet/col.rb +17 -1
- data/lib/axlsx/workbook/worksheet/color_scale.rb +76 -0
- data/lib/axlsx/workbook/worksheet/cols.rb +20 -0
- data/lib/axlsx/workbook/worksheet/comment.rb +101 -0
- data/lib/axlsx/workbook/worksheet/comments.rb +85 -0
- data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +82 -0
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +216 -0
- data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +25 -0
- data/lib/axlsx/workbook/worksheet/data_bar.rb +97 -0
- data/lib/axlsx/workbook/worksheet/data_validation.rb +245 -0
- data/lib/axlsx/workbook/worksheet/data_validations.rb +28 -0
- data/lib/axlsx/workbook/worksheet/dimension.rb +65 -0
- data/lib/axlsx/workbook/worksheet/icon_set.rb +83 -0
- data/lib/axlsx/workbook/worksheet/merged_cells.rb +35 -0
- data/lib/axlsx/workbook/worksheet/page_setup.rb +113 -0
- data/lib/axlsx/workbook/worksheet/pane.rb +144 -0
- data/lib/axlsx/workbook/worksheet/print_options.rb +63 -0
- data/lib/axlsx/workbook/worksheet/protected_range.rb +46 -0
- data/lib/axlsx/workbook/worksheet/protected_ranges.rb +34 -0
- data/lib/axlsx/workbook/worksheet/row.rb +69 -12
- data/lib/axlsx/workbook/worksheet/selection.rb +111 -0
- data/lib/axlsx/workbook/worksheet/sheet_data.rb +25 -0
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +24 -0
- data/lib/axlsx/workbook/worksheet/sheet_protection.rb +224 -0
- data/lib/axlsx/workbook/worksheet/sheet_view.rb +379 -0
- data/lib/axlsx/workbook/worksheet/table.rb +3 -3
- data/lib/axlsx/workbook/worksheet/tables.rb +31 -0
- data/lib/axlsx/workbook/worksheet/worksheet.rb +379 -233
- data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +57 -0
- data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +64 -0
- data/lib/axlsx.rb +31 -16
- data/test/benchmark.rb +30 -38
- data/test/content_type/tc_content_type.rb +1 -6
- data/test/doc_props/tc_app.rb +31 -1
- data/test/doc_props/tc_core.rb +3 -1
- data/test/drawing/tc_axis.rb +46 -3
- data/test/drawing/tc_bar_3D_chart.rb +12 -12
- data/test/drawing/tc_bar_series.rb +17 -13
- data/test/drawing/tc_cat_axis.rb +3 -3
- data/test/drawing/tc_cat_axis_data.rb +23 -13
- data/test/drawing/tc_chart.rb +29 -11
- data/test/drawing/tc_d_lbls.rb +47 -0
- data/test/drawing/tc_data_source.rb +17 -0
- data/test/drawing/tc_drawing.rb +11 -5
- data/test/drawing/tc_hyperlink.rb +4 -5
- data/test/drawing/tc_line_series.rb +9 -11
- data/test/drawing/tc_named_axis_data.rb +27 -0
- data/test/drawing/tc_num_data.rb +31 -0
- data/test/drawing/tc_num_val.rb +29 -0
- data/test/drawing/tc_pic.rb +22 -2
- data/test/drawing/tc_pie_3D_chart.rb +4 -8
- data/test/drawing/tc_pie_series.rb +11 -13
- data/test/drawing/tc_scatter_chart.rb +6 -1
- data/test/drawing/tc_scatter_series.rb +6 -5
- data/test/drawing/tc_series.rb +1 -1
- data/test/drawing/tc_str_data.rb +18 -0
- data/test/drawing/tc_str_val.rb +21 -0
- data/test/drawing/tc_title.rb +16 -0
- data/test/drawing/tc_two_cell_anchor.rb +2 -3
- data/test/drawing/tc_view_3D.rb +18 -18
- data/test/drawing/tc_vml_drawing.rb +25 -0
- data/test/drawing/tc_vml_shape.rb +100 -0
- data/test/profile.rb +2 -1
- data/test/rels/tc_relationship.rb +1 -0
- data/test/stylesheet/tc_dxf.rb +81 -0
- data/test/stylesheet/tc_gradient_fill.rb +8 -0
- data/test/stylesheet/tc_pattern_fill.rb +7 -1
- data/test/stylesheet/tc_styles.rb +163 -3
- data/test/stylesheet/tc_table_style.rb +8 -0
- data/test/stylesheet/tc_table_style_element.rb +10 -1
- data/test/tc_helper.rb +1 -0
- data/test/tc_package.rb +93 -17
- data/test/util/tc_simple_typed_list.rb +13 -0
- data/test/util/tc_validators.rb +95 -9
- data/test/workbook/tc_defined_name.rb +41 -0
- data/test/workbook/tc_workbook.rb +5 -3
- data/test/workbook/worksheet/table/tc_table.rb +3 -11
- data/test/workbook/worksheet/tc_cell.rb +52 -18
- data/test/workbook/worksheet/tc_cfvo.rb +31 -0
- data/test/workbook/worksheet/tc_col.rb +9 -0
- data/test/workbook/worksheet/tc_color_scale.rb +29 -0
- data/test/workbook/worksheet/tc_comment.rb +57 -0
- data/test/workbook/worksheet/tc_comments.rb +57 -0
- data/test/workbook/worksheet/tc_conditional_formatting.rb +217 -0
- data/test/workbook/worksheet/tc_data_bar.rb +39 -0
- data/test/workbook/worksheet/tc_data_validation.rb +265 -0
- data/test/workbook/worksheet/tc_date_time_converter.rb +11 -5
- data/test/workbook/worksheet/tc_icon_set.rb +45 -0
- data/test/workbook/worksheet/tc_page_setup.rb +138 -0
- data/test/workbook/worksheet/tc_pane.rb +94 -0
- data/test/workbook/worksheet/tc_print_options.rb +72 -0
- data/test/workbook/worksheet/tc_protected_range.rb +17 -0
- data/test/workbook/worksheet/tc_row.rb +44 -13
- data/test/workbook/worksheet/tc_selection.rb +94 -0
- data/test/workbook/worksheet/tc_sheet_protection.rb +117 -0
- data/test/workbook/worksheet/tc_sheet_view.rb +214 -0
- data/test/workbook/worksheet/tc_worksheet.rb +147 -50
- metadata +216 -148
- data/examples/example.csv +0 -1000
- data/examples/example.rb~ +0 -112
- data/lib/axlsx/drawing/cat_axis_data.rb +0 -34
- data/lib/axlsx/drawing/hlink_click.rb~ +0 -0
- data/lib/axlsx/drawing/hyperlink.rb~ +0 -64
- data/lib/axlsx/drawing/named_axis_data.rb +0 -36
- data/lib/axlsx/drawing/picture_locking.rb~ +0 -36
- data/lib/axlsx/drawing/val_axis_data.rb +0 -27
- data/lib/axlsx/stylesheet/#num_fmt.rb# +0 -69
- data/lib/axlsx/util/cbf.rb +0 -333
- data/lib/axlsx/util/cfb.rb~ +0 -201
- data/lib/axlsx/util/ms_off_crypto.rb +0 -189
- data/lib/axlsx/util/ms_off_crypto.rb~ +0 -3
- data/lib/axlsx/util/ms_offcrypto.rb~ +0 -0
- data/lib/axlsx/util/parser.rb~ +0 -6
- data/lib/axlsx/util/storage.rb~ +0 -0
- data/lib/axlsx/workbook/shared_strings_table.rb~ +0 -69
- data/lib/axlsx/workbook/worksheet/col.rb~ +0 -0
- data/lib/axlsx/workbook/worksheet/shared_strings_table.rb~ +0 -0
- data/lib/axlsx/workbook/worksheet/table.rb~ +0 -97
- data/lib/schema/dc.xsd~ +0 -118
- data/lib/schema/dcterms.xsd~ +0 -331
- data/lib/schema/opc-coreProperties.xsd~ +0 -50
- data/test/#benchmark.txt# +0 -7
- data/test/#tc_helper.rb# +0 -3
- data/test/benchmark.rb~ +0 -0
- data/test/benchmark.txt +0 -6
- data/test/benchmark.txt~ +0 -6
- data/test/drawing/tc_val_axis_data.rb +0 -17
- data/test/example.csv +0 -1000
- data/test/example.xlsx +0 -0
- data/test/example_streamed.xlsx +0 -0
- data/test/tc_axlsx.rb~ +0 -0
- data/test/tc_helper.rb~ +0 -3
- data/test/workbook/worksheet/table/tc_table.rb~ +0 -72
- data/test/workbook/worksheet/tc_col.rb~ +0 -10
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
require 'tc_helper.rb'
|
|
2
|
+
|
|
3
|
+
class TestPageSetup < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
def setup
|
|
6
|
+
@p = Axlsx::Package.new
|
|
7
|
+
ws = @p.workbook.add_worksheet :name => "hmmm"
|
|
8
|
+
@ps = ws.page_setup
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_initialize
|
|
12
|
+
assert_equal(nil, @ps.fit_to_height)
|
|
13
|
+
assert_equal(nil, @ps.fit_to_width)
|
|
14
|
+
assert_equal(nil, @ps.orientation)
|
|
15
|
+
assert_equal(nil, @ps.paper_height)
|
|
16
|
+
assert_equal(nil, @ps.paper_width)
|
|
17
|
+
assert_equal(nil, @ps.scale)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_initialize_with_options
|
|
21
|
+
page_setup = { :fit_to_height => 1,
|
|
22
|
+
:fit_to_width => 2,
|
|
23
|
+
:orientation => :landscape,
|
|
24
|
+
:paper_height => "297mm",
|
|
25
|
+
:paper_width => "210mm",
|
|
26
|
+
:scale => 50 }
|
|
27
|
+
|
|
28
|
+
optioned = @p.workbook.add_worksheet(:name => 'optioned', :page_setup => page_setup).page_setup
|
|
29
|
+
assert_equal(1, optioned.fit_to_height)
|
|
30
|
+
assert_equal(2, optioned.fit_to_width)
|
|
31
|
+
assert_equal(:landscape, optioned.orientation)
|
|
32
|
+
assert_equal("297mm", optioned.paper_height)
|
|
33
|
+
assert_equal("210mm", optioned.paper_width)
|
|
34
|
+
assert_equal(50, optioned.scale)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_set_all_values
|
|
38
|
+
@ps.set(:fit_to_height => 1, :fit_to_width => 2, :orientation => :landscape, :paper_height => "297mm", :paper_width => "210mm", :scale => 50)
|
|
39
|
+
assert_equal(1, @ps.fit_to_height)
|
|
40
|
+
assert_equal(2, @ps.fit_to_width)
|
|
41
|
+
assert_equal(:landscape, @ps.orientation)
|
|
42
|
+
assert_equal("297mm", @ps.paper_height)
|
|
43
|
+
assert_equal("210mm", @ps.paper_width)
|
|
44
|
+
assert_equal(50, @ps.scale)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_set_some_values
|
|
48
|
+
@ps.set(:fit_to_width => 2, :orientation => :portrait)
|
|
49
|
+
assert_equal(2, @ps.fit_to_width)
|
|
50
|
+
assert_equal(:portrait, @ps.orientation)
|
|
51
|
+
assert_equal(nil, @ps.fit_to_height)
|
|
52
|
+
assert_equal(nil, @ps.paper_height)
|
|
53
|
+
assert_equal(nil, @ps.paper_width)
|
|
54
|
+
assert_equal(nil, @ps.scale)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_default_fit_to_page?
|
|
58
|
+
assert(@ps.fit_to_width == nil && @ps.fit_to_height == nil)
|
|
59
|
+
assert(@ps.fit_to_page? == false)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_with_height_fit_to_page?
|
|
63
|
+
assert(@ps.fit_to_width == nil && @ps.fit_to_height == nil)
|
|
64
|
+
@ps.set(:fit_to_height => 1)
|
|
65
|
+
assert(@ps.fit_to_page?)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def test_with_width_fit_to_page?
|
|
69
|
+
assert(@ps.fit_to_width == nil && @ps.fit_to_height == nil)
|
|
70
|
+
@ps.set(:fit_to_width => 1)
|
|
71
|
+
assert(@ps.fit_to_page?)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def test_to_xml_all_values
|
|
75
|
+
@ps.set(:fit_to_height => 1, :fit_to_width => 2, :orientation => :landscape, :paper_height => "297mm", :paper_width => "210mm", :scale => 50)
|
|
76
|
+
doc = Nokogiri::XML.parse(@ps.to_xml_string)
|
|
77
|
+
assert_equal(1, doc.xpath(".//pageSetup[@fitToHeight='1'][@fitToWidth='2'][@orientation='landscape'][@paperHeight='297mm'][@paperWidth='210mm'][@scale='50']").size)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def test_to_xml_some_values
|
|
81
|
+
@ps.set(:orientation => :portrait)
|
|
82
|
+
doc = Nokogiri::XML.parse(@ps.to_xml_string)
|
|
83
|
+
assert_equal(1, doc.xpath(".//pageSetup[@orientation='portrait']").size)
|
|
84
|
+
assert_equal(0, doc.xpath(".//pageSetup[@fitToHeight]").size)
|
|
85
|
+
assert_equal(0, doc.xpath(".//pageSetup[@fitToWidth]").size)
|
|
86
|
+
assert_equal(0, doc.xpath(".//pageSetup[@paperHeight]").size)
|
|
87
|
+
assert_equal(0, doc.xpath(".//pageSetup[@paperWidth]").size)
|
|
88
|
+
assert_equal(0, doc.xpath(".//pageSetup[@scale]").size)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def test_fit_to_height
|
|
92
|
+
assert_raise(ArgumentError) { @ps.fit_to_height = 1.5 }
|
|
93
|
+
assert_nothing_raised { @ps.fit_to_height = 2 }
|
|
94
|
+
assert_equal(2, @ps.fit_to_height)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def test_fit_to_width
|
|
98
|
+
assert_raise(ArgumentError) { @ps.fit_to_width = false }
|
|
99
|
+
assert_nothing_raised { @ps.fit_to_width = 1 }
|
|
100
|
+
assert_equal(1, @ps.fit_to_width)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def test_orientation
|
|
104
|
+
assert_raise(ArgumentError) { @ps.orientation = "" }
|
|
105
|
+
assert_nothing_raised { @ps.orientation = :default }
|
|
106
|
+
assert_equal(:default, @ps.orientation)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def test_paper_height
|
|
110
|
+
assert_raise(ArgumentError) { @ps.paper_height = 99 }
|
|
111
|
+
assert_nothing_raised { @ps.paper_height = "11in" }
|
|
112
|
+
assert_equal("11in", @ps.paper_height)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def test_paper_width
|
|
116
|
+
assert_raise(ArgumentError) { @ps.paper_width = "22" }
|
|
117
|
+
assert_nothing_raised { @ps.paper_width = "29.7cm" }
|
|
118
|
+
assert_equal("29.7cm", @ps.paper_width)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def test_scale
|
|
122
|
+
assert_raise(ArgumentError) { @ps.scale = 50.5 }
|
|
123
|
+
assert_nothing_raised { @ps.scale = 99 }
|
|
124
|
+
assert_equal(99, @ps.scale)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def test_fit_to
|
|
128
|
+
fits = @ps.fit_to(:width => 1)
|
|
129
|
+
assert_equal([1, 9999], fits)
|
|
130
|
+
fits = @ps.fit_to :height => 1
|
|
131
|
+
assert_equal(fits, [9999,1])
|
|
132
|
+
fits = @ps.fit_to :height => 7, :width => 2
|
|
133
|
+
assert_equal(fits, [2, 7])
|
|
134
|
+
assert_raise(ArgumentError) { puts @ps.fit_to(:width => true)}
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
end
|
|
138
|
+
end
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../"
|
|
3
|
+
require 'tc_helper.rb'
|
|
4
|
+
|
|
5
|
+
class TestPane < Test::Unit::TestCase
|
|
6
|
+
def setup
|
|
7
|
+
#inverse defaults for booleans
|
|
8
|
+
@nil_options = { :active_pane => :bottom_left, :state => :frozen, :top_left_cell => 'A2' }
|
|
9
|
+
@int_0_options = { :x_split => 2, :y_split => 2 }
|
|
10
|
+
|
|
11
|
+
@string_options = { :top_left_cell => 'A2' }
|
|
12
|
+
@integer_options = { :x_split => 2, :y_split => 2 }
|
|
13
|
+
@symbol_options = { :active_pane => :bottom_left, :state => :frozen }
|
|
14
|
+
|
|
15
|
+
@options = @nil_options.merge(@int_0_options)
|
|
16
|
+
|
|
17
|
+
@pane = Axlsx::Pane.new(@options)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_initialize
|
|
21
|
+
pane = Axlsx::Pane.new
|
|
22
|
+
|
|
23
|
+
@nil_options.each do |key, value|
|
|
24
|
+
assert_equal(nil, pane.send(key.to_sym), "initialized default #{key} should be nil")
|
|
25
|
+
assert_equal(value, @pane.send(key.to_sym), "initialized options #{key} should be #{value}")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
@int_0_options.each do |key, value|
|
|
29
|
+
assert_equal(0, pane.send(key.to_sym), "initialized default #{key} should be 0")
|
|
30
|
+
assert_equal(value, @pane.send(key.to_sym), "initialized options #{key} should be #{value}")
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_string_attribute_validation
|
|
35
|
+
@string_options.each do |key, value|
|
|
36
|
+
assert_raise(ArgumentError, "#{key} must be string") { @pane.send("#{key}=".to_sym, :symbol) }
|
|
37
|
+
assert_nothing_raised { @pane.send("#{key}=".to_sym, "foo") }
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_symbol_attribute_validation
|
|
42
|
+
@symbol_options.each do |key, value|
|
|
43
|
+
assert_raise(ArgumentError, "#{key} must be symbol") { @pane.send("#{key}=".to_sym, "foo") }
|
|
44
|
+
assert_nothing_raised { @pane.send("#{key}=".to_sym, value) }
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_integer_attribute_validation
|
|
49
|
+
@integer_options.each do |key, value|
|
|
50
|
+
assert_raise(ArgumentError, "#{key} must be integer") { @pane.send("#{key}=".to_sym, "foo") }
|
|
51
|
+
assert_nothing_raised { @pane.send("#{key}=".to_sym, value) }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_active_pane
|
|
56
|
+
assert_raise(ArgumentError) { @pane.active_pane = "10" }
|
|
57
|
+
assert_nothing_raised { @pane.active_pane = :top_left }
|
|
58
|
+
assert_equal(@pane.active_pane, :top_left)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_state
|
|
62
|
+
assert_raise(ArgumentError) { @pane.state = "foo" }
|
|
63
|
+
assert_nothing_raised { @pane.state = :frozen_split }
|
|
64
|
+
assert_equal(@pane.state, :frozen_split)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def test_x_split
|
|
68
|
+
assert_raise(ArgumentError) { @pane.x_split = "foo´" }
|
|
69
|
+
assert_nothing_raised { @pane.x_split = 200 }
|
|
70
|
+
assert_equal(@pane.x_split, 200)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def test_y_split
|
|
74
|
+
assert_raise(ArgumentError) { @pane.y_split = 'foo' }
|
|
75
|
+
assert_nothing_raised { @pane.y_split = 300 }
|
|
76
|
+
assert_equal(@pane.y_split, 300)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def test_top_left_cell
|
|
80
|
+
assert_raise(ArgumentError) { @pane.top_left_cell = :cell }
|
|
81
|
+
assert_nothing_raised { @pane.top_left_cell = "A2" }
|
|
82
|
+
assert_equal(@pane.top_left_cell, "A2")
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_to_xml
|
|
86
|
+
doc = Nokogiri::XML.parse(@pane.to_xml_string)
|
|
87
|
+
assert_equal(1, doc.xpath("//pane[@ySplit=2][@xSplit='2'][@topLeftCell='A2'][@state='frozen'][@activePane='bottomLeft']").size)
|
|
88
|
+
end
|
|
89
|
+
def test_to_xml_frozen
|
|
90
|
+
pane = Axlsx::Pane.new :state => :frozen, :y_split => 2
|
|
91
|
+
doc = Nokogiri::XML(pane.to_xml_string)
|
|
92
|
+
assert_equal(1, doc.xpath("//pane[@topLeftCell='A3']").size)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require 'tc_helper.rb'
|
|
2
|
+
|
|
3
|
+
class TestPrintOptions < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
def setup
|
|
6
|
+
p = Axlsx::Package.new
|
|
7
|
+
ws = p.workbook.add_worksheet :name => "hmmm"
|
|
8
|
+
@po = ws.print_options
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_initialize
|
|
12
|
+
assert_equal(false, @po.grid_lines)
|
|
13
|
+
assert_equal(false, @po.headings)
|
|
14
|
+
assert_equal(false, @po.horizontal_centered)
|
|
15
|
+
assert_equal(false, @po.vertical_centered)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_initialize_with_options
|
|
19
|
+
optioned = Axlsx::PrintOptions.new(:grid_lines => true, :headings => true, :horizontal_centered => true, :vertical_centered => true)
|
|
20
|
+
assert_equal(true, optioned.grid_lines)
|
|
21
|
+
assert_equal(true, optioned.headings)
|
|
22
|
+
assert_equal(true, optioned.horizontal_centered)
|
|
23
|
+
assert_equal(true, optioned.vertical_centered)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_set_all_values
|
|
27
|
+
@po.set(:grid_lines => true, :headings => true, :horizontal_centered => true, :vertical_centered => true)
|
|
28
|
+
assert_equal(true, @po.grid_lines)
|
|
29
|
+
assert_equal(true, @po.headings)
|
|
30
|
+
assert_equal(true, @po.horizontal_centered)
|
|
31
|
+
assert_equal(true, @po.vertical_centered)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_set_some_values
|
|
35
|
+
@po.set(:grid_lines => true, :headings => true)
|
|
36
|
+
assert_equal(true, @po.grid_lines)
|
|
37
|
+
assert_equal(true, @po.headings)
|
|
38
|
+
assert_equal(false, @po.horizontal_centered)
|
|
39
|
+
assert_equal(false, @po.vertical_centered)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_to_xml
|
|
43
|
+
@po.set(:grid_lines => true, :headings => true, :horizontal_centered => true, :vertical_centered => true)
|
|
44
|
+
doc = Nokogiri::XML.parse(@po.to_xml_string)
|
|
45
|
+
assert_equal(1, doc.xpath(".//printOptions[@gridLines='true'][@headings='true'][@horizontalCentered='true'][@verticalCentered='true']").size)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_grid_lines
|
|
49
|
+
assert_raise(ArgumentError) { @po.grid_lines = 99 }
|
|
50
|
+
assert_nothing_raised { @po.grid_lines = true }
|
|
51
|
+
assert_equal(@po.grid_lines, true)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_headings
|
|
55
|
+
assert_raise(ArgumentError) { @po.headings = 99 }
|
|
56
|
+
assert_nothing_raised { @po.headings = true }
|
|
57
|
+
assert_equal(@po.headings, true)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_horizontal_centered
|
|
61
|
+
assert_raise(ArgumentError) { @po.horizontal_centered = 99 }
|
|
62
|
+
assert_nothing_raised { @po.horizontal_centered = true }
|
|
63
|
+
assert_equal(@po.horizontal_centered, true)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_vertical_centered
|
|
67
|
+
assert_raise(ArgumentError) { @po.vertical_centered = 99 }
|
|
68
|
+
assert_nothing_raised { @po.vertical_centered = true }
|
|
69
|
+
assert_equal(@po.vertical_centered, true)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
require 'tc_helper.rb'
|
|
3
|
+
class TestProtectedRange < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@p = Axlsx::Package.new
|
|
6
|
+
@ws = @p.workbook.add_worksheet { |sheet| sheet.add_row [1,2,3,4,5,6,7,8,9] }
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def test_initialize_options
|
|
10
|
+
assert_nothing_raised {Axlsx::ProtectedRange.new(:sqref => 'A1:B1', :name => "only bob")}
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_range
|
|
14
|
+
r = @ws.protect_range('A1:B1')
|
|
15
|
+
assert_equal('A1:B1', r.sqref)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -27,18 +27,6 @@ class TestRow < Test::Unit::TestCase
|
|
|
27
27
|
r.cells.each { |c| assert_equal(c.style,1) }
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
def test_nil_cells
|
|
31
|
-
row = @ws.add_row([nil,1,2,nil,4,5,nil])
|
|
32
|
-
r_s_xml = Nokogiri::XML(row.to_xml_string(0, ''))
|
|
33
|
-
assert_equal(r_s_xml.xpath(".//row/c").size, 4)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def test_nil_cell_r
|
|
37
|
-
row = @ws.add_row([nil,1,2,nil,4,5,nil])
|
|
38
|
-
r_s_xml = Nokogiri::XML(row.to_xml_string(0, ''))
|
|
39
|
-
assert_equal(r_s_xml.xpath(".//row/c").first['r'], 'B1')
|
|
40
|
-
assert_equal(r_s_xml.xpath(".//row/c").last['r'], 'F1')
|
|
41
|
-
end
|
|
42
30
|
|
|
43
31
|
def test_index
|
|
44
32
|
assert_equal(@row.index, @row.worksheet.rows.index(@row))
|
|
@@ -49,9 +37,22 @@ class TestRow < Test::Unit::TestCase
|
|
|
49
37
|
assert_equal(@row.cells.last, c)
|
|
50
38
|
end
|
|
51
39
|
|
|
40
|
+
def test_add_cell_autowidth_info
|
|
41
|
+
cell = @row.add_cell("this is the cell of cells")
|
|
42
|
+
width = cell.send(:autowidth)
|
|
43
|
+
assert_equal(@ws.column_info.last.width, width)
|
|
44
|
+
end
|
|
45
|
+
|
|
52
46
|
def test_array_to_cells
|
|
53
|
-
r = @ws.add_row [1,2,3], :style=>
|
|
47
|
+
r = @ws.add_row [1,2,3], :style=>1, :types=>[:integer, :string, :float]
|
|
54
48
|
assert_equal(r.cells.size, 3)
|
|
49
|
+
r.cells.each do |c|
|
|
50
|
+
assert_equal(c.style, 1)
|
|
51
|
+
end
|
|
52
|
+
r = @ws.add_row [1,2,3], :style=>[1]
|
|
53
|
+
assert_equal(r.cells.first.style, 1, "only apply style to cells with at the same index of of the style array")
|
|
54
|
+
assert_equal(r.cells.last.style, 0, "only apply style to cells with at the same index of of the style array")
|
|
55
|
+
|
|
55
56
|
end
|
|
56
57
|
|
|
57
58
|
def test_custom_height
|
|
@@ -65,6 +66,31 @@ class TestRow < Test::Unit::TestCase
|
|
|
65
66
|
assert_equal(15, @row.height)
|
|
66
67
|
end
|
|
67
68
|
|
|
69
|
+
|
|
70
|
+
def test_ph
|
|
71
|
+
assert_raise(ArgumentError) { @row.ph = -3 }
|
|
72
|
+
assert_nothing_raised { @row.ph = true }
|
|
73
|
+
assert_equal(true, @row.ph)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_hidden
|
|
77
|
+
assert_raise(ArgumentError) { @row.hidden = -3 }
|
|
78
|
+
assert_nothing_raised { @row.hidden = true }
|
|
79
|
+
assert_equal(true, @row.hidden)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def test_collapsed
|
|
83
|
+
assert_raise(ArgumentError) { @row.collapsed = -3 }
|
|
84
|
+
assert_nothing_raised { @row.collapsed = true }
|
|
85
|
+
assert_equal(true, @row.collapsed)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def test_outlineLevel
|
|
89
|
+
assert_raise(ArgumentError) { @row.outlineLevel = -3 }
|
|
90
|
+
assert_nothing_raised { @row.outlineLevel = 2 }
|
|
91
|
+
assert_equal(2, @row.outlineLevel)
|
|
92
|
+
end
|
|
93
|
+
|
|
68
94
|
def test_to_xml_without_custom_height
|
|
69
95
|
doc = Nokogiri::XML.parse(@row.to_xml_string(0))
|
|
70
96
|
assert_equal(0, doc.xpath(".//row[@ht]").size)
|
|
@@ -72,6 +98,11 @@ class TestRow < Test::Unit::TestCase
|
|
|
72
98
|
end
|
|
73
99
|
|
|
74
100
|
def test_to_xml_string
|
|
101
|
+
@row.height = 20
|
|
102
|
+
@row.s = 1
|
|
103
|
+
@row.outlineLevel = 2
|
|
104
|
+
@row.collapsed = true
|
|
105
|
+
@row.hidden = true
|
|
75
106
|
r_s_xml = Nokogiri::XML(@row.to_xml_string(0, ''))
|
|
76
107
|
assert_equal(r_s_xml.xpath(".//row[@r=1]").size, 1)
|
|
77
108
|
end
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
require 'tc_helper.rb'
|
|
3
|
+
|
|
4
|
+
class TestSelection < Test::Unit::TestCase
|
|
5
|
+
def setup
|
|
6
|
+
@nil_options = { :active_cell => 'A2', :active_cell_id => 1, :pane => :top_left, :sqref => 'A2' }
|
|
7
|
+
@options = @nil_options
|
|
8
|
+
|
|
9
|
+
@string_options = { :active_cell => 'A2', :sqref => 'A2' }
|
|
10
|
+
@integer_options = { :active_cell_id => 1 }
|
|
11
|
+
@symbol_options = { :pane => :top_left }
|
|
12
|
+
|
|
13
|
+
@selection = Axlsx::Selection.new(@options)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_initialize
|
|
17
|
+
selection = Axlsx::Selection.new
|
|
18
|
+
|
|
19
|
+
@nil_options.each do |key, value|
|
|
20
|
+
assert_equal(nil, selection.send(key.to_sym), "initialized default #{key} should be nil")
|
|
21
|
+
assert_equal(value, @selection.send(key.to_sym), "initialized options #{key} should be #{value}")
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_string_attribute_validation
|
|
26
|
+
@string_options.each do |key, value|
|
|
27
|
+
assert_raise(ArgumentError, "#{key} must be string") { @selection.send("#{key}=".to_sym, :symbol) }
|
|
28
|
+
assert_nothing_raised { @selection.send("#{key}=".to_sym, "foo") }
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_symbol_attribute_validation
|
|
33
|
+
@symbol_options.each do |key, value|
|
|
34
|
+
assert_raise(ArgumentError, "#{key} must be symbol") { @selection.send("#{key}=".to_sym, "foo") }
|
|
35
|
+
assert_nothing_raised { @selection.send("#{key}=".to_sym, value) }
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_integer_attribute_validation
|
|
40
|
+
@integer_options.each do |key, value|
|
|
41
|
+
assert_raise(ArgumentError, "#{key} must be integer") { @selection.send("#{key}=".to_sym, "foo") }
|
|
42
|
+
assert_nothing_raised { @selection.send("#{key}=".to_sym, value) }
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def test_active_cell
|
|
47
|
+
assert_raise(ArgumentError) { @selection.active_cell = :active_cell }
|
|
48
|
+
assert_nothing_raised { @selection.active_cell = "F5" }
|
|
49
|
+
assert_equal(@selection.active_cell, "F5")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def test_active_cell_id
|
|
53
|
+
assert_raise(ArgumentError) { @selection.active_cell_id = "foo" }
|
|
54
|
+
assert_nothing_raised { @selection.active_cell_id = 11 }
|
|
55
|
+
assert_equal(@selection.active_cell_id, 11)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_pane
|
|
59
|
+
assert_raise(ArgumentError) { @selection.pane = "foo´" }
|
|
60
|
+
assert_nothing_raised { @selection.pane = :bottom_right }
|
|
61
|
+
assert_equal(@selection.pane, :bottom_right)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_sqref
|
|
65
|
+
assert_raise(ArgumentError) { @selection.sqref = :sqref }
|
|
66
|
+
assert_nothing_raised { @selection.sqref = "G32" }
|
|
67
|
+
assert_equal(@selection.sqref, "G32")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_to_xml
|
|
71
|
+
p = Axlsx::Package.new
|
|
72
|
+
@ws = p.workbook.add_worksheet :name => "sheetview"
|
|
73
|
+
@ws.sheet_view do |vs|
|
|
74
|
+
vs.add_selection(:top_left, { :active_cell => 'B2', :sqref => 'B2' })
|
|
75
|
+
vs.add_selection(:top_right, { :active_cell => 'I10', :sqref => 'I10' })
|
|
76
|
+
vs.add_selection(:bottom_left, { :active_cell => 'E55', :sqref => 'E55' })
|
|
77
|
+
vs.add_selection(:bottom_right, { :active_cell => 'I57', :sqref => 'I57' })
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
doc = Nokogiri::XML.parse(@ws.to_xml_string)
|
|
81
|
+
|
|
82
|
+
assert_equal(1, doc.xpath("//xmlns:worksheet/xmlns:sheetViews/xmlns:sheetView/xmlns:selection[@sqref='B2'][@pane='topLeft'][@activeCell='B2']").size)
|
|
83
|
+
assert doc.xpath("//xmlns:worksheet/xmlns:sheetViews/xmlns:sheetView/xmlns:selection[@sqref='B2'][@pane='topLeft'][@activeCell='B2']")
|
|
84
|
+
|
|
85
|
+
assert_equal(1, doc.xpath("//xmlns:worksheet/xmlns:sheetViews/xmlns:sheetView/xmlns:selection[@sqref='I10'][@pane='topRight'][@activeCell='I10']").size)
|
|
86
|
+
assert doc.xpath("//xmlns:worksheet/xmlns:sheetViews/xmlns:sheetView/xmlns:selection[@sqref='I10'][@pane='topRight'][@activeCell='I10']")
|
|
87
|
+
|
|
88
|
+
assert_equal(1, doc.xpath("//xmlns:worksheet/xmlns:sheetViews/xmlns:sheetView/xmlns:selection[@sqref='E55'][@pane='bottomLeft'][@activeCell='E55']").size)
|
|
89
|
+
assert doc.xpath("//xmlns:worksheet/xmlns:sheetViews/xmlns:sheetView/xmlns:selection[@sqref='E55'][@pane='bottomLeft'][@activeCell='E55']")
|
|
90
|
+
|
|
91
|
+
assert_equal(1, doc.xpath("//xmlns:worksheet/xmlns:sheetViews/xmlns:sheetView/xmlns:selection[@sqref='I57'][@pane='bottomRight'][@activeCell='I57']").size)
|
|
92
|
+
assert doc.xpath("//xmlns:worksheet/xmlns:sheetViews/xmlns:sheetView/xmlns:selection[@sqref='I57'][@pane='bottomRight'][@activeCell='I57']")
|
|
93
|
+
end
|
|
94
|
+
end
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
require 'tc_helper.rb'
|
|
3
|
+
|
|
4
|
+
# <xsd:complexType name="CT_SheetProtection">
|
|
5
|
+
# <xsd:attribute name="sheet" type="xsd:boolean" use="optional" default="false"/>
|
|
6
|
+
# <xsd:attribute name="objects" type="xsd:boolean" use="optional" default="false"/>
|
|
7
|
+
# <xsd:attribute name="scenarios" type="xsd:boolean" use="optional" default="false"/>
|
|
8
|
+
# <xsd:attribute name="formatCells" type="xsd:boolean" use="optional" default="true"/>
|
|
9
|
+
# <xsd:attribute name="formatColumns" type="xsd:boolean" use="optional" default="true"/>
|
|
10
|
+
# <xsd:attribute name="formatRows" type="xsd:boolean" use="optional" default="true"/>
|
|
11
|
+
# <xsd:attribute name="insertColumns" type="xsd:boolean" use="optional" default="true"/>
|
|
12
|
+
# <xsd:attribute name="insertRows" type="xsd:boolean" use="optional" default="true"/>
|
|
13
|
+
# <xsd:attribute name="insertHyperlinks" type="xsd:boolean" use="optional" default="true"/>
|
|
14
|
+
# <xsd:attribute name="deleteColumns" type="xsd:boolean" use="optional" default="true"/>
|
|
15
|
+
# <xsd:attribute name="deleteRows" type="xsd:boolean" use="optional" default="true"/>
|
|
16
|
+
# <xsd:attribute name="selectLockedCells" type="xsd:boolean" use="optional" default="false"/>
|
|
17
|
+
# <xsd:attribute name="sort" type="xsd:boolean" use="optional" default="true"/>
|
|
18
|
+
# <xsd:attribute name="autoFilter" type="xsd:boolean" use="optional" default="true"/>
|
|
19
|
+
# <xsd:attribute name="pivotTables" type="xsd:boolean" use="optional" default="true"/>
|
|
20
|
+
# <xsd:attribute name="selectUnlockedCells" type="xsd:boolean" use="optional" default="false"/>
|
|
21
|
+
# <xsd:attribute name="password" type="xsd:string" use="optional" default="nil"/>
|
|
22
|
+
# </xsd:complexType>
|
|
23
|
+
|
|
24
|
+
class TestSheetProtection < Test::Unit::TestCase
|
|
25
|
+
def setup
|
|
26
|
+
#inverse defaults
|
|
27
|
+
@boolean_options = { :sheet => false, :objects => true, :scenarios => true, :format_cells => false,
|
|
28
|
+
:format_columns => false, :format_rows => false, :insert_columns => false, :insert_rows => false,
|
|
29
|
+
:insert_hyperlinks => false, :delete_columns => false, :delete_rows => false, :select_locked_cells => true,
|
|
30
|
+
:sort => false, :auto_filter => false, :pivot_tables => false, :select_unlocked_cells => true }
|
|
31
|
+
|
|
32
|
+
@string_options = { :password => nil }
|
|
33
|
+
|
|
34
|
+
@options = @boolean_options.merge(@string_options)
|
|
35
|
+
|
|
36
|
+
@sp = Axlsx::SheetProtection.new(@options)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_initialize
|
|
40
|
+
sp = Axlsx::SheetProtection.new
|
|
41
|
+
@boolean_options.each do |key, value|
|
|
42
|
+
assert_equal(!value, sp.send(key.to_sym), "initialized default #{key} should be #{!value}")
|
|
43
|
+
assert_equal(value, @sp.send(key.to_sym), "initialized options #{key} should be #{value}")
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_boolean_attribute_validation
|
|
48
|
+
@boolean_options.each do |key, value|
|
|
49
|
+
assert_raise(ArgumentError, "#{key} must be boolean") { @sp.send("#{key}=".to_sym, 'A') }
|
|
50
|
+
assert_nothing_raised { @sp.send("#{key}=".to_sym, true) }
|
|
51
|
+
assert_nothing_raised { @sp.send("#{key}=".to_sym, true) }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_to_xml_string
|
|
56
|
+
@sp.password = 'fish' # -> CA3F
|
|
57
|
+
doc = Nokogiri::XML(@sp.to_xml_string)
|
|
58
|
+
@options.each do |key, value|
|
|
59
|
+
assert(doc.xpath("//sheetProtection[@#{key.to_s.gsub(/_(.)/){ $1.upcase }}='#{value}']"))
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|