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,14 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
require 'write_xlsx/workbook'
|
|
4
|
+
require 'write_xlsx/package/vml'
|
|
5
|
+
|
|
6
|
+
class TestWriteMoveWithCells < Test::Unit::TestCase
|
|
7
|
+
def test_write_move_with_cells
|
|
8
|
+
vml = Writexlsx::Package::VML.new
|
|
9
|
+
vml.__send__('write_move_with_cells')
|
|
10
|
+
result = vml.instance_variable_get(:@writer).string
|
|
11
|
+
expected = '<x:MoveWithCells />'
|
|
12
|
+
assert_equal(expected, result)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
require 'write_xlsx/workbook'
|
|
4
|
+
require 'write_xlsx/package/vml'
|
|
5
|
+
|
|
6
|
+
class TestWritePath < Test::Unit::TestCase
|
|
7
|
+
def test_write_path
|
|
8
|
+
vml = Writexlsx::Package::VML.new
|
|
9
|
+
vml.__send__('write_path', 't', 'rect')
|
|
10
|
+
result = vml.instance_variable_get(:@writer).string
|
|
11
|
+
expected = '<v:path gradientshapeok="t" o:connecttype="rect" />'
|
|
12
|
+
assert_equal(expected, result)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_write_path_without_gradientshapeok
|
|
16
|
+
vml = Writexlsx::Package::VML.new
|
|
17
|
+
vml.__send__('write_path', nil, 'none')
|
|
18
|
+
result = vml.instance_variable_get(:@writer).string
|
|
19
|
+
expected = '<v:path o:connecttype="none" />'
|
|
20
|
+
assert_equal(expected, result)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
require 'write_xlsx/workbook'
|
|
4
|
+
require 'write_xlsx/package/vml'
|
|
5
|
+
|
|
6
|
+
class TestWriteRow < Test::Unit::TestCase
|
|
7
|
+
def test_write_row
|
|
8
|
+
vml = Writexlsx::Package::VML.new
|
|
9
|
+
vml.__send__('write_row', 2)
|
|
10
|
+
result = vml.instance_variable_get(:@writer).string
|
|
11
|
+
expected = '<x:Row>2</x:Row>'
|
|
12
|
+
assert_equal(expected, result)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
require 'write_xlsx/workbook'
|
|
4
|
+
require 'write_xlsx/package/vml'
|
|
5
|
+
|
|
6
|
+
class TestWriteShadow < Test::Unit::TestCase
|
|
7
|
+
def test_write_shadow
|
|
8
|
+
vml = Writexlsx::Package::VML.new
|
|
9
|
+
vml.__send__('write_shadow')
|
|
10
|
+
result = vml.instance_variable_get(:@writer).string
|
|
11
|
+
expected = '<v:shadow on="t" color="black" obscured="t" />'
|
|
12
|
+
assert_equal(expected, result)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
require 'write_xlsx/workbook'
|
|
4
|
+
require 'write_xlsx/package/vml'
|
|
5
|
+
|
|
6
|
+
class TestWriteShapelayout < Test::Unit::TestCase
|
|
7
|
+
def test_write_shapelayout
|
|
8
|
+
vml = Writexlsx::Package::VML.new
|
|
9
|
+
vml.__send__('write_shapelayout', 1)
|
|
10
|
+
result = vml.instance_variable_get(:@writer).string
|
|
11
|
+
expected = '<o:shapelayout v:ext="edit"><o:idmap v:ext="edit" data="1" /></o:shapelayout>'
|
|
12
|
+
assert_equal(expected, result)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
require 'write_xlsx/workbook'
|
|
4
|
+
require 'write_xlsx/package/vml'
|
|
5
|
+
|
|
6
|
+
class TestWriteShapetype < Test::Unit::TestCase
|
|
7
|
+
def test_write_shapetype
|
|
8
|
+
vml = Writexlsx::Package::VML.new
|
|
9
|
+
vml.__send__('write_shapetype')
|
|
10
|
+
result = vml.instance_variable_get(:@writer).string
|
|
11
|
+
expected = '<v:shapetype id="_x0000_t202" coordsize="21600,21600" o:spt="202" path="m,l,21600r21600,l21600,xe"><v:stroke joinstyle="miter" /><v:path gradientshapeok="t" o:connecttype="rect" /></v:shapetype>'
|
|
12
|
+
assert_equal(expected, result)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
require 'write_xlsx/workbook'
|
|
4
|
+
require 'write_xlsx/package/vml'
|
|
5
|
+
|
|
6
|
+
class TestWriteSizeWithCells < Test::Unit::TestCase
|
|
7
|
+
def test_write_size_with_cells
|
|
8
|
+
vml = Writexlsx::Package::VML.new
|
|
9
|
+
vml.__send__('write_size_with_cells')
|
|
10
|
+
result = vml.instance_variable_get(:@writer).string
|
|
11
|
+
expected = '<x:SizeWithCells />'
|
|
12
|
+
assert_equal(expected, result)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
require 'write_xlsx/workbook'
|
|
4
|
+
require 'write_xlsx/package/vml'
|
|
5
|
+
|
|
6
|
+
class TestWriteStroke < Test::Unit::TestCase
|
|
7
|
+
def test_write_stroke
|
|
8
|
+
vml = Writexlsx::Package::VML.new
|
|
9
|
+
vml.__send__('write_stroke')
|
|
10
|
+
result = vml.instance_variable_get(:@writer).string
|
|
11
|
+
expected = '<v:stroke joinstyle="miter" />'
|
|
12
|
+
assert_equal(expected, result)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
require 'write_xlsx/workbook'
|
|
4
|
+
require 'write_xlsx/package/vml'
|
|
5
|
+
|
|
6
|
+
class TestWriteTextbox < Test::Unit::TestCase
|
|
7
|
+
def test_write_textbox
|
|
8
|
+
vml = Writexlsx::Package::VML.new
|
|
9
|
+
vml.__send__('write_textbox')
|
|
10
|
+
result = vml.instance_variable_get(:@writer).string
|
|
11
|
+
expected = '<v:textbox style="mso-direction-alt:auto"><div style="text-align:left"></div></v:textbox>'
|
|
12
|
+
assert_equal(expected, result)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
require 'write_xlsx'
|
|
4
|
+
|
|
5
|
+
class TestDeleteFiles < Test::Unit::TestCase
|
|
6
|
+
def setup
|
|
7
|
+
@dir_path = 'test_delete_empty_directory'
|
|
8
|
+
Writexlsx::Utility.delete_files(@dir_path) if FileTest.exist?(@dir_path)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_delete_empty_directory
|
|
12
|
+
Dir.mkdir(@dir_path)
|
|
13
|
+
assert(FileTest.exist?(@dir_path))
|
|
14
|
+
Writexlsx::Utility.delete_files(@dir_path)
|
|
15
|
+
assert(!FileTest.exist?(@dir_path))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_delete_directory_and_one_file
|
|
19
|
+
filename = 'test_file'
|
|
20
|
+
Dir.mkdir(@dir_path)
|
|
21
|
+
File.open(File.join(@dir_path, filename), "w") { |file| file.write("str") }
|
|
22
|
+
assert(FileTest.exist?(@dir_path))
|
|
23
|
+
assert(FileTest.exist?(File.join(@dir_path, filename)))
|
|
24
|
+
Writexlsx::Utility.delete_files(@dir_path)
|
|
25
|
+
assert(!FileTest.exist?(@dir_path))
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_delete_directory_and_subdirectory
|
|
29
|
+
subdir_name = 'subdir'
|
|
30
|
+
Dir.mkdir(@dir_path)
|
|
31
|
+
Dir.mkdir(File.join(@dir_path, subdir_name))
|
|
32
|
+
assert(FileTest.exist?(@dir_path))
|
|
33
|
+
assert(FileTest.exist?(File.join(@dir_path, subdir_name)))
|
|
34
|
+
Writexlsx::Utility.delete_files(@dir_path)
|
|
35
|
+
assert(!FileTest.exist?(@dir_path))
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,2281 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
require 'write_xlsx'
|
|
4
|
+
|
|
5
|
+
class TestExampleMatch < Test::Unit::TestCase
|
|
6
|
+
def setup
|
|
7
|
+
setup_dir_var
|
|
8
|
+
Writexlsx::Utility.delete_files(@expected_dir) if File.exist?(@expected_dir)
|
|
9
|
+
Writexlsx::Utility.delete_files(@result_dir) if File.exist?(@result_dir)
|
|
10
|
+
raise "cannot create test working directory." if File.exist?(@expected_dir) || File.exist?(@result_dir)
|
|
11
|
+
@obj = Writexlsx::Package::XMLWriterSimple.new
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_a_simple
|
|
15
|
+
xlsx = 'a_simple.xlsx'
|
|
16
|
+
# Create a new workbook called simple.xls and add a worksheet
|
|
17
|
+
workbook = WriteXLSX.new(xlsx)
|
|
18
|
+
worksheet = workbook.add_worksheet
|
|
19
|
+
|
|
20
|
+
# The general syntax is write(row, column, token). Note that row and
|
|
21
|
+
# column are zero indexed
|
|
22
|
+
#
|
|
23
|
+
|
|
24
|
+
# Write some text
|
|
25
|
+
worksheet.write(0, 0, "Hi Excel!")
|
|
26
|
+
|
|
27
|
+
# Write some numbers
|
|
28
|
+
worksheet.write(2, 0, 3) # Writes 3
|
|
29
|
+
worksheet.write(3, 0, 3.00000) # Writes 3
|
|
30
|
+
worksheet.write(4, 0, 3.00001) # Writes 3.00001
|
|
31
|
+
worksheet.write(5, 0, 3.14159) # TeX revision no.?
|
|
32
|
+
|
|
33
|
+
# Write some formulas
|
|
34
|
+
worksheet.write(7, 0, '=A3 + A6')
|
|
35
|
+
worksheet.write(8, 0, '=IF(A5>3,"Yes", "No")')
|
|
36
|
+
|
|
37
|
+
# Write a hyperlink
|
|
38
|
+
hyperlink_format = workbook.add_format(
|
|
39
|
+
:color => 'blue',
|
|
40
|
+
:underline => 1
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
worksheet.write(10, 0, 'http://www.ruby-lang.org/', hyperlink_format)
|
|
44
|
+
|
|
45
|
+
workbook.close
|
|
46
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_array_formula
|
|
50
|
+
xlsx = 'array_formula.xlsx'
|
|
51
|
+
workbook = WriteXLSX.new(xlsx)
|
|
52
|
+
worksheet = workbook.add_worksheet
|
|
53
|
+
|
|
54
|
+
# Write some test data.
|
|
55
|
+
worksheet.write('B1', [ [ 500, 10 ], [ 300, 15 ] ])
|
|
56
|
+
worksheet.write('B5', [ [ 1, 2, 3 ], [ 20234, 21003, 10000 ] ])
|
|
57
|
+
|
|
58
|
+
# Write an array formula that returns a single value
|
|
59
|
+
worksheet.write('A1', '{=SUM(B1:C1*B2:C2)}')
|
|
60
|
+
|
|
61
|
+
# Same as above but more verbose.
|
|
62
|
+
worksheet.write_array_formula('A2:A2', '{=SUM(B1:C1*B2:C2)}')
|
|
63
|
+
|
|
64
|
+
# Write an array formula that returns a range of values
|
|
65
|
+
worksheet.write_array_formula('A5:A7', '{=TREND(C5:C7,B5:B7)}')
|
|
66
|
+
|
|
67
|
+
workbook.close
|
|
68
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_chart_area
|
|
72
|
+
xlsx = 'chart_area.xlsx'
|
|
73
|
+
workbook = WriteXLSX.new(xlsx)
|
|
74
|
+
worksheet = workbook.add_worksheet
|
|
75
|
+
bold = workbook.add_format(:bold => 1)
|
|
76
|
+
|
|
77
|
+
# Add the worksheet data that the charts will refer to.
|
|
78
|
+
headings = [ 'Number', 'Batch 1', 'Batch 2' ]
|
|
79
|
+
data = [
|
|
80
|
+
[ 2, 3, 4, 5, 6, 7 ],
|
|
81
|
+
[ 40, 40, 50, 30, 25, 50 ],
|
|
82
|
+
[ 30, 25, 30, 10, 5, 10 ]
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
worksheet.write('A1', headings, bold)
|
|
86
|
+
worksheet.write('A2', data)
|
|
87
|
+
|
|
88
|
+
# Create a new chart object. In this case an embedded chart.
|
|
89
|
+
chart = workbook.add_chart(:type => 'area', :embedded => 1)
|
|
90
|
+
|
|
91
|
+
# Configure the first series.
|
|
92
|
+
chart.add_series(
|
|
93
|
+
:name => '=Sheet1!$B$1',
|
|
94
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
|
95
|
+
:values => '=Sheet1!$B$2:$B$7'
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
# Configure second series. Note alternative use of array ref to define
|
|
99
|
+
# ranges: [ sheetname, row_start, row_end, col_start, col_end ].
|
|
100
|
+
chart.add_series(
|
|
101
|
+
:name => '=Sheet1!$C$1',
|
|
102
|
+
:categories => [ 'Sheet1', 1, 6, 0, 0 ],
|
|
103
|
+
:values => [ 'Sheet1', 1, 6, 2, 2 ]
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
# Add a chart title and some axis labels.
|
|
107
|
+
chart.set_title(:name => 'Results of sample analysis')
|
|
108
|
+
chart.set_x_axis(:name => 'Test number')
|
|
109
|
+
chart.set_y_axis(:name => 'Sample length (mm)')
|
|
110
|
+
|
|
111
|
+
# Set an Excel chart style. Blue colors with white outline and shadow.
|
|
112
|
+
chart.set_style(11)
|
|
113
|
+
|
|
114
|
+
# Insert the chart into the worksheet (with an offset).
|
|
115
|
+
worksheet.insert_chart('D2', chart, 25, 10)
|
|
116
|
+
|
|
117
|
+
workbook.close
|
|
118
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def test_chart_bar
|
|
122
|
+
xlsx = 'chart_bar.xlsx'
|
|
123
|
+
workbook = WriteXLSX.new(xlsx)
|
|
124
|
+
worksheet = workbook.add_worksheet
|
|
125
|
+
bold = workbook.add_format(:bold => 1)
|
|
126
|
+
|
|
127
|
+
# Add the worksheet data that the charts will refer to.
|
|
128
|
+
headings = [ 'Number', 'Batch 1', 'Batch 2' ]
|
|
129
|
+
data = [
|
|
130
|
+
[ 2, 3, 4, 5, 6, 7 ],
|
|
131
|
+
[ 10, 40, 50, 20, 10, 50 ],
|
|
132
|
+
[ 30, 60, 70, 50, 40, 30 ]
|
|
133
|
+
]
|
|
134
|
+
|
|
135
|
+
worksheet.write('A1', headings, bold)
|
|
136
|
+
worksheet.write('A2', data)
|
|
137
|
+
|
|
138
|
+
# Create a new chart object. In this case an embedded chart.
|
|
139
|
+
chart = workbook.add_chart(:type => 'bar', :embedded => 1)
|
|
140
|
+
|
|
141
|
+
# Configure the first series.
|
|
142
|
+
chart.add_series(
|
|
143
|
+
:name => '=Sheet1!$B$1',
|
|
144
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
|
145
|
+
:values => '=Sheet1!$B$2:$B$7'
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
# Configure second series. Note alternative use of array ref to define
|
|
149
|
+
# ranges: [ sheetname, row_start, row_end, col_start, col_end ].
|
|
150
|
+
chart.add_series(
|
|
151
|
+
:name => '=Sheet1!$C$1',
|
|
152
|
+
:categories => [ 'Sheet1', 1, 6, 0, 0 ],
|
|
153
|
+
:values => [ 'Sheet1', 1, 6, 2, 2 ]
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
# Add a chart title and some axis labels.
|
|
157
|
+
chart.set_title(:name => 'Results of sample analysis')
|
|
158
|
+
chart.set_x_axis(:name => 'Test number')
|
|
159
|
+
chart.set_y_axis(:name => 'Sample length (mm)')
|
|
160
|
+
|
|
161
|
+
# Set an Excel chart style. Blue colors with white outline and shadow.
|
|
162
|
+
chart.set_style(11)
|
|
163
|
+
|
|
164
|
+
# Insert the chart into the worksheet (with an offset).
|
|
165
|
+
worksheet.insert_chart('D2', chart, 25, 10)
|
|
166
|
+
|
|
167
|
+
workbook.close
|
|
168
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def test_chart_column
|
|
172
|
+
xlsx = 'chart_column.xlsx'
|
|
173
|
+
workbook = WriteXLSX.new(xlsx)
|
|
174
|
+
worksheet = workbook.add_worksheet
|
|
175
|
+
bold = workbook.add_format(:bold => 1)
|
|
176
|
+
|
|
177
|
+
# Add the worksheet data that the charts will refer to.
|
|
178
|
+
headings = [ 'Number', 'Batch 1', 'Batch 2' ]
|
|
179
|
+
data = [
|
|
180
|
+
[ 2, 3, 4, 5, 6, 7 ],
|
|
181
|
+
[ 10, 40, 50, 20, 10, 50 ],
|
|
182
|
+
[ 30, 60, 70, 50, 40, 30 ]
|
|
183
|
+
]
|
|
184
|
+
|
|
185
|
+
worksheet.write('A1', headings, bold)
|
|
186
|
+
worksheet.write('A2', data)
|
|
187
|
+
|
|
188
|
+
# Create a new chart object. In this case an embedded chart.
|
|
189
|
+
chart = workbook.add_chart(:type => 'column', :embedded => 1)
|
|
190
|
+
|
|
191
|
+
# Configure the first series.
|
|
192
|
+
chart.add_series(
|
|
193
|
+
:name => '=Sheet1!$B$1',
|
|
194
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
|
195
|
+
:values => '=Sheet1!$B$2:$B$7'
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
# Configure second series. Note alternative use of array ref to define
|
|
199
|
+
# ranges: [ sheetname, row_start, row_end, col_start, col_end ].
|
|
200
|
+
chart.add_series(
|
|
201
|
+
:name => '=Sheet1!$C$1',
|
|
202
|
+
:categories => [ 'Sheet1', 1, 6, 0, 0 ],
|
|
203
|
+
:values => [ 'Sheet1', 1, 6, 2, 2 ]
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
# Add a chart title and some axis labels.
|
|
207
|
+
chart.set_title(:name => 'Results of sample analysis')
|
|
208
|
+
chart.set_x_axis(:name => 'Test number')
|
|
209
|
+
chart.set_y_axis(:name => 'Sample length (mm)')
|
|
210
|
+
|
|
211
|
+
# Set an Excel chart style. Blue colors with white outline and shadow.
|
|
212
|
+
chart.set_style(11)
|
|
213
|
+
|
|
214
|
+
# Insert the chart into the worksheet (with an offset).
|
|
215
|
+
worksheet.insert_chart('D2', chart, 25, 10)
|
|
216
|
+
|
|
217
|
+
workbook.close
|
|
218
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
def test_chart_line
|
|
222
|
+
xlsx = 'chart_line.xlsx'
|
|
223
|
+
workbook = WriteXLSX.new(xlsx)
|
|
224
|
+
worksheet = workbook.add_worksheet
|
|
225
|
+
bold = workbook.add_format(:bold => 1)
|
|
226
|
+
|
|
227
|
+
# Add the worksheet data that the charts will refer to.
|
|
228
|
+
headings = [ 'Number', 'Batch 1', 'Batch 2' ]
|
|
229
|
+
data = [
|
|
230
|
+
[ 2, 3, 4, 5, 6, 7 ],
|
|
231
|
+
[ 10, 40, 50, 20, 10, 50 ],
|
|
232
|
+
[ 30, 60, 70, 50, 40, 30 ]
|
|
233
|
+
]
|
|
234
|
+
|
|
235
|
+
worksheet.write('A1', headings, bold)
|
|
236
|
+
worksheet.write('A2', data)
|
|
237
|
+
|
|
238
|
+
# Create a new chart object. In this case an embedded chart.
|
|
239
|
+
chart = workbook.add_chart(:type => 'line', :embedded => 1)
|
|
240
|
+
|
|
241
|
+
# Configure the first series.
|
|
242
|
+
chart.add_series(
|
|
243
|
+
:name => '=Sheet1!$B$1',
|
|
244
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
|
245
|
+
:values => '=Sheet1!$B$2:$B$7'
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
# Configure second series. Note alternative use of array ref to define
|
|
249
|
+
# ranges: [ sheetname, row_start, row_end, col_start, col_end ].
|
|
250
|
+
chart.add_series(
|
|
251
|
+
:name => '=Sheet1!$C$1',
|
|
252
|
+
:categories => [ 'Sheet1', 1, 6, 0, 0 ],
|
|
253
|
+
:values => [ 'Sheet1', 1, 6, 2, 2 ]
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
# Add a chart title and some axis labels.
|
|
257
|
+
chart.set_title(:name => 'Results of sample analysis')
|
|
258
|
+
chart.set_x_axis(:name => 'Test number')
|
|
259
|
+
chart.set_y_axis(:name => 'Sample length (mm)')
|
|
260
|
+
|
|
261
|
+
# Set an Excel chart style. Blue colors with white outline and shadow.
|
|
262
|
+
chart.set_style(10)
|
|
263
|
+
|
|
264
|
+
# Insert the chart into the worksheet (with an offset).
|
|
265
|
+
worksheet.insert_chart('D2', chart, 25, 10)
|
|
266
|
+
|
|
267
|
+
workbook.close
|
|
268
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
def test_chart_pie
|
|
272
|
+
xlsx = 'chart_pie.xlsx'
|
|
273
|
+
workbook = WriteXLSX.new(xlsx)
|
|
274
|
+
worksheet = workbook.add_worksheet
|
|
275
|
+
bold = workbook.add_format(:bold => 1)
|
|
276
|
+
|
|
277
|
+
# Add the worksheet data that the charts will refer to.
|
|
278
|
+
headings = [ 'Category', 'Values' ]
|
|
279
|
+
data = [
|
|
280
|
+
[ 'Apple', 'Cherry', 'Pecan' ],
|
|
281
|
+
[ 60, 30, 10 ]
|
|
282
|
+
]
|
|
283
|
+
|
|
284
|
+
worksheet.write('A1', headings, bold)
|
|
285
|
+
worksheet.write('A2', data)
|
|
286
|
+
|
|
287
|
+
# Create a new chart object. In this case an embedded chart.
|
|
288
|
+
chart = workbook.add_chart(:type => 'pie', :embedded => 1)
|
|
289
|
+
|
|
290
|
+
# Configure the series. Note the use of the array ref to define ranges:
|
|
291
|
+
# [ $sheetname, $row_start, $row_end, $col_start, $col_end ].
|
|
292
|
+
chart.add_series(
|
|
293
|
+
:name => 'Pie sales data',
|
|
294
|
+
:categories => [ 'Sheet1', 1, 3, 0, 0 ],
|
|
295
|
+
:values => [ 'Sheet1', 1, 3, 1, 1 ]
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
# Add a title.
|
|
299
|
+
chart.set_title(:name => 'Popular Pie Types')
|
|
300
|
+
|
|
301
|
+
# Set an Excel chart style. Blue colors with white outline and shadow.
|
|
302
|
+
chart.set_style(10)
|
|
303
|
+
|
|
304
|
+
# Insert the chart into the worksheet (with an offset).
|
|
305
|
+
worksheet.insert_chart('C2', chart, 25, 10)
|
|
306
|
+
|
|
307
|
+
workbook.close
|
|
308
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
def test_chart_scatter
|
|
312
|
+
xlsx = 'chart_scatter.xlsx'
|
|
313
|
+
workbook = WriteXLSX.new(xlsx)
|
|
314
|
+
worksheet = workbook.add_worksheet
|
|
315
|
+
bold = workbook.add_format(:bold => 1)
|
|
316
|
+
|
|
317
|
+
# Add the worksheet data that the charts will refer to.
|
|
318
|
+
headings = [ 'Number', 'Batch 1', 'Batch 2' ]
|
|
319
|
+
data = [
|
|
320
|
+
[ 2, 3, 4, 5, 6, 7 ],
|
|
321
|
+
[ 10, 40, 50, 20, 10, 50 ],
|
|
322
|
+
[ 30, 60, 70, 50, 40, 30 ]
|
|
323
|
+
]
|
|
324
|
+
|
|
325
|
+
worksheet.write('A1', headings, bold)
|
|
326
|
+
worksheet.write('A2', data)
|
|
327
|
+
|
|
328
|
+
# Create a new chart object. In this case an embedded chart.
|
|
329
|
+
chart = workbook.add_chart(:type => 'scatter', :embedded => 1)
|
|
330
|
+
|
|
331
|
+
# Configure the first series.
|
|
332
|
+
chart.add_series(
|
|
333
|
+
:name => '=Sheet1!$B$1',
|
|
334
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
|
335
|
+
:values => '=Sheet1!$B$2:$B$7'
|
|
336
|
+
)
|
|
337
|
+
|
|
338
|
+
# Configure second series. Note alternative use of array ref to define
|
|
339
|
+
# ranges: [ $sheetname, $row_start, $row_end, $col_start, $col_end ].$chart->add_series(
|
|
340
|
+
chart.add_series(
|
|
341
|
+
:name => '=Sheet1!$C$1',
|
|
342
|
+
:categories => [ 'Sheet1', 1, 6, 0, 0 ],
|
|
343
|
+
:values => [ 'Sheet1', 1, 6, 2, 2 ]
|
|
344
|
+
)
|
|
345
|
+
|
|
346
|
+
# Add a chart title and some axis labels.
|
|
347
|
+
chart.set_title(:name => 'Results of sample analysis')
|
|
348
|
+
chart.set_x_axis(:name => 'Test number')
|
|
349
|
+
chart.set_y_axis(:name => 'Sample length (mm)')
|
|
350
|
+
|
|
351
|
+
# Set an Excel chart style. Blue colors with white outline and shadow.
|
|
352
|
+
chart.set_style(10)
|
|
353
|
+
|
|
354
|
+
# Insert the chart into the worksheet (with an offset).
|
|
355
|
+
worksheet.insert_chart('D2', chart, 25, 10)
|
|
356
|
+
|
|
357
|
+
workbook.close
|
|
358
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
def test_chart_stock
|
|
362
|
+
xlsx = 'chart_stock.xlsx'
|
|
363
|
+
workbook = WriteXLSX.new(xlsx)
|
|
364
|
+
worksheet = workbook.add_worksheet
|
|
365
|
+
bold = workbook.add_format(:bold => 1)
|
|
366
|
+
date_format = workbook.add_format(:num_format => 'dd/mm/yyyy')
|
|
367
|
+
chart = workbook.add_chart(:type => 'stock', :embedded => 1)
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
# Add the worksheet data that the charts will refer to.
|
|
371
|
+
headings = [ 'Date', 'High', 'Low', 'Close' ]
|
|
372
|
+
data = [
|
|
373
|
+
[ '2007-01-01T', '2007-01-02T', '2007-01-03T', '2007-01-04T', '2007-01-05T' ],
|
|
374
|
+
[ 27.2, 25.03, 19.05, 20.34, 18.5 ],
|
|
375
|
+
[ 23.49, 19.55, 15.12, 17.84, 16.34 ],
|
|
376
|
+
[ 25.45, 23.05, 17.32, 20.45, 17.34 ]
|
|
377
|
+
]
|
|
378
|
+
|
|
379
|
+
worksheet.write('A1', headings, bold)
|
|
380
|
+
|
|
381
|
+
(0 .. 4).each do |row|
|
|
382
|
+
worksheet.write_date_time(row + 1, 0, data[0][row], date_format)
|
|
383
|
+
worksheet.write(row + 1, 1, data[1][row])
|
|
384
|
+
worksheet.write(row + 1, 2, data[2][row])
|
|
385
|
+
worksheet.write(row + 1, 3, data[3][row])
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
worksheet.set_column('A:D', 11)
|
|
389
|
+
|
|
390
|
+
# Add a series for each of the High-Low-Close columns.
|
|
391
|
+
chart.add_series(
|
|
392
|
+
:categories => '=Sheet1!$A$2:$A$6',
|
|
393
|
+
:values => '=Sheet1!$B$2:$B$6'
|
|
394
|
+
)
|
|
395
|
+
|
|
396
|
+
chart.add_series(
|
|
397
|
+
:categories => '=Sheet1!$A$2:$A$6',
|
|
398
|
+
:values => '=Sheet1!$C$2:$C$6'
|
|
399
|
+
)
|
|
400
|
+
|
|
401
|
+
chart.add_series(
|
|
402
|
+
:categories => '=Sheet1!$A$2:$A$6',
|
|
403
|
+
:values => '=Sheet1!$D$2:$D$6'
|
|
404
|
+
)
|
|
405
|
+
|
|
406
|
+
# Add a chart title and some axis labels.
|
|
407
|
+
chart.set_title(:name => 'High-Low-Close')
|
|
408
|
+
chart.set_x_axis(:name => 'Date')
|
|
409
|
+
chart.set_y_axis(:name => 'Share price')
|
|
410
|
+
|
|
411
|
+
worksheet.insert_chart('E9', chart)
|
|
412
|
+
|
|
413
|
+
workbook.close
|
|
414
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
def test_conditional_format
|
|
418
|
+
xlsx = 'conditional_format.xlsx'
|
|
419
|
+
workbook = WriteXLSX.new(xlsx)
|
|
420
|
+
worksheet1 = workbook.add_worksheet
|
|
421
|
+
|
|
422
|
+
# Light red fill with dark red text.
|
|
423
|
+
format1 = workbook.add_format(
|
|
424
|
+
:bg_color => '#FFC7CE',
|
|
425
|
+
:color => '#9C0006'
|
|
426
|
+
)
|
|
427
|
+
|
|
428
|
+
# Green fill with dark green text.
|
|
429
|
+
format2 = workbook.add_format(
|
|
430
|
+
:bg_color => '#C6EFCE',
|
|
431
|
+
:color => '#006100'
|
|
432
|
+
)
|
|
433
|
+
|
|
434
|
+
# Some sample data to run the conditional formatting against.
|
|
435
|
+
data = [
|
|
436
|
+
[ 90, 80, 50, 10, 20, 90, 40, 90, 30, 40 ],
|
|
437
|
+
[ 20, 10, 90, 100, 30, 60, 70, 60, 50, 90 ],
|
|
438
|
+
[ 10, 50, 60, 50, 20, 50, 80, 30, 40, 60 ],
|
|
439
|
+
[ 10, 90, 20, 40, 10, 40, 50, 70, 90, 50 ],
|
|
440
|
+
[ 70, 100, 10, 90, 10, 10, 20, 100, 100, 40 ],
|
|
441
|
+
[ 20, 60, 10, 100, 30, 10, 20, 60, 100, 10 ],
|
|
442
|
+
[ 10, 60, 10, 80, 100, 80, 30, 30, 70, 40 ],
|
|
443
|
+
[ 30, 90, 60, 10, 10, 100, 40, 40, 30, 40 ],
|
|
444
|
+
[ 80, 90, 10, 20, 20, 50, 80, 20, 60, 90 ],
|
|
445
|
+
[ 60, 80, 30, 30, 10, 50, 80, 60, 50, 30 ]
|
|
446
|
+
]
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
# This example below highlights cells that have a value greater than or
|
|
450
|
+
# equal to 50 in red and cells below that value in green.
|
|
451
|
+
|
|
452
|
+
caption = 'Cells with values >= 50 are in light red. ' +
|
|
453
|
+
'Values < 50 are in light green'
|
|
454
|
+
|
|
455
|
+
# Write the data.
|
|
456
|
+
worksheet1.write('A1', caption)
|
|
457
|
+
worksheet1.write_col('B3', data)
|
|
458
|
+
|
|
459
|
+
# Write a conditional format over a range.
|
|
460
|
+
worksheet1.conditional_formatting('B3:K12',
|
|
461
|
+
{
|
|
462
|
+
:type => 'cell',
|
|
463
|
+
:format => format1,
|
|
464
|
+
:criteria => '>=',
|
|
465
|
+
:value => 50
|
|
466
|
+
}
|
|
467
|
+
)
|
|
468
|
+
|
|
469
|
+
# Write another conditional format over the same range.
|
|
470
|
+
worksheet1.conditional_formatting('B3:K12',
|
|
471
|
+
{
|
|
472
|
+
:type => 'cell',
|
|
473
|
+
:format => format2,
|
|
474
|
+
:criteria => '<',
|
|
475
|
+
:value => 50
|
|
476
|
+
}
|
|
477
|
+
)
|
|
478
|
+
|
|
479
|
+
workbook.close
|
|
480
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
481
|
+
end
|
|
482
|
+
|
|
483
|
+
def test_data_validate
|
|
484
|
+
xlsx = 'data_validate.xlsx'
|
|
485
|
+
workbook = WriteXLSX.new(xlsx)
|
|
486
|
+
worksheet = workbook.add_worksheet
|
|
487
|
+
|
|
488
|
+
# Add a format for the header cells.
|
|
489
|
+
header_format = workbook.add_format(
|
|
490
|
+
:border => 1,
|
|
491
|
+
:bg_color => 43,
|
|
492
|
+
:bold => 1,
|
|
493
|
+
:text_wrap => 1,
|
|
494
|
+
:valign => 'vcenter',
|
|
495
|
+
:indent => 1
|
|
496
|
+
)
|
|
497
|
+
|
|
498
|
+
# Set up layout of the worksheet.
|
|
499
|
+
worksheet.set_column('A:A', 68)
|
|
500
|
+
worksheet.set_column('B:B', 15)
|
|
501
|
+
worksheet.set_column('D:D', 15)
|
|
502
|
+
worksheet.set_row(0, 36)
|
|
503
|
+
worksheet.set_selection('B3')
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
# Write the header cells and some data that will be used in the examples.
|
|
507
|
+
row = 0
|
|
508
|
+
heading1 = 'Some examples of data validation in WriteXLSX'
|
|
509
|
+
heading2 = 'Enter values in this column'
|
|
510
|
+
heading3 = 'Sample Data'
|
|
511
|
+
|
|
512
|
+
worksheet.write('A1', heading1, header_format)
|
|
513
|
+
worksheet.write('B1', heading2, header_format)
|
|
514
|
+
worksheet.write('D1', heading3, header_format)
|
|
515
|
+
|
|
516
|
+
worksheet.write('D3', ['Integers', 1, 10])
|
|
517
|
+
worksheet.write('D4', ['List data', 'open', 'high', 'close'])
|
|
518
|
+
worksheet.write('D5', ['Formula', '=AND(F5=50,G5=60)', 50, 60])
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
#
|
|
522
|
+
# Example 1. Limiting input to an integer in a fixed range.
|
|
523
|
+
#
|
|
524
|
+
txt = 'Enter an integer between 1 and 10'
|
|
525
|
+
row += 2
|
|
526
|
+
|
|
527
|
+
worksheet.write(row, 0, txt)
|
|
528
|
+
worksheet.data_validation(row, 1,
|
|
529
|
+
{
|
|
530
|
+
:validate => 'integer',
|
|
531
|
+
:criteria => 'between',
|
|
532
|
+
:minimum => 1,
|
|
533
|
+
:maximum => 10
|
|
534
|
+
})
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
#
|
|
538
|
+
# Example 2. Limiting input to an integer outside a fixed range.
|
|
539
|
+
#
|
|
540
|
+
txt = 'Enter an integer that is not between 1 and 10 (using cell references)'
|
|
541
|
+
row += 2
|
|
542
|
+
|
|
543
|
+
worksheet.write(row, 0, txt)
|
|
544
|
+
worksheet.data_validation(row, 1,
|
|
545
|
+
{
|
|
546
|
+
:validate => 'integer',
|
|
547
|
+
:criteria => 'not between',
|
|
548
|
+
:minimum => '=E3',
|
|
549
|
+
:maximum => '=F3'
|
|
550
|
+
})
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
#
|
|
554
|
+
# Example 3. Limiting input to an integer greater than a fixed value.
|
|
555
|
+
#
|
|
556
|
+
txt = 'Enter an integer greater than 0'
|
|
557
|
+
row += 2
|
|
558
|
+
|
|
559
|
+
worksheet.write(row, 0, txt)
|
|
560
|
+
worksheet.data_validation(row, 1,
|
|
561
|
+
{
|
|
562
|
+
:validate => 'integer',
|
|
563
|
+
:criteria => '>',
|
|
564
|
+
:value => 0
|
|
565
|
+
})
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
#
|
|
569
|
+
# Example 4. Limiting input to an integer less than a fixed value.
|
|
570
|
+
#
|
|
571
|
+
txt = 'Enter an integer less than 10'
|
|
572
|
+
row += 2
|
|
573
|
+
|
|
574
|
+
worksheet.write(row, 0, txt)
|
|
575
|
+
worksheet.data_validation(row, 1,
|
|
576
|
+
{
|
|
577
|
+
:validate => 'integer',
|
|
578
|
+
:criteria => '<',
|
|
579
|
+
:value => 10
|
|
580
|
+
})
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
#
|
|
584
|
+
# Example 5. Limiting input to a decimal in a fixed range.
|
|
585
|
+
#
|
|
586
|
+
txt = 'Enter a decimal between 0.1 and 0.5'
|
|
587
|
+
row += 2
|
|
588
|
+
|
|
589
|
+
worksheet.write(row, 0, txt)
|
|
590
|
+
worksheet.data_validation(row, 1,
|
|
591
|
+
{
|
|
592
|
+
:validate => 'decimal',
|
|
593
|
+
:criteria => 'between',
|
|
594
|
+
:minimum => 0.1,
|
|
595
|
+
:maximum => 0.5
|
|
596
|
+
})
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
#
|
|
600
|
+
# Example 6. Limiting input to a value in a dropdown list.
|
|
601
|
+
#
|
|
602
|
+
txt = 'Select a value from a drop down list'
|
|
603
|
+
row += 2
|
|
604
|
+
bp=1
|
|
605
|
+
worksheet.write(row, 0, txt)
|
|
606
|
+
worksheet.data_validation(row, 1,
|
|
607
|
+
{
|
|
608
|
+
:validate => 'list',
|
|
609
|
+
:source => ['open', 'high', 'close']
|
|
610
|
+
})
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
#
|
|
614
|
+
# Example 6. Limiting input to a value in a dropdown list.
|
|
615
|
+
#
|
|
616
|
+
txt = 'Select a value from a drop down list (using a cell range)'
|
|
617
|
+
row += 2
|
|
618
|
+
|
|
619
|
+
worksheet.write(row, 0, txt)
|
|
620
|
+
worksheet.data_validation(row, 1,
|
|
621
|
+
{
|
|
622
|
+
:validate => 'list',
|
|
623
|
+
:source => '=$E$4:$G$4'
|
|
624
|
+
})
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
#
|
|
628
|
+
# Example 7. Limiting input to a date in a fixed range.
|
|
629
|
+
#
|
|
630
|
+
txt = 'Enter a date between 1/1/2008 and 12/12/2008'
|
|
631
|
+
row += 2
|
|
632
|
+
|
|
633
|
+
worksheet.write(row, 0, txt)
|
|
634
|
+
worksheet.data_validation(row, 1,
|
|
635
|
+
{
|
|
636
|
+
:validate => 'date',
|
|
637
|
+
:criteria => 'between',
|
|
638
|
+
:minimum => '2008-01-01T',
|
|
639
|
+
:maximum => '2008-12-12T'
|
|
640
|
+
})
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
#
|
|
644
|
+
# Example 8. Limiting input to a time in a fixed range.
|
|
645
|
+
#
|
|
646
|
+
txt = 'Enter a time between 6:00 and 12:00'
|
|
647
|
+
row += 2
|
|
648
|
+
|
|
649
|
+
worksheet.write(row, 0, txt)
|
|
650
|
+
worksheet.data_validation(row, 1,
|
|
651
|
+
{
|
|
652
|
+
:validate => 'time',
|
|
653
|
+
:criteria => 'between',
|
|
654
|
+
:minimum => 'T06:00',
|
|
655
|
+
:maximum => 'T12:00'
|
|
656
|
+
})
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
#
|
|
660
|
+
# Example 9. Limiting input to a string greater than a fixed length.
|
|
661
|
+
#
|
|
662
|
+
txt = 'Enter a string longer than 3 characters'
|
|
663
|
+
row += 2
|
|
664
|
+
|
|
665
|
+
worksheet.write(row, 0, txt)
|
|
666
|
+
worksheet.data_validation(row, 1,
|
|
667
|
+
{
|
|
668
|
+
:validate => 'length',
|
|
669
|
+
:criteria => '>',
|
|
670
|
+
:value => 3
|
|
671
|
+
})
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
#
|
|
675
|
+
# Example 10. Limiting input based on a formula.
|
|
676
|
+
#
|
|
677
|
+
txt = 'Enter a value if the following is true "=AND(F5=50,G5=60)"'
|
|
678
|
+
row += 2
|
|
679
|
+
|
|
680
|
+
worksheet.write(row, 0, txt)
|
|
681
|
+
worksheet.data_validation(row, 1,
|
|
682
|
+
{
|
|
683
|
+
:validate => 'custom',
|
|
684
|
+
:value => '=AND(F5=50,G5=60)'
|
|
685
|
+
})
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
#
|
|
689
|
+
# Example 11. Displaying and modify data validation messages.
|
|
690
|
+
#
|
|
691
|
+
txt = 'Displays a message when you select the cell'
|
|
692
|
+
row += 2
|
|
693
|
+
|
|
694
|
+
worksheet.write(row, 0, txt)
|
|
695
|
+
worksheet.data_validation(row, 1,
|
|
696
|
+
{
|
|
697
|
+
:validate => 'integer',
|
|
698
|
+
:criteria => 'between',
|
|
699
|
+
:minimum => 1,
|
|
700
|
+
:maximum => 100,
|
|
701
|
+
:input_title => 'Enter an integer:',
|
|
702
|
+
:input_message => 'between 1 and 100'
|
|
703
|
+
})
|
|
704
|
+
|
|
705
|
+
|
|
706
|
+
#
|
|
707
|
+
# Example 12. Displaying and modify data validation messages.
|
|
708
|
+
#
|
|
709
|
+
txt = 'Display a custom error message when integer isn\'t between 1 and 100'
|
|
710
|
+
row += 2
|
|
711
|
+
|
|
712
|
+
worksheet.write(row, 0, txt)
|
|
713
|
+
worksheet.data_validation(row, 1,
|
|
714
|
+
{
|
|
715
|
+
:validate => 'integer',
|
|
716
|
+
:criteria => 'between',
|
|
717
|
+
:minimum => 1,
|
|
718
|
+
:maximum => 100,
|
|
719
|
+
:input_title => 'Enter an integer:',
|
|
720
|
+
:input_message => 'between 1 and 100',
|
|
721
|
+
:error_title => 'Input value is not valid!',
|
|
722
|
+
:error_message => 'It should be an integer between 1 and 100'
|
|
723
|
+
})
|
|
724
|
+
|
|
725
|
+
|
|
726
|
+
#
|
|
727
|
+
# Example 13. Displaying and modify data validation messages.
|
|
728
|
+
#
|
|
729
|
+
txt = 'Display a custom information message when integer isn\'t between 1 and 100'
|
|
730
|
+
row += 2
|
|
731
|
+
|
|
732
|
+
worksheet.write(row, 0, txt)
|
|
733
|
+
worksheet.data_validation(row, 1,
|
|
734
|
+
{
|
|
735
|
+
:validate => 'integer',
|
|
736
|
+
:criteria => 'between',
|
|
737
|
+
:minimum => 1,
|
|
738
|
+
:maximum => 100,
|
|
739
|
+
:input_title => 'Enter an integer:',
|
|
740
|
+
:input_message => 'between 1 and 100',
|
|
741
|
+
:error_title => 'Input value is not valid!',
|
|
742
|
+
:error_message => 'It should be an integer between 1 and 100',
|
|
743
|
+
:error_type => 'information'
|
|
744
|
+
})
|
|
745
|
+
|
|
746
|
+
workbook.close
|
|
747
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
748
|
+
end
|
|
749
|
+
|
|
750
|
+
def test_defined_name
|
|
751
|
+
xlsx = 'defined_name.xlsx'
|
|
752
|
+
workbook = WriteXLSX.new(xlsx)
|
|
753
|
+
worksheet1 = workbook.add_worksheet
|
|
754
|
+
worksheet2 = workbook.add_worksheet
|
|
755
|
+
|
|
756
|
+
# Define some global/workbook names.
|
|
757
|
+
workbook.define_name('Exchange_rate', '=0.96')
|
|
758
|
+
workbook.define_name('Sales', '=Sheet1!$G$1:$H$10')
|
|
759
|
+
|
|
760
|
+
# Define a local/worksheet name.
|
|
761
|
+
workbook.define_name('Sheet2!Sales', '=Sheet2!$G$1:$G$10')
|
|
762
|
+
|
|
763
|
+
# Write some text in the file and one of the defined names in a formula.
|
|
764
|
+
workbook.worksheets.each do |worksheet|
|
|
765
|
+
worksheet.set_column('A:A', 45)
|
|
766
|
+
worksheet.write('A1', 'This worksheet contains some defined names.')
|
|
767
|
+
worksheet.write('A2', 'See Formulas -> Name Manager above.')
|
|
768
|
+
worksheet.write('A3', 'Example formula in cell B3 ->')
|
|
769
|
+
|
|
770
|
+
worksheet.write('B3', '=Exchange_rate')
|
|
771
|
+
end
|
|
772
|
+
|
|
773
|
+
workbook.close
|
|
774
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
775
|
+
end
|
|
776
|
+
|
|
777
|
+
def test_demo
|
|
778
|
+
xlsx = 'demo.xlsx'
|
|
779
|
+
workbook = WriteXLSX.new(xlsx)
|
|
780
|
+
worksheet = workbook.add_worksheet('Demo')
|
|
781
|
+
worksheet2 = workbook.add_worksheet('Another sheet')
|
|
782
|
+
worksheet3 = workbook.add_worksheet('And another')
|
|
783
|
+
|
|
784
|
+
bold = workbook.add_format(:bold => 1)
|
|
785
|
+
|
|
786
|
+
#######################################################################
|
|
787
|
+
#
|
|
788
|
+
# Write a general heading
|
|
789
|
+
#
|
|
790
|
+
worksheet.set_column('A:A', 36, bold)
|
|
791
|
+
worksheet.set_column('B:B', 20)
|
|
792
|
+
worksheet.set_row(0, 40)
|
|
793
|
+
|
|
794
|
+
heading = workbook.add_format(
|
|
795
|
+
:bold => 1,
|
|
796
|
+
:color => 'blue',
|
|
797
|
+
:size => 16,
|
|
798
|
+
:merge => 1,
|
|
799
|
+
:align => 'vcenter'
|
|
800
|
+
)
|
|
801
|
+
|
|
802
|
+
hyperlink_format = workbook.add_format(
|
|
803
|
+
:color => 'blue',
|
|
804
|
+
:underline => 1
|
|
805
|
+
)
|
|
806
|
+
|
|
807
|
+
headings = ['Features of WriteXLSX', '']
|
|
808
|
+
worksheet.write_row('A1', headings, heading)
|
|
809
|
+
|
|
810
|
+
#######################################################################
|
|
811
|
+
#
|
|
812
|
+
# Some text examples
|
|
813
|
+
#
|
|
814
|
+
text_format = workbook.add_format(
|
|
815
|
+
:bold => 1,
|
|
816
|
+
:italic => 1,
|
|
817
|
+
:color => 'red',
|
|
818
|
+
:size => 18,
|
|
819
|
+
:font => 'Lucida Calligraphy'
|
|
820
|
+
)
|
|
821
|
+
|
|
822
|
+
worksheet.write('A2', "Text")
|
|
823
|
+
worksheet.write('B2', "Hello Excel")
|
|
824
|
+
worksheet.write('A3', "Formatted text")
|
|
825
|
+
worksheet.write('B3', "Hello Excel", text_format)
|
|
826
|
+
worksheet.write('A4', "Unicode text")
|
|
827
|
+
worksheet.write('B4', "А Б В Г Д")
|
|
828
|
+
|
|
829
|
+
#######################################################################
|
|
830
|
+
#
|
|
831
|
+
# Some numeric examples
|
|
832
|
+
#
|
|
833
|
+
num1_format = workbook.add_format(:num_format => '$#,##0.00')
|
|
834
|
+
num2_format = workbook.add_format(:num_format => ' d mmmm yyy')
|
|
835
|
+
|
|
836
|
+
worksheet.write('A5', "Numbers")
|
|
837
|
+
worksheet.write('B5', 1234.56)
|
|
838
|
+
worksheet.write('A6', "Formatted numbers")
|
|
839
|
+
worksheet.write('B6', 1234.56, num1_format)
|
|
840
|
+
worksheet.write('A7', "Formatted numbers")
|
|
841
|
+
worksheet.write('B7', 37257, num2_format)
|
|
842
|
+
|
|
843
|
+
#######################################################################
|
|
844
|
+
#
|
|
845
|
+
# Formulae
|
|
846
|
+
#
|
|
847
|
+
worksheet.set_selection('B8')
|
|
848
|
+
worksheet.write('A8', 'Formulas and functions, "=SIN(PI()/4)"')
|
|
849
|
+
worksheet.write('B8', '=SIN(PI()/4)')
|
|
850
|
+
|
|
851
|
+
#######################################################################
|
|
852
|
+
#
|
|
853
|
+
# Hyperlinks
|
|
854
|
+
#
|
|
855
|
+
worksheet.write('A9', "Hyperlinks")
|
|
856
|
+
worksheet.write('B9', 'http://www.ruby-lang.org/', hyperlink_format)
|
|
857
|
+
|
|
858
|
+
#######################################################################
|
|
859
|
+
#
|
|
860
|
+
# Images
|
|
861
|
+
#
|
|
862
|
+
# Not implemented yet.
|
|
863
|
+
#worksheet.write('A10', "Images")
|
|
864
|
+
#worksheet.insert_image('B10', 'republic.png', 16, 8)
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
#######################################################################
|
|
868
|
+
#
|
|
869
|
+
# Misc
|
|
870
|
+
#
|
|
871
|
+
worksheet.write('A18', "Page/printer setup")
|
|
872
|
+
worksheet.write('A19', "Multiple worksheets")
|
|
873
|
+
|
|
874
|
+
workbook.close
|
|
875
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
876
|
+
end
|
|
877
|
+
|
|
878
|
+
def test_diag_border
|
|
879
|
+
xlsx = 'diag_border.xlsx'
|
|
880
|
+
workbook = WriteXLSX.new(xlsx)
|
|
881
|
+
worksheet = workbook.add_worksheet()
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
format1 = workbook.add_format(:diag_type => 1)
|
|
885
|
+
format2 = workbook.add_format(:diag_type => 2)
|
|
886
|
+
format3 = workbook.add_format(:diag_type => 3)
|
|
887
|
+
|
|
888
|
+
format4 = workbook.add_format(
|
|
889
|
+
:diag_type => 3,
|
|
890
|
+
:diag_border => 7,
|
|
891
|
+
:diag_color => 'red'
|
|
892
|
+
)
|
|
893
|
+
|
|
894
|
+
worksheet.write('B3', 'Text', format1)
|
|
895
|
+
worksheet.write('B6', 'Text', format2)
|
|
896
|
+
worksheet.write('B9', 'Text', format3)
|
|
897
|
+
worksheet.write('B12', 'Text', format4)
|
|
898
|
+
|
|
899
|
+
workbook.close
|
|
900
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
901
|
+
end
|
|
902
|
+
|
|
903
|
+
def test_fit_to_pages
|
|
904
|
+
xlsx = 'fit_to_pages.xlsx'
|
|
905
|
+
workbook = WriteXLSX.new(xlsx)
|
|
906
|
+
worksheet1 = workbook.add_worksheet
|
|
907
|
+
worksheet2 = workbook.add_worksheet
|
|
908
|
+
worksheet3 = workbook.add_worksheet
|
|
909
|
+
worksheet4 = workbook.add_worksheet
|
|
910
|
+
|
|
911
|
+
|
|
912
|
+
worksheet1.write( 0, 0, "fit_to_pages(1, 1)" )
|
|
913
|
+
worksheet1.fit_to_pages(1, 1) # Fit to 1x1 pages
|
|
914
|
+
|
|
915
|
+
worksheet2.write( 0, 0, "fit_to_pages(2, 1)" )
|
|
916
|
+
worksheet2.fit_to_pages(2, 1) # Fit to 2x1 pages
|
|
917
|
+
|
|
918
|
+
worksheet3.write( 0, 0, "fit_to_pages(1, 2)" )
|
|
919
|
+
worksheet3.fit_to_pages(1, 2) # Fit to 1x2 pages
|
|
920
|
+
|
|
921
|
+
worksheet4.write( 0, 0, "fit_to_pages(1, 0)" )
|
|
922
|
+
worksheet4.fit_to_pages(1, 0) # 1 page wide and as long as necessary
|
|
923
|
+
|
|
924
|
+
workbook.close
|
|
925
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
926
|
+
end
|
|
927
|
+
|
|
928
|
+
def test_headers
|
|
929
|
+
xlsx = 'headers.xlsx'
|
|
930
|
+
workbook = WriteXLSX.new(xlsx)
|
|
931
|
+
preview = 'Select Print Preview to see the header and footer'
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
######################################################################
|
|
935
|
+
#
|
|
936
|
+
# A simple example to start
|
|
937
|
+
#
|
|
938
|
+
worksheet1 = workbook.add_worksheet('Simple')
|
|
939
|
+
header1 = '&CHere is some centred text.'
|
|
940
|
+
footer1 = '&LHere is some left aligned text.'
|
|
941
|
+
|
|
942
|
+
worksheet1.set_header(header1)
|
|
943
|
+
worksheet1.set_footer(footer1)
|
|
944
|
+
|
|
945
|
+
worksheet1.set_column('A:A', 50)
|
|
946
|
+
worksheet1.write('A1', preview)
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
######################################################################
|
|
950
|
+
#
|
|
951
|
+
# This is an example of some of the header/footer variables.
|
|
952
|
+
#
|
|
953
|
+
worksheet2 = workbook.add_worksheet('Variables')
|
|
954
|
+
header2 = '&LPage &P of &N' + '&CFilename: &F' + '&RSheetname: &A'
|
|
955
|
+
footer2 = '&LCurrent date: &D' + '&RCurrent time: &T'
|
|
956
|
+
|
|
957
|
+
worksheet2.set_header(header2)
|
|
958
|
+
worksheet2.set_footer(footer2)
|
|
959
|
+
|
|
960
|
+
worksheet2.set_column('A:A', 50)
|
|
961
|
+
worksheet2.write('A1', preview)
|
|
962
|
+
worksheet2.write('A21', 'Next sheet')
|
|
963
|
+
worksheet2.set_h_pagebreaks(20)
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
######################################################################
|
|
967
|
+
#
|
|
968
|
+
# This example shows how to use more than one font
|
|
969
|
+
#
|
|
970
|
+
worksheet3 = workbook.add_worksheet('Mixed fonts')
|
|
971
|
+
header3 = %q(&C&"Courier New,Bold"Hello &"Arial,Italic"World)
|
|
972
|
+
footer3 = %q(&C&"Symbol"e&"Arial" = mc&X2)
|
|
973
|
+
|
|
974
|
+
worksheet3.set_header(header3)
|
|
975
|
+
worksheet3.set_footer(footer3)
|
|
976
|
+
|
|
977
|
+
worksheet3.set_column('A:A', 50)
|
|
978
|
+
worksheet3.write('A1', preview)
|
|
979
|
+
|
|
980
|
+
|
|
981
|
+
######################################################################
|
|
982
|
+
#
|
|
983
|
+
# Example of line wrapping
|
|
984
|
+
#
|
|
985
|
+
worksheet4 = workbook.add_worksheet('Word wrap')
|
|
986
|
+
header4 = "&CHeading 1\nHeading 2"
|
|
987
|
+
|
|
988
|
+
worksheet4.set_header(header4)
|
|
989
|
+
|
|
990
|
+
worksheet4.set_column('A:A', 50)
|
|
991
|
+
worksheet4.write('A1', preview)
|
|
992
|
+
|
|
993
|
+
|
|
994
|
+
######################################################################
|
|
995
|
+
#
|
|
996
|
+
# Example of inserting a literal ampersand &
|
|
997
|
+
#
|
|
998
|
+
worksheet5 = workbook.add_worksheet('Ampersand')
|
|
999
|
+
header5 = '&CCuriouser && Curiouser - Attorneys at Law'
|
|
1000
|
+
|
|
1001
|
+
worksheet5.set_header(header5)
|
|
1002
|
+
|
|
1003
|
+
worksheet5.set_column('A:A', 50)
|
|
1004
|
+
worksheet5.write('A1', preview)
|
|
1005
|
+
|
|
1006
|
+
workbook.close
|
|
1007
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
1008
|
+
end
|
|
1009
|
+
|
|
1010
|
+
def test_hide_sheet
|
|
1011
|
+
xlsx = 'hide_sheet.xlsx'
|
|
1012
|
+
workbook = WriteXLSX.new(xlsx)
|
|
1013
|
+
worksheet1 = workbook.add_worksheet
|
|
1014
|
+
worksheet2 = workbook.add_worksheet
|
|
1015
|
+
worksheet3 = workbook.add_worksheet
|
|
1016
|
+
|
|
1017
|
+
worksheet1.set_column('A:A', 30)
|
|
1018
|
+
worksheet2.set_column('A:A', 30)
|
|
1019
|
+
worksheet3.set_column('A:A', 30)
|
|
1020
|
+
|
|
1021
|
+
# Sheet2 won't be visible until it is unhidden in Excel.
|
|
1022
|
+
worksheet2.hide
|
|
1023
|
+
|
|
1024
|
+
worksheet1.write(0, 0, 'Sheet2 is hidden')
|
|
1025
|
+
worksheet2.write(0, 0, "Now it's my turn to find you.")
|
|
1026
|
+
worksheet3.write(0, 0, 'Sheet2 is hidden')
|
|
1027
|
+
|
|
1028
|
+
workbook.close
|
|
1029
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
1030
|
+
end
|
|
1031
|
+
|
|
1032
|
+
def test_hyperlink
|
|
1033
|
+
xlsx = 'hyperlink.xlsx'
|
|
1034
|
+
# Create a new workbook and add a worksheet
|
|
1035
|
+
workbook = WriteXLSX.new(xlsx)
|
|
1036
|
+
|
|
1037
|
+
worksheet = workbook.add_worksheet('Hyperlinks')
|
|
1038
|
+
|
|
1039
|
+
# Format the first column
|
|
1040
|
+
worksheet.set_column('A:A', 30)
|
|
1041
|
+
worksheet.set_selection('B1')
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
# Add the standard url link format.
|
|
1045
|
+
url_format = workbook.add_format(
|
|
1046
|
+
:color => 'blue',
|
|
1047
|
+
:underline => 1
|
|
1048
|
+
)
|
|
1049
|
+
|
|
1050
|
+
# Add a sample format.
|
|
1051
|
+
red_format = workbook.add_format(
|
|
1052
|
+
:color => 'red',
|
|
1053
|
+
:bold => 1,
|
|
1054
|
+
:underline => 1,
|
|
1055
|
+
:size => 12
|
|
1056
|
+
)
|
|
1057
|
+
|
|
1058
|
+
# Add an alternate description string to the URL.
|
|
1059
|
+
str = 'Perl home.'
|
|
1060
|
+
|
|
1061
|
+
# Add a "tool tip" to the URL.
|
|
1062
|
+
tip = 'Get the latest Perl news here.'
|
|
1063
|
+
|
|
1064
|
+
|
|
1065
|
+
# Write some hyperlinks
|
|
1066
|
+
worksheet.write('A1', 'http://www.perl.com/', url_format)
|
|
1067
|
+
worksheet.write('A3', 'http://www.perl.com/', url_format, str)
|
|
1068
|
+
worksheet.write('A5', 'http://www.perl.com/', url_format, str, tip)
|
|
1069
|
+
worksheet.write('A7', 'http://www.perl.com/', red_format)
|
|
1070
|
+
worksheet.write('A9', 'mailto:jmcnamara@cpan.org', url_format, 'Mail me')
|
|
1071
|
+
|
|
1072
|
+
# Write a URL that isn't a hyperlink
|
|
1073
|
+
worksheet.write_string('A11', 'http://www.perl.com/')
|
|
1074
|
+
|
|
1075
|
+
workbook.close
|
|
1076
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
1077
|
+
end
|
|
1078
|
+
|
|
1079
|
+
def test_indent
|
|
1080
|
+
xlsx = 'indent.xlsx'
|
|
1081
|
+
workbook = WriteXLSX.new(xlsx)
|
|
1082
|
+
|
|
1083
|
+
worksheet = workbook.add_worksheet
|
|
1084
|
+
indent1 = workbook.add_format(:indent => 1)
|
|
1085
|
+
indent2 = workbook.add_format(:indent => 2)
|
|
1086
|
+
|
|
1087
|
+
worksheet.set_column('A:A', 40)
|
|
1088
|
+
|
|
1089
|
+
worksheet.write('A1', "This text is indented 1 level", indent1)
|
|
1090
|
+
worksheet.write('A2', "This text is indented 2 levels", indent2)
|
|
1091
|
+
|
|
1092
|
+
workbook.close
|
|
1093
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
1094
|
+
end
|
|
1095
|
+
|
|
1096
|
+
def test_outline
|
|
1097
|
+
xlsx = 'outline.xlsx'
|
|
1098
|
+
# Create a new workbook and add some worksheets
|
|
1099
|
+
workbook = WriteXLSX.new(xlsx)
|
|
1100
|
+
worksheet1 = workbook.add_worksheet('Outlined Rows')
|
|
1101
|
+
worksheet2 = workbook.add_worksheet('Collapsed Rows')
|
|
1102
|
+
worksheet3 = workbook.add_worksheet('Outline Columns')
|
|
1103
|
+
worksheet4 = workbook.add_worksheet('Outline levels')
|
|
1104
|
+
|
|
1105
|
+
# Add a general format
|
|
1106
|
+
bold = workbook.add_format(:bold => 1)
|
|
1107
|
+
|
|
1108
|
+
|
|
1109
|
+
###############################################################################
|
|
1110
|
+
#
|
|
1111
|
+
# Example 1: Create a worksheet with outlined rows. It also includes SUBTOTAL()
|
|
1112
|
+
# functions so that it looks like the type of automatic outlines that are
|
|
1113
|
+
# generated when you use the Excel Data.SubTotals menu item.
|
|
1114
|
+
#
|
|
1115
|
+
|
|
1116
|
+
|
|
1117
|
+
# For outlines the important parameters are $hidden and $level. Rows with the
|
|
1118
|
+
# same $level are grouped together. The group will be collapsed if $hidden is
|
|
1119
|
+
# non-zero. $height and $XF are assigned default values if they are nil.
|
|
1120
|
+
#
|
|
1121
|
+
# The syntax is: set_row($row, $height, $XF, $hidden, $level, $collapsed)
|
|
1122
|
+
#
|
|
1123
|
+
worksheet1.set_row(1, nil, nil, 0, 2)
|
|
1124
|
+
worksheet1.set_row(2, nil, nil, 0, 2)
|
|
1125
|
+
worksheet1.set_row(3, nil, nil, 0, 2)
|
|
1126
|
+
worksheet1.set_row(4, nil, nil, 0, 2)
|
|
1127
|
+
worksheet1.set_row(5, nil, nil, 0, 1)
|
|
1128
|
+
|
|
1129
|
+
worksheet1.set_row(6, nil, nil, 0, 2)
|
|
1130
|
+
worksheet1.set_row(7, nil, nil, 0, 2)
|
|
1131
|
+
worksheet1.set_row(8, nil, nil, 0, 2)
|
|
1132
|
+
worksheet1.set_row(9, nil, nil, 0, 2)
|
|
1133
|
+
worksheet1.set_row(10, nil, nil, 0, 1)
|
|
1134
|
+
|
|
1135
|
+
|
|
1136
|
+
# Add a column format for clarity
|
|
1137
|
+
worksheet1.set_column('A:A', 20)
|
|
1138
|
+
|
|
1139
|
+
# Add the data, labels and formulas
|
|
1140
|
+
worksheet1.write('A1', 'Region', bold)
|
|
1141
|
+
worksheet1.write('A2', 'North')
|
|
1142
|
+
worksheet1.write('A3', 'North')
|
|
1143
|
+
worksheet1.write('A4', 'North')
|
|
1144
|
+
worksheet1.write('A5', 'North')
|
|
1145
|
+
worksheet1.write('A6', 'North Total', bold)
|
|
1146
|
+
|
|
1147
|
+
worksheet1.write('B1', 'Sales', bold)
|
|
1148
|
+
worksheet1.write('B2', 1000)
|
|
1149
|
+
worksheet1.write('B3', 1200)
|
|
1150
|
+
worksheet1.write('B4', 900)
|
|
1151
|
+
worksheet1.write('B5', 1200)
|
|
1152
|
+
worksheet1.write('B6', '=SUBTOTAL(9,B2:B5)', bold)
|
|
1153
|
+
|
|
1154
|
+
worksheet1.write('A7', 'South')
|
|
1155
|
+
worksheet1.write('A8', 'South')
|
|
1156
|
+
worksheet1.write('A9', 'South')
|
|
1157
|
+
worksheet1.write('A10', 'South')
|
|
1158
|
+
worksheet1.write('A11', 'South Total', bold)
|
|
1159
|
+
|
|
1160
|
+
worksheet1.write('B7', 400)
|
|
1161
|
+
worksheet1.write('B8', 600)
|
|
1162
|
+
worksheet1.write('B9', 500)
|
|
1163
|
+
worksheet1.write('B10', 600)
|
|
1164
|
+
worksheet1.write('B11', '=SUBTOTAL(9,B7:B10)', bold)
|
|
1165
|
+
|
|
1166
|
+
worksheet1.write('A12', 'Grand Total', bold)
|
|
1167
|
+
worksheet1.write('B12', '=SUBTOTAL(9,B2:B10)', bold)
|
|
1168
|
+
|
|
1169
|
+
|
|
1170
|
+
###############################################################################
|
|
1171
|
+
#
|
|
1172
|
+
# Example 2: Create a worksheet with outlined rows. This is the same as the
|
|
1173
|
+
# previous example except that the rows are collapsed.
|
|
1174
|
+
# Note: We need to indicate the row that contains the collapsed symbol '+'
|
|
1175
|
+
# with the optional parameter, $collapsed.
|
|
1176
|
+
|
|
1177
|
+
# The group will be collapsed if $hidden is non-zero.
|
|
1178
|
+
# The syntax is: set_row($row, $height, $XF, $hidden, $level, $collapsed)
|
|
1179
|
+
#
|
|
1180
|
+
worksheet2.set_row(1, nil, nil, 1, 2)
|
|
1181
|
+
worksheet2.set_row(2, nil, nil, 1, 2)
|
|
1182
|
+
worksheet2.set_row(3, nil, nil, 1, 2)
|
|
1183
|
+
worksheet2.set_row(4, nil, nil, 1, 2)
|
|
1184
|
+
worksheet2.set_row(5, nil, nil, 1, 1)
|
|
1185
|
+
|
|
1186
|
+
worksheet2.set_row(6, nil, nil, 1, 2)
|
|
1187
|
+
worksheet2.set_row(7, nil, nil, 1, 2)
|
|
1188
|
+
worksheet2.set_row(8, nil, nil, 1, 2)
|
|
1189
|
+
worksheet2.set_row(9, nil, nil, 1, 2)
|
|
1190
|
+
worksheet2.set_row(10, nil, nil, 1, 1)
|
|
1191
|
+
worksheet2.set_row(11, nil, nil, 0, 0, 1)
|
|
1192
|
+
|
|
1193
|
+
|
|
1194
|
+
# Add a column format for clarity
|
|
1195
|
+
worksheet2.set_column('A:A', 20)
|
|
1196
|
+
|
|
1197
|
+
# Add the data, labels and formulas
|
|
1198
|
+
worksheet2.write('A1', 'Region', bold)
|
|
1199
|
+
worksheet2.write('A2', 'North')
|
|
1200
|
+
worksheet2.write('A3', 'North')
|
|
1201
|
+
worksheet2.write('A4', 'North')
|
|
1202
|
+
worksheet2.write('A5', 'North')
|
|
1203
|
+
worksheet2.write('A6', 'North Total', bold)
|
|
1204
|
+
|
|
1205
|
+
worksheet2.write('B1', 'Sales', bold)
|
|
1206
|
+
worksheet2.write('B2', 1000)
|
|
1207
|
+
worksheet2.write('B3', 1200)
|
|
1208
|
+
worksheet2.write('B4', 900)
|
|
1209
|
+
worksheet2.write('B5', 1200)
|
|
1210
|
+
worksheet2.write('B6', '=SUBTOTAL(9,B2:B5)', bold)
|
|
1211
|
+
|
|
1212
|
+
worksheet2.write('A7', 'South')
|
|
1213
|
+
worksheet2.write('A8', 'South')
|
|
1214
|
+
worksheet2.write('A9', 'South')
|
|
1215
|
+
worksheet2.write('A10', 'South')
|
|
1216
|
+
worksheet2.write('A11', 'South Total', bold)
|
|
1217
|
+
|
|
1218
|
+
worksheet2.write('B7', 400)
|
|
1219
|
+
worksheet2.write('B8', 600)
|
|
1220
|
+
worksheet2.write('B9', 500)
|
|
1221
|
+
worksheet2.write('B10', 600)
|
|
1222
|
+
worksheet2.write('B11', '=SUBTOTAL(9,B7:B10)', bold)
|
|
1223
|
+
|
|
1224
|
+
worksheet2.write('A12', 'Grand Total', bold)
|
|
1225
|
+
worksheet2.write('B12', '=SUBTOTAL(9,B2:B10)', bold)
|
|
1226
|
+
|
|
1227
|
+
|
|
1228
|
+
###############################################################################
|
|
1229
|
+
#
|
|
1230
|
+
# Example 3: Create a worksheet with outlined columns.
|
|
1231
|
+
#
|
|
1232
|
+
data = [
|
|
1233
|
+
[ 'Month', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', ' Total' ],
|
|
1234
|
+
[ 'North', 50, 20, 15, 25, 65, 80, '=SUM(B2:G2)' ],
|
|
1235
|
+
[ 'South', 10, 20, 30, 50, 50, 50, '=SUM(B3:G3)' ],
|
|
1236
|
+
[ 'East', 45, 75, 50, 15, 75, 100, '=SUM(B4:G4)' ],
|
|
1237
|
+
[ 'West', 15, 15, 55, 35, 20, 50, '=SUM(B5:G5)' ],
|
|
1238
|
+
]
|
|
1239
|
+
|
|
1240
|
+
# Add bold format to the first row
|
|
1241
|
+
worksheet3.set_row(0, nil, bold)
|
|
1242
|
+
|
|
1243
|
+
# Syntax: set_column($col1, $col2, $width, $XF, $hidden, $level, $collapsed)
|
|
1244
|
+
worksheet3.set_column('A:A', 10, bold)
|
|
1245
|
+
worksheet3.set_column('B:G', 5, nil, 0, 1)
|
|
1246
|
+
worksheet3.set_column('H:H', 10)
|
|
1247
|
+
|
|
1248
|
+
# Write the data and a formula
|
|
1249
|
+
worksheet3.write_col('A1', data)
|
|
1250
|
+
worksheet3.write('H6', '=SUM(H2:H5)', bold)
|
|
1251
|
+
|
|
1252
|
+
|
|
1253
|
+
###############################################################################
|
|
1254
|
+
#
|
|
1255
|
+
# Example 4: Show all possible outline levels.
|
|
1256
|
+
#
|
|
1257
|
+
levels = [
|
|
1258
|
+
"Level 1", "Level 2", "Level 3", "Level 4", "Level 5", "Level 6",
|
|
1259
|
+
"Level 7", "Level 6", "Level 5", "Level 4", "Level 3", "Level 2",
|
|
1260
|
+
"Level 1"
|
|
1261
|
+
]
|
|
1262
|
+
|
|
1263
|
+
|
|
1264
|
+
worksheet4.write_col('A1', levels)
|
|
1265
|
+
|
|
1266
|
+
worksheet4.set_row(0, nil, nil, nil, 1)
|
|
1267
|
+
worksheet4.set_row(1, nil, nil, nil, 2)
|
|
1268
|
+
worksheet4.set_row(2, nil, nil, nil, 3)
|
|
1269
|
+
worksheet4.set_row(3, nil, nil, nil, 4)
|
|
1270
|
+
worksheet4.set_row(4, nil, nil, nil, 5)
|
|
1271
|
+
worksheet4.set_row(5, nil, nil, nil, 6)
|
|
1272
|
+
worksheet4.set_row(6, nil, nil, nil, 7)
|
|
1273
|
+
worksheet4.set_row(7, nil, nil, nil, 6)
|
|
1274
|
+
worksheet4.set_row(8, nil, nil, nil, 5)
|
|
1275
|
+
worksheet4.set_row(9, nil, nil, nil, 4)
|
|
1276
|
+
worksheet4.set_row(10, nil, nil, nil, 3)
|
|
1277
|
+
worksheet4.set_row(11, nil, nil, nil, 2)
|
|
1278
|
+
worksheet4.set_row(12, nil, nil, nil, 1)
|
|
1279
|
+
|
|
1280
|
+
workbook.close
|
|
1281
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
1282
|
+
end
|
|
1283
|
+
|
|
1284
|
+
def test_merge1
|
|
1285
|
+
xlsx = 'merge1.xlsx'
|
|
1286
|
+
# Create a new workbook and add a worksheet
|
|
1287
|
+
workbook = WriteXLSX.new(xlsx)
|
|
1288
|
+
worksheet = workbook.add_worksheet
|
|
1289
|
+
|
|
1290
|
+
# Increase the cell size of the merged cells to highlight the formatting.
|
|
1291
|
+
worksheet.set_column('B:D', 20)
|
|
1292
|
+
worksheet.set_row(2, 30)
|
|
1293
|
+
|
|
1294
|
+
# Create a merge format
|
|
1295
|
+
format = workbook.add_format(:center_across => 1)
|
|
1296
|
+
|
|
1297
|
+
# Only one cell should contain text, the others should be blank.
|
|
1298
|
+
worksheet.write(2, 1, "Center across selection", format)
|
|
1299
|
+
worksheet.write_blank(2, 2, format)
|
|
1300
|
+
worksheet.write_blank(2, 3, format)
|
|
1301
|
+
workbook.close
|
|
1302
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
1303
|
+
end
|
|
1304
|
+
|
|
1305
|
+
def test_merge2
|
|
1306
|
+
# Create a new workbook and add a worksheet
|
|
1307
|
+
xlsx = 'merge2.xlsx'
|
|
1308
|
+
workbook = WriteXLSX.new(xlsx)
|
|
1309
|
+
worksheet = workbook.add_worksheet
|
|
1310
|
+
|
|
1311
|
+
# Increase the cell size of the merged cells to highlight the formatting.
|
|
1312
|
+
worksheet.set_column(1, 2, 30)
|
|
1313
|
+
worksheet.set_row(2, 40)
|
|
1314
|
+
|
|
1315
|
+
# Create a merged format
|
|
1316
|
+
format = workbook.add_format(
|
|
1317
|
+
:center_across => 1,
|
|
1318
|
+
:bold => 1,
|
|
1319
|
+
:size => 15,
|
|
1320
|
+
:pattern => 1,
|
|
1321
|
+
:border => 6,
|
|
1322
|
+
:color => 'white',
|
|
1323
|
+
:fg_color => 'green',
|
|
1324
|
+
:border_color => 'yellow',
|
|
1325
|
+
:align => 'vcenter'
|
|
1326
|
+
)
|
|
1327
|
+
|
|
1328
|
+
# Only one cell should contain text, the others should be blank.
|
|
1329
|
+
worksheet.write(2, 1, "Center across selection", format)
|
|
1330
|
+
worksheet.write_blank(2, 2, format)
|
|
1331
|
+
|
|
1332
|
+
workbook.close
|
|
1333
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
1334
|
+
end
|
|
1335
|
+
|
|
1336
|
+
def test_merge3
|
|
1337
|
+
xlsx = 'merge2.xlsx'
|
|
1338
|
+
# Create a new workbook and add a worksheet
|
|
1339
|
+
workbook = WriteXLSX.new(xlsx)
|
|
1340
|
+
worksheet = workbook.add_worksheet
|
|
1341
|
+
|
|
1342
|
+
# Increase the cell size of the merged cells to highlight the formatting.
|
|
1343
|
+
worksheet.set_column(1, 2, 30)
|
|
1344
|
+
worksheet.set_row(2, 40)
|
|
1345
|
+
|
|
1346
|
+
# Create a merged format
|
|
1347
|
+
format = workbook.add_format(
|
|
1348
|
+
:center_across => 1,
|
|
1349
|
+
:bold => 1,
|
|
1350
|
+
:size => 15,
|
|
1351
|
+
:pattern => 1,
|
|
1352
|
+
:border => 6,
|
|
1353
|
+
:color => 'white',
|
|
1354
|
+
:fg_color => 'green',
|
|
1355
|
+
:border_color => 'yellow',
|
|
1356
|
+
:align => 'vcenter'
|
|
1357
|
+
)
|
|
1358
|
+
|
|
1359
|
+
# Only one cell should contain text, the others should be blank.
|
|
1360
|
+
worksheet.write(2, 1, "Center across selection", format)
|
|
1361
|
+
worksheet.write_blank(2, 2, format)
|
|
1362
|
+
|
|
1363
|
+
workbook.close
|
|
1364
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
1365
|
+
end
|
|
1366
|
+
|
|
1367
|
+
def test_merge3
|
|
1368
|
+
xlsx = 'merge3.xlsx'
|
|
1369
|
+
|
|
1370
|
+
# Create a new workbook and add a worksheet
|
|
1371
|
+
workbook = WriteXLSX.new('merge3.xlsx')
|
|
1372
|
+
worksheet = workbook.add_worksheet()
|
|
1373
|
+
|
|
1374
|
+
# Increase the cell size of the merged cells to highlight the formatting.
|
|
1375
|
+
[3, 6, 7].each { |row| worksheet.set_row(row, 30) }
|
|
1376
|
+
worksheet.set_column('B:D', 20)
|
|
1377
|
+
|
|
1378
|
+
###############################################################################
|
|
1379
|
+
#
|
|
1380
|
+
# Example: Merge cells containing a hyperlink using merge_range().
|
|
1381
|
+
#
|
|
1382
|
+
format = workbook.add_format(
|
|
1383
|
+
:border => 1,
|
|
1384
|
+
:underline => 1,
|
|
1385
|
+
:color => 'blue',
|
|
1386
|
+
:align => 'center',
|
|
1387
|
+
:valign => 'vcenter'
|
|
1388
|
+
)
|
|
1389
|
+
|
|
1390
|
+
# Merge 3 cells
|
|
1391
|
+
worksheet.merge_range('B4:D4', 'http://www.perl.com', format)
|
|
1392
|
+
|
|
1393
|
+
# Merge 3 cells over two rows
|
|
1394
|
+
worksheet.merge_range('B7:D8', 'http://www.perl.com', format)
|
|
1395
|
+
|
|
1396
|
+
workbook.close
|
|
1397
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
1398
|
+
end
|
|
1399
|
+
|
|
1400
|
+
def test_merge4
|
|
1401
|
+
xlsx = 'merge4.xlsx'
|
|
1402
|
+
# Create a new workbook and add a worksheet
|
|
1403
|
+
workbook = WriteXLSX.new(xlsx)
|
|
1404
|
+
worksheet = workbook.add_worksheet
|
|
1405
|
+
|
|
1406
|
+
# Increase the cell size of the merged cells to highlight the formatting.
|
|
1407
|
+
(1 .. 11).each { |i| worksheet.set_row(i, 30) }
|
|
1408
|
+
worksheet.set_column('B:D', 20)
|
|
1409
|
+
|
|
1410
|
+
###############################################################################
|
|
1411
|
+
#
|
|
1412
|
+
# Example 1: Text centered vertically and horizontally
|
|
1413
|
+
#
|
|
1414
|
+
format1 = workbook.add_format(
|
|
1415
|
+
:border => 6,
|
|
1416
|
+
:bold => 1,
|
|
1417
|
+
:color => 'red',
|
|
1418
|
+
:valign => 'vcenter',
|
|
1419
|
+
:align => 'center'
|
|
1420
|
+
)
|
|
1421
|
+
|
|
1422
|
+
worksheet.merge_range('B2:D3', 'Vertical and horizontal', format1)
|
|
1423
|
+
|
|
1424
|
+
###############################################################################
|
|
1425
|
+
#
|
|
1426
|
+
# Example 2: Text aligned to the top and left
|
|
1427
|
+
#
|
|
1428
|
+
format2 = workbook.add_format(
|
|
1429
|
+
:border => 6,
|
|
1430
|
+
:bold => 1,
|
|
1431
|
+
:color => 'red',
|
|
1432
|
+
:valign => 'top',
|
|
1433
|
+
:align => 'left'
|
|
1434
|
+
)
|
|
1435
|
+
|
|
1436
|
+
worksheet.merge_range('B5:D6', 'Aligned to the top and left', format2)
|
|
1437
|
+
|
|
1438
|
+
###############################################################################
|
|
1439
|
+
#
|
|
1440
|
+
# Example 3: Text aligned to the bottom and right
|
|
1441
|
+
#
|
|
1442
|
+
format3 = workbook.add_format(
|
|
1443
|
+
:border => 6,
|
|
1444
|
+
:bold => 1,
|
|
1445
|
+
:color => 'red',
|
|
1446
|
+
:valign => 'bottom',
|
|
1447
|
+
:align => 'right'
|
|
1448
|
+
)
|
|
1449
|
+
|
|
1450
|
+
worksheet.merge_range('B8:D9', 'Aligned to the bottom and right', format3)
|
|
1451
|
+
|
|
1452
|
+
###############################################################################
|
|
1453
|
+
#
|
|
1454
|
+
# Example 4: Text justified (i.e. wrapped) in the cell
|
|
1455
|
+
#
|
|
1456
|
+
format4 = workbook.add_format(
|
|
1457
|
+
:border => 6,
|
|
1458
|
+
:bold => 1,
|
|
1459
|
+
:color => 'red',
|
|
1460
|
+
:valign => 'top',
|
|
1461
|
+
:align => 'justify'
|
|
1462
|
+
)
|
|
1463
|
+
|
|
1464
|
+
worksheet.merge_range('B11:D12', 'Justified: ' << 'so on and ' * 18, format4)
|
|
1465
|
+
|
|
1466
|
+
workbook.close
|
|
1467
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
1468
|
+
end
|
|
1469
|
+
|
|
1470
|
+
def test_merge5
|
|
1471
|
+
xlsx = 'merge5.xlsx'
|
|
1472
|
+
# Create a new workbook and add a worksheet
|
|
1473
|
+
workbook = WriteXLSX.new(xlsx)
|
|
1474
|
+
worksheet = workbook.add_worksheet
|
|
1475
|
+
|
|
1476
|
+
# Increase the cell size of the merged cells to highlight the formatting.
|
|
1477
|
+
(3 .. 8).each { |row| worksheet.set_row(row, 36 ) }
|
|
1478
|
+
[1, 3, 5].each { |col| worksheet.set_column( col, col, 15 ) }
|
|
1479
|
+
|
|
1480
|
+
###############################################################################
|
|
1481
|
+
#
|
|
1482
|
+
# Rotation 1, letters run from top to bottom
|
|
1483
|
+
#
|
|
1484
|
+
format1 = workbook.add_format(
|
|
1485
|
+
:border => 6,
|
|
1486
|
+
:bold => 1,
|
|
1487
|
+
:color => 'red',
|
|
1488
|
+
:valign => 'vcentre',
|
|
1489
|
+
:align => 'centre',
|
|
1490
|
+
:rotation => 270
|
|
1491
|
+
)
|
|
1492
|
+
|
|
1493
|
+
worksheet.merge_range( 'B4:B9', 'Rotation 270', format1 )
|
|
1494
|
+
|
|
1495
|
+
###############################################################################
|
|
1496
|
+
#
|
|
1497
|
+
# Rotation 2, 90ー anticlockwise
|
|
1498
|
+
#
|
|
1499
|
+
format2 = workbook.add_format(
|
|
1500
|
+
:border => 6,
|
|
1501
|
+
:bold => 1,
|
|
1502
|
+
:color => 'red',
|
|
1503
|
+
:valign => 'vcentre',
|
|
1504
|
+
:align => 'centre',
|
|
1505
|
+
:rotation => 90
|
|
1506
|
+
)
|
|
1507
|
+
|
|
1508
|
+
worksheet.merge_range( 'D4:D9', 'Rotation 90°', format2 )
|
|
1509
|
+
|
|
1510
|
+
###############################################################################
|
|
1511
|
+
#
|
|
1512
|
+
# Rotation 3, 90ー clockwise
|
|
1513
|
+
#
|
|
1514
|
+
format3 = workbook.add_format(
|
|
1515
|
+
:border => 6,
|
|
1516
|
+
:bold => 1,
|
|
1517
|
+
:color => 'red',
|
|
1518
|
+
:valign => 'vcentre',
|
|
1519
|
+
:align => 'centre',
|
|
1520
|
+
:rotation => -90
|
|
1521
|
+
)
|
|
1522
|
+
|
|
1523
|
+
worksheet.merge_range( 'F4:F9', 'Rotation -90°', format3 )
|
|
1524
|
+
|
|
1525
|
+
workbook.close
|
|
1526
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
1527
|
+
end
|
|
1528
|
+
|
|
1529
|
+
def test_merge6
|
|
1530
|
+
xlsx = 'merge6.xlsx'
|
|
1531
|
+
# Create a new workbook and add a worksheet
|
|
1532
|
+
workbook = WriteXLSX.new(xlsx)
|
|
1533
|
+
worksheet = workbook.add_worksheet
|
|
1534
|
+
|
|
1535
|
+
# Increase the cell size of the merged cells to highlight the formatting.
|
|
1536
|
+
(2 .. 9).each { |row| worksheet.set_row(row, 36) }
|
|
1537
|
+
worksheet.set_column('B:D', 25)
|
|
1538
|
+
|
|
1539
|
+
# Format for the merged cells.
|
|
1540
|
+
format = workbook.add_format(
|
|
1541
|
+
:border => 6,
|
|
1542
|
+
:bold => 1,
|
|
1543
|
+
:color => 'red',
|
|
1544
|
+
:size => 20,
|
|
1545
|
+
:valign => 'vcentre',
|
|
1546
|
+
:align => 'left',
|
|
1547
|
+
:indent => 1
|
|
1548
|
+
)
|
|
1549
|
+
|
|
1550
|
+
###############################################################################
|
|
1551
|
+
#
|
|
1552
|
+
# Write an Ascii string.
|
|
1553
|
+
#
|
|
1554
|
+
worksheet.merge_range('B3:D4', 'ASCII: A simple string', format)
|
|
1555
|
+
|
|
1556
|
+
###############################################################################
|
|
1557
|
+
#
|
|
1558
|
+
# Write a UTF-8 Unicode string.
|
|
1559
|
+
#
|
|
1560
|
+
smiley = '☺'
|
|
1561
|
+
worksheet.merge_range('B6:D7', "UTF-8: A Unicode smiley #{smiley}", format)
|
|
1562
|
+
|
|
1563
|
+
workbook.close
|
|
1564
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
1565
|
+
end
|
|
1566
|
+
|
|
1567
|
+
def test_comments1
|
|
1568
|
+
xlsx = 'comments1.xlsx'
|
|
1569
|
+
workbook = WriteXLSX.new(xlsx)
|
|
1570
|
+
worksheet = workbook.add_worksheet
|
|
1571
|
+
|
|
1572
|
+
worksheet.write('A1', 'Hello')
|
|
1573
|
+
worksheet.write_comment('A1', 'This is a comment')
|
|
1574
|
+
|
|
1575
|
+
workbook.close
|
|
1576
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
1577
|
+
end
|
|
1578
|
+
|
|
1579
|
+
def test_comments2
|
|
1580
|
+
xlsx = 'comments2.xlsx'
|
|
1581
|
+
workbook = WriteXLSX.new(xlsx)
|
|
1582
|
+
|
|
1583
|
+
text_wrap = workbook.add_format( :text_wrap => 1, :valign => 'top' )
|
|
1584
|
+
worksheet1 = workbook.add_worksheet
|
|
1585
|
+
worksheet2 = workbook.add_worksheet
|
|
1586
|
+
worksheet3 = workbook.add_worksheet
|
|
1587
|
+
worksheet4 = workbook.add_worksheet
|
|
1588
|
+
worksheet5 = workbook.add_worksheet
|
|
1589
|
+
worksheet6 = workbook.add_worksheet
|
|
1590
|
+
worksheet7 = workbook.add_worksheet
|
|
1591
|
+
worksheet8 = workbook.add_worksheet
|
|
1592
|
+
|
|
1593
|
+
|
|
1594
|
+
# Variables that we will use in each example.
|
|
1595
|
+
cell_text = ''
|
|
1596
|
+
comment = ''
|
|
1597
|
+
|
|
1598
|
+
|
|
1599
|
+
###############################################################################
|
|
1600
|
+
#
|
|
1601
|
+
# Example 1. Demonstrates a simple cell comments without formatting.
|
|
1602
|
+
# comments.
|
|
1603
|
+
#
|
|
1604
|
+
|
|
1605
|
+
# Set up some formatting.
|
|
1606
|
+
worksheet1.set_column( 'C:C', 25 )
|
|
1607
|
+
worksheet1.set_row( 2, 50 )
|
|
1608
|
+
worksheet1.set_row( 5, 50 )
|
|
1609
|
+
|
|
1610
|
+
|
|
1611
|
+
# Simple ascii string.
|
|
1612
|
+
cell_text = 'Hold the mouse over this cell to see the comment.'
|
|
1613
|
+
|
|
1614
|
+
comment = 'This is a comment.'
|
|
1615
|
+
|
|
1616
|
+
worksheet1.write( 'C3', cell_text, text_wrap )
|
|
1617
|
+
worksheet1.write_comment( 'C3', comment )
|
|
1618
|
+
|
|
1619
|
+
cell_text = 'This is a UTF-8 string.'
|
|
1620
|
+
comment = '☺'
|
|
1621
|
+
|
|
1622
|
+
worksheet1.write( 'C6', cell_text, text_wrap )
|
|
1623
|
+
worksheet1.write_comment( 'C6', comment )
|
|
1624
|
+
|
|
1625
|
+
|
|
1626
|
+
|
|
1627
|
+
###############################################################################
|
|
1628
|
+
#
|
|
1629
|
+
# Example 2. Demonstrates visible and hidden comments.
|
|
1630
|
+
#
|
|
1631
|
+
|
|
1632
|
+
# Set up some formatting.
|
|
1633
|
+
worksheet2.set_column( 'C:C', 25 )
|
|
1634
|
+
worksheet2.set_row( 2, 50 )
|
|
1635
|
+
worksheet2.set_row( 5, 50 )
|
|
1636
|
+
|
|
1637
|
+
|
|
1638
|
+
cell_text = 'This cell comment is visible.'
|
|
1639
|
+
|
|
1640
|
+
comment = 'Hello.'
|
|
1641
|
+
|
|
1642
|
+
worksheet2.write( 'C3', cell_text, text_wrap )
|
|
1643
|
+
worksheet2.write_comment( 'C3', comment, :visible => 1 )
|
|
1644
|
+
|
|
1645
|
+
|
|
1646
|
+
cell_text = "This cell comment isn't visible (the default)."
|
|
1647
|
+
|
|
1648
|
+
comment = 'Hello.'
|
|
1649
|
+
|
|
1650
|
+
worksheet2.write( 'C6', cell_text, text_wrap )
|
|
1651
|
+
worksheet2.write_comment( 'C6', comment )
|
|
1652
|
+
|
|
1653
|
+
|
|
1654
|
+
###############################################################################
|
|
1655
|
+
#
|
|
1656
|
+
# Example 3. Demonstrates visible and hidden comments set at the worksheet
|
|
1657
|
+
# level.
|
|
1658
|
+
#
|
|
1659
|
+
|
|
1660
|
+
# Set up some formatting.
|
|
1661
|
+
worksheet3.set_column( 'C:C', 25 )
|
|
1662
|
+
worksheet3.set_row( 2, 50 )
|
|
1663
|
+
worksheet3.set_row( 5, 50 )
|
|
1664
|
+
worksheet3.set_row( 8, 50 )
|
|
1665
|
+
|
|
1666
|
+
# Make all comments on the worksheet visible.
|
|
1667
|
+
worksheet3.show_comments
|
|
1668
|
+
|
|
1669
|
+
cell_text = 'This cell comment is visible, explicitly.'
|
|
1670
|
+
|
|
1671
|
+
comment = 'Hello.'
|
|
1672
|
+
|
|
1673
|
+
worksheet3.write( 'C3', cell_text, text_wrap )
|
|
1674
|
+
worksheet3.write_comment( 'C3', comment, :visible => 1 )
|
|
1675
|
+
|
|
1676
|
+
|
|
1677
|
+
cell_text =
|
|
1678
|
+
'This cell comment is also visible because we used show_comments().'
|
|
1679
|
+
|
|
1680
|
+
comment = 'Hello.'
|
|
1681
|
+
|
|
1682
|
+
worksheet3.write( 'C6', cell_text, text_wrap )
|
|
1683
|
+
worksheet3.write_comment( 'C6', comment )
|
|
1684
|
+
|
|
1685
|
+
|
|
1686
|
+
cell_text = 'However, we can still override it locally.'
|
|
1687
|
+
|
|
1688
|
+
comment = 'Hello.'
|
|
1689
|
+
|
|
1690
|
+
worksheet3.write( 'C9', cell_text, text_wrap )
|
|
1691
|
+
worksheet3.write_comment( 'C9', comment, :visible => 0 )
|
|
1692
|
+
|
|
1693
|
+
|
|
1694
|
+
###############################################################################
|
|
1695
|
+
#
|
|
1696
|
+
# Example 4. Demonstrates changes to the comment box dimensions.
|
|
1697
|
+
#
|
|
1698
|
+
|
|
1699
|
+
# Set up some formatting.
|
|
1700
|
+
worksheet4.set_column( 'C:C', 25 )
|
|
1701
|
+
worksheet4.set_row( 2, 50 )
|
|
1702
|
+
worksheet4.set_row( 5, 50 )
|
|
1703
|
+
worksheet4.set_row( 8, 50 )
|
|
1704
|
+
worksheet4.set_row( 15, 50 )
|
|
1705
|
+
|
|
1706
|
+
worksheet4.show_comments
|
|
1707
|
+
|
|
1708
|
+
cell_text = 'This cell comment is default size.'
|
|
1709
|
+
|
|
1710
|
+
comment = 'Hello.'
|
|
1711
|
+
|
|
1712
|
+
worksheet4.write( 'C3', cell_text, text_wrap )
|
|
1713
|
+
worksheet4.write_comment( 'C3', comment )
|
|
1714
|
+
|
|
1715
|
+
|
|
1716
|
+
cell_text = 'This cell comment is twice as wide.'
|
|
1717
|
+
|
|
1718
|
+
comment = 'Hello.'
|
|
1719
|
+
|
|
1720
|
+
worksheet4.write( 'C6', cell_text, text_wrap )
|
|
1721
|
+
worksheet4.write_comment( 'C6', comment, :x_scale => 2 )
|
|
1722
|
+
|
|
1723
|
+
|
|
1724
|
+
cell_text = 'This cell comment is twice as high.'
|
|
1725
|
+
|
|
1726
|
+
comment = 'Hello.'
|
|
1727
|
+
|
|
1728
|
+
worksheet4.write( 'C9', cell_text, text_wrap )
|
|
1729
|
+
worksheet4.write_comment( 'C9', comment, :y_scale => 2 )
|
|
1730
|
+
|
|
1731
|
+
|
|
1732
|
+
cell_text = 'This cell comment is scaled in both directions.'
|
|
1733
|
+
|
|
1734
|
+
comment = 'Hello.'
|
|
1735
|
+
|
|
1736
|
+
worksheet4.write( 'C16', cell_text, text_wrap )
|
|
1737
|
+
worksheet4.write_comment( 'C16', comment, :x_scale => 1.2, :y_scale => 0.8 )
|
|
1738
|
+
|
|
1739
|
+
|
|
1740
|
+
cell_text = 'This cell comment has width and height specified in pixels.'
|
|
1741
|
+
|
|
1742
|
+
comment = 'Hello.'
|
|
1743
|
+
|
|
1744
|
+
worksheet4.write( 'C19', cell_text, text_wrap )
|
|
1745
|
+
worksheet4.write_comment( 'C19', comment, :width => 200, :height => 20 )
|
|
1746
|
+
|
|
1747
|
+
|
|
1748
|
+
###############################################################################
|
|
1749
|
+
#
|
|
1750
|
+
# Example 5. Demonstrates changes to the cell comment position.
|
|
1751
|
+
#
|
|
1752
|
+
|
|
1753
|
+
worksheet5.set_column( 'C:C', 25 )
|
|
1754
|
+
worksheet5.set_row( 2, 50 )
|
|
1755
|
+
worksheet5.set_row( 5, 50 )
|
|
1756
|
+
worksheet5.set_row( 8, 50 )
|
|
1757
|
+
worksheet5.set_row( 11, 50 )
|
|
1758
|
+
|
|
1759
|
+
worksheet5.show_comments
|
|
1760
|
+
|
|
1761
|
+
cell_text = 'This cell comment is in the default position.'
|
|
1762
|
+
|
|
1763
|
+
comment = 'Hello.'
|
|
1764
|
+
|
|
1765
|
+
worksheet5.write( 'C3', cell_text, text_wrap )
|
|
1766
|
+
worksheet5.write_comment( 'C3', comment )
|
|
1767
|
+
|
|
1768
|
+
|
|
1769
|
+
cell_text = 'This cell comment has been moved to another cell.'
|
|
1770
|
+
|
|
1771
|
+
comment = 'Hello.'
|
|
1772
|
+
|
|
1773
|
+
worksheet5.write( 'C6', cell_text, text_wrap )
|
|
1774
|
+
worksheet5.write_comment( 'C6', comment, :start_cell => 'E4' )
|
|
1775
|
+
|
|
1776
|
+
|
|
1777
|
+
cell_text = 'This cell comment has been moved to another cell.'
|
|
1778
|
+
|
|
1779
|
+
comment = 'Hello.'
|
|
1780
|
+
|
|
1781
|
+
worksheet5.write( 'C9', cell_text, text_wrap )
|
|
1782
|
+
worksheet5.write_comment( 'C9', comment, :start_row => 8, :start_col => 4 )
|
|
1783
|
+
|
|
1784
|
+
|
|
1785
|
+
cell_text = 'This cell comment has been shifted within its default cell.'
|
|
1786
|
+
|
|
1787
|
+
comment = 'Hello.'
|
|
1788
|
+
|
|
1789
|
+
worksheet5.write( 'C12', cell_text, text_wrap )
|
|
1790
|
+
worksheet5.write_comment( 'C12', comment, :x_offset => 30, :y_offset => 12 )
|
|
1791
|
+
|
|
1792
|
+
|
|
1793
|
+
###############################################################################
|
|
1794
|
+
#
|
|
1795
|
+
# Example 6. Demonstrates changes to the comment background colour.
|
|
1796
|
+
#
|
|
1797
|
+
|
|
1798
|
+
worksheet6.set_column( 'C:C', 25 )
|
|
1799
|
+
worksheet6.set_row( 2, 50 )
|
|
1800
|
+
worksheet6.set_row( 5, 50 )
|
|
1801
|
+
worksheet6.set_row( 8, 50 )
|
|
1802
|
+
|
|
1803
|
+
worksheet6.show_comments
|
|
1804
|
+
|
|
1805
|
+
cell_text = 'This cell comment has a different colour.'
|
|
1806
|
+
|
|
1807
|
+
comment = 'Hello.'
|
|
1808
|
+
|
|
1809
|
+
worksheet6.write( 'C3', cell_text, text_wrap )
|
|
1810
|
+
worksheet6.write_comment( 'C3', comment, :color => 'green' )
|
|
1811
|
+
|
|
1812
|
+
|
|
1813
|
+
cell_text = 'This cell comment has the default colour.'
|
|
1814
|
+
|
|
1815
|
+
comment = 'Hello.'
|
|
1816
|
+
|
|
1817
|
+
worksheet6.write( 'C6', cell_text, text_wrap )
|
|
1818
|
+
worksheet6.write_comment( 'C6', comment )
|
|
1819
|
+
|
|
1820
|
+
|
|
1821
|
+
cell_text = 'This cell comment has a different colour.'
|
|
1822
|
+
|
|
1823
|
+
comment = 'Hello.'
|
|
1824
|
+
|
|
1825
|
+
worksheet6.write( 'C9', cell_text, text_wrap )
|
|
1826
|
+
worksheet6.write_comment( 'C9', comment, :color => 0x35 )
|
|
1827
|
+
|
|
1828
|
+
|
|
1829
|
+
###############################################################################
|
|
1830
|
+
#
|
|
1831
|
+
# Example 7. Demonstrates how to set the cell comment author.
|
|
1832
|
+
#
|
|
1833
|
+
|
|
1834
|
+
worksheet7.set_column( 'C:C', 30 )
|
|
1835
|
+
worksheet7.set_row( 2, 50 )
|
|
1836
|
+
worksheet7.set_row( 5, 50 )
|
|
1837
|
+
worksheet7.set_row( 8, 50 )
|
|
1838
|
+
|
|
1839
|
+
author = ''
|
|
1840
|
+
cell = 'C3'
|
|
1841
|
+
|
|
1842
|
+
cell_text = "Move the mouse over this cell and you will see 'Cell commented " +
|
|
1843
|
+
"by #{author}' (blank) in the status bar at the bottom"
|
|
1844
|
+
|
|
1845
|
+
comment = 'Hello.'
|
|
1846
|
+
|
|
1847
|
+
worksheet7.write( cell, cell_text, text_wrap )
|
|
1848
|
+
worksheet7.write_comment( cell, comment )
|
|
1849
|
+
|
|
1850
|
+
|
|
1851
|
+
author = 'Ruby'
|
|
1852
|
+
cell = 'C6'
|
|
1853
|
+
cell_text = "Move the mouse over this cell and you will see 'Cell commented " +
|
|
1854
|
+
"by #{author}' in the status bar at the bottom"
|
|
1855
|
+
|
|
1856
|
+
comment = 'Hello.'
|
|
1857
|
+
|
|
1858
|
+
worksheet7.write( cell, cell_text, text_wrap )
|
|
1859
|
+
worksheet7.write_comment( cell, comment, :author => author )
|
|
1860
|
+
|
|
1861
|
+
|
|
1862
|
+
author = '€'
|
|
1863
|
+
cell = 'C9'
|
|
1864
|
+
cell_text = "Move the mouse over this cell and you will see 'Cell commented " +
|
|
1865
|
+
"by #{author}' in the status bar at the bottom"
|
|
1866
|
+
comment = 'Hello.'
|
|
1867
|
+
|
|
1868
|
+
worksheet7.write( cell, cell_text, text_wrap )
|
|
1869
|
+
worksheet7.write_comment( cell, comment, :author => author )
|
|
1870
|
+
|
|
1871
|
+
|
|
1872
|
+
|
|
1873
|
+
|
|
1874
|
+
###############################################################################
|
|
1875
|
+
#
|
|
1876
|
+
# Example 8. Demonstrates the need to explicitly set the row height.
|
|
1877
|
+
#
|
|
1878
|
+
|
|
1879
|
+
# Set up some formatting.
|
|
1880
|
+
worksheet8.set_column( 'C:C', 25 )
|
|
1881
|
+
worksheet8.set_row( 2, 80 )
|
|
1882
|
+
|
|
1883
|
+
worksheet8.show_comments
|
|
1884
|
+
|
|
1885
|
+
|
|
1886
|
+
cell_text =
|
|
1887
|
+
'The height of this row has been adjusted explicitly using ' +
|
|
1888
|
+
'set_row(). The size of the comment box is adjusted ' +
|
|
1889
|
+
'accordingly by WriteXLSX.'
|
|
1890
|
+
|
|
1891
|
+
comment = 'Hello.'
|
|
1892
|
+
|
|
1893
|
+
worksheet8.write( 'C3', cell_text, text_wrap )
|
|
1894
|
+
worksheet8.write_comment( 'C3', comment )
|
|
1895
|
+
|
|
1896
|
+
|
|
1897
|
+
cell_text =
|
|
1898
|
+
'The height of this row has been adjusted by Excel due to the ' +
|
|
1899
|
+
'text wrap property being set. Unfortunately this means that ' +
|
|
1900
|
+
'the height of the row is unknown to WriteXLSX at ' +
|
|
1901
|
+
"run time and thus the comment box is stretched as well.\n\n" +
|
|
1902
|
+
'Use set_row() to specify the row height explicitly to avoid ' +
|
|
1903
|
+
'this problem.'
|
|
1904
|
+
|
|
1905
|
+
comment = 'Hello.'
|
|
1906
|
+
|
|
1907
|
+
worksheet8.write( 'C6', cell_text, text_wrap )
|
|
1908
|
+
worksheet8.write_comment( 'C6', comment )
|
|
1909
|
+
|
|
1910
|
+
workbook.close
|
|
1911
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
1912
|
+
end
|
|
1913
|
+
|
|
1914
|
+
def test_print_scale
|
|
1915
|
+
xlsx = 'print_scale.xlsx'
|
|
1916
|
+
workbook = WriteXLSX.new(xlsx)
|
|
1917
|
+
worksheet1 = workbook.add_worksheet
|
|
1918
|
+
worksheet2 = workbook.add_worksheet
|
|
1919
|
+
worksheet3 = workbook.add_worksheet
|
|
1920
|
+
|
|
1921
|
+
worksheet1.write( 0, 0, "print_scale(100)")
|
|
1922
|
+
worksheet1.print_scale = 100
|
|
1923
|
+
|
|
1924
|
+
worksheet2.write( 0, 0, "print_scale(50)")
|
|
1925
|
+
worksheet2.print_scale = 50
|
|
1926
|
+
|
|
1927
|
+
worksheet3.write( 0, 0, "print_scale(200)")
|
|
1928
|
+
worksheet3.print_scale = 200
|
|
1929
|
+
|
|
1930
|
+
workbook.close
|
|
1931
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
1932
|
+
end
|
|
1933
|
+
|
|
1934
|
+
def test_properties
|
|
1935
|
+
xlsx = 'properties.xlsx'
|
|
1936
|
+
workbook = WriteXLSX.new(xlsx)
|
|
1937
|
+
worksheet = workbook.add_worksheet
|
|
1938
|
+
|
|
1939
|
+
workbook.set_properties(
|
|
1940
|
+
:title => 'This is an example spreadsheet',
|
|
1941
|
+
:subject => 'With document properties',
|
|
1942
|
+
:author => 'John McNamara',
|
|
1943
|
+
:manager => 'Dr. Heinz Doofenshmirtz',
|
|
1944
|
+
:company => 'of Wolves',
|
|
1945
|
+
:category => 'Example spreadsheets',
|
|
1946
|
+
:keywords => 'Sample, Example, Properties',
|
|
1947
|
+
:comments => 'Created with Perl and Excel::Writer::XLSX',
|
|
1948
|
+
:status => 'Quo'
|
|
1949
|
+
)
|
|
1950
|
+
|
|
1951
|
+
worksheet.set_column('A:A', 70)
|
|
1952
|
+
worksheet.write('A1', "Select 'Office Button -> Prepare -> Properties' to see the file properties.")
|
|
1953
|
+
|
|
1954
|
+
workbook.close
|
|
1955
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
1956
|
+
end
|
|
1957
|
+
|
|
1958
|
+
def test_protection
|
|
1959
|
+
xlsx = 'protection.xlsx'
|
|
1960
|
+
workbook = WriteXLSX.new(xlsx)
|
|
1961
|
+
worksheet = workbook.add_worksheet
|
|
1962
|
+
|
|
1963
|
+
# Create some format objects
|
|
1964
|
+
unlocked = workbook.add_format(:locked => 0)
|
|
1965
|
+
hidden = workbook.add_format(:hidden => 1)
|
|
1966
|
+
|
|
1967
|
+
# Format the columns
|
|
1968
|
+
worksheet.set_column('A:A', 45)
|
|
1969
|
+
worksheet.set_selection('B3')
|
|
1970
|
+
|
|
1971
|
+
# Protect the worksheet
|
|
1972
|
+
worksheet.protect
|
|
1973
|
+
|
|
1974
|
+
# Examples of cell locking and hiding.
|
|
1975
|
+
worksheet.write('A1', 'Cell B1 is locked. It cannot be edited.')
|
|
1976
|
+
worksheet.write_formula('B1', '=1+2', nil, 3) # Locked by default.
|
|
1977
|
+
|
|
1978
|
+
worksheet.write('A2', 'Cell B2 is unlocked. It can be edited.')
|
|
1979
|
+
worksheet.write_formula('B2', '=1+2', unlocked, 3)
|
|
1980
|
+
|
|
1981
|
+
worksheet.write('A3', "Cell B3 is hidden. The formula isn't visible.")
|
|
1982
|
+
worksheet.write_formula('B3', '=1+2', hidden, 3)
|
|
1983
|
+
|
|
1984
|
+
worksheet.write('A5', 'Use Menu->Tools->Protection->Unprotect Sheet')
|
|
1985
|
+
worksheet.write('A6', 'to remove the worksheet protection.')
|
|
1986
|
+
|
|
1987
|
+
workbook.close
|
|
1988
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
1989
|
+
end
|
|
1990
|
+
|
|
1991
|
+
def test_rich_strings
|
|
1992
|
+
xlsx = 'rich_strings.xlsx'
|
|
1993
|
+
workbook = WriteXLSX.new(xlsx)
|
|
1994
|
+
worksheet = workbook.add_worksheet
|
|
1995
|
+
|
|
1996
|
+
worksheet.set_column('A:A', 30)
|
|
1997
|
+
|
|
1998
|
+
# Set some formats to use.
|
|
1999
|
+
bold = workbook.add_format(:bold => 1)
|
|
2000
|
+
italic = workbook.add_format(:italic => 1)
|
|
2001
|
+
red = workbook.add_format(:color => 'red')
|
|
2002
|
+
blue = workbook.add_format(:color => 'blue')
|
|
2003
|
+
center = workbook.add_format(:align => 'center')
|
|
2004
|
+
superc = workbook.add_format(:font_script => 1)
|
|
2005
|
+
|
|
2006
|
+
# Write some strings with multiple formats.
|
|
2007
|
+
worksheet.write_rich_string('A1',
|
|
2008
|
+
'This is ', bold, 'bold', ' and this is ', italic, 'italic')
|
|
2009
|
+
|
|
2010
|
+
worksheet.write_rich_string('A3',
|
|
2011
|
+
'This is ', red, 'red', ' and this is ', blue, 'blue')
|
|
2012
|
+
|
|
2013
|
+
worksheet.write_rich_string('A5',
|
|
2014
|
+
'Some ', bold, 'bold text', ' centered', center)
|
|
2015
|
+
|
|
2016
|
+
worksheet.write_rich_string('A7',
|
|
2017
|
+
italic, 'j = k', superc, '(n-1)', center)
|
|
2018
|
+
|
|
2019
|
+
workbook.close
|
|
2020
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
2021
|
+
end
|
|
2022
|
+
|
|
2023
|
+
def test_right_to_left
|
|
2024
|
+
xlsx = 'right_to_left.xlsx'
|
|
2025
|
+
workbook = WriteXLSX.new(xlsx)
|
|
2026
|
+
worksheet1 = workbook.add_worksheet
|
|
2027
|
+
worksheet2 = workbook.add_worksheet
|
|
2028
|
+
|
|
2029
|
+
worksheet2.right_to_left
|
|
2030
|
+
|
|
2031
|
+
worksheet1.write(0, 0, 'Hello') # A1, B1, C1, ...
|
|
2032
|
+
worksheet2.write(0, 0, 'Hello') # ..., C1, B1, A1
|
|
2033
|
+
workbook.close
|
|
2034
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
2035
|
+
end
|
|
2036
|
+
|
|
2037
|
+
def test_tab_colors
|
|
2038
|
+
xlsx = 'tab_colors.xlsx'
|
|
2039
|
+
workbook = WriteXLSX.new(xlsx)
|
|
2040
|
+
|
|
2041
|
+
worksheet1 = workbook.add_worksheet
|
|
2042
|
+
worksheet2 = workbook.add_worksheet
|
|
2043
|
+
worksheet3 = workbook.add_worksheet
|
|
2044
|
+
worksheet4 = workbook.add_worksheet
|
|
2045
|
+
|
|
2046
|
+
# Worksheet1 will have the default tab colour.
|
|
2047
|
+
worksheet2.set_tab_color('red')
|
|
2048
|
+
worksheet3.set_tab_color('green')
|
|
2049
|
+
worksheet4.set_tab_color(0x35) # Orange
|
|
2050
|
+
|
|
2051
|
+
workbook.close
|
|
2052
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
2053
|
+
end
|
|
2054
|
+
|
|
2055
|
+
def test_autofilter
|
|
2056
|
+
xlsx = 'autofilter.xlsx'
|
|
2057
|
+
workbook = WriteXLSX.new(xlsx)
|
|
2058
|
+
|
|
2059
|
+
worksheet1 = workbook.add_worksheet
|
|
2060
|
+
worksheet2 = workbook.add_worksheet
|
|
2061
|
+
worksheet3 = workbook.add_worksheet
|
|
2062
|
+
worksheet4 = workbook.add_worksheet
|
|
2063
|
+
worksheet5 = workbook.add_worksheet
|
|
2064
|
+
worksheet6 = workbook.add_worksheet
|
|
2065
|
+
|
|
2066
|
+
bold = workbook.add_format( :bold => 1 )
|
|
2067
|
+
|
|
2068
|
+
# Extract the data embedded at the end of this file.
|
|
2069
|
+
data_array = autofilter_data.split("\n")
|
|
2070
|
+
headings = data_array.shift.split
|
|
2071
|
+
data = []
|
|
2072
|
+
data_array.each { |line| data << line.split }
|
|
2073
|
+
|
|
2074
|
+
# Set up several sheets with the same data.
|
|
2075
|
+
workbook.worksheets.each do |worksheet|
|
|
2076
|
+
worksheet.set_column( 'A:D', 12 )
|
|
2077
|
+
worksheet.set_row( 0, 20, bold )
|
|
2078
|
+
worksheet.write( 'A1', headings )
|
|
2079
|
+
end
|
|
2080
|
+
|
|
2081
|
+
|
|
2082
|
+
###############################################################################
|
|
2083
|
+
#
|
|
2084
|
+
# Example 1. Autofilter without conditions.
|
|
2085
|
+
#
|
|
2086
|
+
|
|
2087
|
+
worksheet1.autofilter( 'A1:D51' )
|
|
2088
|
+
worksheet1.write( 'A2', [ data ] )
|
|
2089
|
+
|
|
2090
|
+
###############################################################################
|
|
2091
|
+
#
|
|
2092
|
+
#
|
|
2093
|
+
# Example 2. Autofilter with a filter condition in the first column.
|
|
2094
|
+
#
|
|
2095
|
+
|
|
2096
|
+
# The range in this example is the same as above but in row-column notation.
|
|
2097
|
+
worksheet2.autofilter( 0, 0, 50, 3 )
|
|
2098
|
+
|
|
2099
|
+
# The placeholder "Region" in the filter is ignored and can be any string
|
|
2100
|
+
# that adds clarity to the expression.
|
|
2101
|
+
#
|
|
2102
|
+
worksheet2.filter_column( 0, 'Region eq East' )
|
|
2103
|
+
|
|
2104
|
+
#
|
|
2105
|
+
# Hide the rows that don't match the filter criteria.
|
|
2106
|
+
#
|
|
2107
|
+
row = 1
|
|
2108
|
+
|
|
2109
|
+
data.each do |row_data|
|
|
2110
|
+
region = row_data[0]
|
|
2111
|
+
|
|
2112
|
+
worksheet2.set_row(row, nil, nil, 1) unless region == 'East'
|
|
2113
|
+
worksheet2.write(row, 0, row_data)
|
|
2114
|
+
row += 1
|
|
2115
|
+
end
|
|
2116
|
+
|
|
2117
|
+
###############################################################################
|
|
2118
|
+
#
|
|
2119
|
+
#
|
|
2120
|
+
# Example 3. Autofilter with a dual filter condition in one of the columns.
|
|
2121
|
+
#
|
|
2122
|
+
|
|
2123
|
+
worksheet3.autofilter( 'A1:D51' )
|
|
2124
|
+
|
|
2125
|
+
worksheet3.filter_column( 'A', 'x eq East or x eq South' )
|
|
2126
|
+
|
|
2127
|
+
#
|
|
2128
|
+
# Hide the rows that don't match the filter criteria.
|
|
2129
|
+
#
|
|
2130
|
+
row = 1
|
|
2131
|
+
|
|
2132
|
+
data.each do |row_data|
|
|
2133
|
+
region = row_data[0]
|
|
2134
|
+
|
|
2135
|
+
worksheet3.set_row(row, nil, nil, 1) unless region == 'East' || region == 'South'
|
|
2136
|
+
worksheet3.write(row, 0,row_data)
|
|
2137
|
+
row += 1
|
|
2138
|
+
end
|
|
2139
|
+
|
|
2140
|
+
|
|
2141
|
+
###############################################################################
|
|
2142
|
+
#
|
|
2143
|
+
#
|
|
2144
|
+
# Example 4. Autofilter with filter conditions in two columns.
|
|
2145
|
+
#
|
|
2146
|
+
|
|
2147
|
+
worksheet4.autofilter('A1:D51')
|
|
2148
|
+
|
|
2149
|
+
worksheet4.filter_column('A', 'x eq East')
|
|
2150
|
+
worksheet4.filter_column('C', 'x > 3000 and x < 8000')
|
|
2151
|
+
|
|
2152
|
+
#
|
|
2153
|
+
# Hide the rows that don't match the filter criteria.
|
|
2154
|
+
#
|
|
2155
|
+
row = 1
|
|
2156
|
+
|
|
2157
|
+
data.each do |row_data|
|
|
2158
|
+
region = row_data[0]
|
|
2159
|
+
volume = row_data[2]
|
|
2160
|
+
|
|
2161
|
+
unless region == 'East' && volume.to_i > 3000 && volume.to_i < 8000
|
|
2162
|
+
# Hide row.
|
|
2163
|
+
worksheet4.set_row(row, nil, nil, 1)
|
|
2164
|
+
end
|
|
2165
|
+
|
|
2166
|
+
worksheet4.write(row, 0, row_data)
|
|
2167
|
+
row += 1
|
|
2168
|
+
end
|
|
2169
|
+
|
|
2170
|
+
|
|
2171
|
+
###############################################################################
|
|
2172
|
+
#
|
|
2173
|
+
#
|
|
2174
|
+
# Example 5. Autofilter with filter for blanks.
|
|
2175
|
+
#
|
|
2176
|
+
|
|
2177
|
+
# Create a blank cell in our test data.
|
|
2178
|
+
data[5][0] = ''
|
|
2179
|
+
|
|
2180
|
+
worksheet5.autofilter('A1:D51')
|
|
2181
|
+
worksheet5.filter_column('A', 'x eq Blanks')
|
|
2182
|
+
|
|
2183
|
+
#
|
|
2184
|
+
# Hide the rows that don't match the filter criteria.
|
|
2185
|
+
#
|
|
2186
|
+
row = 1
|
|
2187
|
+
|
|
2188
|
+
data.each do |row_data|
|
|
2189
|
+
region = row_data[0]
|
|
2190
|
+
|
|
2191
|
+
worksheet5.set_row(row, nil, nil, 1) unless region == ''
|
|
2192
|
+
|
|
2193
|
+
worksheet5.write(row, 0, row_data)
|
|
2194
|
+
row += 1
|
|
2195
|
+
end
|
|
2196
|
+
|
|
2197
|
+
|
|
2198
|
+
###############################################################################
|
|
2199
|
+
#
|
|
2200
|
+
#
|
|
2201
|
+
# Example 6. Autofilter with filter for non-blanks.
|
|
2202
|
+
#
|
|
2203
|
+
|
|
2204
|
+
|
|
2205
|
+
worksheet6.autofilter('A1:D51')
|
|
2206
|
+
worksheet6.filter_column('A', 'x eq NonBlanks')
|
|
2207
|
+
|
|
2208
|
+
#
|
|
2209
|
+
# Hide the rows that don't match the filter criteria.
|
|
2210
|
+
#
|
|
2211
|
+
row = 1
|
|
2212
|
+
|
|
2213
|
+
data.each do |row_data|
|
|
2214
|
+
region = row_data[0]
|
|
2215
|
+
|
|
2216
|
+
worksheet6.set_row(row, nil, nil, 1) unless region != ''
|
|
2217
|
+
|
|
2218
|
+
worksheet6.write(row, 0, row_data)
|
|
2219
|
+
row += 1
|
|
2220
|
+
end
|
|
2221
|
+
|
|
2222
|
+
workbook.close
|
|
2223
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
|
2224
|
+
end
|
|
2225
|
+
|
|
2226
|
+
def autofilter_data
|
|
2227
|
+
<<EOS
|
|
2228
|
+
Region Item Volume Month
|
|
2229
|
+
East Apple 9000 July
|
|
2230
|
+
East Apple 5000 July
|
|
2231
|
+
South Orange 9000 September
|
|
2232
|
+
North Apple 2000 November
|
|
2233
|
+
West Apple 9000 November
|
|
2234
|
+
South Pear 7000 October
|
|
2235
|
+
North Pear 9000 August
|
|
2236
|
+
West Orange 1000 December
|
|
2237
|
+
West Grape 1000 November
|
|
2238
|
+
South Pear 10000 April
|
|
2239
|
+
West Grape 6000 January
|
|
2240
|
+
South Orange 3000 May
|
|
2241
|
+
North Apple 3000 December
|
|
2242
|
+
South Apple 7000 February
|
|
2243
|
+
West Grape 1000 December
|
|
2244
|
+
East Grape 8000 February
|
|
2245
|
+
South Grape 10000 June
|
|
2246
|
+
West Pear 7000 December
|
|
2247
|
+
South Apple 2000 October
|
|
2248
|
+
East Grape 7000 December
|
|
2249
|
+
North Grape 6000 April
|
|
2250
|
+
East Pear 8000 February
|
|
2251
|
+
North Apple 7000 August
|
|
2252
|
+
North Orange 7000 July
|
|
2253
|
+
North Apple 6000 June
|
|
2254
|
+
South Grape 8000 September
|
|
2255
|
+
West Apple 3000 October
|
|
2256
|
+
South Orange 10000 November
|
|
2257
|
+
West Grape 4000 July
|
|
2258
|
+
North Orange 5000 August
|
|
2259
|
+
East Orange 1000 November
|
|
2260
|
+
East Orange 4000 October
|
|
2261
|
+
North Grape 5000 August
|
|
2262
|
+
East Apple 1000 December
|
|
2263
|
+
South Apple 10000 March
|
|
2264
|
+
East Grape 7000 October
|
|
2265
|
+
West Grape 1000 September
|
|
2266
|
+
East Grape 10000 October
|
|
2267
|
+
South Orange 8000 March
|
|
2268
|
+
North Apple 4000 July
|
|
2269
|
+
South Orange 5000 July
|
|
2270
|
+
West Apple 4000 June
|
|
2271
|
+
East Apple 5000 April
|
|
2272
|
+
North Pear 3000 August
|
|
2273
|
+
East Grape 9000 November
|
|
2274
|
+
North Orange 8000 October
|
|
2275
|
+
East Apple 10000 June
|
|
2276
|
+
South Pear 1000 December
|
|
2277
|
+
North Grape 10000 July
|
|
2278
|
+
East Grape 6000 February
|
|
2279
|
+
EOS
|
|
2280
|
+
end
|
|
2281
|
+
end
|