write_xlsx 0.60.0 → 0.61.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/README.rdoc +11 -1
  2. data/examples/hide_row_col.rb +33 -0
  3. data/html/en/doc_en.html +7765 -0
  4. data/html/index.html +16 -0
  5. data/html/style.css +433 -0
  6. data/lib/write_xlsx/chart.rb +20 -0
  7. data/lib/write_xlsx/package/button.rb +132 -0
  8. data/lib/write_xlsx/package/comments.rb +97 -1
  9. data/lib/write_xlsx/package/shared_strings.rb +2 -2
  10. data/lib/write_xlsx/package/vml.rb +9 -419
  11. data/lib/write_xlsx/utility.rb +138 -0
  12. data/lib/write_xlsx/version.rb +1 -1
  13. data/lib/write_xlsx/workbook.rb +2 -2
  14. data/lib/write_xlsx/worksheet.rb +178 -115
  15. data/test/drawing/test_write_row.rb +1 -1
  16. data/test/perl_output/hide_row_col.xlsx +0 -0
  17. data/test/perl_output/merge4.xlsx +0 -0
  18. data/test/perl_output/merge6.xlsx +0 -0
  19. data/test/regression/{test_vml04.rb → disabled_test_vml04.rb} +0 -0
  20. data/test/regression/test_chart_size01.rb +41 -0
  21. data/test/regression/test_chart_size02.rb +41 -0
  22. data/test/regression/test_chart_size03.rb +39 -0
  23. data/test/regression/test_default_row01.rb +26 -0
  24. data/test/regression/test_default_row02.rb +28 -0
  25. data/test/regression/test_default_row03.rb +28 -0
  26. data/test/regression/test_default_row04.rb +31 -0
  27. data/test/regression/xlsx_files/chart_size01.xlsx +0 -0
  28. data/test/regression/xlsx_files/default_row01.xlsx +0 -0
  29. data/test/regression/xlsx_files/default_row02.xlsx +0 -0
  30. data/test/regression/xlsx_files/default_row03.xlsx +0 -0
  31. data/test/regression/xlsx_files/default_row04.xlsx +0 -0
  32. data/test/test_example_match.rb +22 -0
  33. data/test/worksheet/test_write_methods.rb +0 -7
  34. metadata +35 -22
  35. data/test/package/vml/test_write_anchor.rb +0 -14
  36. data/test/package/vml/test_write_column.rb +0 -14
  37. data/test/package/vml/test_write_fill.rb +0 -22
  38. data/test/package/vml/test_write_move_with_cells.rb +0 -14
  39. data/test/package/vml/test_write_row.rb +0 -14
  40. data/test/package/vml/test_write_shadow.rb +0 -14
  41. data/test/package/vml/test_write_size_with_cells.rb +0 -14
  42. data/test/package/vml/test_write_textbox.rb +0 -14
  43. data/test/worksheet/test_write_hyperlinks.rb +0 -27
data/html/index.html ADDED
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4
+ <head>
5
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
6
+ <title>writeexcel rubygem reference</title>
7
+
8
+ </head>
9
+ <body class="indexpage">
10
+ <h1>writeexcel rubygem reference</h1>
11
+ <ul>
12
+ <li><a href="en/doc_en.html">English Version</a></li>
13
+ <li><a href="ja/doc_ja.html">日本語版</a></li>
14
+ </ul>
15
+ </body>
16
+ </html>
data/html/style.css ADDED
@@ -0,0 +1,433 @@
1
+ BODY, .logo { background: white; }
2
+
3
+ BODY {
4
+ color: black;
5
+ font-family: arial,sans-serif;
6
+ margin: 0;
7
+ padding: 1ex;
8
+ }
9
+
10
+ TABLE {
11
+ border-collapse: collapse;
12
+ border-spacing: 0;
13
+ border-width: 0;
14
+ color: inherit;
15
+ }
16
+
17
+ IMG { border: 0; }
18
+ FORM { margin: 0; }
19
+ input { margin: 2px; }
20
+
21
+ .logo {
22
+ float: left;
23
+ width: 264px;
24
+ height: 77px;
25
+ }
26
+
27
+ .front .logo {
28
+ float: none;
29
+ display:block;
30
+ }
31
+
32
+ .front .searchbox {
33
+ margin: 2ex auto;
34
+ text-align: center;
35
+ }
36
+
37
+ .front .menubar {
38
+ text-align: center;
39
+ }
40
+
41
+ .menubar {
42
+ background: #006699;
43
+ margin: 1ex 0;
44
+ padding: 1px;
45
+ }
46
+
47
+ .menubar A {
48
+ padding: 0.8ex;
49
+ font: bold 10pt Arial,Helvetica,sans-serif;
50
+ }
51
+
52
+ .menubar A:link, .menubar A:visited {
53
+ color: white;
54
+ text-decoration: none;
55
+ }
56
+
57
+ .menubar A:hover {
58
+ color: #ff6600;
59
+ text-decoration: underline;
60
+ }
61
+
62
+ A:link, A:visited {
63
+ background: transparent;
64
+ color: #006699;
65
+ }
66
+
67
+ A[href="#POD_ERRORS"] {
68
+ background: transparent;
69
+ color: #FF0000;
70
+ }
71
+
72
+ TD {
73
+ margin: 0;
74
+ padding: 0;
75
+ }
76
+
77
+ DIV {
78
+ border-width: 0;
79
+ }
80
+
81
+ DT {
82
+ margin-top: 1em;
83
+ }
84
+
85
+ .credits TD {
86
+ padding: 0.5ex 2ex;
87
+ }
88
+
89
+ .huge {
90
+ font-size: 32pt;
91
+ }
92
+
93
+ .s {
94
+ background: #dddddd;
95
+ color: inherit;
96
+ }
97
+
98
+ .s TD, .r TD {
99
+ padding: 0.2ex 1ex;
100
+ vertical-align: baseline;
101
+ }
102
+
103
+ TH {
104
+ background: #bbbbbb;
105
+ color: inherit;
106
+ padding: 0.4ex 1ex;
107
+ text-align: left;
108
+ }
109
+
110
+ TH A:link, TH A:visited {
111
+ background: transparent;
112
+ color: black;
113
+ }
114
+
115
+ .box {
116
+ border: 1px solid #006699;
117
+ margin: 1ex 0;
118
+ padding: 0;
119
+ }
120
+
121
+ .distfiles TD {
122
+ padding: 0 2ex 0 0;
123
+ vertical-align: baseline;
124
+ }
125
+
126
+ .manifest TD {
127
+ padding: 0 1ex;
128
+ vertical-align: top;
129
+ }
130
+
131
+ .l1 {
132
+ font-weight: bold;
133
+ }
134
+
135
+ .l2 {
136
+ font-weight: normal;
137
+ }
138
+
139
+ .t1, .t2, .t3, .t4, .t5 {
140
+ background: #006699;
141
+ color: white;
142
+ }
143
+ .t4 {
144
+ padding: 0.2ex 0.4ex;
145
+ }
146
+ .t1, .t2, .t3 {
147
+ padding: 0.5ex 1ex;
148
+ }
149
+
150
+ /* IE does not support .box>.t1 Grrr */
151
+ .box .t1, .box .t2, .box .t3, .box .t5 {
152
+ margin: 0;
153
+ }
154
+
155
+ .t1 {
156
+ font-size: 1.4em;
157
+ font-weight: bold;
158
+ text-align: center;
159
+ }
160
+
161
+ .t2 {
162
+ font-size: 1.0em;
163
+ font-weight: bold;
164
+ text-align: left;
165
+ }
166
+
167
+ .t3 {
168
+ font-size: 1.0em;
169
+ font-weight: normal;
170
+ text-align: left;
171
+ }
172
+
173
+ .t5 {
174
+ font-size: 0.8em;
175
+ font-weight: normal;
176
+ text-align: center;
177
+ }
178
+
179
+ /* width: 100%; border: 0.1px solid #FFFFFF; */ /* NN4 hack */
180
+
181
+ .datecell {
182
+ text-align: center;
183
+ width: 17em;
184
+ }
185
+
186
+ .cell {
187
+ padding: 0.2ex 1ex;
188
+ text-align: left;
189
+ }
190
+
191
+ .label {
192
+ background: #aaaaaa;
193
+ color: black;
194
+ font-weight: bold;
195
+ padding: 0.2ex 1ex;
196
+ text-align: right;
197
+ white-space: nowrap;
198
+ vertical-align: baseline;
199
+ }
200
+
201
+ .categories {
202
+ border-bottom: 3px double #006699;
203
+ margin-bottom: 1ex;
204
+ padding-bottom: 3ex;
205
+ padding-top: 2ex;
206
+ }
207
+
208
+ .categories TABLE {
209
+ margin: auto;
210
+ }
211
+
212
+ .categories TD {
213
+ padding: 0.5ex 1ex;
214
+ vertical-align: baseline;
215
+ }
216
+
217
+ .path A {
218
+ background: transparent;
219
+ color: #006699;
220
+ font-weight: bold;
221
+ }
222
+
223
+ .pages {
224
+ background: #dddddd;
225
+ color: #006699;
226
+ padding: 0.2ex 0.4ex;
227
+ }
228
+
229
+ .path {
230
+ background: #dddddd;
231
+ border-bottom: 1px solid #006699;
232
+ color: #006699;
233
+ /* font-size: 1.4em;*/
234
+ margin: 1ex 0;
235
+ padding: 0.5ex 1ex;
236
+ }
237
+
238
+ .menubar TD {
239
+ background: #006699;
240
+ color: white;
241
+ }
242
+
243
+ .menubar {
244
+ background: #006699;
245
+ color: white;
246
+ margin: 1ex 0;
247
+ padding: 1px;
248
+ }
249
+
250
+ .menubar .links {
251
+ background: transparent;
252
+ color: white;
253
+ padding: 0.2ex;
254
+ text-align: left;
255
+ }
256
+
257
+ .menubar .searchbar {
258
+ background: black;
259
+ color: black;
260
+ margin: 0px;
261
+ padding: 2px;
262
+ text-align: right;
263
+ }
264
+
265
+ A.m:link, A.m:visited {
266
+ background: #006699;
267
+ color: white;
268
+ font: bold 10pt Arial,Helvetica,sans-serif;
269
+ text-decoration: none;
270
+ }
271
+
272
+ A.o:link, A.o:visited {
273
+ background: #006699;
274
+ color: #ccffcc;
275
+ font: bold 10pt Arial,Helvetica,sans-serif;
276
+ text-decoration: none;
277
+ }
278
+
279
+ A.o:hover {
280
+ background: transparent;
281
+ color: #ff6600;
282
+ text-decoration: underline;
283
+ }
284
+
285
+ A.m:hover {
286
+ background: transparent;
287
+ color: #ff6600;
288
+ text-decoration: underline;
289
+ }
290
+
291
+ table.dlsip {
292
+ background: #dddddd;
293
+ border: 0.4ex solid #dddddd;
294
+ }
295
+
296
+ .pod, .manifest { margin-right: 20ex; }
297
+
298
+ .pod PRE {
299
+ background: #eeeeee;
300
+ border: 1px solid #888888;
301
+ color: black;
302
+ padding: 1em;
303
+ white-space: pre;
304
+ }
305
+
306
+ .pod H1 {
307
+ background: transparent;
308
+ color: #006699;
309
+ font-size: large;
310
+ }
311
+
312
+ .pod H1 A { text-decoration: none; }
313
+ .pod H2 A { text-decoration: none; }
314
+ .pod H3 A { text-decoration: none; }
315
+ .pod H4 A { text-decoration: none; }
316
+
317
+ .pod H2 {
318
+ background: transparent;
319
+ color: #006699;
320
+ font-size: medium;
321
+ }
322
+
323
+ .pod H3 {
324
+ background: transparent;
325
+ color: #006699;
326
+ font-size: medium;
327
+ font-style: italic;
328
+ }
329
+
330
+ .pod H4 {
331
+ background: transparent;
332
+ color: #006699;
333
+ font-size: medium;
334
+ font-weight: normal;
335
+ }
336
+
337
+ .pod IMG {
338
+ vertical-align: top;
339
+ }
340
+
341
+ .pod .toc A {
342
+ text-decoration: none;
343
+ }
344
+
345
+ .pod .toc LI {
346
+ line-height: 1.2em;
347
+ list-style-type: none;
348
+ }
349
+
350
+ .faq DT {
351
+ font-size: 1.4em;
352
+ font-weight: bold;
353
+ }
354
+
355
+ .chmenu {
356
+ background: black;
357
+ color: red;
358
+ font: bold 1.1em Arial,Helvetica,sans-serif;
359
+ margin: 1ex auto;
360
+ padding: 0.5ex;
361
+ }
362
+
363
+ .chmenu TD {
364
+ padding: 0.2ex 1ex;
365
+ }
366
+
367
+ .chmenu A:link, .chmenu A:visited {
368
+ background: transparent;
369
+ color: white;
370
+ text-decoration: none;
371
+ }
372
+
373
+ .chmenu A:hover {
374
+ background: transparent;
375
+ color: #ff6600;
376
+ text-decoration: underline;
377
+ }
378
+
379
+ .column {
380
+ padding: 0.5ex 1ex;
381
+ vertical-align: top;
382
+ }
383
+
384
+ .datebar {
385
+ margin: auto;
386
+ width: 14em;
387
+ }
388
+
389
+ .date {
390
+ background: transparent;
391
+ color: #008000;
392
+ }
393
+
394
+ .footer {
395
+ margin-top: 1ex;
396
+ text-align: right;
397
+ color: #006699;
398
+ font-size: x-small;
399
+ border-top: 1px solid #006699;
400
+ line-height: 120%;
401
+ }
402
+
403
+ .front .footer {
404
+ border-top: none;
405
+ }
406
+
407
+ #permalink {
408
+ float: right
409
+ }
410
+
411
+ #permalink A {
412
+ font-size: small;
413
+ }
414
+
415
+ .sr {
416
+ font-size: inherit;
417
+ margin: 0;
418
+ }
419
+
420
+ .cpanstats {
421
+ float: left;
422
+ text-align: left;
423
+ color: #bbb;
424
+ white-space: pre;
425
+ }
426
+
427
+ form.tool {
428
+ margin: 1ex;
429
+ }
430
+
431
+ .styleswitch {
432
+ text-align: right;
433
+ }
@@ -438,6 +438,8 @@ module Writexlsx
438
438
  attr_accessor :id, :name # :nodoc:
439
439
  attr_writer :index, :palette, :protection # :nodoc:
440
440
  attr_reader :embedded, :formula_ids, :formula_data # :nodoc:
441
+ attr_reader :x_scale, :y_scale, :x_offset, :y_offset # :nodoc:
442
+ attr_reader :width, :height
441
443
 
442
444
  #
443
445
  # Factory method for returning chart objects based on their class type.
@@ -504,6 +506,12 @@ module Writexlsx
504
506
  @show_blanks = 'gap'
505
507
  @show_hidden_data = false
506
508
  @show_crosses = true
509
+ @width = 480
510
+ @height = 288
511
+ @x_scale = 1
512
+ @y_scale = 1
513
+ @x_offset = 0
514
+ @y_offset = 0
507
515
 
508
516
  set_default_properties
509
517
  end
@@ -964,6 +972,18 @@ module Writexlsx
964
972
  @show_hidden_data = true
965
973
  end
966
974
 
975
+ #
976
+ # Set dimensions for scale for the chart.
977
+ #
978
+ def size(params = {})
979
+ @width = params[:width] if params[:width]
980
+ @height = params[:height] if params[:height]
981
+ @x_scale = params[:x_scale] if params[:x_scale]
982
+ @y_scale = params[:y_scale] if params[:y_scale]
983
+ @x_offset = params[:x_offset] if params[:x_offset]
984
+ @y_offset = params[:y_offset] if params[:y_offset]
985
+ end
986
+
967
987
  #
968
988
  # Setup the default configuration data for an embedded chart.
969
989
  #
@@ -0,0 +1,132 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'write_xlsx/utility'
3
+
4
+ module Writexlsx
5
+ module Package
6
+
7
+ class Button
8
+ include Writexlsx::Utility
9
+
10
+ attr_accessor :font, :macro, :vertices
11
+
12
+ def v_shape_attributes(id, z_index)
13
+ v_shape_attributes_base(id, z_index) <<
14
+ 'o:button' << 't' <<
15
+ 'fillcolor' << color <<
16
+ 'strokecolor' << 'windowText [64]' <<
17
+ 'o:insetmode' << 'auto'
18
+ end
19
+
20
+ def type
21
+ '#_x0000_t201'
22
+ end
23
+
24
+ def color
25
+ 'buttonFace [67]'
26
+ end
27
+
28
+ def style_addition
29
+ ['mso-wrap-style:tight']
30
+ end
31
+
32
+ def write_shape(writer, id, z_index)
33
+ @writer = writer
34
+
35
+ attributes = v_shape_attributes(id, z_index)
36
+
37
+ @writer.tag_elements('v:shape', attributes) do
38
+ # Write the v:fill element.
39
+ write_fill
40
+ # Write the o:lock element.
41
+ write_rotation_lock
42
+ # Write the v:textbox element.
43
+ write_textbox
44
+ # Write the x:ClientData element.
45
+ write_client_data
46
+ end
47
+ end
48
+
49
+ # attributes for <v:fill> element.
50
+ def fill_attributes
51
+ [
52
+ 'color2', 'buttonFace [67]',
53
+ 'o:detectmouseclick', 't'
54
+ ]
55
+ end
56
+
57
+ #
58
+ # Write the <o:lock> element.
59
+ #
60
+ def write_rotation_lock
61
+ attributes = [
62
+ 'v:ext', 'edit',
63
+ 'rotation', 't'
64
+ ]
65
+ @writer.empty_tag('o:lock', attributes)
66
+ end
67
+
68
+ #
69
+ # Write the <v:textbox> element.
70
+ #
71
+ def write_textbox
72
+ attributes = ['style', 'mso-direction-alt:auto', 'o:singleclick', 'f']
73
+
74
+ @writer.tag_elements('v:textbox', attributes) do
75
+ # Write the div element.
76
+ write_div('center', font)
77
+ end
78
+ end
79
+
80
+ #
81
+ # Write the <x:ClientData> element.
82
+ #
83
+ def write_client_data
84
+ attributes = ['ObjectType', 'Button']
85
+
86
+ @writer.tag_elements('x:ClientData', attributes) do
87
+ # Write the x:Anchor element.
88
+ write_anchor
89
+ # Write the x:PrintObject element.
90
+ write_print_object
91
+ # Write the x:AutoFill element.
92
+ write_auto_fill
93
+ # Write the x:FmlaMacro element.
94
+ write_fmla_macro
95
+ # Write the x:TextHAlign element.
96
+ write_text_halign
97
+ # Write the x:TextVAlign element.
98
+ write_text_valign
99
+ end
100
+ end
101
+
102
+ #
103
+ # Write the <x:PrintObject> element.
104
+ #
105
+ def write_print_object
106
+ @writer.data_element('x:PrintObject', 'False')
107
+ end
108
+
109
+ #
110
+ # Write the <x:FmlaMacro> element.
111
+ #
112
+ def write_fmla_macro
113
+ @writer.data_element('x:FmlaMacro', macro)
114
+ end
115
+
116
+ #
117
+ # Write the <x:TextHAlign> element.
118
+ #
119
+ def write_text_halign
120
+ @writer.data_element('x:TextHAlign', 'Center')
121
+ end
122
+
123
+ #
124
+ # Write the <x:TextVAlign> element.
125
+ #
126
+ def write_text_valign
127
+ @writer.data_element('x:TextVAlign', 'Center')
128
+ end
129
+ end
130
+ end
131
+ end
132
+
@@ -7,7 +7,6 @@ module Writexlsx
7
7
  module Package
8
8
 
9
9
  class Comment
10
-
11
10
  include Writexlsx::Utility
12
11
 
13
12
  DEFAULT_COLOR = 81 # what color ?
@@ -117,6 +116,103 @@ module Writexlsx
117
116
  10
118
117
  end
119
118
  end
119
+
120
+ def v_shape_attributes(id, z_index)
121
+ v_shape_attributes_base(id, z_index) <<
122
+ 'fillcolor' << color <<
123
+ 'o:insetmode' << 'auto'
124
+ end
125
+
126
+ def type
127
+ '#_x0000_t202'
128
+ end
129
+
130
+ def style_addition
131
+ ['visibility:', visibility]
132
+ end
133
+
134
+ def write_shape(writer, id, z_index)
135
+ @writer = writer
136
+
137
+ attributes = v_shape_attributes(id, z_index)
138
+
139
+ @writer.tag_elements('v:shape', attributes) do
140
+ writer = @writer
141
+
142
+ # Write the v:fill element.
143
+ write_fill
144
+ # Write the v:shadow element.
145
+ write_shadow
146
+ # Write the v:path element.
147
+ write_comment_path(nil, 'none')
148
+ # Write the v:textbox element.
149
+ write_textbox
150
+ # Write the x:ClientData element.
151
+ write_client_data
152
+ end
153
+ end
154
+
155
+ def visibility
156
+ ptrue?(visible) ? 'visible' : 'hidden'
157
+ end
158
+
159
+ #
160
+ # Write the <v:fill> element.
161
+ #
162
+ def fill_attributes
163
+ ['color2', '#ffffe1']
164
+ end
165
+
166
+ #
167
+ # Write the <v:shadow> element.
168
+ #
169
+ def write_shadow
170
+ attributes = [
171
+ 'on', 't',
172
+ 'color', 'black',
173
+ 'obscured', 't'
174
+ ]
175
+
176
+ @writer.empty_tag('v:shadow', attributes)
177
+ end
178
+
179
+ #
180
+ # Write the <v:textbox> element.
181
+ #
182
+ def write_textbox
183
+ attributes = ['style', 'mso-direction-alt:auto']
184
+
185
+ @writer.tag_elements('v:textbox', attributes) do
186
+ # Write the div element.
187
+ write_div('left')
188
+ end
189
+ end
190
+
191
+ #
192
+ # Write the <x:ClientData> element.
193
+ #
194
+ def write_client_data
195
+ attributes = ['ObjectType', 'Note']
196
+
197
+ @writer.tag_elements('x:ClientData', attributes) do
198
+ @writer.empty_tag('x:MoveWithCells')
199
+ @writer.empty_tag('x:SizeWithCells')
200
+ # Write the x:Anchor element.
201
+ write_anchor
202
+ # Write the x:AutoFill element.
203
+ write_auto_fill
204
+ # Write the x:Row element.
205
+ @writer.data_element('x:Row', row)
206
+ # Write the x:Column element.
207
+ @writer.data_element('x:Column', col)
208
+ # Write the x:Visible element.
209
+ @writer.empty_tag('x:Visible') if ptrue?(visible)
210
+ end
211
+ end
212
+
213
+ def writer=(w)
214
+ @writer = w
215
+ end
120
216
  end
121
217
 
122
218
  class Comments