write_xlsx 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/README.rdoc +3 -0
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/examples/formats.rb +498 -0
  5. data/lib/write_xlsx/chart.rb +15 -15
  6. data/lib/write_xlsx/chartsheet.rb +1 -1
  7. data/lib/write_xlsx/format.rb +10 -3
  8. data/lib/write_xlsx/package/comments.rb +171 -27
  9. data/lib/write_xlsx/package/packager.rb +8 -17
  10. data/lib/write_xlsx/package/shared_strings.rb +36 -15
  11. data/lib/write_xlsx/package/styles.rb +2 -12
  12. data/lib/write_xlsx/package/vml.rb +14 -22
  13. data/lib/write_xlsx/utility.rb +53 -4
  14. data/lib/write_xlsx/workbook.rb +21 -37
  15. data/lib/write_xlsx/worksheet.rb +533 -765
  16. data/test/helper.rb +10 -3
  17. data/test/package/comments/test_write_text_t.rb +1 -1
  18. data/test/package/shared_strings/test_shared_strings01.rb +3 -3
  19. data/test/package/shared_strings/test_shared_strings02.rb +3 -3
  20. data/test/package/shared_strings/test_write_sst.rb +3 -2
  21. data/test/package/vml/test_write_anchor.rb +1 -1
  22. data/test/package/vml/test_write_auto_fill.rb +1 -1
  23. data/test/package/vml/test_write_column.rb +1 -1
  24. data/test/package/vml/test_write_div.rb +1 -1
  25. data/test/package/vml/test_write_fill.rb +1 -1
  26. data/test/package/vml/test_write_idmap.rb +1 -1
  27. data/test/package/vml/test_write_move_with_cells.rb +1 -1
  28. data/test/package/vml/test_write_path.rb +2 -2
  29. data/test/package/vml/test_write_row.rb +1 -1
  30. data/test/package/vml/test_write_shadow.rb +1 -1
  31. data/test/package/vml/test_write_shapelayout.rb +1 -1
  32. data/test/package/vml/test_write_shapetype.rb +1 -1
  33. data/test/package/vml/test_write_size_with_cells.rb +1 -1
  34. data/test/package/vml/test_write_stroke.rb +1 -1
  35. data/test/package/vml/test_write_textbox.rb +1 -1
  36. data/test/perl_output/formats.xlsx +0 -0
  37. data/test/perl_output/indent.xlsx +0 -0
  38. data/test/perl_output/merge4.xlsx +0 -0
  39. data/test/perl_output/merge5.xlsx +0 -0
  40. data/test/test_example_match.rb +482 -0
  41. data/test/worksheet/test_repeat_formula.rb +5 -5
  42. data/test/worksheet/test_write_cell.rb +10 -5
  43. data/test/worksheet/test_write_legacy_drawing.rb +1 -1
  44. data/write_xlsx.gemspec +5 -5
  45. metadata +15 -15
  46. data/test/package/comments/test_comments01.rb +0 -36
  47. data/test/package/vml/test_vml_01.rb +0 -42
data/README.rdoc CHANGED
@@ -60,6 +60,9 @@ in an Excel XMLX spreadsheet called ruby.xlsx:
60
60
 
61
61
  == Recent change
62
62
 
63
+ 2012-01-25 v0.0.3
64
+ alignment format support. see examples/formats.rb
65
+
63
66
  2012-01-20 v0.0.1
64
67
  initial release
65
68
 
data/Rakefile CHANGED
@@ -40,7 +40,7 @@ The WriteXLSX supports the following features:
40
40
 
41
41
  write_xlsx uses the same interface as writeexcel gem.
42
42
 
43
- documentation is not completed, but writeexcel’s documentation will help you. See writeexcel.web.fc2.com/
43
+ documentation is not completed, but writeexcel’s documentation will help you. See http://writeexcel.web.fc2.com/
44
44
 
45
45
  And you can find many examples in this gem.
46
46
  EOS
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -0,0 +1,498 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+
4
+ ###############################################################################
5
+ #
6
+ # Examples of formatting using the Excel::Writer::XLSX module.
7
+ #
8
+ # This program demonstrates almost all possible formatting options. It is worth
9
+ # running this program and viewing the output Excel file if you are interested
10
+ # in the various formatting possibilities.
11
+ #
12
+ # reverse('ゥ'), September 2002, John McNamara, jmcnamara@cpan.org
13
+ # convert to Ruby by Hideo NAKAMURA, cxn03651@msj.biglobe.ne.jp
14
+ #
15
+
16
+ require 'rubygems'
17
+ require 'write_xlsx'
18
+
19
+ workbook = WriteXLSX.new('formats.xlsx')
20
+
21
+ # Some common formats
22
+ center = workbook.add_format(:align => 'center')
23
+ heading = workbook.add_format(:align => 'center', :bold => 1)
24
+
25
+ # The named colors
26
+ colors = {
27
+ 0x08 => 'black',
28
+ 0x0C => 'blue',
29
+ 0x10 => 'brown',
30
+ 0x0F => 'cyan',
31
+ 0x17 => 'gray',
32
+ 0x11 => 'green',
33
+ 0x0B => 'lime',
34
+ 0x0E => 'magenta',
35
+ 0x12 => 'navy',
36
+ 0x35 => 'orange',
37
+ 0x21 => 'pink',
38
+ 0x14 => 'purple',
39
+ 0x0A => 'red',
40
+ 0x16 => 'silver',
41
+ 0x09 => 'white',
42
+ 0x0D => 'yellow'
43
+ }
44
+
45
+ ######################################################################
46
+ #
47
+ # Intro.
48
+ #
49
+ def intro(workbook, center, heading, colors)
50
+ worksheet = workbook.add_worksheet('Introduction')
51
+
52
+ worksheet.set_column(0, 0, 60)
53
+
54
+ format = workbook.add_format
55
+ format.set_bold
56
+ format.set_size(14)
57
+ format.set_color('blue')
58
+ format.set_align('center')
59
+
60
+ format2 = workbook.add_format
61
+ format2.set_bold
62
+ format2.set_color('blue')
63
+
64
+ format3 = workbook.add_format(
65
+ :color => 'blue',
66
+ :underline => 1,
67
+ )
68
+
69
+ worksheet.write(2, 0, 'This workbook demonstrates some of', format)
70
+ worksheet.write(3, 0, 'the formatting options provided by', format)
71
+ worksheet.write(4, 0, 'the Excel::Writer::XLSX module.', format)
72
+ worksheet.write('A7', 'Sections:', format2)
73
+
74
+ worksheet.write('A8', "internal:Fonts!A1", 'Fonts', format3)
75
+
76
+ worksheet.write('A9', "internal:'Named colors'!A1",
77
+ 'Named colors', format3)
78
+
79
+ worksheet.write(
80
+ 'A10',
81
+ "internal:'Standard colors'!A1",
82
+ 'Standard colors', format3
83
+ )
84
+
85
+ worksheet.write(
86
+ 'A11',
87
+ "internal:'Numeric formats'!A1",
88
+ 'Numeric formats', format3
89
+ )
90
+
91
+ worksheet.write('A12', "internal:Borders!A1", 'Borders', format3)
92
+ worksheet.write('A13', "internal:Patterns!A1", 'Patterns', format3)
93
+ worksheet.write('A14', "internal:Alignment!A1", 'Alignment', format3)
94
+ worksheet.write('A15', "internal:Miscellaneous!A1", 'Miscellaneous',
95
+ format3)
96
+
97
+ end
98
+
99
+ ######################################################################
100
+ #
101
+ # Demonstrate the named colors.
102
+ #
103
+ def named_colors(workbook, center, heading, colors)
104
+
105
+ worksheet = workbook.add_worksheet('Named colors')
106
+
107
+ worksheet.set_column(0, 3, 15)
108
+
109
+ worksheet.write(0, 0, "Index", heading)
110
+ worksheet.write(0, 1, "Index", heading)
111
+ worksheet.write(0, 2, "Name", heading)
112
+ worksheet.write(0, 3, "Color", heading)
113
+
114
+ i = 1
115
+
116
+ [33, 11, 53, 17, 22, 18, 13, 16, 23, 9, 12, 15, 14, 20, 8, 10].each do |index|
117
+ color = colors[index]
118
+ format = workbook.add_format(
119
+ :bg_color => color,
120
+ :pattern => 1,
121
+ :border => 1
122
+ )
123
+
124
+ worksheet.write(i + 1, 0, index, center)
125
+ worksheet.write(i + 1, 1, sprintf("0x%02X", index), center)
126
+ worksheet.write(i + 1, 2, color, center)
127
+ worksheet.write(i + 1, 3, '', format)
128
+ i += 1
129
+ end
130
+ end
131
+
132
+ ######################################################################
133
+ #
134
+ # Demonstrate the standard Excel colors in the range 8..63.
135
+ #
136
+ def standard_colors(workbook, center, heading, colors)
137
+
138
+ worksheet = workbook.add_worksheet('Standard colors')
139
+
140
+ worksheet.set_column(0, 3, 15)
141
+
142
+ worksheet.write(0, 0, "Index", heading)
143
+ worksheet.write(0, 1, "Index", heading)
144
+ worksheet.write(0, 2, "Color", heading)
145
+ worksheet.write(0, 3, "Name", heading)
146
+
147
+ (8 .. 63).each do |i|
148
+ format = workbook.add_format(
149
+ :bg_color => i,
150
+ :pattern => 1,
151
+ :border => 1
152
+ )
153
+
154
+ worksheet.write((i - 7), 0, i, center)
155
+ worksheet.write((i - 7), 1, sprintf("0x%02X", i), center)
156
+ worksheet.write((i - 7), 2, '', format)
157
+
158
+ # Add the color names
159
+ if colors[i]
160
+ worksheet.write((i - 7), 3, colors[i], center)
161
+ end
162
+ end
163
+ end
164
+
165
+ ######################################################################
166
+ #
167
+ # Demonstrate the standard numeric formats.
168
+ #
169
+ def numeric_formats(workbook, center, heading, colors)
170
+
171
+ worksheet = workbook.add_worksheet('Numeric formats')
172
+
173
+ worksheet.set_column(0, 4, 15)
174
+ worksheet.set_column(5, 5, 45)
175
+
176
+ worksheet.write(0, 0, "Index", heading)
177
+ worksheet.write(0, 1, "Index", heading)
178
+ worksheet.write(0, 2, "Unformatted", heading)
179
+ worksheet.write(0, 3, "Formatted", heading)
180
+ worksheet.write(0, 4, "Negative", heading)
181
+ worksheet.write(0, 5, "Format", heading)
182
+
183
+ formats = []
184
+ formats << [ 0x00, 1234.567, 0, 'General' ]
185
+ formats << [ 0x01, 1234.567, 0, '0' ]
186
+ formats << [ 0x02, 1234.567, 0, '0.00' ]
187
+ formats << [ 0x03, 1234.567, 0, '#,##0' ]
188
+ formats << [ 0x04, 1234.567, 0, '#,##0.00' ]
189
+ formats << [ 0x05, 1234.567, -1234.567, '($#,##0_);($#,##0)' ]
190
+ formats << [ 0x06, 1234.567, -1234.567, '($#,##0_);[Red]($#,##0)' ]
191
+ formats << [ 0x07, 1234.567, -1234.567, '($#,##0.00_);($#,##0.00)' ]
192
+ formats << [ 0x08, 1234.567, -1234.567, '($#,##0.00_);[Red]($#,##0.00)' ]
193
+ formats << [ 0x09, 0.567, 0, '0%' ]
194
+ formats << [ 0x0a, 0.567, 0, '0.00%' ]
195
+ formats << [ 0x0b, 1234.567, 0, '0.00E+00' ]
196
+ formats << [ 0x0c, 0.75, 0, '# ?/?' ]
197
+ formats << [ 0x0d, 0.3125, 0, '# ??/??' ]
198
+ formats << [ 0x0e, 36892.521, 0, 'm/d/yy' ]
199
+ formats << [ 0x0f, 36892.521, 0, 'd-mmm-yy' ]
200
+ formats << [ 0x10, 36892.521, 0, 'd-mmm' ]
201
+ formats << [ 0x11, 36892.521, 0, 'mmm-yy' ]
202
+ formats << [ 0x12, 36892.521, 0, 'h:mm AM/PM' ]
203
+ formats << [ 0x13, 36892.521, 0, 'h:mm:ss AM/PM' ]
204
+ formats << [ 0x14, 36892.521, 0, 'h:mm' ]
205
+ formats << [ 0x15, 36892.521, 0, 'h:mm:ss' ]
206
+ formats << [ 0x16, 36892.521, 0, 'm/d/yy h:mm' ]
207
+ formats << [ 0x25, 1234.567, -1234.567, '(#,##0_);(#,##0)' ]
208
+ formats << [ 0x26, 1234.567, -1234.567, '(#,##0_);[Red](#,##0)' ]
209
+ formats << [ 0x27, 1234.567, -1234.567, '(#,##0.00_);(#,##0.00)' ]
210
+ formats << [ 0x28, 1234.567, -1234.567, '(#,##0.00_);[Red](#,##0.00)' ]
211
+ formats << [ 0x29, 1234.567, -1234.567, '_(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)' ]
212
+ formats << [ 0x2a, 1234.567, -1234.567, '_($* #,##0_);_($* (#,##0);_($* "-"_);_(@_)' ]
213
+ formats << [ 0x2b, 1234.567, -1234.567, '_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)' ]
214
+ formats << [ 0x2c, 1234.567, -1234.567, '_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)' ]
215
+ formats << [ 0x2d, 36892.521, 0, 'mm:ss' ]
216
+ formats << [ 0x2e, 3.0153, 0, '[h]:mm:ss' ]
217
+ formats << [ 0x2f, 36892.521, 0, 'mm:ss.0' ]
218
+ formats << [ 0x30, 1234.567, 0, '##0.0E+0' ]
219
+ formats << [ 0x31, 1234.567, 0, '@' ]
220
+
221
+ i = 0
222
+ formats.each do |format|
223
+ style = workbook.add_format
224
+ style.set_num_format(format[0])
225
+
226
+ i += 1
227
+ worksheet.write(i, 0, format[0], center)
228
+ worksheet.write(i, 1, sprintf("0x%02X", format[0]), center)
229
+ worksheet.write(i, 2, format[1], center)
230
+ worksheet.write(i, 3, format[1], style)
231
+
232
+ if format[2] != 0
233
+ worksheet.write(i, 4, format[2], style)
234
+ end
235
+
236
+ worksheet.write_string(i, 5, format[3])
237
+ end
238
+ end
239
+
240
+ ######################################################################
241
+ #
242
+ # Demonstrate the font options.
243
+ #
244
+ def fonts(workbook, center, heading, colors)
245
+
246
+ worksheet = workbook.add_worksheet('Fonts')
247
+
248
+ worksheet.set_column(0, 0, 30)
249
+ worksheet.set_column(1, 1, 10)
250
+
251
+ worksheet.write(0, 0, "Font name", heading)
252
+ worksheet.write(0, 1, "Font size", heading)
253
+
254
+ fonts = []
255
+ fonts << [ 10, 'Arial' ]
256
+ fonts << [ 12, 'Arial' ]
257
+ fonts << [ 14, 'Arial' ]
258
+ fonts << [ 12, 'Arial Black' ]
259
+ fonts << [ 12, 'Arial Narrow' ]
260
+ fonts << [ 12, 'Century Schoolbook' ]
261
+ fonts << [ 12, 'Courier' ]
262
+ fonts << [ 12, 'Courier New' ]
263
+ fonts << [ 12, 'Garamond' ]
264
+ fonts << [ 12, 'Impact' ]
265
+ fonts << [ 12, 'Lucida Handwriting' ]
266
+ fonts << [ 12, 'Times New Roman' ]
267
+ fonts << [ 12, 'Symbol' ]
268
+ fonts << [ 12, 'Wingdings' ]
269
+ fonts << [ 12, 'A font that doesn\'t exist' ]
270
+
271
+ i = 0
272
+ fonts.each do |font|
273
+ format = workbook.add_format
274
+
275
+ format.set_size(font[0])
276
+ format.set_font(font[1])
277
+
278
+ i += 1
279
+ worksheet.write(i, 0, font[1], format)
280
+ worksheet.write(i, 1, font[0], format)
281
+ end
282
+ end
283
+
284
+ ######################################################################
285
+ #
286
+ # Demonstrate the standard Excel border styles.
287
+ #
288
+ def borders(workbook, center, heading, colors)
289
+ worksheet = workbook.add_worksheet('Borders')
290
+
291
+ worksheet.set_column(0, 4, 10)
292
+ worksheet.set_column(5, 5, 40)
293
+
294
+ worksheet.write(0, 0, "Index", heading)
295
+ worksheet.write(0, 1, "Index", heading)
296
+ worksheet.write(0, 3, "Style", heading)
297
+ worksheet.write(0, 5, "The style is highlighted in red for ", heading)
298
+ worksheet.write(1, 5, "emphasis, the default color is black.",
299
+ heading)
300
+
301
+ (0 .. 13).each do |i|
302
+
303
+ format = workbook.add_format
304
+ format.set_border(i)
305
+ format.set_border_color('red')
306
+ format.set_align('center')
307
+
308
+ worksheet.write((2 * (i + 1)), 0, i, center)
309
+ worksheet.write((2 * (i + 1)),
310
+ 1, sprintf("0x%02X", i), center)
311
+
312
+ worksheet.write((2 * (i + 1)), 3, "Border", format)
313
+ end
314
+
315
+ worksheet.write(30, 0, "Diag type", heading)
316
+ worksheet.write(30, 1, "Index", heading)
317
+ worksheet.write(30, 3, "Style", heading)
318
+ worksheet.write(30, 5, "Diagonal Boder styles", heading)
319
+
320
+ (1 .. 3).each do |i|
321
+ format = workbook.add_format
322
+ format.set_diag_type(i)
323
+ format.set_diag_border(1)
324
+ format.set_diag_color('red')
325
+ format.set_align('center')
326
+
327
+ worksheet.write((2 * (i + 15)), 0, i, center)
328
+ worksheet.write((2 * (i + 15)),
329
+ 1, sprintf("0x%02X", i), center)
330
+
331
+ worksheet.write((2 * (i + 15)), 3, "Border", format)
332
+ end
333
+ end
334
+
335
+ ######################################################################
336
+ #
337
+ # Demonstrate the standard Excel cell patterns.
338
+ #
339
+ def patterns(workbook, center, heading, colors)
340
+ worksheet = workbook.add_worksheet('Patterns')
341
+
342
+ worksheet.set_column(0, 4, 10)
343
+ worksheet.set_column(5, 5, 50)
344
+
345
+ worksheet.write(0, 0, "Index", heading)
346
+ worksheet.write(0, 1, "Index", heading)
347
+ worksheet.write(0, 3, "Pattern", heading)
348
+
349
+ worksheet.write(0, 5, "The background colour has been set to silver.",
350
+ heading)
351
+ worksheet.write(1, 5, "The foreground colour has been set to green.",
352
+ heading)
353
+
354
+ (0 .. 18).each do |i|
355
+ format = workbook.add_format
356
+
357
+ format.set_pattern(i)
358
+ format.set_bg_color('silver')
359
+ format.set_fg_color('green')
360
+ format.set_align('center')
361
+
362
+ worksheet.write((2 * (i + 1)), 0, i, center)
363
+ worksheet.write((2 * (i + 1)),
364
+ 1, sprintf("0x%02X", i), center)
365
+
366
+ worksheet.write((2 * (i + 1)), 3, "Pattern", format)
367
+
368
+ if i == 1
369
+ worksheet.write((2 * (i + 1)),
370
+ 5, "This is solid colour, the most useful pattern.", heading)
371
+ end
372
+ end
373
+ end
374
+
375
+ ######################################################################
376
+ #
377
+ # Demonstrate the standard Excel cell alignments.
378
+ #
379
+ def alignment(workbook, center, heading, colors)
380
+ worksheet = workbook.add_worksheet('Alignment')
381
+
382
+ worksheet.set_column(0, 7, 12)
383
+ worksheet.set_row(0, 40)
384
+ worksheet.set_selection(7, 0)
385
+
386
+ format01 = workbook.add_format
387
+ format02 = workbook.add_format
388
+ format03 = workbook.add_format
389
+ format04 = workbook.add_format
390
+ format05 = workbook.add_format
391
+ format06 = workbook.add_format
392
+ format07 = workbook.add_format
393
+ format08 = workbook.add_format
394
+ format09 = workbook.add_format
395
+ format10 = workbook.add_format
396
+ format11 = workbook.add_format
397
+ format12 = workbook.add_format
398
+ format13 = workbook.add_format
399
+ format14 = workbook.add_format
400
+ format15 = workbook.add_format
401
+ format16 = workbook.add_format
402
+ format17 = workbook.add_format
403
+
404
+ format02.set_align('top')
405
+ format03.set_align('bottom')
406
+ format04.set_align('vcenter')
407
+ format05.set_align('vjustify')
408
+ format06.set_text_wrap
409
+
410
+ format07.set_align('left')
411
+ format08.set_align('right')
412
+ format09.set_align('center')
413
+ format10.set_align('fill')
414
+ format11.set_align('justify')
415
+ format12.set_merge
416
+
417
+ format13.set_rotation(45)
418
+ format14.set_rotation(-45)
419
+ format15.set_rotation(270)
420
+
421
+ format16.set_shrink
422
+ format17.set_indent(1)
423
+
424
+ worksheet.write(0, 0, 'Vertical', heading)
425
+ worksheet.write(0, 1, 'top', format02)
426
+ worksheet.write(0, 2, 'bottom', format03)
427
+ worksheet.write(0, 3, 'vcenter', format04)
428
+ worksheet.write(0, 4, 'vjustify', format05)
429
+ worksheet.write(0, 5, "text\nwrap", format06)
430
+
431
+ worksheet.write(2, 0, 'Horizontal', heading)
432
+ worksheet.write(2, 1, 'left', format07)
433
+ worksheet.write(2, 2, 'right', format08)
434
+ worksheet.write(2, 3, 'center', format09)
435
+ worksheet.write(2, 4, 'fill', format10)
436
+ worksheet.write(2, 5, 'justify', format11)
437
+
438
+ worksheet.write(3, 1, 'merge', format12)
439
+ worksheet.write(3, 2, '', format12)
440
+
441
+ worksheet.write(3, 3, 'Shrink ' * 3, format16)
442
+ worksheet.write(3, 4, 'Indent', format17)
443
+
444
+
445
+ worksheet.write(5, 0, 'Rotation', heading)
446
+ worksheet.write(5, 1, 'Rotate 45', format13)
447
+ worksheet.write(6, 1, 'Rotate -45', format14)
448
+ worksheet.write(7, 1, 'Rotate 270', format15)
449
+ end
450
+
451
+ ######################################################################
452
+ #
453
+ # Demonstrate other miscellaneous features.
454
+ #
455
+ def misc(workbook, center, heading, colors)
456
+ worksheet = workbook.add_worksheet('Miscellaneous')
457
+
458
+ worksheet.set_column(2, 2, 25)
459
+
460
+ format01 = workbook.add_format
461
+ format02 = workbook.add_format
462
+ format03 = workbook.add_format
463
+ format04 = workbook.add_format
464
+ format05 = workbook.add_format
465
+ format06 = workbook.add_format
466
+ format07 = workbook.add_format
467
+
468
+ format01.set_underline(0x01)
469
+ format02.set_underline(0x02)
470
+ format03.set_underline(0x21)
471
+ format04.set_underline(0x22)
472
+ format05.set_font_strikeout
473
+ format06.set_font_outline
474
+ format07.set_font_shadow
475
+
476
+ worksheet.write(1, 2, 'Underline 0x01', format01)
477
+ worksheet.write(3, 2, 'Underline 0x02', format02)
478
+ worksheet.write(5, 2, 'Underline 0x21', format03)
479
+ worksheet.write(7, 2, 'Underline 0x22', format04)
480
+ worksheet.write(9, 2, 'Strikeout', format05)
481
+ worksheet.write(11, 2, 'Outline (Macintosh only)', format06)
482
+ worksheet.write(13, 2, 'Shadow (Macintosh only)', format07)
483
+ end
484
+
485
+ # Call these subroutines to demonstrate different formatting options
486
+ intro(workbook, center, heading, colors)
487
+ fonts(workbook, center, heading, colors)
488
+ named_colors(workbook, center, heading, colors)
489
+ standard_colors(workbook, center, heading, colors)
490
+ numeric_formats(workbook, center, heading, colors)
491
+ borders(workbook, center, heading, colors)
492
+ patterns(workbook, center, heading, colors)
493
+ alignment(workbook, center, heading, colors)
494
+ misc(workbook, center, heading, colors)
495
+
496
+ # Note: this is required
497
+ workbook.close
498
+
@@ -3,7 +3,7 @@ require 'write_xlsx/package/xml_writer_simple'
3
3
  require 'write_xlsx/utility'
4
4
 
5
5
  module Writexlsx
6
- # ==SYNOPSIS
6
+ # ==SYNOPSIS
7
7
  #
8
8
  # To create a simple Excel file with a chart using WriteXLSX:
9
9
  #
@@ -32,7 +32,7 @@ module Writexlsx
32
32
  #
33
33
  # workbook.close
34
34
  #
35
- # ==DESCRIPTION
35
+ # ==DESCRIPTION
36
36
  #
37
37
  # The Chart module is an abstract base class for modules that implement
38
38
  # charts in WriteXLSX. The information below is applicable to all of
@@ -66,10 +66,10 @@ module Writexlsx
66
66
  # ===stock
67
67
  # Creates an Stock style chart. See Writexlsx::Chart::Stock.
68
68
  #
69
- # ==CHART FORMATTING
69
+ # ==CHART FORMATTING
70
70
  #
71
71
  # The following chart formatting properties can be set for any chart object
72
- # that they apply to (and that are supported by Excel::Writer::XLSX) such
72
+ # that they apply to (and that are supported by WriteXLSX) such
73
73
  # as chart lines, column fill areas, plot area borders, markers and other
74
74
  # chart elements documented above.
75
75
  #
@@ -570,7 +570,7 @@ module Writexlsx
570
570
  # You can add more than one series to a chart. In fact, some chart
571
571
  # types such as stock require it. The series numbering and order in
572
572
  # the Excel chart will be the same as the order in which that are added
573
- # in Excel::Writer::XLSX.
573
+ # in WriteXLSX.
574
574
  #
575
575
  # # Add the first series.
576
576
  # chart.add_series(
@@ -1715,7 +1715,7 @@ module Writexlsx
1715
1715
  horiz = @horiz_cat_axis
1716
1716
  x_axis = @x_axis
1717
1717
  y_axis = @y_axis
1718
-
1718
+
1719
1719
  # Overwrite the default axis position with a user supplied value.
1720
1720
  position = x_axis[:_position] || position
1721
1721
 
@@ -1823,10 +1823,10 @@ module Writexlsx
1823
1823
 
1824
1824
  # Write the c:majorUnit element.
1825
1825
  write_c_major_unit(y_axis[:_major_unit])
1826
-
1826
+
1827
1827
  # Write the c:minorUnit element.
1828
1828
  write_c_minor_unit(y_axis[:_minor_unit])
1829
-
1829
+
1830
1830
  @writer.end_tag('c:valAx')
1831
1831
  end
1832
1832
 
@@ -1945,15 +1945,15 @@ module Writexlsx
1945
1945
 
1946
1946
  # Write the c:majorUnit element.
1947
1947
  write_c_major_unit(x_axis[:_major_unit])
1948
-
1948
+
1949
1949
  # Write the c:majorTimeUnit element.
1950
1950
  if !x_axis[:_major_unit].nil?
1951
1951
  write_c_major_time_unit(x_axis[:_major_unit_type])
1952
1952
  end
1953
-
1953
+
1954
1954
  # Write the c:minorUnit element.
1955
1955
  write_c_minor_unit(x_axis[:_minor_unit])
1956
-
1956
+
1957
1957
  # Write the c:minorTimeUnit element.
1958
1958
  if !x_axis[:_minor_unit].nil?
1959
1959
  write_c_minor_time_unit(x_axis[:_minor_unit_type])
@@ -1967,7 +1967,7 @@ module Writexlsx
1967
1967
  #
1968
1968
  def write_scaling(reverse, min = nil, max = nil, log_base = nil) # :nodoc:
1969
1969
  @writer.start_tag('c:scaling')
1970
-
1970
+
1971
1971
  # Write the c:logBase element.
1972
1972
  write_c_log_base(log_base)
1973
1973
 
@@ -1976,7 +1976,7 @@ module Writexlsx
1976
1976
 
1977
1977
  # Write the c:max element.
1978
1978
  write_c_max(max)
1979
-
1979
+
1980
1980
  # Write the c:min element.
1981
1981
  write_c_min(min)
1982
1982
 
@@ -2001,7 +2001,7 @@ module Writexlsx
2001
2001
  return if val == 0 || val.nil?
2002
2002
 
2003
2003
  attributes = ['val', val]
2004
-
2004
+
2005
2005
  @writer.empty_tag('c:logBase', attributes)
2006
2006
  end
2007
2007
 
@@ -2096,7 +2096,7 @@ module Writexlsx
2096
2096
  #
2097
2097
  def write_crosses(val) # :nodoc:
2098
2098
  val ||= 'autoZero'
2099
-
2099
+
2100
2100
  attributes = ['val', val]
2101
2101
 
2102
2102
  @writer.empty_tag('c:crosses', attributes)
@@ -123,7 +123,7 @@ module Writexlsx
123
123
  #
124
124
  def prepare_chart(index, chart_id, drawing_id) # :nodoc:
125
125
  drawing = Drawing.new
126
- @drawing = $drawing
126
+ @drawing = drawing
127
127
  @drawing.orientation = @orientation
128
128
 
129
129
  @external_drawing_links << [ '/drawing', '../drawings/drawing' << drawing_id << '.xml' ]
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Writexlsx
3
- # ==CELL FORMATTING
3
+ # ==CELL FORMATTING
4
4
  #
5
5
  # This section describes the methods and properties that are available
6
6
  # for formatting cells in Excel. The properties of a cell that can be
@@ -131,7 +131,7 @@ module Writexlsx
131
131
  #
132
132
  # The default format is Arial 10 with all other properties off.
133
133
  #
134
- # Each unique format in Excel::Writer::XLSX must have a corresponding Format
134
+ # Each unique format in WriteXLSX must have a corresponding Format
135
135
  # object. It isn't possible to use a Format with a write() method and then
136
136
  # redefine the Format for use at a later stage. This is because a Format
137
137
  # is applied to a cell not in its current state but in its final state.
@@ -364,7 +364,7 @@ module Writexlsx
364
364
  # Returns a unique hash key for the Format object.
365
365
  #
366
366
  def get_format_key
367
- [get_font_key, get_border_key, get_fill_key, @num_format].join(':')
367
+ [get_font_key, get_border_key, get_fill_key, @num_format, get_alignment_key].join(':')
368
368
  end
369
369
 
370
370
  #
@@ -417,6 +417,13 @@ module Writexlsx
417
417
  ].join(':')
418
418
  end
419
419
 
420
+ #
421
+ # Returns a unique hash key for alignment formats.
422
+ #
423
+ def get_alignment_key
424
+ [@text_h_align, @text_v_align, @indent, @rotation, @text_wrap, @shrink, @reading_order].join(':')
425
+ end
426
+
420
427
  #
421
428
  # Returns the index used by Worksheet->_XF()
422
429
  #