write_xlsx 0.72.2 → 0.72.3.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/{README.rdoc → Changes} +3 -94
  3. data/README.md +96 -0
  4. data/lib/write_xlsx/chart.rb +115 -259
  5. data/lib/write_xlsx/chart/axis.rb +4 -4
  6. data/lib/write_xlsx/chart/bar.rb +1 -1
  7. data/lib/write_xlsx/chart/column.rb +1 -1
  8. data/lib/write_xlsx/chart/pie.rb +3 -3
  9. data/lib/write_xlsx/chart/radar.rb +1 -1
  10. data/lib/write_xlsx/chart/scatter.rb +1 -1
  11. data/lib/write_xlsx/chart/series.rb +0 -37
  12. data/lib/write_xlsx/chartsheet.rb +25 -37
  13. data/lib/write_xlsx/col_name.rb +40 -0
  14. data/lib/write_xlsx/drawing.rb +95 -85
  15. data/lib/write_xlsx/format.rb +32 -32
  16. data/lib/write_xlsx/package/app.rb +18 -23
  17. data/lib/write_xlsx/package/button.rb +15 -12
  18. data/lib/write_xlsx/package/comments.rb +33 -30
  19. data/lib/write_xlsx/package/conditional_format.rb +18 -14
  20. data/lib/write_xlsx/package/content_types.rb +22 -17
  21. data/lib/write_xlsx/package/core.rb +19 -24
  22. data/lib/write_xlsx/package/relationships.rb +10 -13
  23. data/lib/write_xlsx/package/shared_strings.rb +8 -16
  24. data/lib/write_xlsx/package/styles.rb +59 -64
  25. data/lib/write_xlsx/package/table.rb +27 -37
  26. data/lib/write_xlsx/package/vml.rb +23 -21
  27. data/lib/write_xlsx/package/xml_writer_simple.rb +3 -6
  28. data/lib/write_xlsx/sheets.rb +4 -4
  29. data/lib/write_xlsx/sparkline.rb +22 -22
  30. data/lib/write_xlsx/utility.rb +61 -33
  31. data/lib/write_xlsx/version.rb +1 -1
  32. data/lib/write_xlsx/workbook.rb +46 -50
  33. data/lib/write_xlsx/worksheet.rb +149 -133
  34. data/lib/write_xlsx/worksheet/cell_data.rb +8 -6
  35. data/lib/write_xlsx/worksheet/data_validation.rb +14 -14
  36. data/lib/write_xlsx/worksheet/hyperlink.rb +97 -65
  37. data/lib/write_xlsx/worksheet/page_setup.rb +23 -22
  38. data/test/chart/test_write_a_latin.rb +3 -3
  39. data/test/regression/test_chart_font01.rb +1 -1
  40. data/test/regression/test_chart_font02.rb +1 -1
  41. data/test/regression/test_chart_font03.rb +1 -1
  42. data/test/regression/test_chart_font04.rb +1 -1
  43. data/test/regression/test_chart_font05.rb +1 -1
  44. data/test/regression/test_chart_font06.rb +1 -1
  45. data/test/test_xml_writer_simple.rb +3 -3
  46. data/test/worksheet/test_write_hyperlink.rb +4 -4
  47. data/test/worksheet/test_write_worksheet_attributes.rb +3 -3
  48. data/write_xlsx.gemspec +2 -1
  49. metadata +9 -8
  50. data/test/package/table/test_write_xml_declaration.rb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66ec26ddd5f837ef4d832d0efea345aaf5fdc524
4
- data.tar.gz: e3e5c86594dd02a88a0dd3c18a018ff28b261ba2
3
+ metadata.gz: 7d6e30ec99cbb2730ee191dc212d2c30806486f1
4
+ data.tar.gz: d67dbc2cc225f0cb7dde96feebaf39600a718039
5
5
  SHA512:
6
- metadata.gz: 5115cdfdcbfc75c4fdd51d14898b288ee0e17dde96156ce73319bd947683243e5ffb44ef7aaad674f3798f9f0b3dd9a2b3b4e74aa6e59248942464dd8ef8c28a
7
- data.tar.gz: 3360712655ad5a43349666c8c7e7b9e76aafb0e5ea3cfec89785b5b3f7df087c485f6d463688a991855dfe486be3d1b810a77a86fec86f2e62b1dc985cf9230b
6
+ metadata.gz: d78099249c92fdc5f11f4d977a97d9b1e70b1ee9469ec3a6a0f96e298046703996c9841320c9e2c4276df8907700b33d7055588b1e72fa902737c256999f25a4
7
+ data.tar.gz: f78e06828d1e804f0a17730b5b80305082ead39dfd650c535f4289fe7ef35f51d43abf2e1f6550766c0be24ea30fa1fc5be6d2e5c08d405bd2f468cddd2c2ee5
@@ -1,82 +1,8 @@
1
- = write_xlsx
1
+ Change history of write_xlsx rubygem.
2
2
 
3
- gem to create a new file in the Excel 2007+ XLSX format, and you can use the same interface as writeexcel gem. write_xlsx is converted from Perl's module Excel::Writer::XLSX-0.70, https://github.com/jmcnamara/excel-writer-xlsx .
3
+ 2013-09-21 v0.72.3.beta1
4
+ speed up when script handles large number of cells.
4
5
 
5
- == Description
6
-
7
- Reference doc : http://cxn03651.github.io/write_xlsx/
8
-
9
- The WriteXLSX supports the following features:
10
- * Multiple worksheets
11
- * Strings and numbers
12
- * Unicode text
13
- * Cell formatting
14
- * Formulas (including array formats)
15
- * Images
16
- * Charts
17
- * Autofilters
18
- * Data validation
19
- * Conditional formatting
20
- * Macros
21
- * Tables
22
- * Shapes
23
- * Sparklines
24
- * Hyperlinks
25
- * Rich string formats
26
- * Defined names
27
- * Grouping/Outlines
28
- * Cell comments
29
- * Panes
30
- * Page set-up and printing options
31
-
32
- write_xlsx uses the same interface as writeexcel gem.
33
-
34
- == Installation
35
-
36
- Add this line to your application's Gemfile:
37
-
38
- gem 'write_xlsx'
39
-
40
- And then execute:
41
-
42
- $ bundle
43
-
44
- Or install it yourself as:
45
-
46
- $ gem install write_xlsx
47
-
48
- == Synopsis
49
-
50
- To write a string, a formatted string, a number and a formula to
51
- the first worksheet in an Excel XML spreadsheet called ruby.xlsx:
52
-
53
- require 'rubygems'
54
- require 'write_xlsx'
55
-
56
- # Create a new Excel workbook
57
- workbook = WriteXLSX.new('ruby.xlsx')
58
-
59
- # Add a worksheet
60
- worksheet = workbook.add_worksheet
61
-
62
- # Add and define a format
63
- format = workbook.add_format # Add a format
64
- format.set_bold
65
- format.set_color('red')
66
- format.set_align('center')
67
-
68
- # Write a formatted and unformatted string, row and column notation.
69
- col = row = 0
70
- worksheet.write(row, col, "Hi Excel!", format)
71
- worksheet.write(1, col, "Hi Excel!")
72
-
73
- # Write a number and a formula using A1 notation
74
- worksheet.write('A3', 1.2345)
75
- worksheet.write('A4', '=SIN(PI()/4)')
76
-
77
- workbook.close
78
-
79
- == Recent change
80
6
  2013-09-07 v0.72.2
81
7
  work well with rubyzip 1.0.0
82
8
 
@@ -193,20 +119,3 @@ the first worksheet in an Excel XML spreadsheet called ruby.xlsx:
193
119
 
194
120
  2012-01-20 v0.0.1
195
121
  initial release
196
-
197
- == Copyright
198
- Original Perl module was written by John McNamara(jmcnamara@cpan.org).
199
-
200
- Converted to ruby by Hideo NAKAMURA(cxn03651@msj.biglobe.ne.jp)
201
- Copyright (c) 2012 HIDEO NAKAMURA. See LICENSE.txt for further details.
202
-
203
- == Contributing to write_xlsx
204
-
205
- * repsitory: http://github.com/cxn03651/write_xlsx
206
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
207
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
208
- * Fork the project
209
- * Start a feature/bugfix branch
210
- * Commit and push until you are happy with your contribution
211
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
212
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
data/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # write_xlsx
2
+
3
+ gem to create a new file in the Excel 2007+ XLSX format, and you can use the same interface as writeexcel gem. write_xlsx is converted from Perl's module [Excel::Writer::XLSX-0.72](https://github.com/jmcnamara/excel-writer-xlsx) .
4
+
5
+ ## Description
6
+
7
+ Reference doc : http://cxn03651.github.io/write_xlsx/
8
+
9
+ The WriteXLSX supports the following features:
10
+ * Multiple worksheets
11
+ * Strings and numbers
12
+ * Unicode text
13
+ * Cell formatting
14
+ * Formulas (including array formats)
15
+ * Images
16
+ * Charts
17
+ * Autofilters
18
+ * Data validation
19
+ * Conditional formatting
20
+ * Macros
21
+ * Tables
22
+ * Shapes
23
+ * Sparklines
24
+ * Hyperlinks
25
+ * Rich string formats
26
+ * Defined names
27
+ * Grouping/Outlines
28
+ * Cell comments
29
+ * Panes
30
+ * Page set-up and printing options
31
+
32
+ write_xlsx uses the same interface as writeexcel gem.
33
+
34
+ ## Installation
35
+
36
+ Add this line to your application's Gemfile:
37
+
38
+ gem 'write_xlsx'
39
+
40
+ And then execute:
41
+
42
+ $ bundle
43
+
44
+ Or install it yourself as:
45
+
46
+ $ gem install write_xlsx
47
+
48
+ ## Synopsis
49
+
50
+ To write a string, a formatted string, a number and a formula to
51
+ the first worksheet in an Excel XML spreadsheet called ruby.xlsx:
52
+
53
+ require 'rubygems'
54
+ require 'write_xlsx'
55
+
56
+ # Create a new Excel workbook
57
+ workbook = WriteXLSX.new('ruby.xlsx')
58
+
59
+ # Add a worksheet
60
+ worksheet = workbook.add_worksheet
61
+
62
+ # Add and define a format
63
+ format = workbook.add_format # Add a format
64
+ format.set_bold
65
+ format.set_color('red')
66
+ format.set_align('center')
67
+
68
+ # Write a formatted and unformatted string, row and column notation.
69
+ col = row = 0
70
+ worksheet.write(row, col, "Hi Excel!", format)
71
+ worksheet.write(1, col, "Hi Excel!")
72
+
73
+ # Write a number and a formula using A1 notation
74
+ worksheet.write('A3', 1.2345)
75
+ worksheet.write('A4', '=SIN(PI()/4)')
76
+
77
+ workbook.close
78
+
79
+ ## Copyright
80
+ Original Perl module was written by John McNamara(jmcnamara@cpan.org).
81
+
82
+ Converted to ruby by Hideo NAKAMURA(cxn03651@msj.biglobe.ne.jp)
83
+ Copyright (c) 2012-2013 Hideo NAKAMURA.
84
+
85
+ See LICENSE.txt for further details.
86
+
87
+ ## Contributing to write_xlsx
88
+
89
+ * repsitory: http://github.com/cxn03651/write_xlsx
90
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
91
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
92
+ * Fork the project
93
+ * Start a feature/bugfix branch
94
+ * Commit and push until you are happy with your contribution
95
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
96
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
@@ -31,7 +31,7 @@ def write_d_table(writer)
31
31
  private
32
32
 
33
33
  def attributes
34
- ['val', 1]
34
+ [ ['val', 1] ]
35
35
  end
36
36
  end
37
37
 
@@ -130,33 +130,23 @@ def set_xml_writer(filename) # :nodoc:
130
130
  # Assemble and write the XML file.
131
131
  #
132
132
  def assemble_xml_file # :nodoc:
133
- @writer.xml_decl
134
-
135
- # Write the c:chartSpace element.
136
- write_chart_space do
137
-
138
- # Write the c:lang element.
139
- write_lang
140
-
141
- # Write the c:style element.
142
- write_style
143
-
144
- # Write the c:protection element.
145
- write_protection
146
-
147
- # Write the c:chart element.
148
- write_chart
149
-
150
- # Write the c:spPr element for the chartarea formatting.
151
- write_sp_pr(@chartarea)
152
-
153
- # Write the c:printSettings element.
154
- write_print_settings if @embedded && @embedded != 0
133
+ write_xml_declaration do
134
+ # Write the c:chartSpace element.
135
+ write_chart_space do
136
+ # Write the c:lang element.
137
+ write_lang
138
+ # Write the c:style element.
139
+ write_style
140
+ # Write the c:protection element.
141
+ write_protection
142
+ # Write the c:chart element.
143
+ write_chart
144
+ # Write the c:spPr element for the chartarea formatting.
145
+ write_sp_pr(@chartarea)
146
+ # Write the c:printSettings element.
147
+ write_print_settings if @embedded && @embedded != 0
148
+ end
155
149
  end
156
-
157
- # Close the XML writer object and filehandle.
158
- @writer.crlf
159
- @writer.close
160
150
  end
161
151
 
162
152
  #
@@ -415,38 +405,6 @@ def convert_font_args(params)
415
405
  font
416
406
  end
417
407
 
418
- #
419
- # Convert user defined line properties to the structure required internally.
420
- #
421
- def line_properties(line) # :nodoc:
422
- return { :_defined => 0 } unless line
423
-
424
- dash_types = {
425
- :solid => 'solid',
426
- :round_dot => 'sysDot',
427
- :square_dot => 'sysDash',
428
- :dash => 'dash',
429
- :dash_dot => 'dashDot',
430
- :long_dash => 'lgDash',
431
- :long_dash_dot => 'lgDashDot',
432
- :long_dash_dot_dot => 'lgDashDotDot',
433
- :dot => 'dot',
434
- :system_dash_dot => 'sysDashDot',
435
- :system_dash_dot_dot => 'sysDashDotDot'
436
- }
437
-
438
- # Check the dash type.
439
- dash_type = line[:dash_type]
440
-
441
- if dash_type
442
- line[:dash_type] = value_or_raise(dash_types, dash_type, 'dash type')
443
- end
444
-
445
- line[:_defined] = 1
446
-
447
- line
448
- end
449
-
450
408
  #
451
409
  # Switch name and name_formula parameters if required.
452
410
  #
@@ -673,11 +631,6 @@ def area_properties(arg) # :nodoc:
673
631
  return area
674
632
  end
675
633
 
676
- def value_or_raise(hash, key, msg)
677
- raise "Unknown #{msg} '#{key}'" unless hash[key.to_sym]
678
- hash[key.to_sym]
679
- end
680
-
681
634
  #
682
635
  # Returns series which use the primary axes.
683
636
  #
@@ -722,12 +675,12 @@ def get_font_style_attributes(font)
722
675
  return [] unless font
723
676
 
724
677
  attributes = []
725
- attributes << 'sz' << font[:_size] if ptrue?(font[:_size])
726
- attributes << 'b' << font[:_bold] if font[:_bold]
727
- attributes << 'i' << font[:_italic] if font[:_italic]
728
- attributes << 'u' << 'sng' if font[:_underline]
678
+ attributes << ['sz', font[:_size]] if ptrue?(font[:_size])
679
+ attributes << ['b', font[:_bold]] if font[:_bold]
680
+ attributes << ['i', font[:_italic]] if font[:_italic]
681
+ attributes << ['u', 'sng'] if font[:_underline]
729
682
 
730
- attributes << 'baseline' << font[:_baseline]
683
+ attributes << ['baseline', font[:_baseline]]
731
684
  attributes
732
685
  end
733
686
 
@@ -738,9 +691,9 @@ def get_font_latin_attributes(font)
738
691
  return [] unless font
739
692
 
740
693
  attributes = []
741
- attributes << 'typeface' << font[:_name] if ptrue?(font[:_name])
742
- attributes << 'pitchFamily' << font[:_pitch_family] if font[:_pitch_family]
743
- attributes << 'charset' << font[:_charset] if font[:_charset]
694
+ attributes << ['typeface', font[:_name]] if ptrue?(font[:_name])
695
+ attributes << ['pitchFamily', font[:_pitch_family]] if font[:_pitch_family]
696
+ attributes << ['charset', font[:_charset]] if font[:_charset]
744
697
 
745
698
  attributes
746
699
  end
@@ -780,52 +733,6 @@ def set_default_properties # :nodoc:
780
733
  set_y2_axis
781
734
  end
782
735
 
783
- def default_chartarea_property
784
- {
785
- :_visible => 0,
786
- :_fg_color_index => 0x4E,
787
- :_fg_color_rgb => 0xFFFFFF,
788
- :_bg_color_index => 0x4D,
789
- :_bg_color_rgb => 0x000000,
790
- :_area_pattern => 0x0000,
791
- :_area_options => 0x0000,
792
- :_line_pattern => 0x0005,
793
- :_line_weight => 0xFFFF,
794
- :_line_color_index => 0x4D,
795
- :_line_color_rgb => 0x000000,
796
- :_line_options => 0x0008
797
- }
798
- end
799
-
800
- def default_chartarea_property_for_embedded
801
- default_chartarea_property.
802
- merge(
803
- :_visible => 1,
804
- :_area_pattern => 0x0001,
805
- :_area_options => 0x0001,
806
- :_line_pattern => 0x0000,
807
- :_line_weight => 0x0000,
808
- :_line_options => 0x0009
809
- )
810
- end
811
-
812
- def default_plotarea_property
813
- {
814
- :_visible => 1,
815
- :_fg_color_index => 0x16,
816
- :_fg_color_rgb => 0xC0C0C0,
817
- :_bg_color_index => 0x4F,
818
- :_bg_color_rgb => 0x000000,
819
- :_area_pattern => 0x0001,
820
- :_area_options => 0x0000,
821
- :_line_pattern => 0x0000,
822
- :_line_weight => 0x0000,
823
- :_line_color_index => 0x17,
824
- :_line_color_rgb => 0x808080,
825
- :_line_options => 0x0000
826
- }
827
- end
828
-
829
736
  #
830
737
  # Write the <c:chartSpace> element.
831
738
  #
@@ -839,9 +746,9 @@ def write_chart_space # :nodoc:
839
746
  def chart_space_attributes # :nodoc:
840
747
  schema = 'http://schemas.openxmlformats.org/'
841
748
  [
842
- 'xmlns:c', "#{schema}drawingml/2006/chart",
843
- 'xmlns:a', "#{schema}drawingml/2006/main",
844
- 'xmlns:r', "#{schema}officeDocument/2006/relationships"
749
+ ['xmlns:c', "#{schema}drawingml/2006/chart"],
750
+ ['xmlns:a', "#{schema}drawingml/2006/main"],
751
+ ['xmlns:r', "#{schema}officeDocument/2006/relationships"]
845
752
  ]
846
753
  end
847
754
 
@@ -849,7 +756,7 @@ def chart_space_attributes # :nodoc:
849
756
  # Write the <c:lang> element.
850
757
  #
851
758
  def write_lang # :nodoc:
852
- @writer.empty_tag('c:lang', ['val', 'en-US'])
759
+ @writer.empty_tag('c:lang', [ ['val', 'en-US'] ])
853
760
  end
854
761
 
855
762
  #
@@ -858,7 +765,7 @@ def write_lang # :nodoc:
858
765
  def write_style # :nodoc:
859
766
  return if @style_id == 2
860
767
 
861
- @writer.empty_tag('c:style', ['val', @style_id])
768
+ @writer.empty_tag('c:style', [ ['val', @style_id] ])
862
769
  end
863
770
 
864
771
  #
@@ -891,7 +798,7 @@ def write_chart # :nodoc:
891
798
  def write_disp_blanks_as
892
799
  return if @show_blanks == 'gap'
893
800
 
894
- @writer.empty_tag('c:dispBlanksAs', ['val', @show_blanks])
801
+ @writer.empty_tag('c:dispBlanksAs', [ ['val', @show_blanks] ])
895
802
  end
896
803
 
897
804
  #
@@ -962,7 +869,7 @@ def write_chart_type # :nodoc:
962
869
  # Write the <c:grouping> element.
963
870
  #
964
871
  def write_grouping(val) # :nodoc:
965
- @writer.empty_tag('c:grouping', ['val', val])
872
+ @writer.empty_tag('c:grouping', [ ['val', val] ])
966
873
  end
967
874
 
968
875
  #
@@ -1013,14 +920,14 @@ def write_ser(series) # :nodoc:
1013
920
  # Write the <c:idx> element.
1014
921
  #
1015
922
  def write_idx(val) # :nodoc:
1016
- @writer.empty_tag('c:idx', ['val', val])
923
+ @writer.empty_tag('c:idx', [ ['val', val] ])
1017
924
  end
1018
925
 
1019
926
  #
1020
927
  # Write the <c:order> element.
1021
928
  #
1022
929
  def write_order(val) # :nodoc:
1023
- @writer.empty_tag('c:order', ['val', val])
930
+ @writer.empty_tag('c:order', [ ['val', val] ])
1024
931
  end
1025
932
 
1026
933
  #
@@ -1143,7 +1050,7 @@ def write_axis_ids(params)
1143
1050
  # Write the <c:axId> element.
1144
1051
  #
1145
1052
  def write_axis_id(val) # :nodoc:
1146
- @writer.empty_tag('c:axId', ['val', val])
1053
+ @writer.empty_tag('c:axId', [ ['val', val] ])
1147
1054
  end
1148
1055
 
1149
1056
  #
@@ -1219,12 +1126,21 @@ def write_cat_axis(params) # :nodoc:
1219
1126
  #
1220
1127
  # TODO. Maybe should have a _write_cat_val_axis method as well for scatter.
1221
1128
  #
1222
- def write_val_axis(params) # :nodoc:
1223
- x_axis = params[:x_axis]
1224
- y_axis = params[:y_axis]
1129
+ def write_val_axis(params, cat = false) # :nodoc:
1225
1130
  axis_ids = params[:axis_ids]
1226
1131
  position = params[:position] || @val_axis_position
1227
1132
  horiz = @horiz_val_axis
1133
+ if cat
1134
+ x_axis = params[:y_axis]
1135
+ y_axis = params[:x_axis]
1136
+ axis_ids_0 = axis_ids[1]
1137
+ axis_ids_1 = axis_ids[0]
1138
+ else
1139
+ x_axis = params[:x_axis]
1140
+ y_axis = params[:y_axis]
1141
+ axis_ids_0 = axis_ids[0]
1142
+ axis_ids_1 = axis_ids[1]
1143
+ end
1228
1144
 
1229
1145
  return unless axis_ids && !axis_ids.empty?
1230
1146
 
@@ -1232,7 +1148,7 @@ def write_val_axis(params) # :nodoc:
1232
1148
  position = y_axis.position || position
1233
1149
 
1234
1150
  @writer.tag_elements('c:valAx') do
1235
- write_axis_id(axis_ids[1])
1151
+ write_axis_id(axis_ids_1)
1236
1152
 
1237
1153
  # Write the c:scaling element.
1238
1154
  write_scaling_with_param(y_axis)
@@ -1268,7 +1184,7 @@ def write_val_axis(params) # :nodoc:
1268
1184
  write_axis_font(y_axis.num_font)
1269
1185
 
1270
1186
  # Write the c:crossAx element.
1271
- write_cross_axis(axis_ids[0])
1187
+ write_cross_axis(axis_ids_0)
1272
1188
 
1273
1189
  write_crossing(x_axis.crossing)
1274
1190
 
@@ -1290,67 +1206,7 @@ def write_val_axis(params) # :nodoc:
1290
1206
  # Usually the X axis.
1291
1207
  #
1292
1208
  def write_cat_val_axis(params) # :nodoc:
1293
- x_axis = params[:x_axis]
1294
- y_axis = params[:y_axis]
1295
- axis_ids = params[:axis_ids]
1296
- position = params[:position] || @val_axis_position
1297
- horiz = @horiz_val_axis
1298
-
1299
- return unless axis_ids && !axis_ids.empty?
1300
-
1301
- # Overwrite the default axis position with a user supplied value.
1302
- position = x_axis.position || position
1303
-
1304
- @writer.tag_elements('c:valAx') do
1305
- write_axis_id(axis_ids[0])
1306
-
1307
- # Write the c:scaling element.
1308
- write_scaling_with_param(x_axis)
1309
-
1310
- write_delete(1) unless ptrue?(x_axis.visible)
1311
-
1312
- # Write the c:axPos element.
1313
- write_axis_pos(position, y_axis.reverse)
1314
-
1315
- # Write the c:majorGridlines element.
1316
- write_major_gridlines(x_axis.major_gridlines)
1317
-
1318
- # Write the c:minorGridlines element.
1319
- write_minor_gridlines(x_axis.minor_gridlines)
1320
-
1321
- # Write the axis title elements.
1322
- if x_axis.formula
1323
- write_title_formula(x_axis, horiz)
1324
- elsif x_axis.name
1325
- write_title_rich(x_axis, horiz)
1326
- end
1327
-
1328
- # Write the c:numberFormat element.
1329
- write_number_format(x_axis)
1330
-
1331
- # Write the c:majorTickMark element.
1332
- write_major_tick_mark(x_axis.major_tick_mark)
1333
-
1334
- # Write the c:tickLblPos element.
1335
- write_tick_label_pos(x_axis.label_position)
1336
-
1337
- # Write the axis font elements.
1338
- write_axis_font(x_axis.num_font)
1339
-
1340
- # Write the c:crossAx element.
1341
- write_cross_axis(axis_ids[1])
1342
-
1343
- write_crossing(y_axis.crossing)
1344
-
1345
- # Write the c:crossBetween element.
1346
- write_cross_between
1347
-
1348
- # Write the c:majorUnit element.
1349
- write_c_major_unit(x_axis.major_unit)
1350
-
1351
- # Write the c:minorunit element.
1352
- write_c_minor_unit(x_axis.minor_unit)
1353
- end
1209
+ write_val_axis(params, true)
1354
1210
  end
1355
1211
 
1356
1212
  #
@@ -1466,7 +1322,7 @@ def write_scaling(reverse, min = nil, max = nil, log_base = nil) # :nodoc:
1466
1322
  def write_c_log_base(val) # :nodoc:
1467
1323
  return unless ptrue?(val)
1468
1324
 
1469
- @writer.empty_tag('c:logBase', ['val', val])
1325
+ @writer.empty_tag('c:logBase', [ ['val', val] ])
1470
1326
  end
1471
1327
 
1472
1328
  #
@@ -1475,7 +1331,7 @@ def write_c_log_base(val) # :nodoc:
1475
1331
  def write_orientation(reverse = nil) # :nodoc:
1476
1332
  val = ptrue?(reverse) ? 'maxMin' : 'minMax'
1477
1333
 
1478
- @writer.empty_tag('c:orientation', ['val', val])
1334
+ @writer.empty_tag('c:orientation', [ ['val', val] ])
1479
1335
  end
1480
1336
 
1481
1337
  #
@@ -1484,7 +1340,7 @@ def write_orientation(reverse = nil) # :nodoc:
1484
1340
  def write_c_max(max = nil) # :nodoc:
1485
1341
  return if max.nil?
1486
1342
 
1487
- @writer.empty_tag('c:max', ['val', max])
1343
+ @writer.empty_tag('c:max', [ ['val', max] ])
1488
1344
  end
1489
1345
 
1490
1346
  #
@@ -1493,7 +1349,7 @@ def write_c_max(max = nil) # :nodoc:
1493
1349
  def write_c_min(min = nil) # :nodoc:
1494
1350
  return if min.nil?
1495
1351
 
1496
- @writer.empty_tag('c:min', ['val', min])
1352
+ @writer.empty_tag('c:min', [ ['val', min] ])
1497
1353
  end
1498
1354
 
1499
1355
  #
@@ -1505,7 +1361,7 @@ def write_axis_pos(val, reverse = false) # :nodoc:
1505
1361
  val = 't' if val == 'b'
1506
1362
  end
1507
1363
 
1508
- @writer.empty_tag('c:axPos', ['val', val])
1364
+ @writer.empty_tag('c:axPos', [ ['val', val] ])
1509
1365
  end
1510
1366
 
1511
1367
  #
@@ -1532,7 +1388,7 @@ def write_cat_number_format(axis)
1532
1388
  def write_major_tick_mark(val)
1533
1389
  return unless ptrue?(val)
1534
1390
 
1535
- @writer.empty_tag('c:majorTickMark', ['val', val])
1391
+ @writer.empty_tag('c:majorTickMark', [ ['val', val] ])
1536
1392
  end
1537
1393
 
1538
1394
  #
@@ -1542,14 +1398,14 @@ def write_tick_label_pos(val) # :nodoc:
1542
1398
  val ||= 'nextTo'
1543
1399
  val = 'nextTo' if val == 'next_to'
1544
1400
 
1545
- @writer.empty_tag('c:tickLblPos', ['val', val])
1401
+ @writer.empty_tag('c:tickLblPos', [ ['val', val] ])
1546
1402
  end
1547
1403
 
1548
1404
  #
1549
1405
  # Write the <c:crossAx> element.
1550
1406
  #
1551
1407
  def write_cross_axis(val = 'autoZero') # :nodoc:
1552
- @writer.empty_tag('c:crossAx', ['val', val])
1408
+ @writer.empty_tag('c:crossAx', [ ['val', val] ])
1553
1409
  end
1554
1410
 
1555
1411
  #
@@ -1558,35 +1414,35 @@ def write_cross_axis(val = 'autoZero') # :nodoc:
1558
1414
  def write_crosses(val) # :nodoc:
1559
1415
  val ||= 'autoZero'
1560
1416
 
1561
- @writer.empty_tag('c:crosses', ['val', val])
1417
+ @writer.empty_tag('c:crosses', [ ['val', val] ])
1562
1418
  end
1563
1419
 
1564
1420
  #
1565
1421
  # Write the <c:crossesAt> element.
1566
1422
  #
1567
1423
  def write_c_crosses_at(val) # :nodoc:
1568
- @writer.empty_tag('c:crossesAt', ['val', val])
1424
+ @writer.empty_tag('c:crossesAt', [ ['val', val] ])
1569
1425
  end
1570
1426
 
1571
1427
  #
1572
1428
  # Write the <c:auto> element.
1573
1429
  #
1574
1430
  def write_auto(val) # :nodoc:
1575
- @writer.empty_tag('c:auto', ['val', val])
1431
+ @writer.empty_tag('c:auto', [ ['val', val] ])
1576
1432
  end
1577
1433
 
1578
1434
  #
1579
1435
  # Write the <c:labelAlign> element.
1580
1436
  #
1581
1437
  def write_label_align(val) # :nodoc:
1582
- @writer.empty_tag('c:lblAlgn', ['val', val])
1438
+ @writer.empty_tag('c:lblAlgn', [ ['val', val] ])
1583
1439
  end
1584
1440
 
1585
1441
  #
1586
1442
  # Write the <c:labelOffset> element.
1587
1443
  #
1588
1444
  def write_label_offset(val) # :nodoc:
1589
- @writer.empty_tag('c:lblOffset', ['val', val])
1445
+ @writer.empty_tag('c:lblOffset', [ ['val', val] ])
1590
1446
  end
1591
1447
 
1592
1448
  #
@@ -1614,7 +1470,7 @@ def write_gridlines_base(tag, gridlines) # :nodoc:
1614
1470
  def write_cross_between # :nodoc:
1615
1471
  val = @cross_between || 'between'
1616
1472
 
1617
- @writer.empty_tag('c:crossBetween', ['val', val])
1473
+ @writer.empty_tag('c:crossBetween', [ ['val', val] ])
1618
1474
  end
1619
1475
 
1620
1476
  #
@@ -1623,7 +1479,7 @@ def write_cross_between # :nodoc:
1623
1479
  def write_c_major_unit(val = nil) # :nodoc:
1624
1480
  return unless val
1625
1481
 
1626
- @writer.empty_tag('c:majorUnit', ['val', val])
1482
+ @writer.empty_tag('c:majorUnit', [ ['val', val] ])
1627
1483
  end
1628
1484
 
1629
1485
  #
@@ -1632,7 +1488,7 @@ def write_c_major_unit(val = nil) # :nodoc:
1632
1488
  def write_c_minor_unit(val = nil) # :nodoc:
1633
1489
  return unless val
1634
1490
 
1635
- @writer.empty_tag('c:minorUnit', ['val', val])
1491
+ @writer.empty_tag('c:minorUnit', [ ['val', val] ])
1636
1492
  end
1637
1493
 
1638
1494
  #
@@ -1641,7 +1497,7 @@ def write_c_minor_unit(val = nil) # :nodoc:
1641
1497
  def write_c_major_time_unit(val) # :nodoc:
1642
1498
  val ||= 'days'
1643
1499
 
1644
- @writer.empty_tag('c:majorTimeUnit', ['val', val])
1500
+ @writer.empty_tag('c:majorTimeUnit', [ ['val', val] ])
1645
1501
  end
1646
1502
 
1647
1503
  #
@@ -1650,7 +1506,7 @@ def write_c_major_time_unit(val) # :nodoc:
1650
1506
  def write_c_minor_time_unit(val) # :nodoc:
1651
1507
  val ||= 'days'
1652
1508
 
1653
- @writer.empty_tag('c:minorTimeUnit', ['val', val])
1509
+ @writer.empty_tag('c:minorTimeUnit', [ ['val', val] ])
1654
1510
  end
1655
1511
 
1656
1512
  #
@@ -1700,7 +1556,7 @@ def write_legend # :nodoc:
1700
1556
  # Write the <c:legendPos> element.
1701
1557
  #
1702
1558
  def write_legend_pos(val) # :nodoc:
1703
- @writer.empty_tag('c:legendPos', ['val', val])
1559
+ @writer.empty_tag('c:legendPos', [ ['val', val] ])
1704
1560
  end
1705
1561
 
1706
1562
  #
@@ -1731,7 +1587,7 @@ def write_plot_vis_only # :nodoc:
1731
1587
  # Ignore this element if we are plotting hidden data.
1732
1588
  return if @show_hidden_data
1733
1589
 
1734
- @writer.empty_tag('c:plotVisOnly', ['val', val])
1590
+ @writer.empty_tag('c:plotVisOnly', [ ['val', val] ])
1735
1591
  end
1736
1592
 
1737
1593
  #
@@ -1767,12 +1623,12 @@ def write_page_margins # :nodoc:
1767
1623
  footer = 0.3
1768
1624
 
1769
1625
  attributes = [
1770
- 'b', b,
1771
- 'l', l,
1772
- 'r', r,
1773
- 't', t,
1774
- 'header', header,
1775
- 'footer', footer
1626
+ ['b', b],
1627
+ ['l', l],
1628
+ ['r', r],
1629
+ ['t', t],
1630
+ ['header', header],
1631
+ ['footer', footer]
1776
1632
  ]
1777
1633
 
1778
1634
  @writer.empty_tag('c:pageMargins', attributes)
@@ -1856,8 +1712,8 @@ def write_a_body_pr(horiz) # :nodoc:
1856
1712
  vert = 'horz'
1857
1713
 
1858
1714
  attributes = [
1859
- 'rot', rot,
1860
- 'vert', vert
1715
+ ['rot', rot],
1716
+ ['vert', vert]
1861
1717
  ]
1862
1718
 
1863
1719
  attributes = [] unless ptrue?(horiz)
@@ -1871,8 +1727,8 @@ def write_a_body_pr(horiz) # :nodoc:
1871
1727
  def write_axis_body_pr(rot = nil, vert = nil)
1872
1728
  attributes = []
1873
1729
 
1874
- attributes << 'rot' << rot if rot
1875
- attributes << 'vert' << vert if vert
1730
+ attributes << ['rot', rot] if rot
1731
+ attributes << ['vert', vert] if vert
1876
1732
 
1877
1733
  @writer.empty_tag('a:bodyPr', attributes)
1878
1734
  end
@@ -1936,7 +1792,7 @@ def write_a_def_rpr(font = nil) # :nodoc:
1936
1792
  # Write the <a:endParaRPr> element.
1937
1793
  #
1938
1794
  def write_a_end_para_rpr # :nodoc:
1939
- @writer.empty_tag('a:endParaRPr', ['lang', 'en-US'])
1795
+ @writer.empty_tag('a:endParaRPr', [ ['lang', 'en-US'] ])
1940
1796
  end
1941
1797
 
1942
1798
  #
@@ -1955,11 +1811,11 @@ def write_a_r(title) # :nodoc:
1955
1811
  # Write the <a:rPr> element.
1956
1812
  #
1957
1813
  def write_a_r_pr(font) # :nodoc:
1958
- write_def_rpr_r_pr_common(
1959
- font,
1960
- get_font_style_attributes(font).unshift('en-US').unshift('lang'),
1961
- 'a:rPr'
1962
- )
1814
+ attributes = [ ['lang', 'en-US'] ]
1815
+ attr_font = get_font_style_attributes(font)
1816
+ attributes += attr_font unless attr_font.empty?
1817
+
1818
+ write_def_rpr_r_pr_common(font, attributes, 'a:rPr')
1963
1819
  end
1964
1820
 
1965
1821
  def write_def_rpr_r_pr_common(font, style_attributes, tag) # :nodoc:
@@ -2027,21 +1883,21 @@ def write_marker(marker = nil) # :nodoc:
2027
1883
  def write_marker_value # :nodoc:
2028
1884
  return unless @default_marker
2029
1885
 
2030
- @writer.empty_tag('c:marker', ['val', 1])
1886
+ @writer.empty_tag('c:marker', [ ['val', 1] ])
2031
1887
  end
2032
1888
 
2033
1889
  #
2034
1890
  # Write the <c:size> element.
2035
1891
  #
2036
1892
  def write_marker_size(val) # :nodoc:
2037
- @writer.empty_tag('c:size', ['val', val])
1893
+ @writer.empty_tag('c:size', [ ['val', val] ])
2038
1894
  end
2039
1895
 
2040
1896
  #
2041
1897
  # Write the <c:symbol> element.
2042
1898
  #
2043
1899
  def write_symbol(val) # :nodoc:
2044
- @writer.empty_tag('c:symbol', ['val', val])
1900
+ @writer.empty_tag('c:symbol', [ ['val', val] ])
2045
1901
  end
2046
1902
 
2047
1903
  #
@@ -2084,7 +1940,7 @@ def write_a_ln(line) # :nodoc:
2084
1940
  # Convert to internal units.
2085
1941
  width = (0.5 + (12700 * width)).to_i
2086
1942
 
2087
- attributes = ['w', width]
1943
+ attributes << ['w', width]
2088
1944
  end
2089
1945
 
2090
1946
  @writer.tag_elements('a:ln', attributes) do
@@ -2129,14 +1985,14 @@ def write_a_solid_fill(line) # :nodoc:
2129
1985
  # Write the <a:srgbClr> element.
2130
1986
  #
2131
1987
  def write_a_srgb_clr(val) # :nodoc:
2132
- @writer.empty_tag('a:srgbClr', ['val', val])
1988
+ @writer.empty_tag('a:srgbClr', [ ['val', val] ])
2133
1989
  end
2134
1990
 
2135
1991
  #
2136
1992
  # Write the <a:prstDash> element.
2137
1993
  #
2138
1994
  def write_a_prst_dash(val) # :nodoc:
2139
- @writer.empty_tag('a:prstDash', ['val', val])
1995
+ @writer.empty_tag('a:prstDash', [ ['val', val] ])
2140
1996
  end
2141
1997
 
2142
1998
  #
@@ -2167,7 +2023,7 @@ def write_trendline(trendline) # :nodoc:
2167
2023
  # Write the <c:trendlineType> element.
2168
2024
  #
2169
2025
  def write_trendline_type(val) # :nodoc:
2170
- @writer.empty_tag('c:trendlineType', ['val', val])
2026
+ @writer.empty_tag('c:trendlineType', [ ['val', val] ])
2171
2027
  end
2172
2028
 
2173
2029
  #
@@ -2183,14 +2039,14 @@ def write_name(data) # :nodoc:
2183
2039
  # Write the <c:order> element.
2184
2040
  #
2185
2041
  def write_trendline_order(val = 2) # :nodoc:
2186
- @writer.empty_tag('c:order', ['val', val])
2042
+ @writer.empty_tag('c:order', [ ['val', val] ])
2187
2043
  end
2188
2044
 
2189
2045
  #
2190
2046
  # Write the <c:period> element.
2191
2047
  #
2192
2048
  def write_period(val = 2) # :nodoc:
2193
- @writer.empty_tag('c:period', ['val', val])
2049
+ @writer.empty_tag('c:period', [ ['val', val] ])
2194
2050
  end
2195
2051
 
2196
2052
  #
@@ -2199,7 +2055,7 @@ def write_period(val = 2) # :nodoc:
2199
2055
  def write_forward(val) # :nodoc:
2200
2056
  return unless val
2201
2057
 
2202
- @writer.empty_tag('c:forward', ['val', val])
2058
+ @writer.empty_tag('c:forward', [ ['val', val] ])
2203
2059
  end
2204
2060
 
2205
2061
  #
@@ -2208,7 +2064,7 @@ def write_forward(val) # :nodoc:
2208
2064
  def write_backward(val) # :nodoc:
2209
2065
  return unless val
2210
2066
 
2211
- @writer.empty_tag('c:backward', ['val', val])
2067
+ @writer.empty_tag('c:backward', [ ['val', val] ])
2212
2068
  end
2213
2069
 
2214
2070
  #
@@ -2244,7 +2100,7 @@ def write_lines_base(tag, lines)
2244
2100
  def write_overlap(val = nil) # :nodoc:
2245
2101
  return unless val
2246
2102
 
2247
- @writer.empty_tag('c:overlap', ['val', val])
2103
+ @writer.empty_tag('c:overlap', [ ['val', val] ])
2248
2104
  end
2249
2105
 
2250
2106
  #
@@ -2299,7 +2155,7 @@ def write_format_code(data) # :nodoc:
2299
2155
  # Write the <c:ptCount> element.
2300
2156
  #
2301
2157
  def write_pt_count(val) # :nodoc:
2302
- @writer.empty_tag('c:ptCount', ['val', val])
2158
+ @writer.empty_tag('c:ptCount', [ ['val', val] ])
2303
2159
  end
2304
2160
 
2305
2161
  #
@@ -2308,7 +2164,7 @@ def write_pt_count(val) # :nodoc:
2308
2164
  def write_pt(idx, value) # :nodoc:
2309
2165
  return unless value
2310
2166
 
2311
- attributes = ['idx', idx]
2167
+ attributes = [ ['idx', idx] ]
2312
2168
 
2313
2169
  @writer.tag_elements('c:pt', attributes) { write_v(value) }
2314
2170
  end
@@ -2381,49 +2237,49 @@ def write_d_lbls(labels) # :nodoc:
2381
2237
  # Write the <c:showVal> element.
2382
2238
  #
2383
2239
  def write_show_val # :nodoc:
2384
- @writer.empty_tag('c:showVal', ['val', 1])
2240
+ @writer.empty_tag('c:showVal', [ ['val', 1] ])
2385
2241
  end
2386
2242
 
2387
2243
  #
2388
2244
  # Write the <c:showCatName> element.
2389
2245
  #
2390
2246
  def write_show_cat_name # :nodoc:
2391
- @writer.empty_tag('c:showCatName', ['val', 1])
2247
+ @writer.empty_tag('c:showCatName', [ ['val', 1] ])
2392
2248
  end
2393
2249
 
2394
2250
  #
2395
2251
  # Write the <c:showSerName> element.
2396
2252
  #
2397
2253
  def write_show_ser_name # :nodoc:
2398
- @writer.empty_tag('c:showSerName', ['val', 1])
2254
+ @writer.empty_tag('c:showSerName', [ ['val', 1] ])
2399
2255
  end
2400
2256
 
2401
2257
  #
2402
2258
  # Write the <c:showPercent> element.
2403
2259
  #
2404
2260
  def write_show_percent
2405
- @writer.empty_tag('c:showPercent', ['val', 1])
2261
+ @writer.empty_tag('c:showPercent', [ ['val', 1] ])
2406
2262
  end
2407
2263
 
2408
2264
  #
2409
2265
  # Write the <c:showLeaderLines> element.
2410
2266
  #
2411
2267
  def write_show_leader_lines
2412
- @writer.empty_tag('c:showLeaderLines', ['val', 1])
2268
+ @writer.empty_tag('c:showLeaderLines', [ ['val', 1] ])
2413
2269
  end
2414
2270
 
2415
2271
  #
2416
2272
  # Write the <c:dLblPos> element.
2417
2273
  #
2418
2274
  def write_d_lbl_pos(val)
2419
- @writer.empty_tag('c:dLblPos', ['val', val])
2275
+ @writer.empty_tag('c:dLblPos', [ ['val', val] ])
2420
2276
  end
2421
2277
 
2422
2278
  #
2423
2279
  # Write the <c:delete> element.
2424
2280
  #
2425
2281
  def write_delete(val) # :nodoc:
2426
- @writer.empty_tag('c:delete', ['val', val])
2282
+ @writer.empty_tag('c:delete', [ ['val', val] ])
2427
2283
  end
2428
2284
 
2429
2285
  #
@@ -2432,7 +2288,7 @@ def write_delete(val) # :nodoc:
2432
2288
  def write_c_invert_if_negative(invert = nil) # :nodoc:
2433
2289
  return unless ptrue?(invert)
2434
2290
 
2435
- @writer.empty_tag('c:invertIfNegative', ['val', 1])
2291
+ @writer.empty_tag('c:invertIfNegative', [ ['val', 1] ])
2436
2292
  end
2437
2293
 
2438
2294
  #
@@ -2514,35 +2370,35 @@ def write_err_bars(direction, error_bars)
2514
2370
  # Write the <c:errDir> element.
2515
2371
  #
2516
2372
  def write_err_dir(val)
2517
- @writer.empty_tag('c:errDir', ['val', val])
2373
+ @writer.empty_tag('c:errDir', [ ['val', val] ])
2518
2374
  end
2519
2375
 
2520
2376
  #
2521
2377
  # Write the <c:errBarType> element.
2522
2378
  #
2523
2379
  def write_err_bar_type(val)
2524
- @writer.empty_tag('c:errBarType', ['val', val])
2380
+ @writer.empty_tag('c:errBarType', [ ['val', val] ])
2525
2381
  end
2526
2382
 
2527
2383
  #
2528
2384
  # Write the <c:errValType> element.
2529
2385
  #
2530
2386
  def write_err_val_type(val)
2531
- @writer.empty_tag('c:errValType', ['val', val])
2387
+ @writer.empty_tag('c:errValType', [ ['val', val] ])
2532
2388
  end
2533
2389
 
2534
2390
  #
2535
2391
  # Write the <c:noEndCap> element.
2536
2392
  #
2537
2393
  def write_no_end_cap
2538
- @writer.empty_tag('c:noEndCap', ['val', 1])
2394
+ @writer.empty_tag('c:noEndCap', [ ['val', 1] ])
2539
2395
  end
2540
2396
 
2541
2397
  #
2542
2398
  # Write the <c:val> element.
2543
2399
  #
2544
2400
  def write_error_val(val)
2545
- @writer.empty_tag('c:val', ['val', val])
2401
+ @writer.empty_tag('c:val', [ ['val', val] ])
2546
2402
  end
2547
2403
 
2548
2404
  #
@@ -2569,7 +2425,7 @@ def write_up_down_bars
2569
2425
  def write_gap_width(val = nil)
2570
2426
  return unless val
2571
2427
 
2572
- @writer.empty_tag('c:gapWidth', ['val', val])
2428
+ @writer.empty_tag('c:gapWidth', [ ['val', val] ])
2573
2429
  end
2574
2430
 
2575
2431
  #
@@ -2592,7 +2448,7 @@ def write_down_bars(format)
2592
2448
  def write_c_smooth(smooth)
2593
2449
  return unless ptrue?(smooth)
2594
2450
 
2595
- attributes = ['val', 1]
2451
+ attributes = [ ['val', 1] ]
2596
2452
 
2597
2453
  @writer.empty_tag('c:smooth', attributes)
2598
2454
  end