writeexcel 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. data/.gitattributes +1 -1
  2. data/.gitignore +24 -24
  3. data/README.rdoc +34 -55
  4. data/VERSION +1 -1
  5. data/charts/chartex.rb +316 -316
  6. data/charts/demo1.rb +46 -46
  7. data/charts/demo2.rb +65 -65
  8. data/charts/demo3.rb +117 -117
  9. data/charts/demo4.rb +119 -119
  10. data/charts/demo5.rb +48 -48
  11. data/examples/a_simple.rb +43 -43
  12. data/examples/autofilter.rb +265 -265
  13. data/examples/bigfile.rb +30 -30
  14. data/examples/chart_area.rb +121 -121
  15. data/examples/chart_bar.rb +120 -120
  16. data/examples/chart_column.rb +120 -120
  17. data/examples/chart_line.rb +120 -120
  18. data/examples/chart_pie.rb +108 -108
  19. data/examples/chart_scatter.rb +121 -121
  20. data/examples/chart_stock.rb +148 -148
  21. data/examples/chess.rb +142 -142
  22. data/examples/colors.rb +129 -129
  23. data/examples/comments1.rb +27 -27
  24. data/examples/comments2.rb +352 -352
  25. data/examples/copyformat.rb +52 -52
  26. data/examples/data_validate.rb +279 -279
  27. data/examples/date_time.rb +87 -87
  28. data/examples/defined_name.rb +32 -32
  29. data/examples/demo.rb +124 -124
  30. data/examples/diag_border.rb +36 -36
  31. data/examples/formats.rb +490 -490
  32. data/examples/formula_result.rb +30 -30
  33. data/examples/header.rb +137 -137
  34. data/examples/hide_sheet.rb +29 -29
  35. data/examples/hyperlink.rb +43 -43
  36. data/examples/images.rb +63 -63
  37. data/examples/indent.rb +31 -31
  38. data/examples/merge1.rb +40 -40
  39. data/examples/merge2.rb +45 -45
  40. data/examples/merge3.rb +66 -66
  41. data/examples/merge4.rb +83 -83
  42. data/examples/merge5.rb +80 -80
  43. data/examples/merge6.rb +67 -67
  44. data/examples/outline.rb +255 -255
  45. data/examples/outline_collapsed.rb +209 -209
  46. data/examples/panes.rb +113 -113
  47. data/examples/properties.rb +34 -34
  48. data/examples/properties_jp.rb +33 -33
  49. data/examples/protection.rb +47 -47
  50. data/examples/regions.rb +53 -53
  51. data/examples/repeat.rb +43 -43
  52. data/examples/right_to_left.rb +27 -27
  53. data/examples/row_wrap.rb +53 -53
  54. data/examples/stats.rb +74 -74
  55. data/examples/stocks.rb +81 -81
  56. data/examples/tab_colors.rb +31 -31
  57. data/examples/utf8.rb +15 -15
  58. data/examples/write_arrays.rb +83 -83
  59. data/lib/writeexcel/biffwriter.rb +232 -232
  60. data/lib/writeexcel/caller_info.rb +12 -12
  61. data/lib/writeexcel/chart.rb +2190 -2177
  62. data/lib/writeexcel/charts/area.rb +154 -154
  63. data/lib/writeexcel/charts/bar.rb +177 -177
  64. data/lib/writeexcel/charts/column.rb +156 -156
  65. data/lib/writeexcel/charts/external.rb +66 -66
  66. data/lib/writeexcel/charts/line.rb +154 -154
  67. data/lib/writeexcel/charts/pie.rb +169 -169
  68. data/lib/writeexcel/charts/scatter.rb +192 -192
  69. data/lib/writeexcel/charts/stock.rb +213 -213
  70. data/lib/writeexcel/colors.rb +64 -64
  71. data/lib/writeexcel/compatibility.rb +0 -255
  72. data/lib/writeexcel/debug_info.rb +37 -33
  73. data/lib/writeexcel/excelformulaparser.rb +587 -587
  74. data/lib/writeexcel/format.rb +13 -4
  75. data/lib/writeexcel/formula.rb +26 -9
  76. data/lib/writeexcel/helper.rb +68 -64
  77. data/lib/writeexcel/olewriter.rb +311 -311
  78. data/lib/writeexcel/properties.rb +242 -240
  79. data/lib/writeexcel/storage_lite.rb +984 -978
  80. data/lib/writeexcel/workbook.rb +3210 -3192
  81. data/lib/writeexcel/worksheet.rb +143 -51
  82. data/lib/writeexcel/write_file.rb +44 -40
  83. data/lib/writeexcel.rb +1159 -1159
  84. data/test/helper.rb +31 -28
  85. data/test/perl_output/README +31 -31
  86. data/test/test_00_IEEE_double.rb +13 -13
  87. data/test/test_01_add_worksheet.rb +10 -10
  88. data/test/test_02_merge_formats.rb +53 -53
  89. data/test/test_04_dimensions.rb +392 -392
  90. data/test/test_05_rows.rb +179 -179
  91. data/test/test_06_extsst.rb +77 -77
  92. data/test/test_11_date_time.rb +479 -479
  93. data/test/test_12_date_only.rb +501 -501
  94. data/test/test_13_date_seconds.rb +481 -481
  95. data/test/test_21_escher.rb +637 -637
  96. data/test/test_22_mso_drawing_group.rb +745 -745
  97. data/test/test_23_note.rb +73 -73
  98. data/test/test_24_txo.rb +75 -75
  99. data/test/test_25_position_object.rb +84 -84
  100. data/test/test_26_autofilter.rb +314 -314
  101. data/test/test_27_autofilter.rb +131 -131
  102. data/test/test_28_autofilter.rb +161 -161
  103. data/test/test_29_process_jpg.rb +683 -683
  104. data/test/test_30_validation_dval.rb +77 -77
  105. data/test/test_31_validation_dv_strings.rb +126 -126
  106. data/test/test_32_validation_dv_formula.rb +206 -206
  107. data/test/test_40_property_types.rb +188 -188
  108. data/test/test_41_properties.rb +235 -235
  109. data/test/test_42_set_properties.rb +437 -437
  110. data/test/test_50_name_stored.rb +299 -299
  111. data/test/test_51_name_print_area.rb +357 -357
  112. data/test/test_52_name_print_titles.rb +454 -454
  113. data/test/test_53_autofilter.rb +203 -203
  114. data/test/test_60_chart_generic.rb +578 -578
  115. data/test/test_61_chart_subclasses.rb +95 -95
  116. data/test/test_62_chart_formats.rb +272 -272
  117. data/test/test_63_chart_area_formats.rb +649 -649
  118. data/test/test_biff.rb +75 -75
  119. data/test/test_compatibility.rb +12 -627
  120. data/test/test_example_match.rb +3144 -3144
  121. data/test/test_formula.rb +61 -61
  122. data/test/test_ole.rb +106 -106
  123. data/test/test_storage_lite.rb +125 -125
  124. data/test/test_workbook.rb +139 -139
  125. data/test/test_worksheet.rb +110 -110
  126. data/utils/add_magic_comment.rb +80 -80
  127. data/writeexcel.gemspec +4 -6
  128. data/writeexcel.rdoc +58 -15
  129. metadata +9 -6
  130. data/test/test_new_encoding.rb +0 -205
@@ -1,501 +1,501 @@
1
- # -*- coding: utf-8 -*-
2
- ###############################################################################
3
- #
4
- # A test for WriteExcel.
5
- #
6
- # Tests date and time handling. Tests dates in 1900 and 1904 format.
7
- #
8
- # reverse('©'), May 2004, John McNamara, jmcnamara@cpan.org
9
- #
10
- # original written in Perl by John McNamara
11
- # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
12
- #
13
- ############################################################################
14
- require 'helper'
15
- require 'stringio'
16
-
17
- class TC_data_only < Test::Unit::TestCase
18
-
19
- def setup
20
- @workbook = WriteExcel.new(StringIO.new)
21
- @worksheet = @workbook.add_worksheet
22
- end
23
-
24
- def teardown
25
- @workbook.close
26
- end
27
-
28
- def test_the_dates_generated_by_excel
29
- lines = data_generated_excel.split(/\n/)
30
- while !lines.empty?
31
- line = lines.shift.sub(/^\s*/,'')
32
- braak if line =~ /^\s*# stop/ # For debugging
33
-
34
- @worksheet.date_1904 = false if line =~ /Excel 1900/
35
- @worksheet.date_1904 = true if line =~ /Excel 1904/
36
-
37
- next unless line =~ /\S/ # Ignore blank lines
38
- next if line =~ /^\s*#/ # Ignore comments
39
-
40
- count, date, result = line.split(/\s+/)
41
- number = @worksheet.convert_date_time(date)
42
- number = -1 if number.nil?
43
- assert_equal(result.to_i, number,
44
- "Testing convert_date_time: #{date} #{result}")
45
- end
46
- end
47
-
48
- def data_generated_excel
49
-
50
- return <<-__DATA_END__
51
-
52
- #
53
- # The following data was generated by Excel.
54
- #
55
-
56
- #
57
- # Excel 1900 date system
58
- #
59
- 1 1899-12-31T 0
60
- 2 1900-01-00T 0
61
- 3 1900-01-01T 1
62
- 4 1900-02-27T 58
63
- 5 1900-02-28T 59
64
- 6 1900-02-29T 60
65
- 7 1900-03-01T 61
66
- 8 1900-03-02T 62
67
- 9 1900-03-11T 71
68
- 10 1900-04-08T 99
69
- 11 1900-09-12T 256
70
- 12 1901-05-03T 489
71
- 13 1901-10-13T 652
72
- 14 1902-02-15T 777
73
- 15 1902-06-06T 888
74
- 16 1902-09-25T 999
75
- 17 1902-09-27T 1001
76
- 18 1903-04-26T 1212
77
- 19 1903-08-05T 1313
78
- 20 1903-12-31T 1461
79
- 21 1904-01-01T 1462
80
- 22 1904-02-28T 1520
81
- 23 1904-02-29T 1521
82
- 24 1904-03-01T 1522
83
- 25 1907-02-27T 2615
84
- 26 1907-02-28T 2616
85
- 27 1907-03-01T 2617
86
- 28 1907-03-02T 2618
87
- 29 1907-03-03T 2619
88
- 30 1907-03-04T 2620
89
- 31 1907-03-05T 2621
90
- 32 1907-03-06T 2622
91
- 33 1999-01-01T 36161
92
- 34 1999-01-31T 36191
93
- 35 1999-02-01T 36192
94
- 36 1999-02-28T 36219
95
- 37 1999-03-01T 36220
96
- 38 1999-03-31T 36250
97
- 39 1999-04-01T 36251
98
- 40 1999-04-30T 36280
99
- 41 1999-05-01T 36281
100
- 42 1999-05-31T 36311
101
- 43 1999-06-01T 36312
102
- 44 1999-06-30T 36341
103
- 45 1999-07-01T 36342
104
- 46 1999-07-31T 36372
105
- 47 1999-08-01T 36373
106
- 48 1999-08-31T 36403
107
- 49 1999-09-01T 36404
108
- 50 1999-09-30T 36433
109
- 51 1999-10-01T 36434
110
- 52 1999-10-31T 36464
111
- 53 1999-11-01T 36465
112
- 54 1999-11-30T 36494
113
- 55 1999-12-01T 36495
114
- 56 1999-12-31T 36525
115
- 57 2000-01-01T 36526
116
- 58 2000-01-31T 36556
117
- 59 2000-02-01T 36557
118
- 60 2000-02-29T 36585
119
- 61 2000-03-01T 36586
120
- 62 2000-03-31T 36616
121
- 63 2000-04-01T 36617
122
- 64 2000-04-30T 36646
123
- 65 2000-05-01T 36647
124
- 66 2000-05-31T 36677
125
- 67 2000-06-01T 36678
126
- 68 2000-06-30T 36707
127
- 69 2000-07-01T 36708
128
- 70 2000-07-31T 36738
129
- 71 2000-08-01T 36739
130
- 72 2000-08-31T 36769
131
- 73 2000-09-01T 36770
132
- 74 2000-09-30T 36799
133
- 75 2000-10-01T 36800
134
- 76 2000-10-31T 36830
135
- 77 2000-11-01T 36831
136
- 78 2000-11-30T 36860
137
- 79 2000-12-01T 36861
138
- 80 2000-12-31T 36891
139
- 81 2001-01-01T 36892
140
- 82 2001-01-31T 36922
141
- 83 2001-02-01T 36923
142
- 84 2001-02-28T 36950
143
- 85 2001-03-01T 36951
144
- 86 2001-03-31T 36981
145
- 87 2001-04-01T 36982
146
- 88 2001-04-30T 37011
147
- 89 2001-05-01T 37012
148
- 90 2001-05-31T 37042
149
- 91 2001-06-01T 37043
150
- 92 2001-06-30T 37072
151
- 93 2001-07-01T 37073
152
- 94 2001-07-31T 37103
153
- 95 2001-08-01T 37104
154
- 96 2001-08-31T 37134
155
- 97 2001-09-01T 37135
156
- 98 2001-09-30T 37164
157
- 99 2001-10-01T 37165
158
- 100 2001-10-31T 37195
159
- 101 2001-11-01T 37196
160
- 102 2001-11-30T 37225
161
- 103 2001-12-01T 37226
162
- 104 2001-12-31T 37256
163
- 105 2400-01-01T 182623
164
- 106 2400-01-31T 182653
165
- 107 2400-02-01T 182654
166
- 108 2400-02-29T 182682
167
- 109 2400-03-01T 182683
168
- 110 2400-03-31T 182713
169
- 111 2400-04-01T 182714
170
- 112 2400-04-30T 182743
171
- 113 2400-05-01T 182744
172
- 114 2400-05-31T 182774
173
- 115 2400-06-01T 182775
174
- 116 2400-06-30T 182804
175
- 117 2400-07-01T 182805
176
- 118 2400-07-31T 182835
177
- 119 2400-08-01T 182836
178
- 120 2400-08-31T 182866
179
- 121 2400-09-01T 182867
180
- 122 2400-09-30T 182896
181
- 123 2400-10-01T 182897
182
- 124 2400-10-31T 182927
183
- 125 2400-11-01T 182928
184
- 126 2400-11-30T 182957
185
- 127 2400-12-01T 182958
186
- 128 2400-12-31T 182988
187
- 129 4000-01-01T 767011
188
- 130 4000-01-31T 767041
189
- 131 4000-02-01T 767042
190
- 132 4000-02-29T 767070
191
- 133 4000-03-01T 767071
192
- 134 4000-03-31T 767101
193
- 135 4000-04-01T 767102
194
- 136 4000-04-30T 767131
195
- 137 4000-05-01T 767132
196
- 138 4000-05-31T 767162
197
- 139 4000-06-01T 767163
198
- 140 4000-06-30T 767192
199
- 141 4000-07-01T 767193
200
- 142 4000-07-31T 767223
201
- 143 4000-08-01T 767224
202
- 144 4000-08-31T 767254
203
- 145 4000-09-01T 767255
204
- 146 4000-09-30T 767284
205
- 147 4000-10-01T 767285
206
- 148 4000-10-31T 767315
207
- 149 4000-11-01T 767316
208
- 150 4000-11-30T 767345
209
- 151 4000-12-01T 767346
210
- 152 4000-12-31T 767376
211
- 153 4321-01-01T 884254
212
- 154 4321-01-31T 884284
213
- 155 4321-02-01T 884285
214
- 156 4321-02-28T 884312
215
- 157 4321-03-01T 884313
216
- 158 4321-03-31T 884343
217
- 159 4321-04-01T 884344
218
- 160 4321-04-30T 884373
219
- 161 4321-05-01T 884374
220
- 162 4321-05-31T 884404
221
- 163 4321-06-01T 884405
222
- 164 4321-06-30T 884434
223
- 165 4321-07-01T 884435
224
- 166 4321-07-31T 884465
225
- 167 4321-08-01T 884466
226
- 168 4321-08-31T 884496
227
- 169 4321-09-01T 884497
228
- 170 4321-09-30T 884526
229
- 171 4321-10-01T 884527
230
- 172 4321-10-31T 884557
231
- 173 4321-11-01T 884558
232
- 174 4321-11-30T 884587
233
- 175 4321-12-01T 884588
234
- 176 4321-12-31T 884618
235
- 177 9999-01-01T 2958101
236
- 178 9999-01-31T 2958131
237
- 179 9999-02-01T 2958132
238
- 180 9999-02-28T 2958159
239
- 181 9999-03-01T 2958160
240
- 182 9999-03-31T 2958190
241
- 183 9999-04-01T 2958191
242
- 184 9999-04-30T 2958220
243
- 185 9999-05-01T 2958221
244
- 186 9999-05-31T 2958251
245
- 187 9999-06-01T 2958252
246
- 188 9999-06-30T 2958281
247
- 189 9999-07-01T 2958282
248
- 190 9999-07-31T 2958312
249
- 191 9999-08-01T 2958313
250
- 192 9999-08-31T 2958343
251
- 193 9999-09-01T 2958344
252
- 194 9999-09-30T 2958373
253
- 195 9999-10-01T 2958374
254
- 196 9999-10-31T 2958404
255
- 197 9999-11-01T 2958405
256
- 198 9999-11-30T 2958434
257
- 199 9999-12-01T 2958435
258
- 200 9999-12-31T 2958465
259
-
260
- #
261
- # Excel 1904 date system
262
- #
263
- 201 1904-01-01T 0
264
- 202 1904-01-31T 30
265
- 203 1904-02-01T 31
266
- 204 1904-02-29T 59
267
- 205 1904-03-01T 60
268
- 206 1904-03-31T 90
269
- 207 1904-04-01T 91
270
- 208 1904-04-30T 120
271
- 209 1904-05-01T 121
272
- 210 1904-05-31T 151
273
- 211 1904-06-01T 152
274
- 212 1904-06-30T 181
275
- 213 1904-07-01T 182
276
- 214 1904-07-31T 212
277
- 215 1904-08-01T 213
278
- 216 1904-08-31T 243
279
- 217 1904-09-01T 244
280
- 218 1904-09-30T 273
281
- 219 1904-10-01T 274
282
- 220 1904-10-31T 304
283
- 221 1904-11-01T 305
284
- 222 1904-11-30T 334
285
- 223 1904-12-01T 335
286
- 224 1904-12-31T 365
287
- 225 1907-02-27T 1153
288
- 226 1907-02-28T 1154
289
- 227 1907-03-01T 1155
290
- 228 1907-03-02T 1156
291
- 229 1907-03-03T 1157
292
- 230 1907-03-04T 1158
293
- 231 1907-03-05T 1159
294
- 232 1907-03-06T 1160
295
- 233 1999-01-01T 34699
296
- 234 1999-01-31T 34729
297
- 235 1999-02-01T 34730
298
- 236 1999-02-28T 34757
299
- 237 1999-03-01T 34758
300
- 238 1999-03-31T 34788
301
- 239 1999-04-01T 34789
302
- 240 1999-04-30T 34818
303
- 241 1999-05-01T 34819
304
- 242 1999-05-31T 34849
305
- 243 1999-06-01T 34850
306
- 244 1999-06-30T 34879
307
- 245 1999-07-01T 34880
308
- 246 1999-07-31T 34910
309
- 247 1999-08-01T 34911
310
- 248 1999-08-31T 34941
311
- 249 1999-09-01T 34942
312
- 250 1999-09-30T 34971
313
- 251 1999-10-01T 34972
314
- 252 1999-10-31T 35002
315
- 253 1999-11-01T 35003
316
- 254 1999-11-30T 35032
317
- 255 1999-12-01T 35033
318
- 256 1999-12-31T 35063
319
- 257 2000-01-01T 35064
320
- 258 2000-01-31T 35094
321
- 259 2000-02-01T 35095
322
- 260 2000-02-29T 35123
323
- 261 2000-03-01T 35124
324
- 262 2000-03-31T 35154
325
- 263 2000-04-01T 35155
326
- 264 2000-04-30T 35184
327
- 265 2000-05-01T 35185
328
- 266 2000-05-31T 35215
329
- 267 2000-06-01T 35216
330
- 268 2000-06-30T 35245
331
- 269 2000-07-01T 35246
332
- 270 2000-07-31T 35276
333
- 271 2000-08-01T 35277
334
- 272 2000-08-31T 35307
335
- 273 2000-09-01T 35308
336
- 274 2000-09-30T 35337
337
- 275 2000-10-01T 35338
338
- 276 2000-10-31T 35368
339
- 277 2000-11-01T 35369
340
- 278 2000-11-30T 35398
341
- 279 2000-12-01T 35399
342
- 280 2000-12-31T 35429
343
- 281 2001-01-01T 35430
344
- 282 2001-01-31T 35460
345
- 283 2001-02-01T 35461
346
- 284 2001-02-28T 35488
347
- 285 2001-03-01T 35489
348
- 286 2001-03-31T 35519
349
- 287 2001-04-01T 35520
350
- 288 2001-04-30T 35549
351
- 289 2001-05-01T 35550
352
- 290 2001-05-31T 35580
353
- 291 2001-06-01T 35581
354
- 292 2001-06-30T 35610
355
- 293 2001-07-01T 35611
356
- 294 2001-07-31T 35641
357
- 295 2001-08-01T 35642
358
- 296 2001-08-31T 35672
359
- 297 2001-09-01T 35673
360
- 298 2001-09-30T 35702
361
- 299 2001-10-01T 35703
362
- 300 2001-10-31T 35733
363
- 301 2001-11-01T 35734
364
- 302 2001-11-30T 35763
365
- 303 2001-12-01T 35764
366
- 304 2001-12-31T 35794
367
- 305 2400-01-01T 181161
368
- 306 2400-01-31T 181191
369
- 307 2400-02-01T 181192
370
- 308 2400-02-29T 181220
371
- 309 2400-03-01T 181221
372
- 310 2400-03-31T 181251
373
- 311 2400-04-01T 181252
374
- 312 2400-04-30T 181281
375
- 313 2400-05-01T 181282
376
- 314 2400-05-31T 181312
377
- 315 2400-06-01T 181313
378
- 316 2400-06-30T 181342
379
- 317 2400-07-01T 181343
380
- 318 2400-07-31T 181373
381
- 319 2400-08-01T 181374
382
- 320 2400-08-31T 181404
383
- 321 2400-09-01T 181405
384
- 322 2400-09-30T 181434
385
- 323 2400-10-01T 181435
386
- 324 2400-10-31T 181465
387
- 325 2400-11-01T 181466
388
- 326 2400-11-30T 181495
389
- 327 2400-12-01T 181496
390
- 328 2400-12-31T 181526
391
- 329 4000-01-01T 765549
392
- 330 4000-01-31T 765579
393
- 331 4000-02-01T 765580
394
- 332 4000-02-29T 765608
395
- 333 4000-03-01T 765609
396
- 334 4000-03-31T 765639
397
- 335 4000-04-01T 765640
398
- 336 4000-04-30T 765669
399
- 337 4000-05-01T 765670
400
- 338 4000-05-31T 765700
401
- 339 4000-06-01T 765701
402
- 340 4000-06-30T 765730
403
- 341 4000-07-01T 765731
404
- 342 4000-07-31T 765761
405
- 343 4000-08-01T 765762
406
- 344 4000-08-31T 765792
407
- 345 4000-09-01T 765793
408
- 346 4000-09-30T 765822
409
- 347 4000-10-01T 765823
410
- 348 4000-10-31T 765853
411
- 349 4000-11-01T 765854
412
- 350 4000-11-30T 765883
413
- 351 4000-12-01T 765884
414
- 352 4000-12-31T 765914
415
- 353 4321-01-01T 882792
416
- 354 4321-01-31T 882822
417
- 355 4321-02-01T 882823
418
- 356 4321-02-28T 882850
419
- 357 4321-03-01T 882851
420
- 358 4321-03-31T 882881
421
- 359 4321-04-01T 882882
422
- 360 4321-04-30T 882911
423
- 361 4321-05-01T 882912
424
- 362 4321-05-31T 882942
425
- 363 4321-06-01T 882943
426
- 364 4321-06-30T 882972
427
- 365 4321-07-01T 882973
428
- 366 4321-07-31T 883003
429
- 367 4321-08-01T 883004
430
- 368 4321-08-31T 883034
431
- 369 4321-09-01T 883035
432
- 370 4321-09-30T 883064
433
- 371 4321-10-01T 883065
434
- 372 4321-10-31T 883095
435
- 373 4321-11-01T 883096
436
- 374 4321-11-30T 883125
437
- 375 4321-12-01T 883126
438
- 376 4321-12-31T 883156
439
- 377 9999-01-01T 2956639
440
- 378 9999-01-31T 2956669
441
- 379 9999-02-01T 2956670
442
- 380 9999-02-28T 2956697
443
- 381 9999-03-01T 2956698
444
- 382 9999-03-31T 2956728
445
- 383 9999-04-01T 2956729
446
- 384 9999-04-30T 2956758
447
- 385 9999-05-01T 2956759
448
- 386 9999-05-31T 2956789
449
- 387 9999-06-01T 2956790
450
- 388 9999-06-30T 2956819
451
- 389 9999-07-01T 2956820
452
- 390 9999-07-31T 2956850
453
- 391 9999-08-01T 2956851
454
- 392 9999-08-31T 2956881
455
- 393 9999-09-01T 2956882
456
- 394 9999-09-30T 2956911
457
- 395 9999-10-01T 2956912
458
- 396 9999-10-31T 2956942
459
- 397 9999-11-01T 2956943
460
- 398 9999-11-30T 2956972
461
- 399 9999-12-01T 2956973
462
- 400 9999-12-31T 2957003
463
-
464
-
465
- #
466
- # The following dates are invalid.
467
- #
468
-
469
- #
470
- # Excel 1900 date system
471
- #
472
- 401 0000-12-30T -1 # Below year range.
473
- 402 1000-12-30T -1 # Below year range.
474
- 403 1899-12-30T -1 # Below year range.
475
- 404 2002-02-29T -1 # False leap-day.
476
- 405 2000-00-00T -1 # No month or day.
477
- 406 2000-01-00T -1 # No day.
478
- 407 2000-00-01T -1 # No month.
479
- 408 2000-13-01T -1 # Month out of range.
480
- 409 2000-12-32T -1 # Day out of range.
481
- 410 10000-01-01T -1 # Year out of range.
482
-
483
- #
484
- # Excel 1904 date system
485
- #
486
- 411 1899-12-31T -1 # Below year range.
487
- 412 1900-01-01T -1 # Below year range.
488
- 413 1903-12-31T -1 # Below year range.
489
- 414 2001-02-29T -1 # False leap-day.
490
- 415 2000-00-00T -1 # No month or day.
491
- 416 2000-01-00T -1 # No day.
492
- 417 2000-00-01T -1 # No month.
493
- 418 2000-13-01T -1 # Month out of range.
494
- 419 2000-12-32T -1 # Day out of range.
495
- 420 10000-01-01T -1 # Year out of range.
496
-
497
- __DATA_END__
498
-
499
- end
500
-
501
- end
1
+ # -*- coding: utf-8 -*-
2
+ ###############################################################################
3
+ #
4
+ # A test for WriteExcel.
5
+ #
6
+ # Tests date and time handling. Tests dates in 1900 and 1904 format.
7
+ #
8
+ # reverse('©'), May 2004, John McNamara, jmcnamara@cpan.org
9
+ #
10
+ # original written in Perl by John McNamara
11
+ # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
12
+ #
13
+ ############################################################################
14
+ require 'helper'
15
+ require 'stringio'
16
+
17
+ class TC_data_only < Test::Unit::TestCase
18
+
19
+ def setup
20
+ @workbook = WriteExcel.new(StringIO.new)
21
+ @worksheet = @workbook.add_worksheet
22
+ end
23
+
24
+ def teardown
25
+ @workbook.close
26
+ end
27
+
28
+ def test_the_dates_generated_by_excel
29
+ lines = data_generated_excel.split(/\n/)
30
+ while !lines.empty?
31
+ line = lines.shift.sub(/^\s*/,'')
32
+ braak if line =~ /^\s*# stop/ # For debugging
33
+
34
+ @worksheet.date_1904 = false if line =~ /Excel 1900/
35
+ @worksheet.date_1904 = true if line =~ /Excel 1904/
36
+
37
+ next unless line =~ /\S/ # Ignore blank lines
38
+ next if line =~ /^\s*#/ # Ignore comments
39
+
40
+ count, date, result = line.split(/\s+/)
41
+ number = @worksheet.convert_date_time(date)
42
+ number = -1 if number.nil?
43
+ assert_equal(result.to_i, number,
44
+ "Testing convert_date_time: #{date} #{result}")
45
+ end
46
+ end
47
+
48
+ def data_generated_excel
49
+
50
+ return <<-__DATA_END__
51
+
52
+ #
53
+ # The following data was generated by Excel.
54
+ #
55
+
56
+ #
57
+ # Excel 1900 date system
58
+ #
59
+ 1 1899-12-31T 0
60
+ 2 1900-01-00T 0
61
+ 3 1900-01-01T 1
62
+ 4 1900-02-27T 58
63
+ 5 1900-02-28T 59
64
+ 6 1900-02-29T 60
65
+ 7 1900-03-01T 61
66
+ 8 1900-03-02T 62
67
+ 9 1900-03-11T 71
68
+ 10 1900-04-08T 99
69
+ 11 1900-09-12T 256
70
+ 12 1901-05-03T 489
71
+ 13 1901-10-13T 652
72
+ 14 1902-02-15T 777
73
+ 15 1902-06-06T 888
74
+ 16 1902-09-25T 999
75
+ 17 1902-09-27T 1001
76
+ 18 1903-04-26T 1212
77
+ 19 1903-08-05T 1313
78
+ 20 1903-12-31T 1461
79
+ 21 1904-01-01T 1462
80
+ 22 1904-02-28T 1520
81
+ 23 1904-02-29T 1521
82
+ 24 1904-03-01T 1522
83
+ 25 1907-02-27T 2615
84
+ 26 1907-02-28T 2616
85
+ 27 1907-03-01T 2617
86
+ 28 1907-03-02T 2618
87
+ 29 1907-03-03T 2619
88
+ 30 1907-03-04T 2620
89
+ 31 1907-03-05T 2621
90
+ 32 1907-03-06T 2622
91
+ 33 1999-01-01T 36161
92
+ 34 1999-01-31T 36191
93
+ 35 1999-02-01T 36192
94
+ 36 1999-02-28T 36219
95
+ 37 1999-03-01T 36220
96
+ 38 1999-03-31T 36250
97
+ 39 1999-04-01T 36251
98
+ 40 1999-04-30T 36280
99
+ 41 1999-05-01T 36281
100
+ 42 1999-05-31T 36311
101
+ 43 1999-06-01T 36312
102
+ 44 1999-06-30T 36341
103
+ 45 1999-07-01T 36342
104
+ 46 1999-07-31T 36372
105
+ 47 1999-08-01T 36373
106
+ 48 1999-08-31T 36403
107
+ 49 1999-09-01T 36404
108
+ 50 1999-09-30T 36433
109
+ 51 1999-10-01T 36434
110
+ 52 1999-10-31T 36464
111
+ 53 1999-11-01T 36465
112
+ 54 1999-11-30T 36494
113
+ 55 1999-12-01T 36495
114
+ 56 1999-12-31T 36525
115
+ 57 2000-01-01T 36526
116
+ 58 2000-01-31T 36556
117
+ 59 2000-02-01T 36557
118
+ 60 2000-02-29T 36585
119
+ 61 2000-03-01T 36586
120
+ 62 2000-03-31T 36616
121
+ 63 2000-04-01T 36617
122
+ 64 2000-04-30T 36646
123
+ 65 2000-05-01T 36647
124
+ 66 2000-05-31T 36677
125
+ 67 2000-06-01T 36678
126
+ 68 2000-06-30T 36707
127
+ 69 2000-07-01T 36708
128
+ 70 2000-07-31T 36738
129
+ 71 2000-08-01T 36739
130
+ 72 2000-08-31T 36769
131
+ 73 2000-09-01T 36770
132
+ 74 2000-09-30T 36799
133
+ 75 2000-10-01T 36800
134
+ 76 2000-10-31T 36830
135
+ 77 2000-11-01T 36831
136
+ 78 2000-11-30T 36860
137
+ 79 2000-12-01T 36861
138
+ 80 2000-12-31T 36891
139
+ 81 2001-01-01T 36892
140
+ 82 2001-01-31T 36922
141
+ 83 2001-02-01T 36923
142
+ 84 2001-02-28T 36950
143
+ 85 2001-03-01T 36951
144
+ 86 2001-03-31T 36981
145
+ 87 2001-04-01T 36982
146
+ 88 2001-04-30T 37011
147
+ 89 2001-05-01T 37012
148
+ 90 2001-05-31T 37042
149
+ 91 2001-06-01T 37043
150
+ 92 2001-06-30T 37072
151
+ 93 2001-07-01T 37073
152
+ 94 2001-07-31T 37103
153
+ 95 2001-08-01T 37104
154
+ 96 2001-08-31T 37134
155
+ 97 2001-09-01T 37135
156
+ 98 2001-09-30T 37164
157
+ 99 2001-10-01T 37165
158
+ 100 2001-10-31T 37195
159
+ 101 2001-11-01T 37196
160
+ 102 2001-11-30T 37225
161
+ 103 2001-12-01T 37226
162
+ 104 2001-12-31T 37256
163
+ 105 2400-01-01T 182623
164
+ 106 2400-01-31T 182653
165
+ 107 2400-02-01T 182654
166
+ 108 2400-02-29T 182682
167
+ 109 2400-03-01T 182683
168
+ 110 2400-03-31T 182713
169
+ 111 2400-04-01T 182714
170
+ 112 2400-04-30T 182743
171
+ 113 2400-05-01T 182744
172
+ 114 2400-05-31T 182774
173
+ 115 2400-06-01T 182775
174
+ 116 2400-06-30T 182804
175
+ 117 2400-07-01T 182805
176
+ 118 2400-07-31T 182835
177
+ 119 2400-08-01T 182836
178
+ 120 2400-08-31T 182866
179
+ 121 2400-09-01T 182867
180
+ 122 2400-09-30T 182896
181
+ 123 2400-10-01T 182897
182
+ 124 2400-10-31T 182927
183
+ 125 2400-11-01T 182928
184
+ 126 2400-11-30T 182957
185
+ 127 2400-12-01T 182958
186
+ 128 2400-12-31T 182988
187
+ 129 4000-01-01T 767011
188
+ 130 4000-01-31T 767041
189
+ 131 4000-02-01T 767042
190
+ 132 4000-02-29T 767070
191
+ 133 4000-03-01T 767071
192
+ 134 4000-03-31T 767101
193
+ 135 4000-04-01T 767102
194
+ 136 4000-04-30T 767131
195
+ 137 4000-05-01T 767132
196
+ 138 4000-05-31T 767162
197
+ 139 4000-06-01T 767163
198
+ 140 4000-06-30T 767192
199
+ 141 4000-07-01T 767193
200
+ 142 4000-07-31T 767223
201
+ 143 4000-08-01T 767224
202
+ 144 4000-08-31T 767254
203
+ 145 4000-09-01T 767255
204
+ 146 4000-09-30T 767284
205
+ 147 4000-10-01T 767285
206
+ 148 4000-10-31T 767315
207
+ 149 4000-11-01T 767316
208
+ 150 4000-11-30T 767345
209
+ 151 4000-12-01T 767346
210
+ 152 4000-12-31T 767376
211
+ 153 4321-01-01T 884254
212
+ 154 4321-01-31T 884284
213
+ 155 4321-02-01T 884285
214
+ 156 4321-02-28T 884312
215
+ 157 4321-03-01T 884313
216
+ 158 4321-03-31T 884343
217
+ 159 4321-04-01T 884344
218
+ 160 4321-04-30T 884373
219
+ 161 4321-05-01T 884374
220
+ 162 4321-05-31T 884404
221
+ 163 4321-06-01T 884405
222
+ 164 4321-06-30T 884434
223
+ 165 4321-07-01T 884435
224
+ 166 4321-07-31T 884465
225
+ 167 4321-08-01T 884466
226
+ 168 4321-08-31T 884496
227
+ 169 4321-09-01T 884497
228
+ 170 4321-09-30T 884526
229
+ 171 4321-10-01T 884527
230
+ 172 4321-10-31T 884557
231
+ 173 4321-11-01T 884558
232
+ 174 4321-11-30T 884587
233
+ 175 4321-12-01T 884588
234
+ 176 4321-12-31T 884618
235
+ 177 9999-01-01T 2958101
236
+ 178 9999-01-31T 2958131
237
+ 179 9999-02-01T 2958132
238
+ 180 9999-02-28T 2958159
239
+ 181 9999-03-01T 2958160
240
+ 182 9999-03-31T 2958190
241
+ 183 9999-04-01T 2958191
242
+ 184 9999-04-30T 2958220
243
+ 185 9999-05-01T 2958221
244
+ 186 9999-05-31T 2958251
245
+ 187 9999-06-01T 2958252
246
+ 188 9999-06-30T 2958281
247
+ 189 9999-07-01T 2958282
248
+ 190 9999-07-31T 2958312
249
+ 191 9999-08-01T 2958313
250
+ 192 9999-08-31T 2958343
251
+ 193 9999-09-01T 2958344
252
+ 194 9999-09-30T 2958373
253
+ 195 9999-10-01T 2958374
254
+ 196 9999-10-31T 2958404
255
+ 197 9999-11-01T 2958405
256
+ 198 9999-11-30T 2958434
257
+ 199 9999-12-01T 2958435
258
+ 200 9999-12-31T 2958465
259
+
260
+ #
261
+ # Excel 1904 date system
262
+ #
263
+ 201 1904-01-01T 0
264
+ 202 1904-01-31T 30
265
+ 203 1904-02-01T 31
266
+ 204 1904-02-29T 59
267
+ 205 1904-03-01T 60
268
+ 206 1904-03-31T 90
269
+ 207 1904-04-01T 91
270
+ 208 1904-04-30T 120
271
+ 209 1904-05-01T 121
272
+ 210 1904-05-31T 151
273
+ 211 1904-06-01T 152
274
+ 212 1904-06-30T 181
275
+ 213 1904-07-01T 182
276
+ 214 1904-07-31T 212
277
+ 215 1904-08-01T 213
278
+ 216 1904-08-31T 243
279
+ 217 1904-09-01T 244
280
+ 218 1904-09-30T 273
281
+ 219 1904-10-01T 274
282
+ 220 1904-10-31T 304
283
+ 221 1904-11-01T 305
284
+ 222 1904-11-30T 334
285
+ 223 1904-12-01T 335
286
+ 224 1904-12-31T 365
287
+ 225 1907-02-27T 1153
288
+ 226 1907-02-28T 1154
289
+ 227 1907-03-01T 1155
290
+ 228 1907-03-02T 1156
291
+ 229 1907-03-03T 1157
292
+ 230 1907-03-04T 1158
293
+ 231 1907-03-05T 1159
294
+ 232 1907-03-06T 1160
295
+ 233 1999-01-01T 34699
296
+ 234 1999-01-31T 34729
297
+ 235 1999-02-01T 34730
298
+ 236 1999-02-28T 34757
299
+ 237 1999-03-01T 34758
300
+ 238 1999-03-31T 34788
301
+ 239 1999-04-01T 34789
302
+ 240 1999-04-30T 34818
303
+ 241 1999-05-01T 34819
304
+ 242 1999-05-31T 34849
305
+ 243 1999-06-01T 34850
306
+ 244 1999-06-30T 34879
307
+ 245 1999-07-01T 34880
308
+ 246 1999-07-31T 34910
309
+ 247 1999-08-01T 34911
310
+ 248 1999-08-31T 34941
311
+ 249 1999-09-01T 34942
312
+ 250 1999-09-30T 34971
313
+ 251 1999-10-01T 34972
314
+ 252 1999-10-31T 35002
315
+ 253 1999-11-01T 35003
316
+ 254 1999-11-30T 35032
317
+ 255 1999-12-01T 35033
318
+ 256 1999-12-31T 35063
319
+ 257 2000-01-01T 35064
320
+ 258 2000-01-31T 35094
321
+ 259 2000-02-01T 35095
322
+ 260 2000-02-29T 35123
323
+ 261 2000-03-01T 35124
324
+ 262 2000-03-31T 35154
325
+ 263 2000-04-01T 35155
326
+ 264 2000-04-30T 35184
327
+ 265 2000-05-01T 35185
328
+ 266 2000-05-31T 35215
329
+ 267 2000-06-01T 35216
330
+ 268 2000-06-30T 35245
331
+ 269 2000-07-01T 35246
332
+ 270 2000-07-31T 35276
333
+ 271 2000-08-01T 35277
334
+ 272 2000-08-31T 35307
335
+ 273 2000-09-01T 35308
336
+ 274 2000-09-30T 35337
337
+ 275 2000-10-01T 35338
338
+ 276 2000-10-31T 35368
339
+ 277 2000-11-01T 35369
340
+ 278 2000-11-30T 35398
341
+ 279 2000-12-01T 35399
342
+ 280 2000-12-31T 35429
343
+ 281 2001-01-01T 35430
344
+ 282 2001-01-31T 35460
345
+ 283 2001-02-01T 35461
346
+ 284 2001-02-28T 35488
347
+ 285 2001-03-01T 35489
348
+ 286 2001-03-31T 35519
349
+ 287 2001-04-01T 35520
350
+ 288 2001-04-30T 35549
351
+ 289 2001-05-01T 35550
352
+ 290 2001-05-31T 35580
353
+ 291 2001-06-01T 35581
354
+ 292 2001-06-30T 35610
355
+ 293 2001-07-01T 35611
356
+ 294 2001-07-31T 35641
357
+ 295 2001-08-01T 35642
358
+ 296 2001-08-31T 35672
359
+ 297 2001-09-01T 35673
360
+ 298 2001-09-30T 35702
361
+ 299 2001-10-01T 35703
362
+ 300 2001-10-31T 35733
363
+ 301 2001-11-01T 35734
364
+ 302 2001-11-30T 35763
365
+ 303 2001-12-01T 35764
366
+ 304 2001-12-31T 35794
367
+ 305 2400-01-01T 181161
368
+ 306 2400-01-31T 181191
369
+ 307 2400-02-01T 181192
370
+ 308 2400-02-29T 181220
371
+ 309 2400-03-01T 181221
372
+ 310 2400-03-31T 181251
373
+ 311 2400-04-01T 181252
374
+ 312 2400-04-30T 181281
375
+ 313 2400-05-01T 181282
376
+ 314 2400-05-31T 181312
377
+ 315 2400-06-01T 181313
378
+ 316 2400-06-30T 181342
379
+ 317 2400-07-01T 181343
380
+ 318 2400-07-31T 181373
381
+ 319 2400-08-01T 181374
382
+ 320 2400-08-31T 181404
383
+ 321 2400-09-01T 181405
384
+ 322 2400-09-30T 181434
385
+ 323 2400-10-01T 181435
386
+ 324 2400-10-31T 181465
387
+ 325 2400-11-01T 181466
388
+ 326 2400-11-30T 181495
389
+ 327 2400-12-01T 181496
390
+ 328 2400-12-31T 181526
391
+ 329 4000-01-01T 765549
392
+ 330 4000-01-31T 765579
393
+ 331 4000-02-01T 765580
394
+ 332 4000-02-29T 765608
395
+ 333 4000-03-01T 765609
396
+ 334 4000-03-31T 765639
397
+ 335 4000-04-01T 765640
398
+ 336 4000-04-30T 765669
399
+ 337 4000-05-01T 765670
400
+ 338 4000-05-31T 765700
401
+ 339 4000-06-01T 765701
402
+ 340 4000-06-30T 765730
403
+ 341 4000-07-01T 765731
404
+ 342 4000-07-31T 765761
405
+ 343 4000-08-01T 765762
406
+ 344 4000-08-31T 765792
407
+ 345 4000-09-01T 765793
408
+ 346 4000-09-30T 765822
409
+ 347 4000-10-01T 765823
410
+ 348 4000-10-31T 765853
411
+ 349 4000-11-01T 765854
412
+ 350 4000-11-30T 765883
413
+ 351 4000-12-01T 765884
414
+ 352 4000-12-31T 765914
415
+ 353 4321-01-01T 882792
416
+ 354 4321-01-31T 882822
417
+ 355 4321-02-01T 882823
418
+ 356 4321-02-28T 882850
419
+ 357 4321-03-01T 882851
420
+ 358 4321-03-31T 882881
421
+ 359 4321-04-01T 882882
422
+ 360 4321-04-30T 882911
423
+ 361 4321-05-01T 882912
424
+ 362 4321-05-31T 882942
425
+ 363 4321-06-01T 882943
426
+ 364 4321-06-30T 882972
427
+ 365 4321-07-01T 882973
428
+ 366 4321-07-31T 883003
429
+ 367 4321-08-01T 883004
430
+ 368 4321-08-31T 883034
431
+ 369 4321-09-01T 883035
432
+ 370 4321-09-30T 883064
433
+ 371 4321-10-01T 883065
434
+ 372 4321-10-31T 883095
435
+ 373 4321-11-01T 883096
436
+ 374 4321-11-30T 883125
437
+ 375 4321-12-01T 883126
438
+ 376 4321-12-31T 883156
439
+ 377 9999-01-01T 2956639
440
+ 378 9999-01-31T 2956669
441
+ 379 9999-02-01T 2956670
442
+ 380 9999-02-28T 2956697
443
+ 381 9999-03-01T 2956698
444
+ 382 9999-03-31T 2956728
445
+ 383 9999-04-01T 2956729
446
+ 384 9999-04-30T 2956758
447
+ 385 9999-05-01T 2956759
448
+ 386 9999-05-31T 2956789
449
+ 387 9999-06-01T 2956790
450
+ 388 9999-06-30T 2956819
451
+ 389 9999-07-01T 2956820
452
+ 390 9999-07-31T 2956850
453
+ 391 9999-08-01T 2956851
454
+ 392 9999-08-31T 2956881
455
+ 393 9999-09-01T 2956882
456
+ 394 9999-09-30T 2956911
457
+ 395 9999-10-01T 2956912
458
+ 396 9999-10-31T 2956942
459
+ 397 9999-11-01T 2956943
460
+ 398 9999-11-30T 2956972
461
+ 399 9999-12-01T 2956973
462
+ 400 9999-12-31T 2957003
463
+
464
+
465
+ #
466
+ # The following dates are invalid.
467
+ #
468
+
469
+ #
470
+ # Excel 1900 date system
471
+ #
472
+ 401 0000-12-30T -1 # Below year range.
473
+ 402 1000-12-30T -1 # Below year range.
474
+ 403 1899-12-30T -1 # Below year range.
475
+ 404 2002-02-29T -1 # False leap-day.
476
+ 405 2000-00-00T -1 # No month or day.
477
+ 406 2000-01-00T -1 # No day.
478
+ 407 2000-00-01T -1 # No month.
479
+ 408 2000-13-01T -1 # Month out of range.
480
+ 409 2000-12-32T -1 # Day out of range.
481
+ 410 10000-01-01T -1 # Year out of range.
482
+
483
+ #
484
+ # Excel 1904 date system
485
+ #
486
+ 411 1899-12-31T -1 # Below year range.
487
+ 412 1900-01-01T -1 # Below year range.
488
+ 413 1903-12-31T -1 # Below year range.
489
+ 414 2001-02-29T -1 # False leap-day.
490
+ 415 2000-00-00T -1 # No month or day.
491
+ 416 2000-01-00T -1 # No day.
492
+ 417 2000-00-01T -1 # No month.
493
+ 418 2000-13-01T -1 # Month out of range.
494
+ 419 2000-12-32T -1 # Day out of range.
495
+ 420 10000-01-01T -1 # Year out of range.
496
+
497
+ __DATA_END__
498
+
499
+ end
500
+
501
+ end