axlsx 2.0.1 → 2.1.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -3
- data/Rakefile +9 -10
- data/examples/IMAGE1UP.JPEG +0 -0
- data/examples/auto_filter.rb +10 -1
- data/examples/conditional_formatting/example_conditional_formatting.rb +3 -3
- data/examples/example.rb +72 -4
- data/examples/merge_cells.rb +17 -0
- data/examples/no_grid_with_borders.rb +18 -0
- data/examples/pivot_test.rb +63 -0
- data/examples/split.rb +16 -0
- data/lib/axlsx.rb +30 -16
- data/lib/axlsx/content_type/abstract_content_type.rb +1 -1
- data/lib/axlsx/content_type/content_type.rb +1 -1
- data/lib/axlsx/doc_props/app.rb +1 -1
- data/lib/axlsx/doc_props/core.rb +5 -5
- data/lib/axlsx/drawing/axes.rb +1 -1
- data/lib/axlsx/drawing/axis.rb +12 -9
- data/lib/axlsx/drawing/bar_3D_chart.rb +13 -13
- data/lib/axlsx/drawing/bar_series.rb +9 -9
- data/lib/axlsx/drawing/bubble_chart.rb +59 -0
- data/lib/axlsx/drawing/bubble_series.rb +63 -0
- data/lib/axlsx/drawing/cat_axis.rb +5 -5
- data/lib/axlsx/drawing/chart.rb +44 -7
- data/lib/axlsx/drawing/drawing.rb +3 -1
- data/lib/axlsx/drawing/graphic_frame.rb +3 -3
- data/lib/axlsx/drawing/hyperlink.rb +1 -3
- data/lib/axlsx/drawing/line_3D_chart.rb +2 -2
- data/lib/axlsx/drawing/line_chart.rb +10 -10
- data/lib/axlsx/drawing/line_series.rb +14 -2
- data/lib/axlsx/drawing/marker.rb +1 -1
- data/lib/axlsx/drawing/num_data.rb +4 -4
- data/lib/axlsx/drawing/num_data_source.rb +6 -6
- data/lib/axlsx/drawing/num_val.rb +1 -1
- data/lib/axlsx/drawing/one_cell_anchor.rb +1 -1
- data/lib/axlsx/drawing/pic.rb +2 -3
- data/lib/axlsx/drawing/picture_locking.rb +1 -3
- data/lib/axlsx/drawing/pie_3D_chart.rb +5 -6
- data/lib/axlsx/drawing/pie_series.rb +6 -6
- data/lib/axlsx/drawing/scaling.rb +4 -4
- data/lib/axlsx/drawing/scatter_chart.rb +10 -10
- data/lib/axlsx/drawing/scatter_series.rb +26 -7
- data/lib/axlsx/drawing/ser_axis.rb +2 -2
- data/lib/axlsx/drawing/series.rb +3 -3
- data/lib/axlsx/drawing/series_title.rb +2 -2
- data/lib/axlsx/drawing/str_data.rb +3 -3
- data/lib/axlsx/drawing/str_val.rb +1 -1
- data/lib/axlsx/drawing/title.rb +3 -3
- data/lib/axlsx/drawing/val_axis.rb +1 -1
- data/lib/axlsx/drawing/vml_drawing.rb +1 -1
- data/lib/axlsx/package.rb +39 -28
- data/lib/axlsx/rels/relationship.rb +1 -1
- data/lib/axlsx/rels/relationships.rb +2 -2
- data/lib/axlsx/stylesheet/border_pr.rb +2 -2
- data/lib/axlsx/stylesheet/cell_alignment.rb +1 -3
- data/lib/axlsx/stylesheet/cell_protection.rb +1 -3
- data/lib/axlsx/stylesheet/cell_style.rb +1 -3
- data/lib/axlsx/stylesheet/color.rb +1 -3
- data/lib/axlsx/stylesheet/font.rb +1 -1
- data/lib/axlsx/stylesheet/gradient_stop.rb +1 -1
- data/lib/axlsx/stylesheet/num_fmt.rb +1 -3
- data/lib/axlsx/stylesheet/pattern_fill.rb +1 -1
- data/lib/axlsx/stylesheet/styles.rb +6 -6
- data/lib/axlsx/stylesheet/table_style_element.rb +1 -3
- data/lib/axlsx/util/accessors.rb +6 -6
- data/lib/axlsx/util/constants.rb +106 -101
- data/lib/axlsx/util/options_parser.rb +2 -1
- data/lib/axlsx/util/parser.rb +4 -4
- data/lib/axlsx/util/serialized_attributes.rb +16 -6
- data/lib/axlsx/util/simple_typed_list.rb +28 -52
- data/lib/axlsx/util/storage.rb +4 -4
- data/lib/axlsx/util/string.rb +7 -0
- data/lib/axlsx/util/validators.rb +20 -13
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/defined_name.rb +11 -12
- data/lib/axlsx/workbook/defined_names.rb +2 -2
- data/lib/axlsx/workbook/shared_strings_table.rb +5 -5
- data/lib/axlsx/workbook/workbook.rb +19 -12
- data/lib/axlsx/workbook/workbook_view.rb +78 -0
- data/lib/axlsx/workbook/workbook_views.rb +22 -0
- data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +2 -2
- data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +1 -3
- data/lib/axlsx/workbook/worksheet/break.rb +1 -3
- data/lib/axlsx/workbook/worksheet/cell.rb +128 -73
- data/lib/axlsx/workbook/worksheet/cell_serializer.rb +50 -40
- data/lib/axlsx/workbook/worksheet/cfvo.rb +1 -3
- data/lib/axlsx/workbook/worksheet/cfvos.rb +1 -1
- data/lib/axlsx/workbook/worksheet/col.rb +7 -10
- data/lib/axlsx/workbook/worksheet/col_breaks.rb +2 -2
- data/lib/axlsx/workbook/worksheet/comment.rb +5 -6
- data/lib/axlsx/workbook/worksheet/comments.rb +9 -12
- data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +1 -1
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +1 -1
- data/lib/axlsx/workbook/worksheet/data_bar.rb +4 -6
- data/lib/axlsx/workbook/worksheet/data_validation.rb +6 -4
- data/lib/axlsx/workbook/worksheet/dimension.rb +2 -2
- data/lib/axlsx/workbook/worksheet/header_footer.rb +6 -8
- data/lib/axlsx/workbook/worksheet/icon_set.rb +3 -5
- data/lib/axlsx/workbook/worksheet/merged_cells.rb +2 -2
- data/lib/axlsx/workbook/worksheet/page_margins.rb +1 -3
- data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +1 -1
- data/lib/axlsx/workbook/worksheet/page_setup.rb +21 -23
- data/lib/axlsx/workbook/worksheet/pane.rb +1 -3
- data/lib/axlsx/workbook/worksheet/pivot_table.rb +17 -24
- data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +4 -4
- data/lib/axlsx/workbook/worksheet/print_options.rb +1 -3
- data/lib/axlsx/workbook/worksheet/protected_range.rb +1 -3
- data/lib/axlsx/workbook/worksheet/protected_ranges.rb +1 -1
- data/lib/axlsx/workbook/worksheet/rich_text.rb +35 -0
- data/lib/axlsx/workbook/worksheet/rich_text_run.rb +254 -0
- data/lib/axlsx/workbook/worksheet/row.rb +33 -51
- data/lib/axlsx/workbook/worksheet/row_breaks.rb +2 -2
- data/lib/axlsx/workbook/worksheet/selection.rb +1 -3
- data/lib/axlsx/workbook/worksheet/sheet_data.rb +3 -1
- data/lib/axlsx/workbook/worksheet/sheet_protection.rb +1 -3
- data/lib/axlsx/workbook/worksheet/table.rb +6 -6
- data/lib/axlsx/workbook/worksheet/table_style_info.rb +1 -3
- data/lib/axlsx/workbook/worksheet/tables.rb +1 -1
- data/lib/axlsx/workbook/worksheet/worksheet.rb +59 -30
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +3 -3
- data/test/drawing/tc_axis.rb +27 -0
- data/test/drawing/tc_bubble_chart.rb +44 -0
- data/test/drawing/tc_bubble_series.rb +21 -0
- data/test/drawing/tc_data_source.rb +6 -0
- data/test/drawing/tc_line_chart.rb +5 -5
- data/test/drawing/tc_line_series.rb +10 -2
- data/test/drawing/tc_pic.rb +4 -0
- data/test/drawing/tc_scatter_series.rb +25 -1
- data/test/tc_helper.rb +1 -1
- data/test/tc_package.rb +7 -1
- data/test/util/tc_simple_typed_list.rb +1 -2
- data/test/workbook/tc_defined_name.rb +12 -4
- data/test/workbook/tc_workbook.rb +16 -2
- data/test/workbook/tc_workbook_view.rb +50 -0
- data/test/workbook/worksheet/auto_filter/tc_filters.rb +1 -1
- data/test/workbook/worksheet/tc_break.rb +1 -1
- data/test/workbook/worksheet/tc_cell.rb +30 -4
- data/test/workbook/worksheet/tc_col.rb +2 -2
- data/test/workbook/worksheet/tc_conditional_formatting.rb +2 -2
- data/test/workbook/worksheet/tc_data_bar.rb +1 -1
- data/test/workbook/worksheet/tc_data_validation.rb +11 -11
- data/test/workbook/worksheet/tc_header_footer.rb +2 -2
- data/test/workbook/worksheet/tc_icon_set.rb +1 -1
- data/test/workbook/worksheet/tc_page_setup.rb +3 -3
- data/test/workbook/worksheet/tc_print_options.rb +1 -1
- data/test/workbook/worksheet/tc_rich_text.rb +44 -0
- data/test/workbook/worksheet/tc_rich_text_run.rb +172 -0
- data/test/workbook/worksheet/tc_row.rb +2 -2
- data/test/workbook/worksheet/tc_sheet_calc_pr.rb +1 -1
- data/test/workbook/worksheet/tc_sheet_format_pr.rb +4 -4
- data/test/workbook/worksheet/tc_sheet_protection.rb +5 -5
- data/test/workbook/worksheet/tc_sheet_view.rb +4 -4
- data/test/workbook/worksheet/tc_worksheet.rb +49 -10
- metadata +81 -55
- data/test/axlsx.qcachegrind +0 -2226
@@ -61,11 +61,11 @@ class TestCol < Test::Unit::TestCase
|
|
61
61
|
def test_to_xml_string
|
62
62
|
@col.width = 100
|
63
63
|
doc = Nokogiri::XML(@col.to_xml_string)
|
64
|
-
assert_equal(1, doc.xpath("//col [@bestFit='#{@col.best_fit}']").size)
|
64
|
+
assert_equal(1, doc.xpath("//col [@bestFit='#{@col.best_fit ? 1 : 0}']").size)
|
65
65
|
assert_equal(1, doc.xpath("//col [@max=#{@col.max}]").size)
|
66
66
|
assert_equal(1, doc.xpath("//col [@min=#{@col.min}]").size)
|
67
67
|
assert_equal(1, doc.xpath("//col [@width=#{@col.width}]").size)
|
68
|
-
assert_equal(1, doc.xpath("//col [@customWidth='#{@col.custom_width}']").size)
|
68
|
+
assert_equal(1, doc.xpath("//col [@customWidth='#{@col.custom_width ? 1 : 0}']").size)
|
69
69
|
end
|
70
70
|
|
71
71
|
def test_style
|
@@ -113,8 +113,8 @@ class TestConditionalFormatting < Test::Unit::TestCase
|
|
113
113
|
:percent => false, :rank => 0, :stdDev => 1, :stopIfTrue => true, :timePeriod => :today,
|
114
114
|
:formula => "0.0"})
|
115
115
|
doc = Nokogiri::XML.parse(cf.to_xml_string)
|
116
|
-
assert_equal(1, doc.xpath(".//conditionalFormatting//cfRule[@type='cellIs'][@aboveAverage=
|
117
|
-
assert doc.xpath(".//conditionalFormatting//cfRule[@type='cellIs'][@aboveAverage=
|
116
|
+
assert_equal(1, doc.xpath(".//conditionalFormatting//cfRule[@type='cellIs'][@aboveAverage=0][@bottom=0][@dxfId=0][@equalAverage=0][@priority=2][@operator='lessThan'][@text=''][@percent=0][@rank=0][@stdDev=1][@stopIfTrue=1][@timePeriod='today']").size)
|
117
|
+
assert doc.xpath(".//conditionalFormatting//cfRule[@type='cellIs'][@aboveAverage=0][@bottom=0][@dxfId=0][@equalAverage=0][@priority=2][@operator='lessThan'][@text=''][@percent=0][@rank=0][@stdDev=1][@stopIfTrue=1][@timePeriod='today']//formula=0.0")
|
118
118
|
end
|
119
119
|
|
120
120
|
def test_to_xml
|
@@ -38,7 +38,7 @@ class TestDataBar < Test::Unit::TestCase
|
|
38
38
|
|
39
39
|
def test_to_xml_string
|
40
40
|
doc = Nokogiri::XML.parse(@data_bar.to_xml_string)
|
41
|
-
assert_equal(doc.xpath(".//dataBar[@minLength=10][@maxLength=90][@showValue=
|
41
|
+
assert_equal(doc.xpath(".//dataBar[@minLength=10][@maxLength=90][@showValue=1]").size, 1)
|
42
42
|
assert_equal(doc.xpath(".//dataBar//cfvo").size, 2)
|
43
43
|
assert_equal(doc.xpath(".//dataBar//color").size, 1)
|
44
44
|
end
|
@@ -160,11 +160,11 @@ class TestDataValidation < Test::Unit::TestCase
|
|
160
160
|
#test attributes
|
161
161
|
assert_equal(1, doc.xpath("//xmlns:worksheet/xmlns:dataValidations[@count='1']/xmlns:dataValidation[@sqref='A1']
|
162
162
|
[@promptTitle='Be carful!'][@prompt='Only values between 5 and 10'][@operator='between'][@errorTitle='Wrong input']
|
163
|
-
[@error='Only values between 5 and 10'][@showErrorMessage=
|
163
|
+
[@error='Only values between 5 and 10'][@showErrorMessage=1][@allowBlank=1][@showInputMessage=1][@type='whole']
|
164
164
|
[@errorStyle='information']").size)
|
165
165
|
assert doc.xpath("//xmlns:worksheet/xmlns:dataValidations[@count='1']/xmlns:dataValidation[@sqref='A1']
|
166
166
|
[@promptTitle='Be carful!'][@prompt='Only values between 5 and 10'][@operator='between'][@errorTitle='Wrong input']
|
167
|
-
[@error='Only values between 5 and 10'][@showErrorMessage=
|
167
|
+
[@error='Only values between 5 and 10'][@showErrorMessage=1][@allowBlank=1][@showInputMessage=1]
|
168
168
|
[@type='whole'][@errorStyle='information']")
|
169
169
|
|
170
170
|
#test forumula1
|
@@ -189,11 +189,11 @@ class TestDataValidation < Test::Unit::TestCase
|
|
189
189
|
#test attributes
|
190
190
|
assert_equal(1, doc.xpath("//xmlns:worksheet/xmlns:dataValidations[@count='1']/xmlns:dataValidation[@sqref='A1']
|
191
191
|
[@promptTitle='Be carful!'][@prompt='Only values from list'][@errorTitle='Wrong input'][@error='Only values from list']
|
192
|
-
[@showErrorMessage=
|
192
|
+
[@showErrorMessage=1][@allowBlank=1][@showInputMessage=1][@showDropDown=1][@type='list']
|
193
193
|
[@errorStyle='stop']").size)
|
194
194
|
assert doc.xpath("//xmlns:worksheet/xmlns:dataValidations[@count='1']/xmlns:dataValidation[@sqref='A1']
|
195
195
|
[@promptTitle='Be carful!'][@prompt='Only values from list'][@errorTitle='Wrong input'][@error='Only values from list']
|
196
|
-
[@showErrorMessage=
|
196
|
+
[@showErrorMessage=1][@allowBlank=1][@showInputMessage=1][@showDropDown=1][@type='list'][@errorStyle='stop']")
|
197
197
|
|
198
198
|
#test forumula1
|
199
199
|
assert_equal(1, doc.xpath("//xmlns:worksheet/xmlns:dataValidations/xmlns:dataValidation/xmlns:formula1").size)
|
@@ -212,11 +212,11 @@ class TestDataValidation < Test::Unit::TestCase
|
|
212
212
|
|
213
213
|
#test attributes
|
214
214
|
assert_equal(1, doc.xpath("//xmlns:worksheet/xmlns:dataValidations[@count='1']/xmlns:dataValidation[@sqref='A1'][@promptTitle='Be carful!']
|
215
|
-
[@prompt='Only values corresponding formula'][@errorTitle='Wrong input'][@error='Only values corresponding formula'][@showErrorMessage=
|
216
|
-
[@allowBlank=
|
215
|
+
[@prompt='Only values corresponding formula'][@errorTitle='Wrong input'][@error='Only values corresponding formula'][@showErrorMessage=1]
|
216
|
+
[@allowBlank=1][@showInputMessage=1][@type='custom'][@errorStyle='stop']").size)
|
217
217
|
assert doc.xpath("//xmlns:worksheet/xmlns:dataValidations[@count='1']/xmlns:dataValidation[@sqref='A1'][@promptTitle='Be carful!']
|
218
218
|
[@prompt='Only values corresponding formula'][@errorTitle='Wrong input'][@error='Only values corresponding formula']
|
219
|
-
[@showErrorMessage=
|
219
|
+
[@showErrorMessage=1][@allowBlank=1][@showInputMessage=1][@type='custom'][@errorStyle='stop']")
|
220
220
|
|
221
221
|
#test forumula1
|
222
222
|
assert_equal(1, doc.xpath("//xmlns:worksheet/xmlns:dataValidations/xmlns:dataValidation/xmlns:formula1").size)
|
@@ -240,21 +240,21 @@ class TestDataValidation < Test::Unit::TestCase
|
|
240
240
|
#test attributes
|
241
241
|
assert_equal(1, doc.xpath("//xmlns:worksheet/xmlns:dataValidations[@count='2']/xmlns:dataValidation[@sqref='A1']
|
242
242
|
[@promptTitle='Be carful!'][@prompt='Only values between 5 and 10'][@operator='between'][@errorTitle='Wrong input']
|
243
|
-
[@error='Only values between 5 and 10'][@showErrorMessage=
|
243
|
+
[@error='Only values between 5 and 10'][@showErrorMessage=1][@allowBlank=1][@showInputMessage=1][@type='whole']
|
244
244
|
[@errorStyle='information']").size)
|
245
245
|
assert doc.xpath("//xmlns:worksheet/xmlns:dataValidations[@count='2']/xmlns:dataValidation[@sqref='A1']
|
246
246
|
[@promptTitle='Be carful!'][@prompt='Only values between 5 and 10'][@operator='between'][@errorTitle='Wrong input']
|
247
|
-
[@error='Only values between 5 and 10'][@showErrorMessage=
|
247
|
+
[@error='Only values between 5 and 10'][@showErrorMessage=1][@allowBlank=1][@showInputMessage=1]
|
248
248
|
[@type='whole'][@errorStyle='information']")
|
249
249
|
|
250
250
|
#test attributes
|
251
251
|
assert_equal(1, doc.xpath("//xmlns:worksheet/xmlns:dataValidations[@count='2']/xmlns:dataValidation[@sqref='B1']
|
252
252
|
[@promptTitle='Be carful!'][@prompt='Only values from list'][@errorTitle='Wrong input'][@error='Only values from list']
|
253
|
-
[@showErrorMessage=
|
253
|
+
[@showErrorMessage=1][@allowBlank=1][@showInputMessage=1][@showDropDown=1][@type='list']
|
254
254
|
[@errorStyle='stop']").size)
|
255
255
|
assert doc.xpath("//xmlns:worksheet/xmlns:dataValidations[@count='2']/xmlns:dataValidation[@sqref='B1']
|
256
256
|
[@promptTitle='Be carful!'][@prompt='Only values from list'][@errorTitle='Wrong input'][@error='Only values from list']
|
257
|
-
[@showErrorMessage=
|
257
|
+
[@showErrorMessage=1][@allowBlank=1][@showInputMessage=1][@showDropDown=1][@type='list'][@errorStyle='stop']")
|
258
258
|
end
|
259
259
|
|
260
260
|
def test_empty_attributes
|
@@ -109,7 +109,7 @@ class TestHeaderFooter < Test::Unit::TestCase
|
|
109
109
|
)
|
110
110
|
|
111
111
|
doc = Nokogiri::XML.parse(@hf.to_xml_string)
|
112
|
-
assert_equal(1, doc.xpath(".//headerFooter[@differentFirst=
|
112
|
+
assert_equal(1, doc.xpath(".//headerFooter[@differentFirst=1][@differentOddEven=1]").size)
|
113
113
|
|
114
114
|
assert_equal(1, doc.xpath(".//headerFooter/oddHeader").size)
|
115
115
|
assert_equal('oh', doc.xpath(".//headerFooter/oddHeader").text)
|
@@ -134,7 +134,7 @@ class TestHeaderFooter < Test::Unit::TestCase
|
|
134
134
|
)
|
135
135
|
|
136
136
|
doc = Nokogiri::XML.parse(@hf.to_xml_string)
|
137
|
-
assert_equal(1, doc.xpath(".//headerFooter[@differentOddEven=
|
137
|
+
assert_equal(1, doc.xpath(".//headerFooter[@differentOddEven=0]").size)
|
138
138
|
assert_equal(0, doc.xpath(".//headerFooter[@differentFirst]").size)
|
139
139
|
|
140
140
|
assert_equal(1, doc.xpath(".//headerFooter/oddHeader").size)
|
@@ -38,7 +38,7 @@ class TestIconSet < Test::Unit::TestCase
|
|
38
38
|
|
39
39
|
def test_to_xml_string
|
40
40
|
doc = Nokogiri::XML.parse(@icon_set.to_xml_string)
|
41
|
-
assert_equal(doc.xpath(".//iconSet[@iconSet='3TrafficLights1'][@percent=
|
41
|
+
assert_equal(doc.xpath(".//iconSet[@iconSet='3TrafficLights1'][@percent=1][@reverse=0][@showValue=1]").size, 1)
|
42
42
|
assert_equal(doc.xpath(".//iconSet//cfvo").size, 3)
|
43
43
|
end
|
44
44
|
|
@@ -63,7 +63,7 @@ class TestPageSetup < Test::Unit::TestCase
|
|
63
63
|
assert(@ps.fit_to_width == nil && @ps.fit_to_height == nil)
|
64
64
|
assert(@ps.fit_to_page? == false)
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
def test_with_height_fit_to_page?
|
68
68
|
assert(@ps.fit_to_width == nil && @ps.fit_to_height == nil)
|
69
69
|
@ps.set(:fit_to_height => 1)
|
@@ -131,9 +131,9 @@ class TestPageSetup < Test::Unit::TestCase
|
|
131
131
|
|
132
132
|
def test_fit_to
|
133
133
|
fits = @ps.fit_to(:width => 1)
|
134
|
-
assert_equal([1,
|
134
|
+
assert_equal([1, 999], fits)
|
135
135
|
fits = @ps.fit_to :height => 1
|
136
|
-
assert_equal(fits, [
|
136
|
+
assert_equal(fits, [999 ,1])
|
137
137
|
fits = @ps.fit_to :height => 7, :width => 2
|
138
138
|
assert_equal(fits, [2, 7])
|
139
139
|
assert_raise(ArgumentError) { puts @ps.fit_to(:width => true)}
|
@@ -42,7 +42,7 @@ class TestPrintOptions < Test::Unit::TestCase
|
|
42
42
|
def test_to_xml
|
43
43
|
@po.set(:grid_lines => true, :headings => true, :horizontal_centered => true, :vertical_centered => true)
|
44
44
|
doc = Nokogiri::XML.parse(@po.to_xml_string)
|
45
|
-
assert_equal(1, doc.xpath(".//printOptions[@gridLines=
|
45
|
+
assert_equal(1, doc.xpath(".//printOptions[@gridLines=1][@headings=1][@horizontalCentered=1][@verticalCentered=1]").size)
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_grid_lines
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'tc_helper.rb'
|
2
|
+
|
3
|
+
class RichText < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
p = Axlsx::Package.new
|
6
|
+
@ws = p.workbook.add_worksheet :name => "hmmmz"
|
7
|
+
p.workbook.styles.add_style :sz => 20
|
8
|
+
@rt = Axlsx::RichText.new
|
9
|
+
b = true
|
10
|
+
(0..26).each do |r|
|
11
|
+
@rt.add_run "run #{r}, ", :b => (b=!b), :i => !b
|
12
|
+
end
|
13
|
+
@row = @ws.add_row [@rt]
|
14
|
+
@c = @row.first
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_initialize
|
18
|
+
assert_equal(@c.value, @rt)
|
19
|
+
rt_direct = Axlsx::RichText.new('hi', :i => true)
|
20
|
+
rt_indirect = Axlsx::RichText.new()
|
21
|
+
rt_indirect.add_run('hi', :i => true)
|
22
|
+
assert_equal(rt_direct.runs.length, 1)
|
23
|
+
assert_equal(rt_indirect.runs.length, 1)
|
24
|
+
row = @ws.add_row [rt_direct, rt_indirect]
|
25
|
+
assert_equal(row[0].to_xml_string(0,0), row[1].to_xml_string(0,0))
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_textruns
|
29
|
+
runs = @rt.runs
|
30
|
+
assert_equal(runs.length, 27)
|
31
|
+
assert_equal(runs.first.b, false)
|
32
|
+
assert_equal(runs.first.i, true)
|
33
|
+
assert_equal(runs[1].b, true)
|
34
|
+
assert_equal(runs[1].i, false)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_implicit_richtext
|
38
|
+
rt = Axlsx::RichText.new('a', :b => true)
|
39
|
+
row_rt = @ws.add_row [rt]
|
40
|
+
row_imp = @ws.add_row ['a']
|
41
|
+
row_imp[0].b = true
|
42
|
+
assert_equal(row_rt[0].to_xml_string(0,0), row_imp[0].to_xml_string(0,0))
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
require 'tc_helper.rb'
|
2
|
+
|
3
|
+
class RichTextRun < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@p = Axlsx::Package.new
|
6
|
+
@ws = @p.workbook.add_worksheet :name => "hmmmz"
|
7
|
+
@p.workbook.styles.add_style :sz => 20
|
8
|
+
@rtr = Axlsx::RichTextRun.new('hihihi', b: true, i: false)
|
9
|
+
@rtr2 = Axlsx::RichTextRun.new('hihi2hi2', b: false, i: true)
|
10
|
+
@rt = Axlsx::RichText.new
|
11
|
+
@rt.runs << @rtr
|
12
|
+
@rt.runs << @rtr2
|
13
|
+
@row = @ws.add_row [@rt]
|
14
|
+
@c = @row.first
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_initialize
|
18
|
+
assert_equal(@rtr.value, 'hihihi')
|
19
|
+
assert_equal(@rtr.b, true)
|
20
|
+
assert_equal(@rtr.i, false)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_font_size_with_custom_style_and_no_sz
|
24
|
+
@c.style = @c.row.worksheet.workbook.styles.add_style :bg_color => 'FF00FF'
|
25
|
+
sz = @rtr.send(:font_size)
|
26
|
+
assert_equal(sz, @c.row.worksheet.workbook.styles.fonts.first.sz * 1.5)
|
27
|
+
sz = @rtr2.send(:font_size)
|
28
|
+
assert_equal(sz, @c.row.worksheet.workbook.styles.fonts.first.sz)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_font_size_with_bolding
|
32
|
+
@c.style = @c.row.worksheet.workbook.styles.add_style :b => true
|
33
|
+
assert_equal(@c.row.worksheet.workbook.styles.fonts.first.sz * 1.5, @rtr.send(:font_size))
|
34
|
+
assert_equal(@c.row.worksheet.workbook.styles.fonts.first.sz * 1.5, @rtr2.send(:font_size)) # is this the correct behaviour?
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_font_size_with_custom_sz
|
38
|
+
@c.style = @c.row.worksheet.workbook.styles.add_style :sz => 52
|
39
|
+
sz = @rtr.send(:font_size)
|
40
|
+
assert_equal(sz, 52 * 1.5)
|
41
|
+
sz2 = @rtr2.send(:font_size)
|
42
|
+
assert_equal(sz2, 52)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_rtr_with_sz
|
46
|
+
@rtr.sz = 25
|
47
|
+
assert_equal(25, @rtr.send(:font_size))
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_color
|
51
|
+
assert_raise(ArgumentError) { @rtr.color = -1.1 }
|
52
|
+
assert_nothing_raised { @rtr.color = "FF00FF00" }
|
53
|
+
assert_equal(@rtr.color.rgb, "FF00FF00")
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_scheme
|
57
|
+
assert_raise(ArgumentError) { @rtr.scheme = -1.1 }
|
58
|
+
assert_nothing_raised { @rtr.scheme = :major }
|
59
|
+
assert_equal(@rtr.scheme, :major)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_vertAlign
|
63
|
+
assert_raise(ArgumentError) { @rtr.vertAlign = -1.1 }
|
64
|
+
assert_nothing_raised { @rtr.vertAlign = :baseline }
|
65
|
+
assert_equal(@rtr.vertAlign, :baseline)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_sz
|
69
|
+
assert_raise(ArgumentError) { @rtr.sz = -1.1 }
|
70
|
+
assert_nothing_raised { @rtr.sz = 12 }
|
71
|
+
assert_equal(@rtr.sz, 12)
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_extend
|
75
|
+
assert_raise(ArgumentError) { @rtr.extend = -1.1 }
|
76
|
+
assert_nothing_raised { @rtr.extend = false }
|
77
|
+
assert_equal(@rtr.extend, false)
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_condense
|
81
|
+
assert_raise(ArgumentError) { @rtr.condense = -1.1 }
|
82
|
+
assert_nothing_raised { @rtr.condense = false }
|
83
|
+
assert_equal(@rtr.condense, false)
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_shadow
|
87
|
+
assert_raise(ArgumentError) { @rtr.shadow = -1.1 }
|
88
|
+
assert_nothing_raised { @rtr.shadow = false }
|
89
|
+
assert_equal(@rtr.shadow, false)
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_outline
|
93
|
+
assert_raise(ArgumentError) { @rtr.outline = -1.1 }
|
94
|
+
assert_nothing_raised { @rtr.outline = false }
|
95
|
+
assert_equal(@rtr.outline, false)
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_strike
|
99
|
+
assert_raise(ArgumentError) { @rtr.strike = -1.1 }
|
100
|
+
assert_nothing_raised { @rtr.strike = false }
|
101
|
+
assert_equal(@rtr.strike, false)
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_u
|
105
|
+
@c.type = :string
|
106
|
+
assert_raise(ArgumentError) { @c.u = -1.1 }
|
107
|
+
assert_nothing_raised { @c.u = :single }
|
108
|
+
assert_equal(@c.u, :single)
|
109
|
+
doc = Nokogiri::XML(@c.to_xml_string(1,1))
|
110
|
+
assert(doc.xpath('//u[@val="single"]'))
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_i
|
114
|
+
assert_raise(ArgumentError) { @c.i = -1.1 }
|
115
|
+
assert_nothing_raised { @c.i = false }
|
116
|
+
assert_equal(@c.i, false)
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_rFont
|
120
|
+
assert_raise(ArgumentError) { @c.font_name = -1.1 }
|
121
|
+
assert_nothing_raised { @c.font_name = "Arial" }
|
122
|
+
assert_equal(@c.font_name, "Arial")
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_charset
|
126
|
+
assert_raise(ArgumentError) { @c.charset = -1.1 }
|
127
|
+
assert_nothing_raised { @c.charset = 1 }
|
128
|
+
assert_equal(@c.charset, 1)
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_family
|
132
|
+
assert_raise(ArgumentError) { @c.family = -1.1 }
|
133
|
+
assert_nothing_raised { @c.family = 5 }
|
134
|
+
assert_equal(@c.family, 5)
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_b
|
138
|
+
assert_raise(ArgumentError) { @c.b = -1.1 }
|
139
|
+
assert_nothing_raised { @c.b = false }
|
140
|
+
assert_equal(@c.b, false)
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_multiline_autowidth
|
144
|
+
wrap = @p.workbook.styles.add_style({:alignment => {:wrap_text => true}})
|
145
|
+
awtr = Axlsx::RichTextRun.new('I\'m bold' + "\n", :b => true)
|
146
|
+
rt = Axlsx::RichText.new
|
147
|
+
rt.runs << awtr
|
148
|
+
@ws.add_row [rt], :style => wrap
|
149
|
+
ar = [0]
|
150
|
+
awtr.autowidth(ar)
|
151
|
+
assert_equal(ar.length, 2)
|
152
|
+
assert_equal(ar.last, 0)
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_to_xml
|
156
|
+
schema = Nokogiri::XML::Schema(File.open(Axlsx::SML_XSD))
|
157
|
+
doc = Nokogiri::XML(@ws.to_xml_string)
|
158
|
+
errors = []
|
159
|
+
schema.validate(doc).each do |error|
|
160
|
+
puts error.message
|
161
|
+
errors.push error
|
162
|
+
end
|
163
|
+
assert(errors.empty?, "error free validation")
|
164
|
+
|
165
|
+
assert(doc.xpath('//rPr/b[@val=1]'))
|
166
|
+
assert(doc.xpath('//rPr/i[@val=0]'))
|
167
|
+
assert(doc.xpath('//rPr/b[@val=0]'))
|
168
|
+
assert(doc.xpath('//rPr/i[@val=1]'))
|
169
|
+
assert(doc.xpath('//is//t[contains(text(), "hihihi")]'))
|
170
|
+
assert(doc.xpath('//is//t[contains(text(), "hihi2hi2")]'))
|
171
|
+
end
|
172
|
+
end
|
@@ -29,7 +29,7 @@ class TestRow < Test::Unit::TestCase
|
|
29
29
|
|
30
30
|
|
31
31
|
def test_index
|
32
|
-
assert_equal(@row.
|
32
|
+
assert_equal(@row.row_index, @row.worksheet.rows.index(@row))
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_add_cell
|
@@ -111,7 +111,7 @@ class TestRow < Test::Unit::TestCase
|
|
111
111
|
@row.add_cell 1
|
112
112
|
@row.height = 20
|
113
113
|
r_s_xml = Nokogiri::XML(@row.to_xml_string(0, ''))
|
114
|
-
assert_equal(r_s_xml.xpath(".//row[@r=1][@ht=20][@customHeight=
|
114
|
+
assert_equal(r_s_xml.xpath(".//row[@r=1][@ht=20][@customHeight=1]").size, 1)
|
115
115
|
end
|
116
116
|
|
117
117
|
end
|
@@ -13,6 +13,6 @@ class TestSheetCalcPr < Test::Unit::TestCase
|
|
13
13
|
|
14
14
|
def test_to_xml_string
|
15
15
|
doc = Nokogiri::XML(@sheet_calc_pr.to_xml_string)
|
16
|
-
assert_equal 1, doc.xpath('//sheetCalcPr[@fullCalcOnLoad=
|
16
|
+
assert_equal 1, doc.xpath('//sheetCalcPr[@fullCalcOnLoad=0]').size
|
17
17
|
end
|
18
18
|
end
|
@@ -74,13 +74,13 @@ class TestSheetFormatPr < Test::Unit::TestCase
|
|
74
74
|
|
75
75
|
def test_to_xml_string
|
76
76
|
doc = Nokogiri::XML(@sheet_format_pr.to_xml_string)
|
77
|
-
assert doc.xpath("sheetFormatPr[@thickBottom=
|
77
|
+
assert doc.xpath("sheetFormatPr[@thickBottom=1]")
|
78
78
|
assert doc.xpath("sheetFormatPr[@baseColWidth=5]")
|
79
79
|
assert doc.xpath("sheetFormatPr[@default_col_width=7.2]")
|
80
80
|
assert doc.xpath("sheetFormatPr[@default_row_height=5.2]")
|
81
|
-
assert doc.xpath("sheetFormatPr[@custom_height=
|
82
|
-
assert doc.xpath("sheetFormatPr[@zero_height=
|
83
|
-
assert doc.xpath("sheetFormatPr[@thick_top=
|
81
|
+
assert doc.xpath("sheetFormatPr[@custom_height=1]")
|
82
|
+
assert doc.xpath("sheetFormatPr[@zero_height=0]")
|
83
|
+
assert doc.xpath("sheetFormatPr[@thick_top=1]")
|
84
84
|
assert doc.xpath("sheetFormatPr[@outline_level_row=0]")
|
85
85
|
assert doc.xpath("sheetFormatPr[@outline_level_col=0]")
|
86
86
|
end
|
@@ -2,9 +2,9 @@
|
|
2
2
|
require 'tc_helper.rb'
|
3
3
|
|
4
4
|
# <xsd:complexType name="CT_SheetProtection">
|
5
|
-
# <xsd:attribute name="sheet" type="xsd:boolean" use="optional" default=
|
6
|
-
# <xsd:attribute name="objects" type="xsd:boolean" use="optional" default=
|
7
|
-
# <xsd:attribute name="scenarios" type="xsd:boolean" use="optional" default=
|
5
|
+
# <xsd:attribute name="sheet" type="xsd:boolean" use="optional" default=0/>
|
6
|
+
# <xsd:attribute name="objects" type="xsd:boolean" use="optional" default=0/>
|
7
|
+
# <xsd:attribute name="scenarios" type="xsd:boolean" use="optional" default=0/>
|
8
8
|
# <xsd:attribute name="formatCells" type="xsd:boolean" use="optional" default="true"/>
|
9
9
|
# <xsd:attribute name="formatColumns" type="xsd:boolean" use="optional" default="true"/>
|
10
10
|
# <xsd:attribute name="formatRows" type="xsd:boolean" use="optional" default="true"/>
|
@@ -13,11 +13,11 @@ require 'tc_helper.rb'
|
|
13
13
|
# <xsd:attribute name="insertHyperlinks" type="xsd:boolean" use="optional" default="true"/>
|
14
14
|
# <xsd:attribute name="deleteColumns" type="xsd:boolean" use="optional" default="true"/>
|
15
15
|
# <xsd:attribute name="deleteRows" type="xsd:boolean" use="optional" default="true"/>
|
16
|
-
# <xsd:attribute name="selectLockedCells" type="xsd:boolean" use="optional" default=
|
16
|
+
# <xsd:attribute name="selectLockedCells" type="xsd:boolean" use="optional" default=0/>
|
17
17
|
# <xsd:attribute name="sort" type="xsd:boolean" use="optional" default="true"/>
|
18
18
|
# <xsd:attribute name="autoFilter" type="xsd:boolean" use="optional" default="true"/>
|
19
19
|
# <xsd:attribute name="pivotTables" type="xsd:boolean" use="optional" default="true"/>
|
20
|
-
# <xsd:attribute name="selectUnlockedCells" type="xsd:boolean" use="optional" default=
|
20
|
+
# <xsd:attribute name="selectUnlockedCells" type="xsd:boolean" use="optional" default=0/>
|
21
21
|
# <xsd:attribute name="password" type="xsd:string" use="optional" default="nil"/>
|
22
22
|
# </xsd:complexType>
|
23
23
|
|