write_xlsx 0.0.2
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/.document +5 -0
- data/.gitattributes +1 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +82 -0
- data/Rakefile +78 -0
- data/VERSION +1 -0
- data/examples/a_simple.rb +45 -0
- data/examples/array_formula.rb +33 -0
- data/examples/autofilter.rb +235 -0
- data/examples/chart_area.rb +59 -0
- data/examples/chart_bar.rb +59 -0
- data/examples/chart_column.rb +58 -0
- data/examples/chart_line.rb +59 -0
- data/examples/chart_pie.rb +49 -0
- data/examples/chart_scatter.rb +59 -0
- data/examples/chart_stock.rb +65 -0
- data/examples/colors.rb +130 -0
- data/examples/comments1.rb +12 -0
- data/examples/comments2.rb +335 -0
- data/examples/conditional_format.rb +67 -0
- data/examples/data_validate.rb +279 -0
- data/examples/defined_name.rb +28 -0
- data/examples/demo.rb +104 -0
- data/examples/diag_border.rb +26 -0
- data/examples/headers.rb +119 -0
- data/examples/hide_sheet.rb +30 -0
- data/examples/hyperlink1.rb +58 -0
- data/examples/indent.rb +28 -0
- data/examples/merge1.rb +38 -0
- data/examples/merge2.rb +48 -0
- data/examples/merge3.rb +43 -0
- data/examples/merge4.rb +82 -0
- data/examples/merge5.rb +70 -0
- data/examples/merge6.rb +48 -0
- data/examples/outline.rb +252 -0
- data/examples/properties.rb +33 -0
- data/examples/protection.rb +34 -0
- data/examples/rich_strings.rb +42 -0
- data/examples/right_to_left.rb +24 -0
- data/examples/tab_colors.rb +26 -0
- data/lib/write_xlsx.rb +77 -0
- data/lib/write_xlsx/chart.rb +3027 -0
- data/lib/write_xlsx/chart/area.rb +52 -0
- data/lib/write_xlsx/chart/bar.rb +126 -0
- data/lib/write_xlsx/chart/column.rb +132 -0
- data/lib/write_xlsx/chart/line.rb +51 -0
- data/lib/write_xlsx/chart/pie.rb +210 -0
- data/lib/write_xlsx/chart/scatter.rb +252 -0
- data/lib/write_xlsx/chart/stock.rb +134 -0
- data/lib/write_xlsx/chartsheet.rb +173 -0
- data/lib/write_xlsx/colors.rb +65 -0
- data/lib/write_xlsx/compatibility.rb +71 -0
- data/lib/write_xlsx/drawing.rb +547 -0
- data/lib/write_xlsx/format.rb +683 -0
- data/lib/write_xlsx/package/app.rb +218 -0
- data/lib/write_xlsx/package/comments.rb +221 -0
- data/lib/write_xlsx/package/content_types.rb +189 -0
- data/lib/write_xlsx/package/core.rb +196 -0
- data/lib/write_xlsx/package/packager.rb +510 -0
- data/lib/write_xlsx/package/relationships.rb +98 -0
- data/lib/write_xlsx/package/shared_strings.rb +96 -0
- data/lib/write_xlsx/package/styles.rb +705 -0
- data/lib/write_xlsx/package/theme.rb +45 -0
- data/lib/write_xlsx/package/vml.rb +386 -0
- data/lib/write_xlsx/package/xml_writer_simple.rb +90 -0
- data/lib/write_xlsx/utility.rb +113 -0
- data/lib/write_xlsx/workbook.rb +1488 -0
- data/lib/write_xlsx/worksheet.rb +6578 -0
- data/lib/write_xlsx/zip_file_utils.rb +98 -0
- data/test/chart/test_add_series.rb +113 -0
- data/test/chart/test_process_names.rb +27 -0
- data/test/chart/test_write_auto.rb +15 -0
- data/test/chart/test_write_ax_id.rb +15 -0
- data/test/chart/test_write_ax_pos.rb +15 -0
- data/test/chart/test_write_chart_space.rb +15 -0
- data/test/chart/test_write_cross_ax.rb +15 -0
- data/test/chart/test_write_crosses.rb +15 -0
- data/test/chart/test_write_format_code.rb +15 -0
- data/test/chart/test_write_idx.rb +15 -0
- data/test/chart/test_write_label_align.rb +15 -0
- data/test/chart/test_write_label_offset.rb +15 -0
- data/test/chart/test_write_lang.rb +15 -0
- data/test/chart/test_write_layout.rb +15 -0
- data/test/chart/test_write_legend.rb +16 -0
- data/test/chart/test_write_legend_pos.rb +15 -0
- data/test/chart/test_write_major_gridlines.rb +15 -0
- data/test/chart/test_write_marker.rb +17 -0
- data/test/chart/test_write_marker_size.rb +15 -0
- data/test/chart/test_write_marker_value.rb +16 -0
- data/test/chart/test_write_num_cache.rb +16 -0
- data/test/chart/test_write_num_fmt.rb +16 -0
- data/test/chart/test_write_number_format.rb +15 -0
- data/test/chart/test_write_order.rb +15 -0
- data/test/chart/test_write_orientation.rb +15 -0
- data/test/chart/test_write_page_margins.rb +15 -0
- data/test/chart/test_write_page_setup.rb +15 -0
- data/test/chart/test_write_plot_vis_only.rb +15 -0
- data/test/chart/test_write_pt.rb +16 -0
- data/test/chart/test_write_pt_count.rb +16 -0
- data/test/chart/test_write_series_formula.rb +16 -0
- data/test/chart/test_write_style.rb +41 -0
- data/test/chart/test_write_symbol.rb +16 -0
- data/test/chart/test_write_tick_lbl_pos.rb +16 -0
- data/test/chart/test_write_v.rb +16 -0
- data/test/drawing/test_drawing_chart_01.rb +50 -0
- data/test/drawing/test_drawing_image_01.rb +59 -0
- data/test/helper.rb +90 -0
- data/test/package/app/test_app01.rb +44 -0
- data/test/package/app/test_app02.rb +46 -0
- data/test/package/app/test_app03.rb +53 -0
- data/test/package/comments/test_comments01.rb +36 -0
- data/test/package/comments/test_write_text_t.rb +44 -0
- data/test/package/content_types/test_content_types.rb +35 -0
- data/test/package/content_types/test_write_default.rb +13 -0
- data/test/package/content_types/test_write_override.rb +13 -0
- data/test/package/core/test_core01.rb +28 -0
- data/test/package/core/test_core02.rb +42 -0
- data/test/package/relationships/test_relationships.rb +28 -0
- data/test/package/relationships/test_sheet_rels.rb +22 -0
- data/test/package/shared_strings/test_shared_strings01.rb +30 -0
- data/test/package/shared_strings/test_shared_strings02.rb +30 -0
- data/test/package/shared_strings/test_write_si.rb +13 -0
- data/test/package/shared_strings/test_write_sst.rb +15 -0
- data/test/package/styles/test_styles_01.rb +69 -0
- data/test/package/styles/test_styles_02.rb +104 -0
- data/test/package/styles/test_styles_03.rb +90 -0
- data/test/package/styles/test_styles_04.rb +216 -0
- data/test/package/styles/test_styles_05.rb +150 -0
- data/test/package/styles/test_styles_06.rb +104 -0
- data/test/package/styles/test_styles_07.rb +104 -0
- data/test/package/styles/test_styles_08.rb +109 -0
- data/test/package/styles/test_styles_09.rb +95 -0
- data/test/package/vml/test_vml_01.rb +42 -0
- data/test/package/vml/test_write_anchor.rb +14 -0
- data/test/package/vml/test_write_auto_fill.rb +14 -0
- data/test/package/vml/test_write_column.rb +14 -0
- data/test/package/vml/test_write_div.rb +14 -0
- data/test/package/vml/test_write_fill.rb +14 -0
- data/test/package/vml/test_write_idmap.rb +14 -0
- data/test/package/vml/test_write_move_with_cells.rb +14 -0
- data/test/package/vml/test_write_path.rb +22 -0
- data/test/package/vml/test_write_row.rb +14 -0
- data/test/package/vml/test_write_shadow.rb +14 -0
- data/test/package/vml/test_write_shapelayout.rb +14 -0
- data/test/package/vml/test_write_shapetype.rb +14 -0
- data/test/package/vml/test_write_size_with_cells.rb +14 -0
- data/test/package/vml/test_write_stroke.rb +14 -0
- data/test/package/vml/test_write_textbox.rb +14 -0
- data/test/perl_output/a_simple.xlsx +0 -0
- data/test/perl_output/array_formula.xlsx +0 -0
- data/test/perl_output/autofilter.xlsx +0 -0
- data/test/perl_output/chart_area.xlsx +0 -0
- data/test/perl_output/chart_bar.xlsx +0 -0
- data/test/perl_output/chart_column.xlsx +0 -0
- data/test/perl_output/chart_line.xlsx +0 -0
- data/test/perl_output/chart_pie.xlsx +0 -0
- data/test/perl_output/chart_scatter.xlsx +0 -0
- data/test/perl_output/chart_stock.xlsx +0 -0
- data/test/perl_output/comments1.xlsx +0 -0
- data/test/perl_output/comments2.xlsx +0 -0
- data/test/perl_output/conditional_format.xlsx +0 -0
- data/test/perl_output/data_validate.xlsx +0 -0
- data/test/perl_output/defined_name.xlsx +0 -0
- data/test/perl_output/demo.xlsx +0 -0
- data/test/perl_output/diag_border.xlsx +0 -0
- data/test/perl_output/fit_to_pages.xlsx +0 -0
- data/test/perl_output/headers.xlsx +0 -0
- data/test/perl_output/hide_sheet.xlsx +0 -0
- data/test/perl_output/hyperlink.xlsx +0 -0
- data/test/perl_output/indent.xlsx +0 -0
- data/test/perl_output/merge1.xlsx +0 -0
- data/test/perl_output/merge2.xlsx +0 -0
- data/test/perl_output/merge3.xlsx +0 -0
- data/test/perl_output/merge4.xlsx +0 -0
- data/test/perl_output/merge5.xlsx +0 -0
- data/test/perl_output/merge6.xlsx +0 -0
- data/test/perl_output/outline.xlsx +0 -0
- data/test/perl_output/print_scale.xlsx +0 -0
- data/test/perl_output/properties.xlsx +0 -0
- data/test/perl_output/protection.xlsx +0 -0
- data/test/perl_output/rich_strings.xlsx +0 -0
- data/test/perl_output/right_to_left.xlsx +0 -0
- data/test/perl_output/tab_colors.xlsx +0 -0
- data/test/test_delete_files.rb +37 -0
- data/test/test_example_match.rb +2281 -0
- data/test/test_xml_writer_simple.rb +63 -0
- data/test/workbook/test_get_chart_range.rb +59 -0
- data/test/workbook/test_sort_defined_names.rb +77 -0
- data/test/workbook/test_workbook_01.rb +29 -0
- data/test/workbook/test_workbook_02.rb +31 -0
- data/test/workbook/test_workbook_03.rb +31 -0
- data/test/workbook/test_workbook_new.rb +18 -0
- data/test/workbook/test_write_defined_name.rb +17 -0
- data/test/workbook/test_write_defined_names.rb +41 -0
- data/test/worksheet/test_calculate_spans.rb +58 -0
- data/test/worksheet/test_convert_date_time_01.rb +439 -0
- data/test/worksheet/test_convert_date_time_02.rb +478 -0
- data/test/worksheet/test_convert_date_time_03.rb +435 -0
- data/test/worksheet/test_extract_filter_tokens.rb +109 -0
- data/test/worksheet/test_parse_filter_expression.rb +143 -0
- data/test/worksheet/test_position_object.rb +50 -0
- data/test/worksheet/test_repeat_formula.rb +55 -0
- data/test/worksheet/test_worksheet_01.rb +32 -0
- data/test/worksheet/test_worksheet_02.rb +38 -0
- data/test/worksheet/test_worksheet_03.rb +44 -0
- data/test/worksheet/test_worksheet_04.rb +45 -0
- data/test/worksheet/test_write_array_formula_01.rb +99 -0
- data/test/worksheet/test_write_autofilter.rb +260 -0
- data/test/worksheet/test_write_brk.rb +18 -0
- data/test/worksheet/test_write_cell.rb +49 -0
- data/test/worksheet/test_write_cell_value.rb +33 -0
- data/test/worksheet/test_write_col_breaks.rb +27 -0
- data/test/worksheet/test_write_col_info.rb +95 -0
- data/test/worksheet/test_write_conditional_formatting.rb +72 -0
- data/test/worksheet/test_write_custom_filter.rb +18 -0
- data/test/worksheet/test_write_custom_filters.rb +25 -0
- data/test/worksheet/test_write_data_validation_01.rb +113 -0
- data/test/worksheet/test_write_data_validation_02.rb +528 -0
- data/test/worksheet/test_write_dimension.rb +94 -0
- data/test/worksheet/test_write_ext.rb +18 -0
- data/test/worksheet/test_write_ext_lst.rb +18 -0
- data/test/worksheet/test_write_filter.rb +18 -0
- data/test/worksheet/test_write_filter_column.rb +18 -0
- data/test/worksheet/test_write_filters.rb +32 -0
- data/test/worksheet/test_write_header_footer.rb +53 -0
- data/test/worksheet/test_write_hyperlink.rb +39 -0
- data/test/worksheet/test_write_hyperlinks.rb +27 -0
- data/test/worksheet/test_write_legacy_drawing.rb +19 -0
- data/test/worksheet/test_write_merge_cell.rb +18 -0
- data/test/worksheet/test_write_merge_cells.rb +192 -0
- data/test/worksheet/test_write_methods.rb +353 -0
- data/test/worksheet/test_write_mx_plv.rb +19 -0
- data/test/worksheet/test_write_page_margins.rb +98 -0
- data/test/worksheet/test_write_page_set_up_pr.rb +19 -0
- data/test/worksheet/test_write_page_setup.rb +54 -0
- data/test/worksheet/test_write_pane.rb +123 -0
- data/test/worksheet/test_write_phonetic_pr.rb +19 -0
- data/test/worksheet/test_write_print_options.rb +77 -0
- data/test/worksheet/test_write_row_breaks.rb +27 -0
- data/test/worksheet/test_write_row_element.rb +69 -0
- data/test/worksheet/test_write_selection.rb +18 -0
- data/test/worksheet/test_write_sheet_calc_pr.rb +18 -0
- data/test/worksheet/test_write_sheet_data.rb +18 -0
- data/test/worksheet/test_write_sheet_format_pr.rb +18 -0
- data/test/worksheet/test_write_sheet_pr.rb +36 -0
- data/test/worksheet/test_write_sheet_protection.rb +174 -0
- data/test/worksheet/test_write_sheet_view.rb +62 -0
- data/test/worksheet/test_write_sheet_view1.rb +64 -0
- data/test/worksheet/test_write_sheet_view2.rb +56 -0
- data/test/worksheet/test_write_sheet_view3.rb +83 -0
- data/test/worksheet/test_write_sheet_view4.rb +83 -0
- data/test/worksheet/test_write_sheet_view5.rb +74 -0
- data/test/worksheet/test_write_sheet_view6.rb +51 -0
- data/test/worksheet/test_write_sheet_view7.rb +71 -0
- data/test/worksheet/test_write_sheet_view8.rb +51 -0
- data/test/worksheet/test_write_sheet_view9.rb +51 -0
- data/test/worksheet/test_write_tab_color.rb +23 -0
- data/test/worksheet/test_write_worksheet.rb +19 -0
- data/write_xlsx.gemspec +308 -0
- metadata +363 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
require 'write_xlsx'
|
|
4
|
+
require 'stringio'
|
|
5
|
+
|
|
6
|
+
class TestWriteConditionalFormatting < Test::Unit::TestCase
|
|
7
|
+
def setup
|
|
8
|
+
@workbook = WriteXLSX.new(StringIO.new)
|
|
9
|
+
@worksheet = @workbook.add_worksheet('')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_conditional_formatting_01
|
|
13
|
+
format = Writexlsx::Format.new({}, {})
|
|
14
|
+
|
|
15
|
+
@worksheet.conditional_formatting('A1',
|
|
16
|
+
:type => 'cell',
|
|
17
|
+
:format => format,
|
|
18
|
+
:criteria => 'greater than',
|
|
19
|
+
:value => 5
|
|
20
|
+
)
|
|
21
|
+
@worksheet.__send__('write_conditional_formats')
|
|
22
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
23
|
+
expected = '<conditionalFormatting sqref="A1"><cfRule type="cellIs" dxfId="0" priority="1" operator="greaterThan"><formula>5</formula></cfRule></conditionalFormatting>'
|
|
24
|
+
assert_equal(expected, result)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_conditional_formatting_02
|
|
28
|
+
format = Writexlsx::Format.new({}, {})
|
|
29
|
+
|
|
30
|
+
@worksheet.conditional_formatting('A2',
|
|
31
|
+
:type => 'cell',
|
|
32
|
+
:format => format,
|
|
33
|
+
:criteria => 'less than',
|
|
34
|
+
:value => 30
|
|
35
|
+
)
|
|
36
|
+
@worksheet.__send__('write_conditional_formats')
|
|
37
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
38
|
+
expected = '<conditionalFormatting sqref="A2"><cfRule type="cellIs" dxfId="0" priority="1" operator="lessThan"><formula>30</formula></cfRule></conditionalFormatting>'
|
|
39
|
+
assert_equal(expected, result)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_conditional_formatting_03
|
|
43
|
+
format = Writexlsx::Format.new({}, {})
|
|
44
|
+
|
|
45
|
+
@worksheet.conditional_formatting('A3',
|
|
46
|
+
:type => 'cell',
|
|
47
|
+
:format => nil,
|
|
48
|
+
:criteria => '>=',
|
|
49
|
+
:value => 50
|
|
50
|
+
)
|
|
51
|
+
@worksheet.__send__('write_conditional_formats')
|
|
52
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
53
|
+
expected = '<conditionalFormatting sqref="A3"><cfRule type="cellIs" priority="1" operator="greaterThanOrEqual"><formula>50</formula></cfRule></conditionalFormatting>'
|
|
54
|
+
assert_equal(expected, result)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_conditional_formatting_04
|
|
58
|
+
format = Writexlsx::Format.new({}, {})
|
|
59
|
+
|
|
60
|
+
@worksheet.conditional_formatting('A1',
|
|
61
|
+
:type => 'cell',
|
|
62
|
+
:format => format,
|
|
63
|
+
:criteria => 'between',
|
|
64
|
+
:minimum => 10,
|
|
65
|
+
:maximum => 20
|
|
66
|
+
)
|
|
67
|
+
@worksheet.__send__('write_conditional_formats')
|
|
68
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
69
|
+
expected = '<conditionalFormatting sqref="A1"><cfRule type="cellIs" dxfId="0" priority="1" operator="between"><formula>10</formula><formula>20</formula></cfRule></conditionalFormatting>'
|
|
70
|
+
assert_equal(expected, result)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
require 'write_xlsx'
|
|
4
|
+
require 'stringio'
|
|
5
|
+
|
|
6
|
+
class TestWriteCustomFilter < Test::Unit::TestCase
|
|
7
|
+
def setup
|
|
8
|
+
@workbook = WriteXLSX.new(StringIO.new)
|
|
9
|
+
@worksheet = @workbook.add_worksheet('')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_write_custom_filter
|
|
13
|
+
@worksheet.__send__('write_custom_filter', 4, 3000)
|
|
14
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
15
|
+
expected = '<customFilter operator="greaterThan" val="3000" />'
|
|
16
|
+
assert_equal(expected, result)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
require 'write_xlsx'
|
|
4
|
+
require 'stringio'
|
|
5
|
+
|
|
6
|
+
class TestWriteCustomFilters < Test::Unit::TestCase
|
|
7
|
+
def setup
|
|
8
|
+
@workbook = WriteXLSX.new(StringIO.new)
|
|
9
|
+
@worksheet = @workbook.add_worksheet('')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_write_custom_filters_4_4000
|
|
13
|
+
@worksheet.__send__('write_custom_filters', 4, 4000)
|
|
14
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
15
|
+
expected = '<customFilters><customFilter operator="greaterThan" val="4000" /></customFilters>'
|
|
16
|
+
assert_equal(expected, result)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_write_custom_filters_4_3000_0_1_8000
|
|
20
|
+
@worksheet.__send__('write_custom_filters', 4, 3000, 0, 1, 8000)
|
|
21
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
22
|
+
expected = '<customFilters and="1"><customFilter operator="greaterThan" val="3000" /><customFilter operator="lessThan" val="8000" /></customFilters>'
|
|
23
|
+
assert_equal(expected, result)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
require 'write_xlsx'
|
|
4
|
+
require 'stringio'
|
|
5
|
+
|
|
6
|
+
class TestWriteDataValidation01 < Test::Unit::TestCase
|
|
7
|
+
def setup
|
|
8
|
+
@workbook = WriteXLSX.new(StringIO.new)
|
|
9
|
+
@worksheet = @workbook.add_worksheet('')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_write_data_validations_gt_zero
|
|
13
|
+
@worksheet.data_validation('A1',
|
|
14
|
+
:validate => 'integer',
|
|
15
|
+
:criteria => '>',
|
|
16
|
+
:value => 0
|
|
17
|
+
)
|
|
18
|
+
@worksheet.__send__('write_data_validations')
|
|
19
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
20
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" operator="greaterThan" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="A1"><formula1>0</formula1></dataValidation></dataValidations>'
|
|
21
|
+
assert_equal(expected, result)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_write_data_validations_gt_zero_with_options_turned_off
|
|
25
|
+
@worksheet.data_validation('A1',
|
|
26
|
+
:validate => 'integer',
|
|
27
|
+
:criteria => '>',
|
|
28
|
+
:value => 0,
|
|
29
|
+
:ignore_blank => 0,
|
|
30
|
+
:show_input => 0,
|
|
31
|
+
:show_error => 0
|
|
32
|
+
)
|
|
33
|
+
@worksheet.__send__('write_data_validations')
|
|
34
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
35
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" operator="greaterThan" sqref="A1"><formula1>0</formula1></dataValidation></dataValidations>'
|
|
36
|
+
assert_equal(expected, result)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_write_data_validations_gt_E3
|
|
40
|
+
@worksheet.data_validation('A2',
|
|
41
|
+
:validate => 'integer',
|
|
42
|
+
:criteria => '>',
|
|
43
|
+
:value => 'E3'
|
|
44
|
+
)
|
|
45
|
+
@worksheet.__send__('write_data_validations')
|
|
46
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
47
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" operator="greaterThan" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="A2"><formula1>E3</formula1></dataValidation></dataValidations>'
|
|
48
|
+
assert_equal(expected, result)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_write_data_validations_decimal_between_01_05
|
|
52
|
+
@worksheet.data_validation('A3',
|
|
53
|
+
:validate => 'decimal',
|
|
54
|
+
:criteria => 'between',
|
|
55
|
+
:minimum => 0.1,
|
|
56
|
+
:maximum => 0.5
|
|
57
|
+
)
|
|
58
|
+
@worksheet.__send__('write_data_validations')
|
|
59
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
60
|
+
expected = '<dataValidations count="1"><dataValidation type="decimal" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="A3"><formula1>0.1</formula1><formula2>0.5</formula2></dataValidation></dataValidations>'
|
|
61
|
+
assert_equal(expected, result)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_write_data_validations_list_array
|
|
65
|
+
@worksheet.data_validation('A4',
|
|
66
|
+
:validate => 'list',
|
|
67
|
+
:source => [ 'open', 'high', 'close' ]
|
|
68
|
+
)
|
|
69
|
+
@worksheet.__send__('write_data_validations')
|
|
70
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
71
|
+
expected = '<dataValidations count="1"><dataValidation type="list" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="A4"><formula1>"open,high,close"</formula1></dataValidation></dataValidations>'
|
|
72
|
+
assert_equal(expected, result)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_write_data_validations_list_reference
|
|
76
|
+
@worksheet.data_validation('A5',
|
|
77
|
+
:validate => 'list',
|
|
78
|
+
:source => '=$E$4:$G$4'
|
|
79
|
+
)
|
|
80
|
+
@worksheet.__send__('write_data_validations')
|
|
81
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
82
|
+
expected = '<dataValidations count="1"><dataValidation type="list" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="A5"><formula1>$E$4:$G$4</formula1></dataValidation></dataValidations>'
|
|
83
|
+
assert_equal(expected, result)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def test_write_data_validations_list_date_between
|
|
87
|
+
@worksheet.data_validation('A6',
|
|
88
|
+
:validate => 'date',
|
|
89
|
+
:criteria => 'between',
|
|
90
|
+
:minimum => '2008-01-01T',
|
|
91
|
+
:maximum => '2008-12-12T'
|
|
92
|
+
)
|
|
93
|
+
@worksheet.__send__('write_data_validations')
|
|
94
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
95
|
+
expected = '<dataValidations count="1"><dataValidation type="date" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="A6"><formula1>39448</formula1><formula2>39794</formula2></dataValidation></dataValidations>'
|
|
96
|
+
assert_equal(expected, result)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def test_write_data_validations_between_with_title_and_message
|
|
100
|
+
@worksheet.data_validation('A7',
|
|
101
|
+
:validate => 'integer',
|
|
102
|
+
:criteria => 'between',
|
|
103
|
+
:minimum => 1,
|
|
104
|
+
:maximum => 100,
|
|
105
|
+
:input_title => 'Enter an integer:',
|
|
106
|
+
:input_message => 'between 1 and 100'
|
|
107
|
+
)
|
|
108
|
+
@worksheet.__send__('write_data_validations')
|
|
109
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
110
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" allowBlank="1" showInputMessage="1" showErrorMessage="1" promptTitle="Enter an integer:" prompt="between 1 and 100" sqref="A7"><formula1>1</formula1><formula2>100</formula2></dataValidation></dataValidations>'
|
|
111
|
+
assert_equal(expected, result)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
require 'write_xlsx'
|
|
4
|
+
require 'stringio'
|
|
5
|
+
|
|
6
|
+
class TestWriteDataValidation02 < Test::Unit::TestCase
|
|
7
|
+
def setup
|
|
8
|
+
@workbook = WriteXLSX.new(StringIO.new)
|
|
9
|
+
@worksheet = @workbook.add_worksheet('')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_write_data_validations_between_1_and_10
|
|
13
|
+
@worksheet.data_validation('B5',
|
|
14
|
+
:validate => 'integer',
|
|
15
|
+
:criteria => 'between',
|
|
16
|
+
:minimum => 1,
|
|
17
|
+
:maximum => 10
|
|
18
|
+
)
|
|
19
|
+
@worksheet.__send__('write_data_validations')
|
|
20
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
21
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>1</formula1><formula2>10</formula2></dataValidation></dataValidations>'
|
|
22
|
+
assert_equal(expected, result)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_write_data_validations_not_between_1_and_10
|
|
26
|
+
@worksheet.data_validation('B5',
|
|
27
|
+
:validate => 'integer',
|
|
28
|
+
:criteria => 'not between',
|
|
29
|
+
:minimum => 1,
|
|
30
|
+
:maximum => 10
|
|
31
|
+
)
|
|
32
|
+
@worksheet.__send__('write_data_validations')
|
|
33
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
34
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" operator="notBetween" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>1</formula1><formula2>10</formula2></dataValidation></dataValidations>'
|
|
35
|
+
assert_equal(expected, result)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_write_data_validations_integer_equal_1
|
|
39
|
+
['equal to', '=', '=='].each do |operator|
|
|
40
|
+
workbook = WriteXLSX.new(StringIO.new)
|
|
41
|
+
worksheet = workbook.add_worksheet('')
|
|
42
|
+
worksheet.data_validation('B5',
|
|
43
|
+
:validate => 'integer',
|
|
44
|
+
:criteria => operator,
|
|
45
|
+
:value => 1
|
|
46
|
+
)
|
|
47
|
+
worksheet.__send__('write_data_validations')
|
|
48
|
+
result = worksheet.instance_variable_get(:@writer).string
|
|
49
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" operator="equal" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>1</formula1></dataValidation></dataValidations>'
|
|
50
|
+
assert_equal(expected, result)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_write_data_validations_integer_not_equal_1
|
|
55
|
+
['not equal to', '<>', '!='].each do |operator|
|
|
56
|
+
workbook = WriteXLSX.new(StringIO.new)
|
|
57
|
+
worksheet = workbook.add_worksheet('')
|
|
58
|
+
worksheet.data_validation('B5',
|
|
59
|
+
:validate => 'integer',
|
|
60
|
+
:criteria => operator,
|
|
61
|
+
:value => 1
|
|
62
|
+
)
|
|
63
|
+
worksheet.__send__('write_data_validations')
|
|
64
|
+
result = worksheet.instance_variable_get(:@writer).string
|
|
65
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" operator="notEqual" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>1</formula1></dataValidation></dataValidations>'
|
|
66
|
+
assert_equal(expected, result)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_write_data_validations_integer_greater_than_1
|
|
71
|
+
['greater than', '>'].each do |operator|
|
|
72
|
+
workbook = WriteXLSX.new(StringIO.new)
|
|
73
|
+
worksheet = workbook.add_worksheet('')
|
|
74
|
+
worksheet.data_validation('B5',
|
|
75
|
+
:validate => 'integer',
|
|
76
|
+
:criteria => operator,
|
|
77
|
+
:value => 1
|
|
78
|
+
)
|
|
79
|
+
worksheet.__send__('write_data_validations')
|
|
80
|
+
result = worksheet.instance_variable_get(:@writer).string
|
|
81
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" operator="greaterThan" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>1</formula1></dataValidation></dataValidations>'
|
|
82
|
+
assert_equal(expected, result)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def test_write_data_validations_integer_less_than_1
|
|
87
|
+
['less than', '<'].each do |operator|
|
|
88
|
+
workbook = WriteXLSX.new(StringIO.new)
|
|
89
|
+
worksheet = workbook.add_worksheet('')
|
|
90
|
+
worksheet.data_validation('B5',
|
|
91
|
+
:validate => 'integer',
|
|
92
|
+
:criteria => operator,
|
|
93
|
+
:value => 1
|
|
94
|
+
)
|
|
95
|
+
worksheet.__send__('write_data_validations')
|
|
96
|
+
result = worksheet.instance_variable_get(:@writer).string
|
|
97
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" operator="lessThan" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>1</formula1></dataValidation></dataValidations>'
|
|
98
|
+
assert_equal(expected, result)
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def test_write_data_validations_integer_greater_than_or_equal_to_1
|
|
103
|
+
['greater than or equal to', '>='].each do |operator|
|
|
104
|
+
workbook = WriteXLSX.new(StringIO.new)
|
|
105
|
+
worksheet = workbook.add_worksheet('')
|
|
106
|
+
worksheet.data_validation('B5',
|
|
107
|
+
:validate => 'integer',
|
|
108
|
+
:criteria => operator,
|
|
109
|
+
:value => 1
|
|
110
|
+
)
|
|
111
|
+
worksheet.__send__('write_data_validations')
|
|
112
|
+
result = worksheet.instance_variable_get(:@writer).string
|
|
113
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" operator="greaterThanOrEqual" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>1</formula1></dataValidation></dataValidations>'
|
|
114
|
+
assert_equal(expected, result)
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def test_write_data_validations_integer_less_than_or_equal_to_1
|
|
119
|
+
['less than or equal to', '<='].each do |operator|
|
|
120
|
+
workbook = WriteXLSX.new(StringIO.new)
|
|
121
|
+
worksheet = workbook.add_worksheet('')
|
|
122
|
+
worksheet.data_validation('B5',
|
|
123
|
+
:validate => 'integer',
|
|
124
|
+
:criteria => operator,
|
|
125
|
+
:value => 1
|
|
126
|
+
)
|
|
127
|
+
worksheet.__send__('write_data_validations')
|
|
128
|
+
result = worksheet.instance_variable_get(:@writer).string
|
|
129
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" operator="lessThanOrEqual" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>1</formula1></dataValidation></dataValidations>'
|
|
130
|
+
assert_equal(expected, result)
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def test_write_data_validations_integer_between_1_and_10_not_ignore_blank
|
|
135
|
+
@worksheet.data_validation('B5',
|
|
136
|
+
:validate => 'integer',
|
|
137
|
+
:criteria => 'between',
|
|
138
|
+
:minimum => 1,
|
|
139
|
+
:maximum => 10,
|
|
140
|
+
:ignore_blank => 0
|
|
141
|
+
)
|
|
142
|
+
@worksheet.__send__('write_data_validations')
|
|
143
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
144
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>1</formula1><formula2>10</formula2></dataValidation></dataValidations>'
|
|
145
|
+
assert_equal(expected, result)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def test_write_data_validations_integer_between_1_and_10_error_type_warning
|
|
149
|
+
@worksheet.data_validation('B5',
|
|
150
|
+
:validate => 'integer',
|
|
151
|
+
:criteria => 'between',
|
|
152
|
+
:minimum => 1,
|
|
153
|
+
:maximum => 10,
|
|
154
|
+
:error_type => 'warning'
|
|
155
|
+
)
|
|
156
|
+
@worksheet.__send__('write_data_validations')
|
|
157
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
158
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" errorStyle="warning" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>1</formula1><formula2>10</formula2></dataValidation></dataValidations>'
|
|
159
|
+
assert_equal(expected, result)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def test_write_data_validations_integer_between_1_and_10_error_type_information
|
|
163
|
+
@worksheet.data_validation('B5',
|
|
164
|
+
:validate => 'integer',
|
|
165
|
+
:criteria => 'between',
|
|
166
|
+
:minimum => 1,
|
|
167
|
+
:maximum => 10,
|
|
168
|
+
:error_type => 'information'
|
|
169
|
+
)
|
|
170
|
+
@worksheet.__send__('write_data_validations')
|
|
171
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
172
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" errorStyle="information" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>1</formula1><formula2>10</formula2></dataValidation></dataValidations>'
|
|
173
|
+
assert_equal(expected, result)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def test_write_data_validations_integer_between_1_and_10_with_input_title
|
|
177
|
+
@worksheet.data_validation('B5',
|
|
178
|
+
:validate => 'integer',
|
|
179
|
+
:criteria => 'between',
|
|
180
|
+
:minimum => 1,
|
|
181
|
+
:maximum => 10,
|
|
182
|
+
:input_title => 'Input title January'
|
|
183
|
+
)
|
|
184
|
+
@worksheet.__send__('write_data_validations')
|
|
185
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
186
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" allowBlank="1" showInputMessage="1" showErrorMessage="1" promptTitle="Input title January" sqref="B5"><formula1>1</formula1><formula2>10</formula2></dataValidation></dataValidations>'
|
|
187
|
+
assert_equal(expected, result)
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def test_write_data_validations_integer_between_1_and_10_with_input_title_and_input_message
|
|
191
|
+
@worksheet.data_validation('B5',
|
|
192
|
+
:validate => 'integer',
|
|
193
|
+
:criteria => 'between',
|
|
194
|
+
:minimum => 1,
|
|
195
|
+
:maximum => 10,
|
|
196
|
+
:input_title => 'Input title January',
|
|
197
|
+
:input_message => 'Input message February'
|
|
198
|
+
)
|
|
199
|
+
@worksheet.__send__('write_data_validations')
|
|
200
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
201
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" allowBlank="1" showInputMessage="1" showErrorMessage="1" promptTitle="Input title January" prompt="Input message February" sqref="B5"><formula1>1</formula1><formula2>10</formula2></dataValidation></dataValidations>'
|
|
202
|
+
assert_equal(expected, result)
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
def test_write_data_validations_integer_between_1_and_10_with_input_title_and_input_message_and_error_title
|
|
206
|
+
@worksheet.data_validation('B5',
|
|
207
|
+
:validate => 'integer',
|
|
208
|
+
:criteria => 'between',
|
|
209
|
+
:minimum => 1,
|
|
210
|
+
:maximum => 10,
|
|
211
|
+
:input_title => 'Input title January',
|
|
212
|
+
:input_message => 'Input message February',
|
|
213
|
+
:error_title => 'Error title March'
|
|
214
|
+
)
|
|
215
|
+
@worksheet.__send__('write_data_validations')
|
|
216
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
217
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" allowBlank="1" showInputMessage="1" showErrorMessage="1" errorTitle="Error title March" promptTitle="Input title January" prompt="Input message February" sqref="B5"><formula1>1</formula1><formula2>10</formula2></dataValidation></dataValidations>'
|
|
218
|
+
assert_equal(expected, result)
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
def test_write_data_validations_integer_between_1_and_10_with_input_title_and_input_message_and_error_title_and_error_message
|
|
222
|
+
@worksheet.data_validation('B5',
|
|
223
|
+
:validate => 'integer',
|
|
224
|
+
:criteria => 'between',
|
|
225
|
+
:minimum => 1,
|
|
226
|
+
:maximum => 10,
|
|
227
|
+
:input_title => 'Input title January',
|
|
228
|
+
:input_message => 'Input message February',
|
|
229
|
+
:error_title => 'Error title March',
|
|
230
|
+
:error_message => 'Error message April'
|
|
231
|
+
)
|
|
232
|
+
@worksheet.__send__('write_data_validations')
|
|
233
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
234
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" allowBlank="1" showInputMessage="1" showErrorMessage="1" errorTitle="Error title March" error="Error message April" promptTitle="Input title January" prompt="Input message February" sqref="B5"><formula1>1</formula1><formula2>10</formula2></dataValidation></dataValidations>'
|
|
235
|
+
assert_equal(expected, result)
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def test_write_data_validations_integer_between_1_and_10_with_input_title_and_input_message_and_error_title_and_error_message_and_show_input
|
|
239
|
+
@worksheet.data_validation('B5',
|
|
240
|
+
:validate => 'integer',
|
|
241
|
+
:criteria => 'between',
|
|
242
|
+
:minimum => 1,
|
|
243
|
+
:maximum => 10,
|
|
244
|
+
:input_title => 'Input title January',
|
|
245
|
+
:input_message => 'Input message February',
|
|
246
|
+
:error_title => 'Error title March',
|
|
247
|
+
:error_message => 'Error message April',
|
|
248
|
+
:show_input => 0
|
|
249
|
+
)
|
|
250
|
+
@worksheet.__send__('write_data_validations')
|
|
251
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
252
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" allowBlank="1" showErrorMessage="1" errorTitle="Error title March" error="Error message April" promptTitle="Input title January" prompt="Input message February" sqref="B5"><formula1>1</formula1><formula2>10</formula2></dataValidation></dataValidations>'
|
|
253
|
+
assert_equal(expected, result)
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
def test_write_data_validations_integer_between_1_and_10_with_input_title_and_input_message_and_error_title_and_error_message_and_show_input_and_show_error
|
|
257
|
+
@worksheet.data_validation('B5',
|
|
258
|
+
:validate => 'integer',
|
|
259
|
+
:criteria => 'between',
|
|
260
|
+
:minimum => 1,
|
|
261
|
+
:maximum => 10,
|
|
262
|
+
:input_title => 'Input title January',
|
|
263
|
+
:input_message => 'Input message February',
|
|
264
|
+
:error_title => 'Error title March',
|
|
265
|
+
:error_message => 'Error message April',
|
|
266
|
+
:show_input => 0,
|
|
267
|
+
:show_error => 0
|
|
268
|
+
)
|
|
269
|
+
@worksheet.__send__('write_data_validations')
|
|
270
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
271
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" allowBlank="1" errorTitle="Error title March" error="Error message April" promptTitle="Input title January" prompt="Input message February" sqref="B5"><formula1>1</formula1><formula2>10</formula2></dataValidation></dataValidations>'
|
|
272
|
+
assert_equal(expected, result)
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
def test_write_data_validation_validate_any
|
|
276
|
+
@worksheet.data_validation('B5', :validate => 'any')
|
|
277
|
+
@worksheet.__send__('write_data_validations')
|
|
278
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
279
|
+
expected = ''
|
|
280
|
+
assert_equal(expected, result)
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
def test_write_data_validation_decimal_equal_to_12345
|
|
284
|
+
@worksheet.data_validation('B5',
|
|
285
|
+
:validate => 'decimal',
|
|
286
|
+
:criteria => '==',
|
|
287
|
+
:value => 1.2345
|
|
288
|
+
)
|
|
289
|
+
@worksheet.__send__('write_data_validations')
|
|
290
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
291
|
+
expected = '<dataValidations count="1"><dataValidation type="decimal" operator="equal" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>1.2345</formula1></dataValidation></dataValidations>'
|
|
292
|
+
assert_equal(expected, result)
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
def test_write_data_validation_list_a_bb_ccc
|
|
296
|
+
@worksheet.data_validation('B5',
|
|
297
|
+
:validate => 'list',
|
|
298
|
+
:source => ['a', 'bb', 'ccc']
|
|
299
|
+
)
|
|
300
|
+
@worksheet.__send__('write_data_validations')
|
|
301
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
302
|
+
expected = '<dataValidations count="1"><dataValidation type="list" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>"a,bb,ccc"</formula1></dataValidation></dataValidations>'
|
|
303
|
+
assert_equal(expected, result)
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
def test_write_data_validation_list_a_bb_ccc_without_dropdown
|
|
307
|
+
@worksheet.data_validation('B5',
|
|
308
|
+
:validate => 'list',
|
|
309
|
+
:source => ['a', 'bb', 'ccc'],
|
|
310
|
+
:dropdown => 0
|
|
311
|
+
)
|
|
312
|
+
@worksheet.__send__('write_data_validations')
|
|
313
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
314
|
+
expected = '<dataValidations count="1"><dataValidation type="list" allowBlank="1" showDropDown="1" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>"a,bb,ccc"</formula1></dataValidation></dataValidations>'
|
|
315
|
+
assert_equal(expected, result)
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
def test_write_data_validation_list_absolute_range
|
|
319
|
+
@worksheet.data_validation(
|
|
320
|
+
'A1:A1',
|
|
321
|
+
:validate => 'list',
|
|
322
|
+
:source => '=$D$1:$D$5'
|
|
323
|
+
)
|
|
324
|
+
@worksheet.__send__('write_data_validations')
|
|
325
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
326
|
+
expected = '<dataValidations count="1"><dataValidation type="list" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="A1"><formula1>$D$1:$D$5</formula1></dataValidation></dataValidations>'
|
|
327
|
+
assert_equal(expected, result)
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
def test_write_data_validation_date_equal_to_39653
|
|
331
|
+
@worksheet.data_validation(
|
|
332
|
+
'B5',
|
|
333
|
+
:validate => 'date',
|
|
334
|
+
:criteria => '==',
|
|
335
|
+
:value => 39653
|
|
336
|
+
)
|
|
337
|
+
@worksheet.__send__('write_data_validations')
|
|
338
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
339
|
+
expected = '<dataValidations count="1"><dataValidation type="date" operator="equal" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>39653</formula1></dataValidation></dataValidations>'
|
|
340
|
+
assert_equal(expected, result)
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
def test_write_data_validation_date_equal_to_2008_07_24T
|
|
344
|
+
@worksheet.data_validation(
|
|
345
|
+
'B5',
|
|
346
|
+
:validate => 'date',
|
|
347
|
+
:criteria => '==',
|
|
348
|
+
:value => '2008-07-24T'
|
|
349
|
+
)
|
|
350
|
+
@worksheet.__send__('write_data_validations')
|
|
351
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
352
|
+
expected = '<dataValidations count="1"><dataValidation type="date" operator="equal" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>39653</formula1></dataValidation></dataValidations>'
|
|
353
|
+
assert_equal(expected, result)
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
def test_write_data_validation_date_between_range
|
|
357
|
+
@worksheet.data_validation(
|
|
358
|
+
'B5',
|
|
359
|
+
:validate => 'date',
|
|
360
|
+
:criteria => 'between',
|
|
361
|
+
:minimum => '2008-01-01T',
|
|
362
|
+
:maximum => '2008-12-12T'
|
|
363
|
+
)
|
|
364
|
+
@worksheet.__send__('write_data_validations')
|
|
365
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
366
|
+
expected = '<dataValidations count="1"><dataValidation type="date" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>39448</formula1><formula2>39794</formula2></dataValidation></dataValidations>'
|
|
367
|
+
assert_equal(expected, result)
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
def test_write_data_validation_time_equal_to_05
|
|
371
|
+
@worksheet.data_validation(
|
|
372
|
+
'B5:B5',
|
|
373
|
+
:validate => 'time',
|
|
374
|
+
:criteria => '==',
|
|
375
|
+
:value => 0.5
|
|
376
|
+
)
|
|
377
|
+
@worksheet.__send__('write_data_validations')
|
|
378
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
379
|
+
expected = '<dataValidations count="1"><dataValidation type="time" operator="equal" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>0.5</formula1></dataValidation></dataValidations>'
|
|
380
|
+
assert_equal(expected, result)
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
def test_write_data_validation_time_equal_to_1200
|
|
384
|
+
@worksheet.data_validation(
|
|
385
|
+
'B5',
|
|
386
|
+
:validate => 'time',
|
|
387
|
+
:criteria => '==',
|
|
388
|
+
:value => 'T12:00:00'
|
|
389
|
+
)
|
|
390
|
+
@worksheet.__send__('write_data_validations')
|
|
391
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
392
|
+
expected = '<dataValidations count="1"><dataValidation type="time" operator="equal" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>0.5</formula1></dataValidation></dataValidations>'
|
|
393
|
+
assert_equal(expected, result)
|
|
394
|
+
end
|
|
395
|
+
|
|
396
|
+
def test_write_data_validation_custom_equal_to_10
|
|
397
|
+
@worksheet.data_validation(
|
|
398
|
+
'B5',
|
|
399
|
+
:validate => 'custom',
|
|
400
|
+
:criteria => '==',
|
|
401
|
+
:value => 10
|
|
402
|
+
)
|
|
403
|
+
@worksheet.__send__('write_data_validations')
|
|
404
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
405
|
+
expected = '<dataValidations count="1"><dataValidation type="custom" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>10</formula1></dataValidation></dataValidations>'
|
|
406
|
+
assert_equal(expected, result)
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
def test_write_data_validations_between_1_and_10_A1_cell
|
|
410
|
+
@worksheet.data_validation(
|
|
411
|
+
'B5',
|
|
412
|
+
:validate => 'integer',
|
|
413
|
+
:criteria => 'between',
|
|
414
|
+
:minimum => 1,
|
|
415
|
+
:maximum => 10
|
|
416
|
+
)
|
|
417
|
+
@worksheet.__send__('write_data_validations')
|
|
418
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
419
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>1</formula1><formula2>10</formula2></dataValidation></dataValidations>'
|
|
420
|
+
assert_equal(expected, result)
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
def test_write_data_validations_between_1_and_10_A1_range
|
|
424
|
+
@worksheet.data_validation(
|
|
425
|
+
'B5:B10',
|
|
426
|
+
:validate => 'integer',
|
|
427
|
+
:criteria => 'between',
|
|
428
|
+
:minimum => 1,
|
|
429
|
+
:maximum => 10
|
|
430
|
+
)
|
|
431
|
+
@worksheet.__send__('write_data_validations')
|
|
432
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
433
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5:B10"><formula1>1</formula1><formula2>10</formula2></dataValidation></dataValidations>'
|
|
434
|
+
assert_equal(expected, result)
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
def test_write_data_validations_between_1_and_10_row_col_cell
|
|
438
|
+
@worksheet.data_validation(
|
|
439
|
+
4, 1,
|
|
440
|
+
:validate => 'integer',
|
|
441
|
+
:criteria => 'between',
|
|
442
|
+
:minimum => 1,
|
|
443
|
+
:maximum => 10
|
|
444
|
+
)
|
|
445
|
+
@worksheet.__send__('write_data_validations')
|
|
446
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
447
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>1</formula1><formula2>10</formula2></dataValidation></dataValidations>'
|
|
448
|
+
assert_equal(expected, result)
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
def test_write_data_validations_between_1_and_10_row_col_range
|
|
452
|
+
@worksheet.data_validation(
|
|
453
|
+
4, 1, 9, 1,
|
|
454
|
+
:validate => 'integer',
|
|
455
|
+
:criteria => 'between',
|
|
456
|
+
:minimum => 1,
|
|
457
|
+
:maximum => 10
|
|
458
|
+
)
|
|
459
|
+
@worksheet.__send__('write_data_validations')
|
|
460
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
461
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5:B10"><formula1>1</formula1><formula2>10</formula2></dataValidation></dataValidations>'
|
|
462
|
+
assert_equal(expected, result)
|
|
463
|
+
end
|
|
464
|
+
|
|
465
|
+
def test_write_data_validations_multiple_style_cells
|
|
466
|
+
@worksheet.data_validation(
|
|
467
|
+
4, 1,
|
|
468
|
+
:validate => 'integer',
|
|
469
|
+
:criteria => 'between',
|
|
470
|
+
:minimum => 1,
|
|
471
|
+
:maximum => 10,
|
|
472
|
+
:other_cells => [ [ 4, 3, 4, 3 ] ]
|
|
473
|
+
)
|
|
474
|
+
@worksheet.__send__('write_data_validations')
|
|
475
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
476
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5 D5"><formula1>1</formula1><formula2>10</formula2></dataValidation></dataValidations>'
|
|
477
|
+
assert_equal(expected, result)
|
|
478
|
+
end
|
|
479
|
+
|
|
480
|
+
def test_write_data_validations_multiple_style_cells_2
|
|
481
|
+
@worksheet.data_validation(
|
|
482
|
+
4, 1,
|
|
483
|
+
:validate => 'integer',
|
|
484
|
+
:criteria => 'between',
|
|
485
|
+
:minimum => 1,
|
|
486
|
+
:maximum => 10,
|
|
487
|
+
:other_cells => [ [ 6, 1, 6, 1 ], [ 8, 1, 8, 1 ] ]
|
|
488
|
+
)
|
|
489
|
+
@worksheet.__send__('write_data_validations')
|
|
490
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
491
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5 B7 B9"><formula1>1</formula1><formula2>10</formula2></dataValidation></dataValidations>'
|
|
492
|
+
assert_equal(expected, result)
|
|
493
|
+
end
|
|
494
|
+
|
|
495
|
+
def test_write_data_validations_multiple_style_cells_3
|
|
496
|
+
@worksheet.data_validation(
|
|
497
|
+
4, 1, 8, 1,
|
|
498
|
+
:validate => 'integer',
|
|
499
|
+
:criteria => 'between',
|
|
500
|
+
:minimum => 1,
|
|
501
|
+
:maximum => 10,
|
|
502
|
+
:other_cells => [ [ 3, 3, 3, 3 ] ]
|
|
503
|
+
)
|
|
504
|
+
@worksheet.__send__('write_data_validations')
|
|
505
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
506
|
+
expected = '<dataValidations count="1"><dataValidation type="whole" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5:B9 D4"><formula1>1</formula1><formula2>10</formula2></dataValidation></dataValidations>'
|
|
507
|
+
assert_equal(expected, result)
|
|
508
|
+
end
|
|
509
|
+
|
|
510
|
+
def test_write_data_validations_multiple_validation
|
|
511
|
+
@worksheet.data_validation(
|
|
512
|
+
'B5',
|
|
513
|
+
:validate => 'integer',
|
|
514
|
+
:criteria => '>',
|
|
515
|
+
:value => 10
|
|
516
|
+
)
|
|
517
|
+
@worksheet.data_validation(
|
|
518
|
+
'C10',
|
|
519
|
+
:validate => 'integer',
|
|
520
|
+
:criteria => '<',
|
|
521
|
+
:value => 10
|
|
522
|
+
)
|
|
523
|
+
@worksheet.__send__('write_data_validations')
|
|
524
|
+
result = @worksheet.instance_variable_get(:@writer).string
|
|
525
|
+
expected = '<dataValidations count="2"><dataValidation type="whole" operator="greaterThan" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="B5"><formula1>10</formula1></dataValidation><dataValidation type="whole" operator="lessThan" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="C10"><formula1>10</formula1></dataValidation></dataValidations>'
|
|
526
|
+
assert_equal(expected, result)
|
|
527
|
+
end
|
|
528
|
+
end
|