write_xlsx 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- 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,216 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
require 'write_xlsx/workbook'
|
4
|
+
require 'write_xlsx/package/styles'
|
5
|
+
require 'stringio'
|
6
|
+
|
7
|
+
class TestStyles04 < Test::Unit::TestCase
|
8
|
+
def test_styles_04
|
9
|
+
workbook = WriteXLSX.new(StringIO.new)
|
10
|
+
|
11
|
+
format1 = workbook.add_format(:top => 7)
|
12
|
+
format2 = workbook.add_format(:top => 4)
|
13
|
+
format3 = workbook.add_format(:top => 11)
|
14
|
+
format4 = workbook.add_format(:top => 9)
|
15
|
+
format5 = workbook.add_format(:top => 3)
|
16
|
+
format6 = workbook.add_format(:top => 1)
|
17
|
+
format7 = workbook.add_format(:top => 12)
|
18
|
+
format8 = workbook.add_format(:top => 13)
|
19
|
+
format9 = workbook.add_format(:top => 10)
|
20
|
+
format10 = workbook.add_format(:top => 8)
|
21
|
+
format11 = workbook.add_format(:top => 2)
|
22
|
+
format12 = workbook.add_format(:top => 5)
|
23
|
+
format13 = workbook.add_format(:top => 6)
|
24
|
+
|
25
|
+
workbook.__send__('set_default_xf_indices')
|
26
|
+
workbook.__send__('prepare_format_properties')
|
27
|
+
|
28
|
+
@style = Writexlsx::Package::Styles.new
|
29
|
+
@style.set_style_properties(
|
30
|
+
workbook.xf_formats,
|
31
|
+
workbook.palette,
|
32
|
+
workbook.font_count,
|
33
|
+
workbook.num_format_count,
|
34
|
+
workbook.border_count,
|
35
|
+
workbook.fill_count,
|
36
|
+
workbook.custom_colors,
|
37
|
+
workbook.dxf_formats
|
38
|
+
)
|
39
|
+
@style.assemble_xml_file
|
40
|
+
result = got_to_array(@style.xml_str)
|
41
|
+
expected = expected_to_array(<<EOS
|
42
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
43
|
+
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
|
44
|
+
<fonts count="1">
|
45
|
+
<font>
|
46
|
+
<sz val="11"/>
|
47
|
+
<color theme="1"/>
|
48
|
+
<name val="Calibri"/>
|
49
|
+
<family val="2"/>
|
50
|
+
<scheme val="minor"/>
|
51
|
+
</font>
|
52
|
+
</fonts>
|
53
|
+
<fills count="2">
|
54
|
+
<fill>
|
55
|
+
<patternFill patternType="none"/>
|
56
|
+
</fill>
|
57
|
+
<fill>
|
58
|
+
<patternFill patternType="gray125"/>
|
59
|
+
</fill>
|
60
|
+
</fills>
|
61
|
+
<borders count="14">
|
62
|
+
<border>
|
63
|
+
<left/>
|
64
|
+
<right/>
|
65
|
+
<top/>
|
66
|
+
<bottom/>
|
67
|
+
<diagonal/>
|
68
|
+
</border>
|
69
|
+
<border>
|
70
|
+
<left/>
|
71
|
+
<right/>
|
72
|
+
<top style="hair">
|
73
|
+
<color auto="1"/>
|
74
|
+
</top>
|
75
|
+
<bottom/>
|
76
|
+
<diagonal/>
|
77
|
+
</border>
|
78
|
+
<border>
|
79
|
+
<left/>
|
80
|
+
<right/>
|
81
|
+
<top style="dotted">
|
82
|
+
<color auto="1"/>
|
83
|
+
</top>
|
84
|
+
<bottom/>
|
85
|
+
<diagonal/>
|
86
|
+
</border>
|
87
|
+
<border>
|
88
|
+
<left/>
|
89
|
+
<right/>
|
90
|
+
<top style="dashDotDot">
|
91
|
+
<color auto="1"/>
|
92
|
+
</top>
|
93
|
+
<bottom/>
|
94
|
+
<diagonal/>
|
95
|
+
</border>
|
96
|
+
<border>
|
97
|
+
<left/>
|
98
|
+
<right/>
|
99
|
+
<top style="dashDot">
|
100
|
+
<color auto="1"/>
|
101
|
+
</top>
|
102
|
+
<bottom/>
|
103
|
+
<diagonal/>
|
104
|
+
</border>
|
105
|
+
<border>
|
106
|
+
<left/>
|
107
|
+
<right/>
|
108
|
+
<top style="dashed">
|
109
|
+
<color auto="1"/>
|
110
|
+
</top>
|
111
|
+
<bottom/>
|
112
|
+
<diagonal/>
|
113
|
+
</border>
|
114
|
+
<border>
|
115
|
+
<left/>
|
116
|
+
<right/>
|
117
|
+
<top style="thin">
|
118
|
+
<color auto="1"/>
|
119
|
+
</top>
|
120
|
+
<bottom/>
|
121
|
+
<diagonal/>
|
122
|
+
</border>
|
123
|
+
<border>
|
124
|
+
<left/>
|
125
|
+
<right/>
|
126
|
+
<top style="mediumDashDotDot">
|
127
|
+
<color auto="1"/>
|
128
|
+
</top>
|
129
|
+
<bottom/>
|
130
|
+
<diagonal/>
|
131
|
+
</border>
|
132
|
+
<border>
|
133
|
+
<left/>
|
134
|
+
<right/>
|
135
|
+
<top style="slantDashDot">
|
136
|
+
<color auto="1"/>
|
137
|
+
</top>
|
138
|
+
<bottom/>
|
139
|
+
<diagonal/>
|
140
|
+
</border>
|
141
|
+
<border>
|
142
|
+
<left/>
|
143
|
+
<right/>
|
144
|
+
<top style="mediumDashDot">
|
145
|
+
<color auto="1"/>
|
146
|
+
</top>
|
147
|
+
<bottom/>
|
148
|
+
<diagonal/>
|
149
|
+
</border>
|
150
|
+
<border>
|
151
|
+
<left/>
|
152
|
+
<right/>
|
153
|
+
<top style="mediumDashed">
|
154
|
+
<color auto="1"/>
|
155
|
+
</top>
|
156
|
+
<bottom/>
|
157
|
+
<diagonal/>
|
158
|
+
</border>
|
159
|
+
<border>
|
160
|
+
<left/>
|
161
|
+
<right/>
|
162
|
+
<top style="medium">
|
163
|
+
<color auto="1"/>
|
164
|
+
</top>
|
165
|
+
<bottom/>
|
166
|
+
<diagonal/>
|
167
|
+
</border>
|
168
|
+
<border>
|
169
|
+
<left/>
|
170
|
+
<right/>
|
171
|
+
<top style="thick">
|
172
|
+
<color auto="1"/>
|
173
|
+
</top>
|
174
|
+
<bottom/>
|
175
|
+
<diagonal/>
|
176
|
+
</border>
|
177
|
+
<border>
|
178
|
+
<left/>
|
179
|
+
<right/>
|
180
|
+
<top style="double">
|
181
|
+
<color auto="1"/>
|
182
|
+
</top>
|
183
|
+
<bottom/>
|
184
|
+
<diagonal/>
|
185
|
+
</border>
|
186
|
+
</borders>
|
187
|
+
<cellStyleXfs count="1">
|
188
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0"/>
|
189
|
+
</cellStyleXfs>
|
190
|
+
<cellXfs count="14">
|
191
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>
|
192
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="1" xfId="0" applyBorder="1"/>
|
193
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="2" xfId="0" applyBorder="1"/>
|
194
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="3" xfId="0" applyBorder="1"/>
|
195
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="4" xfId="0" applyBorder="1"/>
|
196
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="5" xfId="0" applyBorder="1"/>
|
197
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="6" xfId="0" applyBorder="1"/>
|
198
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="7" xfId="0" applyBorder="1"/>
|
199
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="8" xfId="0" applyBorder="1"/>
|
200
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="9" xfId="0" applyBorder="1"/>
|
201
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="10" xfId="0" applyBorder="1"/>
|
202
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="11" xfId="0" applyBorder="1"/>
|
203
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="12" xfId="0" applyBorder="1"/>
|
204
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="13" xfId="0" applyBorder="1"/>
|
205
|
+
</cellXfs>
|
206
|
+
<cellStyles count="1">
|
207
|
+
<cellStyle name="Normal" xfId="0" builtinId="0"/>
|
208
|
+
</cellStyles>
|
209
|
+
<dxfs count="0"/>
|
210
|
+
<tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleLight16"/>
|
211
|
+
</styleSheet>
|
212
|
+
EOS
|
213
|
+
)
|
214
|
+
assert_equal(expected, result)
|
215
|
+
end
|
216
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
require 'write_xlsx/workbook'
|
4
|
+
require 'write_xlsx/package/styles'
|
5
|
+
require 'stringio'
|
6
|
+
|
7
|
+
class TestStyles05 < Test::Unit::TestCase
|
8
|
+
def test_styles_05
|
9
|
+
workbook = WriteXLSX.new(StringIO.new)
|
10
|
+
|
11
|
+
format1 = workbook.add_format(:left => 1)
|
12
|
+
format2 = workbook.add_format(:right => 1)
|
13
|
+
format3 = workbook.add_format(:top => 1)
|
14
|
+
format4 = workbook.add_format(:bottom => 1)
|
15
|
+
format5 = workbook.add_format(:diag_type => 1, :diag_border => 1)
|
16
|
+
format6 = workbook.add_format(:diag_type => 2, :diag_border => 1)
|
17
|
+
format7 = workbook.add_format(:diag_type => 3)
|
18
|
+
|
19
|
+
workbook.__send__('set_default_xf_indices')
|
20
|
+
workbook.__send__('prepare_format_properties')
|
21
|
+
|
22
|
+
@style = Writexlsx::Package::Styles.new
|
23
|
+
@style.set_style_properties(
|
24
|
+
workbook.xf_formats,
|
25
|
+
workbook.palette,
|
26
|
+
workbook.font_count,
|
27
|
+
workbook.num_format_count,
|
28
|
+
workbook.border_count,
|
29
|
+
workbook.fill_count,
|
30
|
+
workbook.custom_colors,
|
31
|
+
workbook.dxf_formats
|
32
|
+
)
|
33
|
+
@style.assemble_xml_file
|
34
|
+
result = got_to_array(@style.xml_str)
|
35
|
+
expected = expected_to_array(<<EOS
|
36
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
37
|
+
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
|
38
|
+
<fonts count="1">
|
39
|
+
<font>
|
40
|
+
<sz val="11"/>
|
41
|
+
<color theme="1"/>
|
42
|
+
<name val="Calibri"/>
|
43
|
+
<family val="2"/>
|
44
|
+
<scheme val="minor"/>
|
45
|
+
</font>
|
46
|
+
</fonts>
|
47
|
+
<fills count="2">
|
48
|
+
<fill>
|
49
|
+
<patternFill patternType="none"/>
|
50
|
+
</fill>
|
51
|
+
<fill>
|
52
|
+
<patternFill patternType="gray125"/>
|
53
|
+
</fill>
|
54
|
+
</fills>
|
55
|
+
<borders count="8">
|
56
|
+
<border>
|
57
|
+
<left/>
|
58
|
+
<right/>
|
59
|
+
<top/>
|
60
|
+
<bottom/>
|
61
|
+
<diagonal/>
|
62
|
+
</border>
|
63
|
+
<border>
|
64
|
+
<left style="thin">
|
65
|
+
<color auto="1"/>
|
66
|
+
</left>
|
67
|
+
<right/>
|
68
|
+
<top/>
|
69
|
+
<bottom/>
|
70
|
+
<diagonal/>
|
71
|
+
</border>
|
72
|
+
<border>
|
73
|
+
<left/>
|
74
|
+
<right style="thin">
|
75
|
+
<color auto="1"/>
|
76
|
+
</right>
|
77
|
+
<top/>
|
78
|
+
<bottom/>
|
79
|
+
<diagonal/>
|
80
|
+
</border>
|
81
|
+
<border>
|
82
|
+
<left/>
|
83
|
+
<right/>
|
84
|
+
<top style="thin">
|
85
|
+
<color auto="1"/>
|
86
|
+
</top>
|
87
|
+
<bottom/>
|
88
|
+
<diagonal/>
|
89
|
+
</border>
|
90
|
+
<border>
|
91
|
+
<left/>
|
92
|
+
<right/>
|
93
|
+
<top/>
|
94
|
+
<bottom style="thin">
|
95
|
+
<color auto="1"/>
|
96
|
+
</bottom>
|
97
|
+
<diagonal/>
|
98
|
+
</border>
|
99
|
+
<border diagonalUp="1">
|
100
|
+
<left/>
|
101
|
+
<right/>
|
102
|
+
<top/>
|
103
|
+
<bottom/>
|
104
|
+
<diagonal style="thin">
|
105
|
+
<color auto="1"/>
|
106
|
+
</diagonal>
|
107
|
+
</border>
|
108
|
+
<border diagonalDown="1">
|
109
|
+
<left/>
|
110
|
+
<right/>
|
111
|
+
<top/>
|
112
|
+
<bottom/>
|
113
|
+
<diagonal style="thin">
|
114
|
+
<color auto="1"/>
|
115
|
+
</diagonal>
|
116
|
+
</border>
|
117
|
+
<border diagonalUp="1" diagonalDown="1">
|
118
|
+
<left/>
|
119
|
+
<right/>
|
120
|
+
<top/>
|
121
|
+
<bottom/>
|
122
|
+
<diagonal style="thin">
|
123
|
+
<color auto="1"/>
|
124
|
+
</diagonal>
|
125
|
+
</border>
|
126
|
+
</borders>
|
127
|
+
<cellStyleXfs count="1">
|
128
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0"/>
|
129
|
+
</cellStyleXfs>
|
130
|
+
<cellXfs count="8">
|
131
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>
|
132
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="1" xfId="0" applyBorder="1"/>
|
133
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="2" xfId="0" applyBorder="1"/>
|
134
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="3" xfId="0" applyBorder="1"/>
|
135
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="4" xfId="0" applyBorder="1"/>
|
136
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="5" xfId="0" applyBorder="1"/>
|
137
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="6" xfId="0" applyBorder="1"/>
|
138
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="7" xfId="0" applyBorder="1"/>
|
139
|
+
</cellXfs>
|
140
|
+
<cellStyles count="1">
|
141
|
+
<cellStyle name="Normal" xfId="0" builtinId="0"/>
|
142
|
+
</cellStyles>
|
143
|
+
<dxfs count="0"/>
|
144
|
+
<tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleLight16"/>
|
145
|
+
</styleSheet>
|
146
|
+
EOS
|
147
|
+
)
|
148
|
+
assert_equal(expected, result)
|
149
|
+
end
|
150
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
require 'write_xlsx/workbook'
|
4
|
+
require 'write_xlsx/package/styles'
|
5
|
+
require 'stringio'
|
6
|
+
|
7
|
+
class TestStyles06 < Test::Unit::TestCase
|
8
|
+
def test_styles_06
|
9
|
+
workbook = WriteXLSX.new(StringIO.new)
|
10
|
+
|
11
|
+
format1 = workbook.add_format(
|
12
|
+
:left => 1,
|
13
|
+
:right => 1,
|
14
|
+
:top => 1,
|
15
|
+
:bottom => 1,
|
16
|
+
:diag_border => 1,
|
17
|
+
:diag_type => 3,
|
18
|
+
:left_color => 'red',
|
19
|
+
:right_color => 'red',
|
20
|
+
:top_color => 'red',
|
21
|
+
:bottom_color => 'red',
|
22
|
+
:diag_color => 'red'
|
23
|
+
)
|
24
|
+
|
25
|
+
workbook.__send__('set_default_xf_indices')
|
26
|
+
workbook.__send__('prepare_format_properties')
|
27
|
+
|
28
|
+
@style = Writexlsx::Package::Styles.new
|
29
|
+
@style.set_style_properties(
|
30
|
+
workbook.xf_formats,
|
31
|
+
workbook.palette,
|
32
|
+
workbook.font_count,
|
33
|
+
workbook.num_format_count,
|
34
|
+
workbook.border_count,
|
35
|
+
workbook.fill_count,
|
36
|
+
workbook.custom_colors,
|
37
|
+
workbook.dxf_formats
|
38
|
+
)
|
39
|
+
@style.assemble_xml_file
|
40
|
+
result = got_to_array(@style.xml_str)
|
41
|
+
expected = expected_to_array(<<EOS
|
42
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
43
|
+
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
|
44
|
+
<fonts count="1">
|
45
|
+
<font>
|
46
|
+
<sz val="11"/>
|
47
|
+
<color theme="1"/>
|
48
|
+
<name val="Calibri"/>
|
49
|
+
<family val="2"/>
|
50
|
+
<scheme val="minor"/>
|
51
|
+
</font>
|
52
|
+
</fonts>
|
53
|
+
<fills count="2">
|
54
|
+
<fill>
|
55
|
+
<patternFill patternType="none"/>
|
56
|
+
</fill>
|
57
|
+
<fill>
|
58
|
+
<patternFill patternType="gray125"/>
|
59
|
+
</fill>
|
60
|
+
</fills>
|
61
|
+
<borders count="2">
|
62
|
+
<border>
|
63
|
+
<left/>
|
64
|
+
<right/>
|
65
|
+
<top/>
|
66
|
+
<bottom/>
|
67
|
+
<diagonal/>
|
68
|
+
</border>
|
69
|
+
<border diagonalUp="1" diagonalDown="1">
|
70
|
+
<left style="thin">
|
71
|
+
<color rgb="FFFF0000"/>
|
72
|
+
</left>
|
73
|
+
<right style="thin">
|
74
|
+
<color rgb="FFFF0000"/>
|
75
|
+
</right>
|
76
|
+
<top style="thin">
|
77
|
+
<color rgb="FFFF0000"/>
|
78
|
+
</top>
|
79
|
+
<bottom style="thin">
|
80
|
+
<color rgb="FFFF0000"/>
|
81
|
+
</bottom>
|
82
|
+
<diagonal style="thin">
|
83
|
+
<color rgb="FFFF0000"/>
|
84
|
+
</diagonal>
|
85
|
+
</border>
|
86
|
+
</borders>
|
87
|
+
<cellStyleXfs count="1">
|
88
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0"/>
|
89
|
+
</cellStyleXfs>
|
90
|
+
<cellXfs count="2">
|
91
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>
|
92
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="1" xfId="0" applyBorder="1"/>
|
93
|
+
</cellXfs>
|
94
|
+
<cellStyles count="1">
|
95
|
+
<cellStyle name="Normal" xfId="0" builtinId="0"/>
|
96
|
+
</cellStyles>
|
97
|
+
<dxfs count="0"/>
|
98
|
+
<tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleLight16"/>
|
99
|
+
</styleSheet>
|
100
|
+
EOS
|
101
|
+
)
|
102
|
+
assert_equal(expected, result)
|
103
|
+
end
|
104
|
+
end
|