ricardoo27-writeexcel 0.6.12.1
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/README.rdoc +136 -0
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/charts/chartex.rb +316 -0
- data/charts/demo1.rb +46 -0
- data/charts/demo101.bin +0 -0
- data/charts/demo2.rb +65 -0
- data/charts/demo201.bin +0 -0
- data/charts/demo3.rb +117 -0
- data/charts/demo301.bin +0 -0
- data/charts/demo4.rb +119 -0
- data/charts/demo401.bin +0 -0
- data/charts/demo5.rb +48 -0
- data/charts/demo501.bin +0 -0
- data/examples/a_simple.rb +43 -0
- data/examples/autofilter.rb +265 -0
- data/examples/bigfile.rb +30 -0
- data/examples/chart_area.rb +121 -0
- data/examples/chart_bar.rb +120 -0
- data/examples/chart_column.rb +120 -0
- data/examples/chart_line.rb +120 -0
- data/examples/chart_pie.rb +108 -0
- data/examples/chart_scatter.rb +121 -0
- data/examples/chart_stock.rb +148 -0
- data/examples/chess.rb +142 -0
- data/examples/colors.rb +129 -0
- data/examples/comments1.rb +27 -0
- data/examples/comments2.rb +352 -0
- data/examples/copyformat.rb +52 -0
- data/examples/data_validate.rb +279 -0
- data/examples/date_time.rb +87 -0
- data/examples/defined_name.rb +32 -0
- data/examples/demo.rb +124 -0
- data/examples/diag_border.rb +36 -0
- data/examples/formats.rb +490 -0
- data/examples/formula_result.rb +30 -0
- data/examples/header.rb +137 -0
- data/examples/hide_sheet.rb +29 -0
- data/examples/hyperlink.rb +43 -0
- data/examples/images.rb +63 -0
- data/examples/indent.rb +31 -0
- data/examples/merge1.rb +40 -0
- data/examples/merge2.rb +45 -0
- data/examples/merge3.rb +66 -0
- data/examples/merge4.rb +83 -0
- data/examples/merge5.rb +80 -0
- data/examples/merge6.rb +67 -0
- data/examples/outline.rb +255 -0
- data/examples/outline_collapsed.rb +209 -0
- data/examples/panes.rb +113 -0
- data/examples/password_protection.rb +33 -0
- data/examples/properties.rb +34 -0
- data/examples/properties_jp.rb +33 -0
- data/examples/protection.rb +47 -0
- data/examples/regions.rb +53 -0
- data/examples/repeat.rb +43 -0
- data/examples/republic.png +0 -0
- data/examples/right_to_left.rb +27 -0
- data/examples/row_wrap.rb +53 -0
- data/examples/set_first_sheet.rb +14 -0
- data/examples/stats.rb +74 -0
- data/examples/stocks.rb +81 -0
- data/examples/store_formula.rb +15 -0
- data/examples/tab_colors.rb +31 -0
- data/examples/utf8.rb +15 -0
- data/examples/write_arrays.rb +83 -0
- data/html/en/doc_en.html +5946 -0
- data/html/images/a_simple.jpg +0 -0
- data/html/images/area1.jpg +0 -0
- data/html/images/bar1.jpg +0 -0
- data/html/images/chart_area.xls +0 -0
- data/html/images/column1.jpg +0 -0
- data/html/images/data_validation.jpg +0 -0
- data/html/images/line1.jpg +0 -0
- data/html/images/pie1.jpg +0 -0
- data/html/images/regions.jpg +0 -0
- data/html/images/scatter1.jpg +0 -0
- data/html/images/stats.jpg +0 -0
- data/html/images/stock1.jpg +0 -0
- data/html/images/stocks.jpg +0 -0
- data/html/index.html +16 -0
- data/html/style.css +433 -0
- data/lib/writeexcel.rb +1159 -0
- data/lib/writeexcel/biffwriter.rb +223 -0
- data/lib/writeexcel/caller_info.rb +12 -0
- data/lib/writeexcel/cell_range.rb +332 -0
- data/lib/writeexcel/chart.rb +1968 -0
- data/lib/writeexcel/charts/area.rb +154 -0
- data/lib/writeexcel/charts/bar.rb +177 -0
- data/lib/writeexcel/charts/column.rb +156 -0
- data/lib/writeexcel/charts/external.rb +66 -0
- data/lib/writeexcel/charts/line.rb +154 -0
- data/lib/writeexcel/charts/pie.rb +169 -0
- data/lib/writeexcel/charts/scatter.rb +192 -0
- data/lib/writeexcel/charts/stock.rb +213 -0
- data/lib/writeexcel/col_info.rb +87 -0
- data/lib/writeexcel/colors.rb +68 -0
- data/lib/writeexcel/comments.rb +460 -0
- data/lib/writeexcel/compatibility.rb +65 -0
- data/lib/writeexcel/convert_date_time.rb +117 -0
- data/lib/writeexcel/data_validations.rb +370 -0
- data/lib/writeexcel/debug_info.rb +41 -0
- data/lib/writeexcel/embedded_chart.rb +35 -0
- data/lib/writeexcel/excelformula.y +139 -0
- data/lib/writeexcel/excelformulaparser.rb +587 -0
- data/lib/writeexcel/format.rb +1575 -0
- data/lib/writeexcel/formula.rb +987 -0
- data/lib/writeexcel/helper.rb +78 -0
- data/lib/writeexcel/image.rb +218 -0
- data/lib/writeexcel/olewriter.rb +305 -0
- data/lib/writeexcel/outline.rb +24 -0
- data/lib/writeexcel/properties.rb +242 -0
- data/lib/writeexcel/shared_string_table.rb +153 -0
- data/lib/writeexcel/storage_lite.rb +984 -0
- data/lib/writeexcel/workbook.rb +2478 -0
- data/lib/writeexcel/worksheet.rb +6925 -0
- data/lib/writeexcel/worksheets.rb +25 -0
- data/lib/writeexcel/write_file.rb +63 -0
- data/test/excelfile/Chart1.xls +0 -0
- data/test/excelfile/Chart2.xls +0 -0
- data/test/excelfile/Chart3.xls +0 -0
- data/test/excelfile/Chart4.xls +0 -0
- data/test/excelfile/Chart5.xls +0 -0
- data/test/helper.rb +31 -0
- data/test/perl_output/Chart1.xls.data +0 -0
- data/test/perl_output/Chart2.xls.data +0 -0
- data/test/perl_output/Chart3.xls.data +0 -0
- data/test/perl_output/Chart4.xls.data +0 -0
- data/test/perl_output/Chart5.xls.data +0 -0
- data/test/perl_output/README +31 -0
- data/test/perl_output/a_simple.xls +0 -0
- data/test/perl_output/autofilter.xls +0 -0
- data/test/perl_output/biff_add_continue_testdata +0 -0
- data/test/perl_output/chart_area.xls +0 -0
- data/test/perl_output/chart_bar.xls +0 -0
- data/test/perl_output/chart_column.xls +0 -0
- data/test/perl_output/chart_line.xls +0 -0
- data/test/perl_output/chess.xls +0 -0
- data/test/perl_output/colors.xls +0 -0
- data/test/perl_output/comments0.xls +0 -0
- data/test/perl_output/comments1.xls +0 -0
- data/test/perl_output/comments2.xls +0 -0
- data/test/perl_output/data_validate.xls +0 -0
- data/test/perl_output/date_time.xls +0 -0
- data/test/perl_output/defined_name.xls +0 -0
- data/test/perl_output/demo.xls +0 -0
- data/test/perl_output/demo101.bin +0 -0
- data/test/perl_output/demo201.bin +0 -0
- data/test/perl_output/demo301.bin +0 -0
- data/test/perl_output/demo401.bin +0 -0
- data/test/perl_output/demo501.bin +0 -0
- data/test/perl_output/diag_border.xls +0 -0
- data/test/perl_output/f_font_biff +0 -0
- data/test/perl_output/f_font_key +1 -0
- data/test/perl_output/f_xf_biff +0 -0
- data/test/perl_output/file_font_biff +0 -0
- data/test/perl_output/file_font_key +1 -0
- data/test/perl_output/file_xf_biff +0 -0
- data/test/perl_output/formula_result.xls +0 -0
- data/test/perl_output/headers.xls +0 -0
- data/test/perl_output/hidden.xls +0 -0
- data/test/perl_output/hide_zero.xls +0 -0
- data/test/perl_output/hyperlink.xls +0 -0
- data/test/perl_output/images.xls +0 -0
- data/test/perl_output/indent.xls +0 -0
- data/test/perl_output/merge1.xls +0 -0
- data/test/perl_output/merge2.xls +0 -0
- data/test/perl_output/merge3.xls +0 -0
- data/test/perl_output/merge4.xls +0 -0
- data/test/perl_output/merge5.xls +0 -0
- data/test/perl_output/merge6.xls +0 -0
- data/test/perl_output/ole_write_header +0 -0
- data/test/perl_output/outline.xls +0 -0
- data/test/perl_output/outline_collapsed.xls +0 -0
- data/test/perl_output/panes.xls +0 -0
- data/test/perl_output/password_protection.xls +0 -0
- data/test/perl_output/protection.xls +0 -0
- data/test/perl_output/regions.xls +0 -0
- data/test/perl_output/right_to_left.xls +0 -0
- data/test/perl_output/set_first_sheet.xls +0 -0
- data/test/perl_output/stats.xls +0 -0
- data/test/perl_output/stocks.xls +0 -0
- data/test/perl_output/store_formula.xls +0 -0
- data/test/perl_output/tab_colors.xls +0 -0
- data/test/perl_output/unicode_cyrillic.xls +0 -0
- data/test/perl_output/utf8.xls +0 -0
- data/test/perl_output/workbook1.xls +0 -0
- data/test/perl_output/workbook2.xls +0 -0
- data/test/perl_output/ws_colinfo +1 -0
- data/test/perl_output/ws_store_colinfo +0 -0
- data/test/perl_output/ws_store_dimensions +0 -0
- data/test/perl_output/ws_store_filtermode +0 -0
- data/test/perl_output/ws_store_filtermode_off +0 -0
- data/test/perl_output/ws_store_filtermode_on +0 -0
- data/test/perl_output/ws_store_selection +0 -0
- data/test/perl_output/ws_store_window2 +1 -0
- data/test/republic.png +0 -0
- data/test/test_00_IEEE_double.rb +13 -0
- data/test/test_01_add_worksheet.rb +10 -0
- data/test/test_02_merge_formats.rb +49 -0
- data/test/test_04_dimensions.rb +388 -0
- data/test/test_05_rows.rb +175 -0
- data/test/test_06_extsst.rb +74 -0
- data/test/test_11_date_time.rb +475 -0
- data/test/test_12_date_only.rb +525 -0
- data/test/test_13_date_seconds.rb +477 -0
- data/test/test_21_escher.rb +624 -0
- data/test/test_22_mso_drawing_group.rb +741 -0
- data/test/test_23_note.rb +57 -0
- data/test/test_24_txo.rb +74 -0
- data/test/test_25_position_object.rb +80 -0
- data/test/test_26_autofilter.rb +309 -0
- data/test/test_27_autofilter.rb +126 -0
- data/test/test_28_autofilter.rb +156 -0
- data/test/test_29_process_jpg.rb +670 -0
- data/test/test_30_validation_dval.rb +74 -0
- data/test/test_31_validation_dv_strings.rb +123 -0
- data/test/test_32_validation_dv_formula.rb +203 -0
- data/test/test_40_property_types.rb +188 -0
- data/test/test_41_properties.rb +235 -0
- data/test/test_42_set_properties.rb +434 -0
- data/test/test_50_name_stored.rb +295 -0
- data/test/test_51_name_print_area.rb +353 -0
- data/test/test_52_name_print_titles.rb +450 -0
- data/test/test_53_autofilter.rb +199 -0
- data/test/test_60_chart_generic.rb +574 -0
- data/test/test_61_chart_subclasses.rb +84 -0
- data/test/test_62_chart_formats.rb +268 -0
- data/test/test_63_chart_area_formats.rb +645 -0
- data/test/test_biff.rb +71 -0
- data/test/test_big_workbook.rb +17 -0
- data/test/test_compatibility.rb +12 -0
- data/test/test_example_match.rb +3246 -0
- data/test/test_format.rb +1189 -0
- data/test/test_formula.rb +61 -0
- data/test/test_ole.rb +102 -0
- data/test/test_storage_lite.rb +116 -0
- data/test/test_workbook.rb +146 -0
- data/test/test_worksheet.rb +106 -0
- data/utils/add_magic_comment.rb +80 -0
- data/writeexcel.gemspec +278 -0
- data/writeexcel.rdoc +1425 -0
- metadata +292 -0
@@ -0,0 +1,624 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
###############################################################################
|
3
|
+
#
|
4
|
+
# A test for WriteExcel.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# all test is commented out because Workbook#add_mso_... was set to private
|
8
|
+
# method. Before that, all test passed.
|
9
|
+
#
|
10
|
+
#
|
11
|
+
#
|
12
|
+
#
|
13
|
+
# Tests for the internal methods used to write the records in an Escher drawing
|
14
|
+
# object such as images, comments and filters.
|
15
|
+
#
|
16
|
+
# reverse('©'), September 2005, John McNamara, jmcnamara@cpan.org
|
17
|
+
#
|
18
|
+
# original written in Perl by John McNamara
|
19
|
+
# converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
|
20
|
+
#
|
21
|
+
############################################################################
|
22
|
+
require 'helper'
|
23
|
+
require 'stringio'
|
24
|
+
|
25
|
+
class TC_escher < Test::Unit::TestCase
|
26
|
+
|
27
|
+
def setup
|
28
|
+
@workbook = WriteExcel.new(StringIO.new)
|
29
|
+
@worksheet = @workbook.add_worksheet
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_for_store_mso_dg_container
|
33
|
+
caption = sprintf(" \t_store_mso_dg_container()")
|
34
|
+
data = [0xC8]
|
35
|
+
target = %w( 0F 00 02 F0 C8 00 00 00 ).join(' ')
|
36
|
+
|
37
|
+
result = unpack_record(@worksheet.__send__("store_mso_dg_container", *data))
|
38
|
+
|
39
|
+
assert_equal(target, result, caption)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_for_store_mso_dg
|
43
|
+
caption = sprintf(" \t_store_mso_dg()")
|
44
|
+
@worksheet.instance_variable_set(:@object_ids, Writeexcel::Worksheet::ObjectIds.new(nil, 1, 2, 1025))
|
45
|
+
target = %w( 10 00 08 F0
|
46
|
+
08 00 00 00 02 00 00 00 01 04 00 00
|
47
|
+
).join(' ')
|
48
|
+
|
49
|
+
result = unpack_record(@worksheet.__send__("store_mso_dg"))
|
50
|
+
|
51
|
+
assert_equal(target, result, caption)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_for_store_mso_dgg
|
55
|
+
caption = sprintf(" \t_store_mso_dgg()")
|
56
|
+
data = [ 1026, 2, 2, 1, [[1,2]] ]
|
57
|
+
target = %w( 00 00 06 F0
|
58
|
+
18 00 00 00 02 04 00 00 02 00 00 00 02 00 00 00
|
59
|
+
01 00 00 00 01 00 00 00 02 00 00 00
|
60
|
+
).join(' ')
|
61
|
+
|
62
|
+
result = unpack_record(@workbook.__send__("store_mso_dgg", *data))
|
63
|
+
|
64
|
+
assert_equal(target, result, caption)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_for_store_mso_spgr_container
|
68
|
+
caption = sprintf(" \t_store_mso_spgr_container()")
|
69
|
+
data = [0xB0]
|
70
|
+
target = %w(
|
71
|
+
0F 00 03 F0 B0 00 00 00
|
72
|
+
).join(' ')
|
73
|
+
|
74
|
+
result = unpack_record(@worksheet.__send__("store_mso_spgr_container", *data))
|
75
|
+
|
76
|
+
assert_equal(target, result, caption)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_for_store_mso_sp_container
|
80
|
+
caption = sprintf(" \t_store_mso_sp_container()")
|
81
|
+
data = [0x28]
|
82
|
+
target = %w(
|
83
|
+
0F 00 04 F0 28 00 00 00
|
84
|
+
).join(' ')
|
85
|
+
|
86
|
+
result = unpack_record(@worksheet.__send__("store_mso_sp_container", *data))
|
87
|
+
|
88
|
+
assert_equal(target, result, caption)
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_for_store_mso_sp
|
92
|
+
caption = sprintf(" \t_store_mso_sp()")
|
93
|
+
data = [0, 1024, 0x0005]
|
94
|
+
target = %w(
|
95
|
+
02 00 0A F0 08 00 00 00 00 04 00 00 05 00 00 00
|
96
|
+
).join(' ')
|
97
|
+
|
98
|
+
result = unpack_record(@worksheet.__send__("store_mso_sp", *data))
|
99
|
+
|
100
|
+
assert_equal(target, result, caption)
|
101
|
+
|
102
|
+
data = [202, 1025, 0x0A00]
|
103
|
+
target = %w(
|
104
|
+
A2 0C 0A F0 08 00 00 00 01 04 00 00 00 0A 00 00
|
105
|
+
).join(' ')
|
106
|
+
|
107
|
+
result = unpack_record(@worksheet.__send__("store_mso_sp", *data))
|
108
|
+
|
109
|
+
assert_equal(target, result, caption)
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_for_store_mso_opt_comment
|
113
|
+
caption = sprintf(" \t_store_mso_opt_comment()")
|
114
|
+
comment = Writeexcel::Worksheet::Comment.new(@worksheet, 1, 1, ' ')
|
115
|
+
data = [0x80]
|
116
|
+
target = %w(
|
117
|
+
93 00 0B F0 36 00 00 00
|
118
|
+
80 00 00 00 00 00 BF 00 08 00 08 00
|
119
|
+
58 01 00 00 00 00 81 01 50 00 00 08 83 01 50 00
|
120
|
+
00 08 BF 01 10 00 11 00 01 02 00 00 00 00 3F 02
|
121
|
+
03 00 03 00 BF 03 02 00 0A 00
|
122
|
+
).join(' ')
|
123
|
+
|
124
|
+
result = unpack_record(comment.store_mso_opt_comment(*data))
|
125
|
+
|
126
|
+
assert_equal(target, result, caption)
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_for_store_mso_client_data
|
130
|
+
caption = sprintf(" \t_store_mso_client_data")
|
131
|
+
target = %w(
|
132
|
+
00 00 11 F0 00 00 00 00
|
133
|
+
).join(' ')
|
134
|
+
|
135
|
+
result = unpack_record(@worksheet.__send__("store_mso_client_data"))
|
136
|
+
|
137
|
+
assert_equal(target, result, caption)
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_for_obj_comment_record
|
141
|
+
caption = sprintf(" \t_obj_comment_record")
|
142
|
+
comment = Writeexcel::Worksheet::Comment.new(@worksheet, 1, 1, ' ')
|
143
|
+
data = [0x01]
|
144
|
+
target = %w(
|
145
|
+
5D 00 34 00 15 00 12 00 19 00 01 00 11 40 00 00
|
146
|
+
00 00 00 00 00 00 00 00 00 00 0D 00 16 00 00 00
|
147
|
+
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
148
|
+
00 00 00 00 00 00 00 00
|
149
|
+
).join(' ')
|
150
|
+
|
151
|
+
result = unpack_record(comment.obj_comment_record(*data))
|
152
|
+
|
153
|
+
assert_equal(target, result, caption)
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_for_store_mso_client_text_box
|
157
|
+
caption = sprintf(" \t_store_mso_client_text_box")
|
158
|
+
comment = Writeexcel::Worksheet::Comment.new(@worksheet, 1, 1, ' ')
|
159
|
+
target = %w(
|
160
|
+
00 00 0D F0 00 00 00 00
|
161
|
+
).join(' ')
|
162
|
+
|
163
|
+
result = unpack_record(comment.__send__("store_mso_client_text_box"))
|
164
|
+
|
165
|
+
assert_equal(target, result, caption)
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_for_store_mso_client_anchor
|
169
|
+
|
170
|
+
# A1
|
171
|
+
range = 'A1'
|
172
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s)", range)
|
173
|
+
row, col = @worksheet.__send__("substitute_cellref", range)
|
174
|
+
vertices = Writeexcel::Worksheet::Comment.new(@worksheet, row, col, 'Test').vertices
|
175
|
+
target = %w(
|
176
|
+
00 00 10 F0 12 00 00 00 03 00 01 00 F0 00 00 00
|
177
|
+
1E 00 03 00 F0 00 04 00 78 00
|
178
|
+
).join(' ')
|
179
|
+
|
180
|
+
result = unpack_record(@worksheet.__send__("store_mso_client_anchor", 3, *vertices))
|
181
|
+
|
182
|
+
assert_equal(target, result, caption)
|
183
|
+
|
184
|
+
# A2
|
185
|
+
range = 'A2'
|
186
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s)", range)
|
187
|
+
row, col = @worksheet.__send__("substitute_cellref", range)
|
188
|
+
vertices = Writeexcel::Worksheet::Comment.new(@worksheet, row, col, 'Test').vertices
|
189
|
+
target = %w(
|
190
|
+
00 00 10 F0 12 00 00 00 03 00 01 00 F0 00 00 00
|
191
|
+
69 00 03 00 F0 00 04 00 C4 00
|
192
|
+
).join(' ')
|
193
|
+
|
194
|
+
result = unpack_record(@worksheet.__send__("store_mso_client_anchor", 3, *vertices))
|
195
|
+
|
196
|
+
assert_equal(target, result, caption)
|
197
|
+
|
198
|
+
|
199
|
+
# A3
|
200
|
+
range = 'A3'
|
201
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s)", range)
|
202
|
+
row, col = @worksheet.__send__("substitute_cellref", range)
|
203
|
+
vertices = Writeexcel::Worksheet::Comment.new(@worksheet, row, col, 'Test').vertices
|
204
|
+
target = %w(
|
205
|
+
00 00 10 F0 12 00 00 00 03 00 01 00 F0 00 01 00
|
206
|
+
69 00 03 00 F0 00 05 00 C4 00
|
207
|
+
).join(' ')
|
208
|
+
|
209
|
+
result = unpack_record(@worksheet.__send__("store_mso_client_anchor", 3, *vertices))
|
210
|
+
|
211
|
+
assert_equal(target, result, caption)
|
212
|
+
|
213
|
+
|
214
|
+
# A65534
|
215
|
+
range = 'A65534'
|
216
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s)", range)
|
217
|
+
row, col = @worksheet.__send__("substitute_cellref", range)
|
218
|
+
vertices = Writeexcel::Worksheet::Comment.new(@worksheet, row, col, 'Test').vertices
|
219
|
+
target = %w(
|
220
|
+
00 00 10 F0 12 00 00 00 03 00 01 00 F0 00 F9 FF
|
221
|
+
3C 00 03 00 F0 00 FD FF 97 00
|
222
|
+
).join(' ')
|
223
|
+
|
224
|
+
result = unpack_record(@worksheet.__send__("store_mso_client_anchor", 3, *vertices))
|
225
|
+
|
226
|
+
assert_equal(target, result, caption)
|
227
|
+
|
228
|
+
|
229
|
+
# A65536
|
230
|
+
range = 'A65536'
|
231
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s)", range)
|
232
|
+
row, col = @worksheet.__send__("substitute_cellref", range)
|
233
|
+
vertices = Writeexcel::Worksheet::Comment.new(@worksheet, row, col, 'Test').vertices
|
234
|
+
target = %w(
|
235
|
+
00 00 10 F0 12 00 00 00 03 00 01 00 F0 00 FB FF
|
236
|
+
1E 00 03 00 F0 00 FF FF 78 00
|
237
|
+
).join(' ')
|
238
|
+
|
239
|
+
result = unpack_record(@worksheet.__send__("store_mso_client_anchor", 3, *vertices))
|
240
|
+
|
241
|
+
assert_equal(target, result, caption)
|
242
|
+
|
243
|
+
|
244
|
+
# IT3
|
245
|
+
range = 'IT3'
|
246
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s)", range)
|
247
|
+
row, col = @worksheet.__send__("substitute_cellref", range)
|
248
|
+
vertices = Writeexcel::Worksheet::Comment.new(@worksheet, row, col, 'Test').vertices
|
249
|
+
target = %w(
|
250
|
+
00 00 10 F0 12 00 00 00 03 00 FA 00 10 03 01 00
|
251
|
+
69 00 FC 00 10 03 05 00 C4 00
|
252
|
+
).join(' ')
|
253
|
+
|
254
|
+
result = unpack_record(@worksheet.__send__("store_mso_client_anchor", 3, *vertices))
|
255
|
+
|
256
|
+
assert_equal(target, result, caption)
|
257
|
+
|
258
|
+
|
259
|
+
# IU3
|
260
|
+
range = 'IU3'
|
261
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s)", range)
|
262
|
+
row, col = @worksheet.__send__("substitute_cellref", range)
|
263
|
+
vertices = Writeexcel::Worksheet::Comment.new(@worksheet, row, col, 'Test').vertices
|
264
|
+
target = %w(
|
265
|
+
00 00 10 F0 12 00 00 00 03 00 FB 00 10 03 01 00
|
266
|
+
69 00 FD 00 10 03 05 00 C4 00
|
267
|
+
).join(' ')
|
268
|
+
|
269
|
+
result = unpack_record(@worksheet.__send__("store_mso_client_anchor", 3, *vertices))
|
270
|
+
|
271
|
+
assert_equal(target, result, caption)
|
272
|
+
|
273
|
+
|
274
|
+
#
|
275
|
+
range = 'IU3'
|
276
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s)", range)
|
277
|
+
row, col = @worksheet.__send__("substitute_cellref", range)
|
278
|
+
vertices = Writeexcel::Worksheet::Comment.new(@worksheet, row, col, 'Test').vertices
|
279
|
+
target = %w(
|
280
|
+
00 00 10 F0 12 00 00 00 03 00 FB 00 10 03 01 00
|
281
|
+
69 00 FD 00 10 03 05 00 C4 00
|
282
|
+
).join(' ')
|
283
|
+
|
284
|
+
result = unpack_record(@worksheet.__send__("store_mso_client_anchor", 3, *vertices))
|
285
|
+
|
286
|
+
assert_equal(target, result, caption)
|
287
|
+
|
288
|
+
|
289
|
+
# IV3
|
290
|
+
range = 'IV3'
|
291
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s)", range)
|
292
|
+
row, col = @worksheet.__send__("substitute_cellref", range)
|
293
|
+
vertices = Writeexcel::Worksheet::Comment.new(@worksheet, row, col, 'Test').vertices
|
294
|
+
target = %w(
|
295
|
+
00 00 10 F0 12 00 00 00 03 00 FC 00 10 03 01 00
|
296
|
+
69 00 FE 00 10 03 05 00 C4 00
|
297
|
+
).join(' ')
|
298
|
+
|
299
|
+
result = unpack_record(@worksheet.__send__("store_mso_client_anchor", 3, *vertices))
|
300
|
+
|
301
|
+
assert_equal(target, result, caption)
|
302
|
+
|
303
|
+
end
|
304
|
+
|
305
|
+
def test_for_store_mso_client_anchor_where_comment_offsets_have_changed
|
306
|
+
range = 'A3'
|
307
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s). Cell offsets changes.", range)
|
308
|
+
row, col = @worksheet.__send__("substitute_cellref", range)
|
309
|
+
vertices = Writeexcel::Worksheet::Comment.new(@worksheet, row, col, 'Test',
|
310
|
+
:x_offset => 18, :y_offset => 9).vertices
|
311
|
+
target = %w(
|
312
|
+
00 00 10 F0 12 00
|
313
|
+
00 00 03 00 01 00 20 01 01 00 88 00 03 00 20 01
|
314
|
+
05 00 E2 00
|
315
|
+
).join(' ')
|
316
|
+
|
317
|
+
result = unpack_record(@worksheet.__send__("store_mso_client_anchor", 3, *vertices))
|
318
|
+
|
319
|
+
assert_equal(target, result, caption)
|
320
|
+
end
|
321
|
+
|
322
|
+
def test_for_store_mso_client_anchor_where_comment_dimensions_have_changed
|
323
|
+
# x_scale, y_scale
|
324
|
+
range = 'A3'
|
325
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s). Dimensions changes.", range)
|
326
|
+
row, col = @worksheet.__send__("substitute_cellref", range)
|
327
|
+
vertices = Writeexcel::Worksheet::Comment.new(@worksheet, row, col, 'Test',
|
328
|
+
:x_scale => 3, :y_scale => 2).vertices
|
329
|
+
target = %w(
|
330
|
+
00 00 10 F0 12 00 00 00 03 00
|
331
|
+
01 00 F0 00 01 00 69 00 07 00 F0 00 0A 00 1E 00
|
332
|
+
).join(' ')
|
333
|
+
|
334
|
+
result = unpack_record(@worksheet.__send__("store_mso_client_anchor", 3, *vertices))
|
335
|
+
|
336
|
+
assert_equal(target, result, caption)
|
337
|
+
|
338
|
+
|
339
|
+
# width, height
|
340
|
+
row, col = @worksheet.__send__("substitute_cellref", range)
|
341
|
+
vertices = Writeexcel::Worksheet::Comment.new(@worksheet, row, col, 'Test',
|
342
|
+
:width => 384, :height => 148).vertices
|
343
|
+
target = %w(
|
344
|
+
00 00 10 F0 12 00 00 00 03 00
|
345
|
+
01 00 F0 00 01 00 69 00 07 00 F0 00 0A 00 1E 00
|
346
|
+
).join(' ')
|
347
|
+
|
348
|
+
result = unpack_record(@worksheet.__send__("store_mso_client_anchor", 3, *vertices))
|
349
|
+
|
350
|
+
assert_equal(target, result, caption)
|
351
|
+
|
352
|
+
end
|
353
|
+
|
354
|
+
def test_for_store_mso_client_anchor_where_column_widths_have_changed
|
355
|
+
# set_column G:G
|
356
|
+
range = 'F3'
|
357
|
+
@worksheet.set_column('G:G', 20)
|
358
|
+
|
359
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s). Col width changes.", range)
|
360
|
+
row, col = @worksheet.__send__("substitute_cellref", range)
|
361
|
+
vertices = Writeexcel::Worksheet::Comment.new(@worksheet, row, col, 'Test').vertices
|
362
|
+
|
363
|
+
target = %w(
|
364
|
+
00 00 10 F0 12 00
|
365
|
+
00 00 03 00 06 00 6A 00 01 00 69 00 06 00 F2 03
|
366
|
+
05 00 C4 00
|
367
|
+
).join(' ')
|
368
|
+
|
369
|
+
result = unpack_record(@worksheet.__send__("store_mso_client_anchor", 3, *vertices))
|
370
|
+
|
371
|
+
assert_equal(target, result, caption)
|
372
|
+
|
373
|
+
|
374
|
+
# set_column L:O
|
375
|
+
range = 'K3'
|
376
|
+
@worksheet.set_column('L:O', 4)
|
377
|
+
|
378
|
+
row, col = @worksheet.__send__("substitute_cellref", range)
|
379
|
+
vertices = Writeexcel::Worksheet::Comment.new(@worksheet, row, col, 'Test').vertices
|
380
|
+
|
381
|
+
target = %w(
|
382
|
+
00 00 10 F0 12 00
|
383
|
+
00 00 03 00 0B 00 D1 01 01 00 69 00 0F 00 B0 00
|
384
|
+
05 00 C4 00
|
385
|
+
).join(' ')
|
386
|
+
|
387
|
+
result = unpack_record(@worksheet.__send__("store_mso_client_anchor", 3, *vertices))
|
388
|
+
|
389
|
+
assert_equal(target, result, caption)
|
390
|
+
|
391
|
+
end
|
392
|
+
|
393
|
+
def test_for_store_mso_client_anchor_where_row_height_have_changed
|
394
|
+
# set_row 5 to 8
|
395
|
+
range = 'A6'
|
396
|
+
@worksheet.set_row(5, 6)
|
397
|
+
@worksheet.set_row(6, 6)
|
398
|
+
@worksheet.set_row(7, 6)
|
399
|
+
@worksheet.set_row(8, 6)
|
400
|
+
|
401
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s). Row height changed.", range)
|
402
|
+
row, col = @worksheet.__send__("substitute_cellref", range)
|
403
|
+
vertices = Writeexcel::Worksheet::Comment.new(@worksheet, row, col, 'Test').vertices
|
404
|
+
|
405
|
+
target = %w(
|
406
|
+
00 00 10 F0 12 00
|
407
|
+
00 00 03 00 01 00 F0 00 04 00 69 00 03 00 F0 00
|
408
|
+
0A 00 E2 00
|
409
|
+
).join(' ')
|
410
|
+
|
411
|
+
result = unpack_record(@worksheet.__send__("store_mso_client_anchor", 3, *vertices))
|
412
|
+
|
413
|
+
assert_equal(target, result, caption)
|
414
|
+
|
415
|
+
|
416
|
+
# set_row 14
|
417
|
+
range = 'A15'
|
418
|
+
@worksheet.set_row(14, 60)
|
419
|
+
|
420
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s). Row height changed.", range)
|
421
|
+
row, col = @worksheet.__send__("substitute_cellref", range)
|
422
|
+
vertices = Writeexcel::Worksheet::Comment.new(@worksheet, row, col, 'Test').vertices
|
423
|
+
|
424
|
+
target = %w(
|
425
|
+
00 00 10 F0 12 00
|
426
|
+
00 00 03 00 01 00 F0 00 0D 00 69 00 03 00 F0 00
|
427
|
+
0E 00 CD 00
|
428
|
+
).join(' ')
|
429
|
+
|
430
|
+
result = unpack_record(@worksheet.__send__("store_mso_client_anchor", 3, *vertices))
|
431
|
+
|
432
|
+
assert_equal(target, result, caption)
|
433
|
+
|
434
|
+
end
|
435
|
+
|
436
|
+
=begin
|
437
|
+
def test_for_the_generic_method
|
438
|
+
data_for_test.each do |data|
|
439
|
+
caption = data.shift
|
440
|
+
target = data.pop
|
441
|
+
|
442
|
+
data[3].gsub!(/ /,'')
|
443
|
+
data[3] = [data[3]].pack('H*')
|
444
|
+
|
445
|
+
caption = sprintf(" \t_add_mso_generic(): (0x%04X) %s", data[0], caption)
|
446
|
+
|
447
|
+
result = unpack_record(@worksheet.add_mso_generic(*data))
|
448
|
+
|
449
|
+
assert_equal(target, result, caption)
|
450
|
+
end
|
451
|
+
end
|
452
|
+
|
453
|
+
def test_for_store_mso_dgg_container
|
454
|
+
caption = sprintf(" \t_store_mso_dgg_container()")
|
455
|
+
target = %w( 0F 00 00 F0 52 00 00 00 ).join(' ')
|
456
|
+
|
457
|
+
@workbook.mso_size = 94
|
458
|
+
result = unpack_record(@workbook.store_mso_dgg_container)
|
459
|
+
|
460
|
+
assert_equal(target, result, caption)
|
461
|
+
end
|
462
|
+
|
463
|
+
def test_for_store_mso_opt
|
464
|
+
caption = sprintf(" \t_store_mso_opt()")
|
465
|
+
target = %w( 33 00 0B F0
|
466
|
+
12 00 00 00 BF 00 08 00 08 00 81 01 09 00 00 08
|
467
|
+
C0 01 40 00 00 08
|
468
|
+
).join(' ')
|
469
|
+
|
470
|
+
result = unpack_record(@workbook.store_mso_opt)
|
471
|
+
|
472
|
+
assert_equal(target, result, caption)
|
473
|
+
end
|
474
|
+
|
475
|
+
def test_for_store_mso_split_menu_colors
|
476
|
+
caption = sprintf(" \t_store_mso_split_menu_colors()")
|
477
|
+
target = %w( 40 00 1E F1 10 00 00 00 0D 00
|
478
|
+
00 08 0C 00 00 08 17 00 00 08 F7 00 00 10
|
479
|
+
).join(' ')
|
480
|
+
|
481
|
+
result = unpack_record(@workbook.store_mso_split_menu_colors)
|
482
|
+
|
483
|
+
assert_equal(target, result, caption)
|
484
|
+
end
|
485
|
+
|
486
|
+
###############################################################################
|
487
|
+
#
|
488
|
+
# Unpack the binary data into a format suitable for printing in tests.
|
489
|
+
#
|
490
|
+
def unpack_record(data)
|
491
|
+
data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
|
492
|
+
end
|
493
|
+
|
494
|
+
def data_for_test
|
495
|
+
return [
|
496
|
+
[ 'DggContainer', # Caption
|
497
|
+
0xF000, # Type
|
498
|
+
15, # Version
|
499
|
+
0, # Instance
|
500
|
+
'', # Data
|
501
|
+
82, # Length
|
502
|
+
'0F 00 00 F0 52 00 00 00', # Target
|
503
|
+
],
|
504
|
+
|
505
|
+
[ 'DgContainer', # Caption
|
506
|
+
0xF002, # Type
|
507
|
+
15, # Version
|
508
|
+
0, # Instance
|
509
|
+
'', # Data
|
510
|
+
328, # Length
|
511
|
+
'0F 00 02 F0 48 01 00 00', # Target
|
512
|
+
],
|
513
|
+
|
514
|
+
[ 'SpgrContainer', # Caption
|
515
|
+
0xF003, # Type
|
516
|
+
15, # Version
|
517
|
+
0, # Instance
|
518
|
+
'', # Data
|
519
|
+
304, # Length
|
520
|
+
'0F 00 03 F0 30 01 00 00', # Target
|
521
|
+
],
|
522
|
+
|
523
|
+
[ 'SpContainer', # Caption
|
524
|
+
0xF004, # Type
|
525
|
+
15, # Version
|
526
|
+
0, # Instance
|
527
|
+
'', # Data
|
528
|
+
40, # Length
|
529
|
+
'0F 00 04 F0 28 00 00 00', # Target
|
530
|
+
],
|
531
|
+
|
532
|
+
[ 'Dgg', # Caption
|
533
|
+
0xF006, # Type
|
534
|
+
0, # Version
|
535
|
+
0, # Instance
|
536
|
+
'02 04 00 00 02 00 00 00 ' + # Data
|
537
|
+
'02 00 00 00 01 00 00 00 ' +
|
538
|
+
'01 00 00 00 02 00 00 00',
|
539
|
+
nil, # Length
|
540
|
+
'00 00 06 F0 18 00 00 00 ' + # Target
|
541
|
+
'02 04 00 00 02 00 00 00 ' +
|
542
|
+
'02 00 00 00 01 00 00 00 ' +
|
543
|
+
'01 00 00 00 02 00 00 00',
|
544
|
+
],
|
545
|
+
|
546
|
+
[ 'Dg', # Caption
|
547
|
+
0xF008, # Type
|
548
|
+
0, # Version
|
549
|
+
1, # Instance
|
550
|
+
'03 00 00 00 02 04 00 00', # Data
|
551
|
+
nil, # Length
|
552
|
+
'10 00 08 F0 08 00 00 00 ' + # Target
|
553
|
+
'03 00 00 00 02 04 00 00',
|
554
|
+
],
|
555
|
+
|
556
|
+
[ 'Spgr', # Caption
|
557
|
+
0xF009, # Type
|
558
|
+
1, # Version
|
559
|
+
0, # Instance
|
560
|
+
'00 0E 00 0E 40 41 00 00 ' + # Data
|
561
|
+
'00 0E 00 0E 40 41 00 00',
|
562
|
+
nil, # Length
|
563
|
+
'01 00 09 F0 10 00 00 00 ' + # Target
|
564
|
+
'00 0E 00 0E 40 41 00 00 ' +
|
565
|
+
'00 0E 00 0E 40 41 00 00',
|
566
|
+
],
|
567
|
+
|
568
|
+
[ 'ClientTextbox', # Caption
|
569
|
+
0xF00D, # Type
|
570
|
+
0, # Version
|
571
|
+
0, # Instance
|
572
|
+
'', # Data
|
573
|
+
nil, # Length
|
574
|
+
'00 00 0D F0 00 00 00 00', # Target
|
575
|
+
],
|
576
|
+
|
577
|
+
[ 'ClientAnchor', # Caption
|
578
|
+
0xF010, # Type
|
579
|
+
0, # Version
|
580
|
+
0, # Instance
|
581
|
+
'03 00 01 00 F0 00 01 00 ' + # Data
|
582
|
+
'69 00 03 00 F0 00 05 00 ' +
|
583
|
+
'C4 00',
|
584
|
+
nil, # Length
|
585
|
+
'00 00 10 F0 12 00 00 00 ' + # Target
|
586
|
+
'03 00 01 00 F0 00 01 00 ' +
|
587
|
+
'69 00 03 00 F0 00 05 00 ' +
|
588
|
+
'C4 00',
|
589
|
+
],
|
590
|
+
|
591
|
+
[ 'ClientData', # Caption
|
592
|
+
0xF011, # Type
|
593
|
+
0, # Version
|
594
|
+
0, # Instance
|
595
|
+
'', # Data
|
596
|
+
nil, # Length
|
597
|
+
'00 00 11 F0 00 00 00 00', # Target
|
598
|
+
],
|
599
|
+
|
600
|
+
[ 'SplitMenuColors', # Caption
|
601
|
+
0xF11E, # Type
|
602
|
+
0, # Version
|
603
|
+
4, # Instance
|
604
|
+
'0D 00 00 08 0C 00 00 08 ' + # Data
|
605
|
+
'17 00 00 08 F7 00 00 10',
|
606
|
+
nil, # Length
|
607
|
+
'40 00 1E F1 10 00 00 00 ' + # Target
|
608
|
+
'0D 00 00 08 0C 00 00 08 ' +
|
609
|
+
'17 00 00 08 F7 00 00 10',
|
610
|
+
],
|
611
|
+
|
612
|
+
[ 'BstoreContainer', # Caption
|
613
|
+
0xF001, # Type
|
614
|
+
15, # Version
|
615
|
+
1, # Instance
|
616
|
+
'', # Data
|
617
|
+
163, # Length
|
618
|
+
'1F 00 01 F0 A3 00 00 00', # Target
|
619
|
+
],
|
620
|
+
]
|
621
|
+
end
|
622
|
+
=end
|
623
|
+
|
624
|
+
end
|