ricardoo27-writeexcel 0.6.12.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (245) hide show
  1. data/.document +5 -0
  2. data/.gitattributes +1 -0
  3. data/README.rdoc +136 -0
  4. data/Rakefile +52 -0
  5. data/VERSION +1 -0
  6. data/charts/chartex.rb +316 -0
  7. data/charts/demo1.rb +46 -0
  8. data/charts/demo101.bin +0 -0
  9. data/charts/demo2.rb +65 -0
  10. data/charts/demo201.bin +0 -0
  11. data/charts/demo3.rb +117 -0
  12. data/charts/demo301.bin +0 -0
  13. data/charts/demo4.rb +119 -0
  14. data/charts/demo401.bin +0 -0
  15. data/charts/demo5.rb +48 -0
  16. data/charts/demo501.bin +0 -0
  17. data/examples/a_simple.rb +43 -0
  18. data/examples/autofilter.rb +265 -0
  19. data/examples/bigfile.rb +30 -0
  20. data/examples/chart_area.rb +121 -0
  21. data/examples/chart_bar.rb +120 -0
  22. data/examples/chart_column.rb +120 -0
  23. data/examples/chart_line.rb +120 -0
  24. data/examples/chart_pie.rb +108 -0
  25. data/examples/chart_scatter.rb +121 -0
  26. data/examples/chart_stock.rb +148 -0
  27. data/examples/chess.rb +142 -0
  28. data/examples/colors.rb +129 -0
  29. data/examples/comments1.rb +27 -0
  30. data/examples/comments2.rb +352 -0
  31. data/examples/copyformat.rb +52 -0
  32. data/examples/data_validate.rb +279 -0
  33. data/examples/date_time.rb +87 -0
  34. data/examples/defined_name.rb +32 -0
  35. data/examples/demo.rb +124 -0
  36. data/examples/diag_border.rb +36 -0
  37. data/examples/formats.rb +490 -0
  38. data/examples/formula_result.rb +30 -0
  39. data/examples/header.rb +137 -0
  40. data/examples/hide_sheet.rb +29 -0
  41. data/examples/hyperlink.rb +43 -0
  42. data/examples/images.rb +63 -0
  43. data/examples/indent.rb +31 -0
  44. data/examples/merge1.rb +40 -0
  45. data/examples/merge2.rb +45 -0
  46. data/examples/merge3.rb +66 -0
  47. data/examples/merge4.rb +83 -0
  48. data/examples/merge5.rb +80 -0
  49. data/examples/merge6.rb +67 -0
  50. data/examples/outline.rb +255 -0
  51. data/examples/outline_collapsed.rb +209 -0
  52. data/examples/panes.rb +113 -0
  53. data/examples/password_protection.rb +33 -0
  54. data/examples/properties.rb +34 -0
  55. data/examples/properties_jp.rb +33 -0
  56. data/examples/protection.rb +47 -0
  57. data/examples/regions.rb +53 -0
  58. data/examples/repeat.rb +43 -0
  59. data/examples/republic.png +0 -0
  60. data/examples/right_to_left.rb +27 -0
  61. data/examples/row_wrap.rb +53 -0
  62. data/examples/set_first_sheet.rb +14 -0
  63. data/examples/stats.rb +74 -0
  64. data/examples/stocks.rb +81 -0
  65. data/examples/store_formula.rb +15 -0
  66. data/examples/tab_colors.rb +31 -0
  67. data/examples/utf8.rb +15 -0
  68. data/examples/write_arrays.rb +83 -0
  69. data/html/en/doc_en.html +5946 -0
  70. data/html/images/a_simple.jpg +0 -0
  71. data/html/images/area1.jpg +0 -0
  72. data/html/images/bar1.jpg +0 -0
  73. data/html/images/chart_area.xls +0 -0
  74. data/html/images/column1.jpg +0 -0
  75. data/html/images/data_validation.jpg +0 -0
  76. data/html/images/line1.jpg +0 -0
  77. data/html/images/pie1.jpg +0 -0
  78. data/html/images/regions.jpg +0 -0
  79. data/html/images/scatter1.jpg +0 -0
  80. data/html/images/stats.jpg +0 -0
  81. data/html/images/stock1.jpg +0 -0
  82. data/html/images/stocks.jpg +0 -0
  83. data/html/index.html +16 -0
  84. data/html/style.css +433 -0
  85. data/lib/writeexcel.rb +1159 -0
  86. data/lib/writeexcel/biffwriter.rb +223 -0
  87. data/lib/writeexcel/caller_info.rb +12 -0
  88. data/lib/writeexcel/cell_range.rb +332 -0
  89. data/lib/writeexcel/chart.rb +1968 -0
  90. data/lib/writeexcel/charts/area.rb +154 -0
  91. data/lib/writeexcel/charts/bar.rb +177 -0
  92. data/lib/writeexcel/charts/column.rb +156 -0
  93. data/lib/writeexcel/charts/external.rb +66 -0
  94. data/lib/writeexcel/charts/line.rb +154 -0
  95. data/lib/writeexcel/charts/pie.rb +169 -0
  96. data/lib/writeexcel/charts/scatter.rb +192 -0
  97. data/lib/writeexcel/charts/stock.rb +213 -0
  98. data/lib/writeexcel/col_info.rb +87 -0
  99. data/lib/writeexcel/colors.rb +68 -0
  100. data/lib/writeexcel/comments.rb +460 -0
  101. data/lib/writeexcel/compatibility.rb +65 -0
  102. data/lib/writeexcel/convert_date_time.rb +117 -0
  103. data/lib/writeexcel/data_validations.rb +370 -0
  104. data/lib/writeexcel/debug_info.rb +41 -0
  105. data/lib/writeexcel/embedded_chart.rb +35 -0
  106. data/lib/writeexcel/excelformula.y +139 -0
  107. data/lib/writeexcel/excelformulaparser.rb +587 -0
  108. data/lib/writeexcel/format.rb +1575 -0
  109. data/lib/writeexcel/formula.rb +987 -0
  110. data/lib/writeexcel/helper.rb +78 -0
  111. data/lib/writeexcel/image.rb +218 -0
  112. data/lib/writeexcel/olewriter.rb +305 -0
  113. data/lib/writeexcel/outline.rb +24 -0
  114. data/lib/writeexcel/properties.rb +242 -0
  115. data/lib/writeexcel/shared_string_table.rb +153 -0
  116. data/lib/writeexcel/storage_lite.rb +984 -0
  117. data/lib/writeexcel/workbook.rb +2478 -0
  118. data/lib/writeexcel/worksheet.rb +6925 -0
  119. data/lib/writeexcel/worksheets.rb +25 -0
  120. data/lib/writeexcel/write_file.rb +63 -0
  121. data/test/excelfile/Chart1.xls +0 -0
  122. data/test/excelfile/Chart2.xls +0 -0
  123. data/test/excelfile/Chart3.xls +0 -0
  124. data/test/excelfile/Chart4.xls +0 -0
  125. data/test/excelfile/Chart5.xls +0 -0
  126. data/test/helper.rb +31 -0
  127. data/test/perl_output/Chart1.xls.data +0 -0
  128. data/test/perl_output/Chart2.xls.data +0 -0
  129. data/test/perl_output/Chart3.xls.data +0 -0
  130. data/test/perl_output/Chart4.xls.data +0 -0
  131. data/test/perl_output/Chart5.xls.data +0 -0
  132. data/test/perl_output/README +31 -0
  133. data/test/perl_output/a_simple.xls +0 -0
  134. data/test/perl_output/autofilter.xls +0 -0
  135. data/test/perl_output/biff_add_continue_testdata +0 -0
  136. data/test/perl_output/chart_area.xls +0 -0
  137. data/test/perl_output/chart_bar.xls +0 -0
  138. data/test/perl_output/chart_column.xls +0 -0
  139. data/test/perl_output/chart_line.xls +0 -0
  140. data/test/perl_output/chess.xls +0 -0
  141. data/test/perl_output/colors.xls +0 -0
  142. data/test/perl_output/comments0.xls +0 -0
  143. data/test/perl_output/comments1.xls +0 -0
  144. data/test/perl_output/comments2.xls +0 -0
  145. data/test/perl_output/data_validate.xls +0 -0
  146. data/test/perl_output/date_time.xls +0 -0
  147. data/test/perl_output/defined_name.xls +0 -0
  148. data/test/perl_output/demo.xls +0 -0
  149. data/test/perl_output/demo101.bin +0 -0
  150. data/test/perl_output/demo201.bin +0 -0
  151. data/test/perl_output/demo301.bin +0 -0
  152. data/test/perl_output/demo401.bin +0 -0
  153. data/test/perl_output/demo501.bin +0 -0
  154. data/test/perl_output/diag_border.xls +0 -0
  155. data/test/perl_output/f_font_biff +0 -0
  156. data/test/perl_output/f_font_key +1 -0
  157. data/test/perl_output/f_xf_biff +0 -0
  158. data/test/perl_output/file_font_biff +0 -0
  159. data/test/perl_output/file_font_key +1 -0
  160. data/test/perl_output/file_xf_biff +0 -0
  161. data/test/perl_output/formula_result.xls +0 -0
  162. data/test/perl_output/headers.xls +0 -0
  163. data/test/perl_output/hidden.xls +0 -0
  164. data/test/perl_output/hide_zero.xls +0 -0
  165. data/test/perl_output/hyperlink.xls +0 -0
  166. data/test/perl_output/images.xls +0 -0
  167. data/test/perl_output/indent.xls +0 -0
  168. data/test/perl_output/merge1.xls +0 -0
  169. data/test/perl_output/merge2.xls +0 -0
  170. data/test/perl_output/merge3.xls +0 -0
  171. data/test/perl_output/merge4.xls +0 -0
  172. data/test/perl_output/merge5.xls +0 -0
  173. data/test/perl_output/merge6.xls +0 -0
  174. data/test/perl_output/ole_write_header +0 -0
  175. data/test/perl_output/outline.xls +0 -0
  176. data/test/perl_output/outline_collapsed.xls +0 -0
  177. data/test/perl_output/panes.xls +0 -0
  178. data/test/perl_output/password_protection.xls +0 -0
  179. data/test/perl_output/protection.xls +0 -0
  180. data/test/perl_output/regions.xls +0 -0
  181. data/test/perl_output/right_to_left.xls +0 -0
  182. data/test/perl_output/set_first_sheet.xls +0 -0
  183. data/test/perl_output/stats.xls +0 -0
  184. data/test/perl_output/stocks.xls +0 -0
  185. data/test/perl_output/store_formula.xls +0 -0
  186. data/test/perl_output/tab_colors.xls +0 -0
  187. data/test/perl_output/unicode_cyrillic.xls +0 -0
  188. data/test/perl_output/utf8.xls +0 -0
  189. data/test/perl_output/workbook1.xls +0 -0
  190. data/test/perl_output/workbook2.xls +0 -0
  191. data/test/perl_output/ws_colinfo +1 -0
  192. data/test/perl_output/ws_store_colinfo +0 -0
  193. data/test/perl_output/ws_store_dimensions +0 -0
  194. data/test/perl_output/ws_store_filtermode +0 -0
  195. data/test/perl_output/ws_store_filtermode_off +0 -0
  196. data/test/perl_output/ws_store_filtermode_on +0 -0
  197. data/test/perl_output/ws_store_selection +0 -0
  198. data/test/perl_output/ws_store_window2 +1 -0
  199. data/test/republic.png +0 -0
  200. data/test/test_00_IEEE_double.rb +13 -0
  201. data/test/test_01_add_worksheet.rb +10 -0
  202. data/test/test_02_merge_formats.rb +49 -0
  203. data/test/test_04_dimensions.rb +388 -0
  204. data/test/test_05_rows.rb +175 -0
  205. data/test/test_06_extsst.rb +74 -0
  206. data/test/test_11_date_time.rb +475 -0
  207. data/test/test_12_date_only.rb +525 -0
  208. data/test/test_13_date_seconds.rb +477 -0
  209. data/test/test_21_escher.rb +624 -0
  210. data/test/test_22_mso_drawing_group.rb +741 -0
  211. data/test/test_23_note.rb +57 -0
  212. data/test/test_24_txo.rb +74 -0
  213. data/test/test_25_position_object.rb +80 -0
  214. data/test/test_26_autofilter.rb +309 -0
  215. data/test/test_27_autofilter.rb +126 -0
  216. data/test/test_28_autofilter.rb +156 -0
  217. data/test/test_29_process_jpg.rb +670 -0
  218. data/test/test_30_validation_dval.rb +74 -0
  219. data/test/test_31_validation_dv_strings.rb +123 -0
  220. data/test/test_32_validation_dv_formula.rb +203 -0
  221. data/test/test_40_property_types.rb +188 -0
  222. data/test/test_41_properties.rb +235 -0
  223. data/test/test_42_set_properties.rb +434 -0
  224. data/test/test_50_name_stored.rb +295 -0
  225. data/test/test_51_name_print_area.rb +353 -0
  226. data/test/test_52_name_print_titles.rb +450 -0
  227. data/test/test_53_autofilter.rb +199 -0
  228. data/test/test_60_chart_generic.rb +574 -0
  229. data/test/test_61_chart_subclasses.rb +84 -0
  230. data/test/test_62_chart_formats.rb +268 -0
  231. data/test/test_63_chart_area_formats.rb +645 -0
  232. data/test/test_biff.rb +71 -0
  233. data/test/test_big_workbook.rb +17 -0
  234. data/test/test_compatibility.rb +12 -0
  235. data/test/test_example_match.rb +3246 -0
  236. data/test/test_format.rb +1189 -0
  237. data/test/test_formula.rb +61 -0
  238. data/test/test_ole.rb +102 -0
  239. data/test/test_storage_lite.rb +116 -0
  240. data/test/test_workbook.rb +146 -0
  241. data/test/test_worksheet.rb +106 -0
  242. data/utils/add_magic_comment.rb +80 -0
  243. data/writeexcel.gemspec +278 -0
  244. data/writeexcel.rdoc +1425 -0
  245. metadata +292 -0
@@ -0,0 +1,235 @@
1
+ # -*- coding: utf-8 -*-
2
+ ##########################################################################
3
+ # test_41_properties.rb
4
+ #
5
+ # Tests for OLE property sets.
6
+ #
7
+ # reverse('©'), September 2005, John McNamara, jmcnamara@cpan.org
8
+ #
9
+ # original written in Perl by John McNamara
10
+ # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
11
+ #
12
+ #########################################################################
13
+ require 'helper'
14
+
15
+ class TC_properties < Test::Unit::TestCase
16
+
17
+ def setup
18
+ @smiley = '☺' # chr 0x263A; in perl
19
+ end
20
+
21
+ def test_codepage_only
22
+ properties = [[0x0001, 'VT_I2', 0x04E4]]
23
+ caption = " \tDoc properties: _create_property_set('Code page')"
24
+ target = %w(
25
+ FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
26
+ 00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
27
+ F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
28
+ 18 00 00 00 01 00 00 00 01 00 00 00 10 00 00 00
29
+ 02 00 00 00 E4 04 00 00
30
+ ).join(' ')
31
+
32
+ result = unpack_record( create_summary_property_set(properties))
33
+ assert_equal(target, result, caption)
34
+ end
35
+
36
+ def test_same_as_previous_plus_title
37
+ properties = [
38
+ [0x0001, 'VT_I2', 0x04E4 ],
39
+ [0x0002, 'VT_LPSTR', 'Title'],
40
+ ]
41
+ caption = " \tDoc properties: _create_property_set('+ Title')"
42
+ target = %w(
43
+ FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
44
+ 00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
45
+ F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
46
+ 30 00 00 00 02 00 00 00 01 00 00 00 18 00 00 00
47
+ 02 00 00 00 20 00 00 00 02 00 00 00 E4 04 00 00
48
+ 1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
49
+ ).join(' ')
50
+
51
+ result = unpack_record( create_summary_property_set(properties))
52
+ assert_equal(target, result, caption)
53
+ end
54
+
55
+ def test_same_as_previous_plus_subject
56
+ properties = [
57
+ [0x0001, 'VT_I2', 0x04E4 ],
58
+ [0x0002, 'VT_LPSTR', 'Title'],
59
+ [0x0003, 'VT_LPSTR', 'Subject'],
60
+ ]
61
+ caption = " \tDoc properties: _create_property_set('+ Subject')"
62
+ target = %w(
63
+ FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
64
+ 00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
65
+ F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
66
+ 48 00 00 00 03 00 00 00 01 00 00 00 20 00 00 00
67
+ 02 00 00 00 28 00 00 00 03 00 00 00 38 00 00 00
68
+ 02 00 00 00 E4 04 00 00 1E 00 00 00 06 00 00 00
69
+ 54 69 74 6C 65 00 00 00 1E 00 00 00 08 00 00 00
70
+ 53 75 62 6A 65 63 74 00
71
+ ).join(' ')
72
+
73
+ result = unpack_record( create_summary_property_set(properties))
74
+ assert_equal(target, result, caption)
75
+ end
76
+
77
+ def test_same_as_previous_plus_author
78
+ properties = [
79
+ [0x0001, 'VT_I2', 0x04E4 ],
80
+ [0x0002, 'VT_LPSTR', 'Title'],
81
+ [0x0003, 'VT_LPSTR', 'Subject'],
82
+ [0x0004, 'VT_LPSTR', 'Author' ],
83
+ ]
84
+ caption = " \tDoc properties: _create_property_set('+ Keywords')"
85
+ target = %w(
86
+ FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
87
+ 00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
88
+ F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
89
+ 60 00 00 00 04 00 00 00 01 00 00 00 28 00 00 00
90
+ 02 00 00 00 30 00 00 00 03 00 00 00 40 00 00 00
91
+ 04 00 00 00 50 00 00 00 02 00 00 00 E4 04 00 00
92
+ 1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
93
+ 1E 00 00 00 08 00 00 00 53 75 62 6A 65 63 74 00
94
+ 1E 00 00 00 07 00 00 00 41 75 74 68 6F 72 00 00
95
+ ).join(' ')
96
+
97
+ result = unpack_record( create_summary_property_set(properties))
98
+ assert_equal(target, result, caption)
99
+ end
100
+
101
+ def test_same_as_previous_plus_keywords
102
+ properties = [
103
+ [0x0001, 'VT_I2', 0x04E4 ],
104
+ [0x0002, 'VT_LPSTR', 'Title'],
105
+ [0x0003, 'VT_LPSTR', 'Subject'],
106
+ [0x0004, 'VT_LPSTR', 'Author' ],
107
+ [0x0005, 'VT_LPSTR', 'Keywords'],
108
+ ]
109
+ caption = " \tDoc properties: _create_property_set('+ Keywords')"
110
+ target = %w(
111
+ FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
112
+ 00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
113
+ F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
114
+ 7C 00 00 00 05 00 00 00 01 00 00 00 30 00 00 00
115
+ 02 00 00 00 38 00 00 00 03 00 00 00 48 00 00 00
116
+ 04 00 00 00 58 00 00 00 05 00 00 00 68 00 00 00
117
+ 02 00 00 00 E4 04 00 00 1E 00 00 00 06 00 00 00
118
+ 54 69 74 6C 65 00 00 00 1E 00 00 00 08 00 00 00
119
+ 53 75 62 6A 65 63 74 00 1E 00 00 00 07 00 00 00
120
+ 41 75 74 68 6F 72 00 00 1E 00 00 00 09 00 00 00
121
+ 4B 65 79 77 6F 72 64 73 00 00 00 00
122
+ ).join(' ')
123
+
124
+ result = unpack_record( create_summary_property_set(properties))
125
+ assert_equal(target, result, caption)
126
+ end
127
+
128
+ def test_same_as_previous_plus_comments
129
+ properties = [
130
+ [0x0001, 'VT_I2', 0x04E4 ],
131
+ [0x0002, 'VT_LPSTR', 'Title'],
132
+ [0x0003, 'VT_LPSTR', 'Subject'],
133
+ [0x0004, 'VT_LPSTR', 'Author' ],
134
+ [0x0005, 'VT_LPSTR', 'Keywords'],
135
+ [0x0006, 'VT_LPSTR', 'Comments'],
136
+ ]
137
+ caption = " \tDoc properties: _create_property_set('+ Comments')"
138
+ target = %w(
139
+ FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
140
+ 00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
141
+ F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
142
+ 98 00 00 00 06 00 00 00 01 00 00 00 38 00 00 00
143
+ 02 00 00 00 40 00 00 00 03 00 00 00 50 00 00 00
144
+ 04 00 00 00 60 00 00 00 05 00 00 00 70 00 00 00
145
+ 06 00 00 00 84 00 00 00 02 00 00 00 E4 04 00 00
146
+ 1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
147
+ 1E 00 00 00 08 00 00 00 53 75 62 6A 65 63 74 00
148
+ 1E 00 00 00 07 00 00 00 41 75 74 68 6F 72 00 00
149
+ 1E 00 00 00 09 00 00 00 4B 65 79 77 6F 72 64 73
150
+ 00 00 00 00 1E 00 00 00 09 00 00 00 43 6F 6D 6D
151
+ 65 6E 74 73 00 00 00 00
152
+ ).join(' ')
153
+
154
+ result = unpack_record( create_summary_property_set(properties))
155
+ assert_equal(target, result, caption)
156
+ end
157
+
158
+ def test_same_as_previous_plus_last_author
159
+ properties = [
160
+ [0x0001, 'VT_I2', 0x04E4 ],
161
+ [0x0002, 'VT_LPSTR', 'Title'],
162
+ [0x0003, 'VT_LPSTR', 'Subject'],
163
+ [0x0004, 'VT_LPSTR', 'Author' ],
164
+ [0x0005, 'VT_LPSTR', 'Keywords'],
165
+ [0x0006, 'VT_LPSTR', 'Comments'],
166
+ [0x0008, 'VT_LPSTR', 'Username'],
167
+ ]
168
+ caption = " \tDoc properties: _create_property_set('+ Comments')"
169
+ target = %w(
170
+ FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
171
+ 00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
172
+ F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
173
+ B4 00 00 00 07 00 00 00 01 00 00 00 40 00 00 00
174
+ 02 00 00 00 48 00 00 00 03 00 00 00 58 00 00 00
175
+ 04 00 00 00 68 00 00 00 05 00 00 00 78 00 00 00
176
+ 06 00 00 00 8C 00 00 00 08 00 00 00 A0 00 00 00
177
+ 02 00 00 00 E4 04 00 00 1E 00 00 00 06 00 00 00
178
+ 54 69 74 6C 65 00 00 00 1E 00 00 00 08 00 00 00
179
+ 53 75 62 6A 65 63 74 00 1E 00 00 00 07 00 00 00
180
+ 41 75 74 68 6F 72 00 00 1E 00 00 00 09 00 00 00
181
+ 4B 65 79 77 6F 72 64 73 00 00 00 00 1E 00 00 00
182
+ 09 00 00 00 43 6F 6D 6D 65 6E 74 73 00 00 00 00
183
+ 1E 00 00 00 09 00 00 00 55 73 65 72 6E 61 6D 65
184
+ 00 00 00 00
185
+ ).join(' ')
186
+
187
+ result = unpack_record( create_summary_property_set(properties))
188
+ assert_equal(target, result, caption)
189
+ end
190
+
191
+ def test_same_as_previous_plus_creation_date
192
+ filetime = Time.gm(2008,8,19,23,20,13)
193
+ properties = [
194
+ [0x0001, 'VT_I2', 0x04E4 ],
195
+ [0x0002, 'VT_LPSTR', 'Title'],
196
+ [0x0003, 'VT_LPSTR', 'Subject'],
197
+ [0x0004, 'VT_LPSTR', 'Author' ],
198
+ [0x0005, 'VT_LPSTR', 'Keywords'],
199
+ [0x0006, 'VT_LPSTR', 'Comments'],
200
+ [0x0008, 'VT_LPSTR', 'Username'],
201
+ [0x000C, 'VT_FILETIME', filetime ],
202
+ ]
203
+ caption = " \tDoc properties: _create_property_set('+ Comments')"
204
+ target = %w(
205
+ FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
206
+ 00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
207
+ F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
208
+ C8 00 00 00 08 00 00 00 01 00 00 00 48 00 00 00
209
+ 02 00 00 00 50 00 00 00 03 00 00 00 60 00 00 00
210
+ 04 00 00 00 70 00 00 00 05 00 00 00 80 00 00 00
211
+ 06 00 00 00 94 00 00 00 08 00 00 00 A8 00 00 00
212
+ 0C 00 00 00 BC 00 00 00 02 00 00 00 E4 04 00 00
213
+ 1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
214
+ 1E 00 00 00 08 00 00 00 53 75 62 6A 65 63 74 00
215
+ 1E 00 00 00 07 00 00 00 41 75 74 68 6F 72 00 00
216
+ 1E 00 00 00 09 00 00 00 4B 65 79 77 6F 72 64 73
217
+ 00 00 00 00 1E 00 00 00 09 00 00 00 43 6F 6D 6D
218
+ 65 6E 74 73 00 00 00 00 1E 00 00 00 09 00 00 00
219
+ 55 73 65 72 6E 61 6D 65 00 00 00 00 40 00 00 00
220
+ 80 74 89 21 52 02 C9 01
221
+ ).join(' ')
222
+
223
+ result = unpack_record( create_summary_property_set(properties))
224
+ assert_equal(target, result, caption)
225
+ end
226
+
227
+ ###############################################################################
228
+ #
229
+ # Unpack the binary data into a format suitable for printing in tests.
230
+ #
231
+ def unpack_record(data)
232
+ data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
233
+ end
234
+
235
+ end
@@ -0,0 +1,434 @@
1
+ # -*- coding: utf-8 -*-
2
+ ##########################################################################
3
+ # test_42_set_properties.rb
4
+ #
5
+ # Tests for Workbook property_sets() interface.
6
+ #
7
+ # some test is commented out because related method was set to
8
+ # private method. Before that, all test passed.
9
+ #
10
+ #
11
+ #
12
+ #
13
+ # reverse('©'), September 2005, John McNamara, jmcnamara@cpan.org
14
+ #
15
+ # original written in Perl by John McNamara
16
+ # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
17
+ #
18
+ #########################################################################
19
+ require 'helper'
20
+ require 'stringio'
21
+
22
+ class TC_set_properties < Test::Unit::TestCase
23
+
24
+ def test_dummy
25
+ assert(true)
26
+ end
27
+
28
+ def setup
29
+ @test_file = StringIO.new
30
+ end
31
+
32
+ def test_same_as_previous_plus_creation_date
33
+ smiley = '☺' # chr 0x263A; in perl
34
+
35
+ workbook = WriteExcel.new(@test_file)
36
+ worksheet = workbook.add_worksheet
37
+
38
+ =begin
39
+ ###############################################################################
40
+ #
41
+ # Test 1. _get_property_set_codepage() for default latin1 strings.
42
+ #
43
+ params ={
44
+ :title => 'Title',
45
+ :subject => 'Subject',
46
+ :author => 'Author',
47
+ :keywords => 'Keywords',
48
+ :comments => 'Comments',
49
+ :last_author => 'Username',
50
+ }
51
+
52
+ strings = %w(title subject author keywords comments last_author)
53
+
54
+ caption = " \t_get_property_set_codepage('latin1')"
55
+ target = 0x04E4
56
+
57
+ result = workbook.get_property_set_codepage(params, strings)
58
+ assert_equal(target, result, caption)
59
+
60
+ ###############################################################################
61
+ #
62
+ # Test 2. _get_property_set_codepage() for manual utf8 strings.
63
+ #
64
+
65
+ params = {
66
+ :title => 'Title',
67
+ :subject => 'Subject',
68
+ :author => 'Author',
69
+ :keywords => 'Keywords',
70
+ :comments => 'Comments',
71
+ :last_author => 'Username',
72
+ :utf8 => 1,
73
+ }
74
+
75
+ strings = %w(title subject author keywords comments last_author)
76
+
77
+ caption = " \t_get_property_set_codepage('utf8')"
78
+ target = 0xFDE9
79
+
80
+ result = workbook.get_property_set_codepage(params, strings)
81
+ assert_equal(target, result, caption)
82
+
83
+ ###############################################################################
84
+ #
85
+ # Test 3. _get_property_set_codepage() for utf8 strings.
86
+ #
87
+ params = {
88
+ :title => 'Title' + smiley,
89
+ :subject => 'Subject',
90
+ :author => 'Author',
91
+ :keywords => 'Keywords',
92
+ :comments => 'Comments',
93
+ :last_author => 'Username',
94
+ }
95
+
96
+ strings = %w(title subject author keywords comments last_author)
97
+
98
+ caption = " \t_get_property_set_codepage('utf8')";
99
+ target = 0xFDE9;
100
+
101
+ result = workbook.get_property_set_codepage(params, strings)
102
+ assert_equal(target, result, caption)
103
+ =end
104
+
105
+ ###############################################################################
106
+ #
107
+ # Note, the "created => nil" parameters in some of the following tests is
108
+ # used to avoid adding the default date to the property sets.
109
+
110
+
111
+ ###############################################################################
112
+ #
113
+ # Test 4. Codepage only.
114
+ #
115
+
116
+ workbook.set_properties(
117
+ :created => nil
118
+ )
119
+
120
+ caption = " \tset_properties(codepage)"
121
+ target = %w(
122
+ FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
123
+ 00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
124
+ F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
125
+ 18 00 00 00 01 00 00 00 01 00 00 00 10 00 00 00
126
+ 02 00 00 00 E4 04 00 00
127
+ ).join(' ')
128
+
129
+ result = unpack_record(workbook.summary)
130
+ assert_equal(target, result, caption)
131
+
132
+ ###############################################################################
133
+ #
134
+ # Test 5. Same as previous + Title.
135
+ #
136
+
137
+ workbook.set_properties(
138
+ :title => 'Title',
139
+ :created => nil
140
+ )
141
+
142
+ caption = " \tset_properties('Title')"
143
+ target = %w(
144
+ FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
145
+ 00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
146
+ F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
147
+ 30 00 00 00 02 00 00 00 01 00 00 00 18 00 00 00
148
+ 02 00 00 00 20 00 00 00 02 00 00 00 E4 04 00 00
149
+ 1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
150
+ ).join(' ')
151
+
152
+ result = unpack_record(workbook.summary)
153
+ assert_equal(target, result, caption)
154
+
155
+ ###############################################################################
156
+ #
157
+ # Test 6. Same as previous + Subject.
158
+ #
159
+
160
+ workbook.set_properties(
161
+ :title => 'Title',
162
+ :subject => 'Subject',
163
+ :created => nil
164
+ )
165
+
166
+ caption = " \tset_properties('+ Subject')"
167
+ target = %w(
168
+ FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
169
+ 00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
170
+ F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
171
+ 48 00 00 00 03 00 00 00 01 00 00 00 20 00 00 00
172
+ 02 00 00 00 28 00 00 00 03 00 00 00 38 00 00 00
173
+ 02 00 00 00 E4 04 00 00 1E 00 00 00 06 00 00 00
174
+ 54 69 74 6C 65 00 00 00 1E 00 00 00 08 00 00 00
175
+ 53 75 62 6A 65 63 74 00
176
+ ).join(' ')
177
+
178
+ result = unpack_record(workbook.summary)
179
+ assert_equal(target, result, caption)
180
+
181
+ ###############################################################################
182
+ #
183
+ # Test 7. Same as previous + Author.
184
+ #
185
+
186
+ workbook.set_properties(
187
+ :title => 'Title',
188
+ :subject => 'Subject',
189
+ :author => 'Author',
190
+ :created => nil
191
+ )
192
+
193
+ caption = " \tset_properties('+ Author')"
194
+ target = %w(
195
+ FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
196
+ 00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
197
+ F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
198
+ 60 00 00 00 04 00 00 00 01 00 00 00 28 00 00 00
199
+ 02 00 00 00 30 00 00 00 03 00 00 00 40 00 00 00
200
+ 04 00 00 00 50 00 00 00 02 00 00 00 E4 04 00 00
201
+ 1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
202
+ 1E 00 00 00 08 00 00 00 53 75 62 6A 65 63 74 00
203
+ 1E 00 00 00 07 00 00 00 41 75 74 68 6F 72 00 00
204
+ ).join(' ')
205
+
206
+ result = unpack_record(workbook.summary)
207
+ assert_equal(target, result, caption)
208
+
209
+ ###############################################################################
210
+ #
211
+ # Test 8. Same as previous + Keywords.
212
+ #
213
+
214
+ workbook.set_properties(
215
+ :title => 'Title',
216
+ :subject => 'Subject',
217
+ :author => 'Author',
218
+ :keywords => 'Keywords',
219
+ :created => nil
220
+ )
221
+
222
+ caption = " \tset_properties('+ Keywords')"
223
+ target = %w(
224
+ FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
225
+ 00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
226
+ F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
227
+ 7C 00 00 00 05 00 00 00 01 00 00 00 30 00 00 00
228
+ 02 00 00 00 38 00 00 00 03 00 00 00 48 00 00 00
229
+ 04 00 00 00 58 00 00 00 05 00 00 00 68 00 00 00
230
+ 02 00 00 00 E4 04 00 00 1E 00 00 00 06 00 00 00
231
+ 54 69 74 6C 65 00 00 00 1E 00 00 00 08 00 00 00
232
+ 53 75 62 6A 65 63 74 00 1E 00 00 00 07 00 00 00
233
+ 41 75 74 68 6F 72 00 00 1E 00 00 00 09 00 00 00
234
+ 4B 65 79 77 6F 72 64 73 00 00 00 00
235
+ ).join(' ')
236
+
237
+ result = unpack_record(workbook.summary)
238
+ assert_equal(target, result, caption)
239
+
240
+ ###############################################################################
241
+ #
242
+ # Test 9. Same as previous + Comments.
243
+ #
244
+
245
+ workbook.set_properties(
246
+ :title => 'Title',
247
+ :subject => 'Subject',
248
+ :author => 'Author',
249
+ :keywords => 'Keywords',
250
+ :comments => 'Comments',
251
+ :created => nil
252
+ )
253
+
254
+ caption = " \tset_properties('+ Comments')"
255
+ target = %w(
256
+ FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
257
+ 00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
258
+ F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
259
+ 98 00 00 00 06 00 00 00 01 00 00 00 38 00 00 00
260
+ 02 00 00 00 40 00 00 00 03 00 00 00 50 00 00 00
261
+ 04 00 00 00 60 00 00 00 05 00 00 00 70 00 00 00
262
+ 06 00 00 00 84 00 00 00 02 00 00 00 E4 04 00 00
263
+ 1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
264
+ 1E 00 00 00 08 00 00 00 53 75 62 6A 65 63 74 00
265
+ 1E 00 00 00 07 00 00 00 41 75 74 68 6F 72 00 00
266
+ 1E 00 00 00 09 00 00 00 4B 65 79 77 6F 72 64 73
267
+ 00 00 00 00 1E 00 00 00 09 00 00 00 43 6F 6D 6D
268
+ 65 6E 74 73 00 00 00 00
269
+ ).join(' ')
270
+
271
+ result = unpack_record(workbook.summary)
272
+ assert_equal(target, result, caption)
273
+
274
+ ###############################################################################
275
+ #
276
+ # Test 10. Same as previous + Last author.
277
+ #
278
+
279
+ workbook.set_properties(
280
+ :title => 'Title',
281
+ :subject => 'Subject',
282
+ :author => 'Author',
283
+ :keywords => 'Keywords',
284
+ :comments => 'Comments',
285
+ :last_author => 'Username',
286
+ :created => nil
287
+ )
288
+
289
+ caption = " \tset_properties('+ Last author')"
290
+ target = %w(
291
+ FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
292
+ 00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
293
+ F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
294
+ B4 00 00 00 07 00 00 00 01 00 00 00 40 00 00 00
295
+ 02 00 00 00 48 00 00 00 03 00 00 00 58 00 00 00
296
+ 04 00 00 00 68 00 00 00 05 00 00 00 78 00 00 00
297
+ 06 00 00 00 8C 00 00 00 08 00 00 00 A0 00 00 00
298
+ 02 00 00 00 E4 04 00 00 1E 00 00 00 06 00 00 00
299
+ 54 69 74 6C 65 00 00 00 1E 00 00 00 08 00 00 00
300
+ 53 75 62 6A 65 63 74 00 1E 00 00 00 07 00 00 00
301
+ 41 75 74 68 6F 72 00 00 1E 00 00 00 09 00 00 00
302
+ 4B 65 79 77 6F 72 64 73 00 00 00 00 1E 00 00 00
303
+ 09 00 00 00 43 6F 6D 6D 65 6E 74 73 00 00 00 00
304
+ 1E 00 00 00 09 00 00 00 55 73 65 72 6E 61 6D 65
305
+ 00 00 00 00
306
+ ).join(' ')
307
+
308
+ result = unpack_record(workbook.summary)
309
+ assert_equal(target, result, caption)
310
+
311
+ ###############################################################################
312
+ #
313
+ # Test 11. Same as previous + Creation date.
314
+ #
315
+
316
+ # Aug 19 23:20:13 2008
317
+ # $sec,$min,$hour,$mday,$mon,$year
318
+ # We normalise the time using timegm() so that the tests don't fail due to
319
+ # different timezones.
320
+
321
+ filetime = Time.gm(2008,8,19,23,20,13)
322
+ workbook.set_properties(
323
+ :title => 'Title',
324
+ :subject => 'Subject',
325
+ :author => 'Author',
326
+ :keywords => 'Keywords',
327
+ :comments => 'Comments',
328
+ :last_author => 'Username',
329
+ :created => filetime
330
+ )
331
+
332
+ caption = " \tset_properties('+ Creation date')"
333
+ target = %w(
334
+ FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
335
+ 00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
336
+ F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
337
+ C8 00 00 00 08 00 00 00 01 00 00 00 48 00 00 00
338
+ 02 00 00 00 50 00 00 00 03 00 00 00 60 00 00 00
339
+ 04 00 00 00 70 00 00 00 05 00 00 00 80 00 00 00
340
+ 06 00 00 00 94 00 00 00 08 00 00 00 A8 00 00 00
341
+ 0C 00 00 00 BC 00 00 00 02 00 00 00 E4 04 00 00
342
+ 1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
343
+ 1E 00 00 00 08 00 00 00 53 75 62 6A 65 63 74 00
344
+ 1E 00 00 00 07 00 00 00 41 75 74 68 6F 72 00 00
345
+ 1E 00 00 00 09 00 00 00 4B 65 79 77 6F 72 64 73
346
+ 00 00 00 00 1E 00 00 00 09 00 00 00 43 6F 6D 6D
347
+ 65 6E 74 73 00 00 00 00 1E 00 00 00 09 00 00 00
348
+ 55 73 65 72 6E 61 6D 65 00 00 00 00 40 00 00 00
349
+ 80 74 89 21 52 02 C9 01
350
+ ).join(' ')
351
+
352
+ result = unpack_record(workbook.summary)
353
+ assert_equal(target, result, caption)
354
+
355
+ ###############################################################################
356
+ #
357
+ # Test 12. Same as previous. Date set at the workbook level.
358
+ #
359
+
360
+ # Wed Aug 20 00:20:13 2008
361
+ # $sec,$min,$hour,$mday,$mon,$year
362
+ # We normalise the time using timegm() so that the tests don't fail due to
363
+ # different timezones.
364
+ workbook.localtime = Time.gm(2008,8,19,23,20,13)
365
+
366
+ workbook.set_properties(
367
+ :title => 'Title',
368
+ :subject => 'Subject',
369
+ :author => 'Author',
370
+ :keywords => 'Keywords',
371
+ :comments => 'Comments',
372
+ :last_author => 'Username'
373
+ )
374
+
375
+ caption = " \tset_properties('+ Creation date')"
376
+ target = %w(
377
+ FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
378
+ 00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
379
+ F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
380
+ C8 00 00 00 08 00 00 00 01 00 00 00 48 00 00 00
381
+ 02 00 00 00 50 00 00 00 03 00 00 00 60 00 00 00
382
+ 04 00 00 00 70 00 00 00 05 00 00 00 80 00 00 00
383
+ 06 00 00 00 94 00 00 00 08 00 00 00 A8 00 00 00
384
+ 0C 00 00 00 BC 00 00 00 02 00 00 00 E4 04 00 00
385
+ 1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
386
+ 1E 00 00 00 08 00 00 00 53 75 62 6A 65 63 74 00
387
+ 1E 00 00 00 07 00 00 00 41 75 74 68 6F 72 00 00
388
+ 1E 00 00 00 09 00 00 00 4B 65 79 77 6F 72 64 73
389
+ 00 00 00 00 1E 00 00 00 09 00 00 00 43 6F 6D 6D
390
+ 65 6E 74 73 00 00 00 00 1E 00 00 00 09 00 00 00
391
+ 55 73 65 72 6E 61 6D 65 00 00 00 00 40 00 00 00
392
+ 80 74 89 21 52 02 C9 01
393
+ ).join(' ')
394
+
395
+ result = unpack_record(workbook.summary)
396
+ assert_equal(target, result, caption)
397
+
398
+ ###############################################################################
399
+ #
400
+ # Test 14. UTF-8 string used.
401
+ #
402
+
403
+ workbook.set_properties(
404
+ :title => 'Title' + smiley,
405
+ :created => nil
406
+ )
407
+
408
+ caption = " \tset_properties(utf8)"
409
+ target = %w(
410
+ FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
411
+ 00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
412
+ F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
413
+ 34 00 00 00 02 00 00 00 01 00 00 00 18 00 00 00
414
+ 02 00 00 00 20 00 00 00 02 00 00 00 E9 FD 00 00
415
+ 1E 00 00 00 09 00 00 00 54 69 74 6C 65 E2 98 BA
416
+ 00 00 00 00
417
+ ).join(' ')
418
+
419
+ result = unpack_record(workbook.summary)
420
+ assert_equal(target, result, caption)
421
+
422
+ workbook.close
423
+
424
+ end
425
+
426
+ ###############################################################################
427
+ #
428
+ # Unpack the binary data into a format suitable for printing in tests.
429
+ #
430
+ def unpack_record(data)
431
+ data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
432
+ end
433
+
434
+ end