write_xlsx 0.89.0 → 1.01.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (340) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Changes +98 -0
  4. data/LICENSE.txt +1 -1
  5. data/README.md +2 -2
  6. data/examples/a_simple.rb +2 -7
  7. data/examples/add_vba_project.rb +1 -1
  8. data/examples/array_formula.rb +1 -1
  9. data/examples/chart_area.rb +5 -2
  10. data/examples/chart_bar.rb +5 -2
  11. data/examples/chart_clustered.rb +1 -1
  12. data/examples/chart_column.rb +5 -2
  13. data/examples/chart_combined.rb +1 -1
  14. data/examples/chart_data_table.rb +9 -3
  15. data/examples/chart_data_tools.rb +25 -7
  16. data/examples/chart_doughnut.rb +17 -5
  17. data/examples/chart_gauge.rb +73 -0
  18. data/examples/chart_line.rb +5 -2
  19. data/examples/chart_pareto.rb +1 -1
  20. data/examples/chart_pie.rb +9 -3
  21. data/examples/chart_radar.rb +13 -4
  22. data/examples/chart_scatter.rb +5 -2
  23. data/examples/chart_secondary_axis.rb +5 -2
  24. data/examples/chart_stock.rb +1 -1
  25. data/examples/chart_styles.rb +1 -1
  26. data/examples/colors.rb +1 -1
  27. data/examples/conditional_format.rb +73 -46
  28. data/examples/data_validate.rb +1 -1
  29. data/examples/date_time.rb +1 -1
  30. data/examples/demo.rb +5 -8
  31. data/examples/formats.rb +1 -1
  32. data/examples/headers.rb +1 -1
  33. data/examples/hide_row_col.rb +1 -1
  34. data/examples/hide_sheet.rb +1 -1
  35. data/examples/hyperlink1.rb +5 -12
  36. data/examples/indent.rb +1 -1
  37. data/examples/macros.rb +1 -1
  38. data/examples/merge1.rb +1 -1
  39. data/examples/merge2.rb +1 -1
  40. data/examples/merge3.rb +1 -1
  41. data/examples/merge4.rb +1 -1
  42. data/examples/merge5.rb +1 -1
  43. data/examples/merge6.rb +1 -1
  44. data/examples/outline.rb +1 -1
  45. data/examples/outline_collapsed.rb +1 -1
  46. data/examples/panes.rb +1 -1
  47. data/examples/properties.rb +1 -1
  48. data/examples/regions.rb +1 -1
  49. data/examples/rich_strings.rb +1 -1
  50. data/examples/right_to_left.rb +1 -1
  51. data/examples/shape1.rb +1 -1
  52. data/examples/shape2.rb +1 -1
  53. data/examples/shape3.rb +1 -1
  54. data/examples/shape4.rb +1 -1
  55. data/examples/shape5.rb +1 -1
  56. data/examples/shape6.rb +1 -1
  57. data/examples/shape7.rb +1 -1
  58. data/examples/shape8.rb +1 -1
  59. data/examples/shape_all.rb +1 -1
  60. data/examples/sparklines1.rb +1 -1
  61. data/examples/sparklines2.rb +1 -1
  62. data/examples/stats.rb +1 -1
  63. data/examples/stats_ext.rb +1 -1
  64. data/examples/stocks.rb +1 -1
  65. data/examples/tab_colors.rb +1 -1
  66. data/examples/tables.rb +1 -1
  67. data/lib/write_xlsx/chart.rb +124 -240
  68. data/lib/write_xlsx/chart/area.rb +1 -1
  69. data/lib/write_xlsx/chart/axis.rb +4 -4
  70. data/lib/write_xlsx/chart/bar.rb +1 -1
  71. data/lib/write_xlsx/chart/caption.rb +3 -1
  72. data/lib/write_xlsx/chart/column.rb +1 -1
  73. data/lib/write_xlsx/chart/doughnut.rb +1 -1
  74. data/lib/write_xlsx/chart/legend.rb +14 -0
  75. data/lib/write_xlsx/chart/line.rb +1 -1
  76. data/lib/write_xlsx/chart/pie.rb +32 -15
  77. data/lib/write_xlsx/chart/radar.rb +1 -1
  78. data/lib/write_xlsx/chart/scatter.rb +1 -1
  79. data/lib/write_xlsx/chart/series.rb +11 -7
  80. data/lib/write_xlsx/chart/stock.rb +1 -1
  81. data/lib/write_xlsx/chartsheet.rb +35 -7
  82. data/lib/write_xlsx/drawing.rb +28 -8
  83. data/lib/write_xlsx/format.rb +19 -15
  84. data/lib/write_xlsx/package/comments.rb +57 -54
  85. data/lib/write_xlsx/package/conditional_format.rb +360 -39
  86. data/lib/write_xlsx/package/content_types.rb +10 -0
  87. data/lib/write_xlsx/package/core.rb +8 -6
  88. data/lib/write_xlsx/package/custom.rb +125 -0
  89. data/lib/write_xlsx/package/packager.rb +26 -0
  90. data/lib/write_xlsx/package/styles.rb +53 -21
  91. data/lib/write_xlsx/package/table.rb +16 -4
  92. data/lib/write_xlsx/shape.rb +4 -3
  93. data/lib/write_xlsx/sheets.rb +11 -1
  94. data/lib/write_xlsx/sparkline.rb +1 -1
  95. data/lib/write_xlsx/utility.rb +305 -35
  96. data/lib/write_xlsx/version.rb +1 -1
  97. data/lib/write_xlsx/workbook.rb +132 -12
  98. data/lib/write_xlsx/worksheet.rb +397 -163
  99. data/lib/write_xlsx/worksheet/data_validation.rb +10 -14
  100. data/lib/write_xlsx/worksheet/hyperlink.rb +4 -13
  101. data/test/chart/test_write_legend_pos.rb +9 -1
  102. data/test/chartsheet/test_write_sheet_protection.rb +91 -0
  103. data/test/drawing/test_drawing_chart_01.rb +6 -2
  104. data/test/drawing/test_drawing_image_01.rb +12 -3
  105. data/test/drawing/test_drawing_shape_01.rb +8 -5
  106. data/test/drawing/test_drawing_shape_02.rb +12 -5
  107. data/test/drawing/test_drawing_shape_03.rb +8 -5
  108. data/test/drawing/test_drawing_shape_04.rb +8 -24
  109. data/test/drawing/test_drawing_shape_05.rb +8 -5
  110. data/test/drawing/test_drawing_shape_06.rb +11 -6
  111. data/test/drawing/test_drawing_shape_07.rb +11 -6
  112. data/test/drawing/test_write_a_graphic_frame_locks.rb +1 -1
  113. data/test/drawing/test_write_c_chart.rb +1 -1
  114. data/test/drawing/test_write_c_nv_graphic_frame_pr.rb +1 -1
  115. data/test/drawing/test_write_c_nv_pr.rb +1 -1
  116. data/test/drawing/test_write_col.rb +1 -1
  117. data/test/drawing/test_write_col_off.rb +1 -1
  118. data/test/drawing/test_write_ext.rb +1 -1
  119. data/test/drawing/test_write_pos.rb +1 -1
  120. data/test/drawing/test_write_row.rb +1 -1
  121. data/test/drawing/test_write_row_off.rb +1 -1
  122. data/test/drawing/test_write_xfrm_extension.rb +1 -1
  123. data/test/drawing/test_write_xfrm_offset.rb +1 -1
  124. data/test/helper.rb +6 -1
  125. data/test/package/comments/test_comments_01.rb +54 -0
  126. data/test/package/comments/test_comments_02.rb +54 -0
  127. data/test/perl_output/chart_gauge.xlsx +0 -0
  128. data/test/perl_output/formats.xlsx +0 -0
  129. data/test/regression/_test_hyperlink31.rb +26 -0
  130. data/test/regression/images/happy.jpg +0 -0
  131. data/test/regression/images/zero_dpi.jpg +0 -0
  132. data/test/regression/test_array_formula03.rb +36 -0
  133. data/test/regression/test_autofilter08.rb +110 -0
  134. data/test/regression/test_autofilter09.rb +110 -0
  135. data/test/regression/test_autofilter10.rb +110 -0
  136. data/test/regression/test_chart_axis26.rb +10 -8
  137. data/test/regression/test_chart_axis27.rb +1 -1
  138. data/test/regression/test_chart_axis28.rb +1 -1
  139. data/test/regression/test_chart_axis29.rb +1 -1
  140. data/test/regression/test_chart_axis33.rb +1 -1
  141. data/test/regression/test_chart_axis42.rb +44 -0
  142. data/test/regression/test_chart_axis43.rb +44 -0
  143. data/test/regression/test_chart_axis44.rb +54 -0
  144. data/test/regression/test_chart_axis45.rb +54 -0
  145. data/test/regression/test_chart_axis46.rb +54 -0
  146. data/test/regression/test_chart_bar08.rb +3 -0
  147. data/test/regression/test_chart_bar11.rb +3 -0
  148. data/test/regression/test_chart_bar14.rb +3 -0
  149. data/test/regression/test_chart_chartarea05.rb +16 -17
  150. data/test/regression/test_chart_chartarea06.rb +49 -0
  151. data/test/regression/test_chart_combined10.rb +43 -0
  152. data/test/regression/test_chart_combined11.rb +63 -0
  153. data/test/regression/test_chart_data_labels25.rb +61 -0
  154. data/test/regression/test_chart_doughnut07.rb +37 -0
  155. data/test/regression/test_chart_font09.rb +1 -1
  156. data/test/regression/test_chart_format26.rb +48 -0
  157. data/test/regression/test_chart_format27.rb +58 -0
  158. data/test/regression/test_chart_format28.rb +52 -0
  159. data/test/regression/test_chart_format29.rb +59 -0
  160. data/test/regression/test_chart_format30.rb +53 -0
  161. data/test/regression/test_chart_format31.rb +60 -0
  162. data/test/regression/test_chart_legend03.rb +41 -0
  163. data/test/regression/test_chart_legend04.rb +41 -0
  164. data/test/regression/test_chart_legend05.rb +41 -0
  165. data/test/regression/test_chart_legend06.rb +41 -0
  166. data/test/regression/test_chart_legend07.rb +38 -0
  167. data/test/regression/test_chart_size03.rb +4 -1
  168. data/test/regression/test_chart_table03.rb +56 -0
  169. data/test/regression/test_comment13.rb +36 -0
  170. data/test/regression/test_comment14.rb +29 -0
  171. data/test/regression/test_cond_format14.rb +42 -0
  172. data/test/regression/test_cond_format15.rb +53 -0
  173. data/test/regression/test_cond_format16.rb +53 -0
  174. data/test/regression/test_cond_format17.rb +37 -0
  175. data/test/regression/test_cond_format18.rb +136 -0
  176. data/test/regression/test_cond_format19.rb +64 -0
  177. data/test/regression/test_cond_format20.rb +43 -0
  178. data/test/regression/test_date_1904_01.rb +1 -1
  179. data/test/regression/test_escapes04.rb +3 -0
  180. data/test/regression/test_escapes05.rb +3 -0
  181. data/test/regression/test_escapes07.rb +3 -0
  182. data/test/regression/test_escapes08.rb +3 -0
  183. data/test/regression/test_format15.rb +26 -0
  184. data/test/regression/test_hyperlink01.rb +3 -0
  185. data/test/regression/test_hyperlink02.rb +3 -0
  186. data/test/regression/test_hyperlink03.rb +4 -0
  187. data/test/regression/test_hyperlink04.rb +3 -0
  188. data/test/regression/test_hyperlink05.rb +3 -0
  189. data/test/regression/test_hyperlink06.rb +3 -0
  190. data/test/regression/test_hyperlink07.rb +3 -0
  191. data/test/regression/test_hyperlink08.rb +3 -0
  192. data/test/regression/test_hyperlink09.rb +3 -0
  193. data/test/regression/test_hyperlink10.rb +3 -0
  194. data/test/regression/test_hyperlink11.rb +3 -0
  195. data/test/regression/test_hyperlink12.rb +3 -0
  196. data/test/regression/test_hyperlink13.rb +3 -0
  197. data/test/regression/test_hyperlink14.rb +3 -0
  198. data/test/regression/test_hyperlink15.rb +3 -0
  199. data/test/regression/test_hyperlink16.rb +3 -0
  200. data/test/regression/test_hyperlink17.rb +3 -0
  201. data/test/regression/test_hyperlink18.rb +3 -0
  202. data/test/regression/test_hyperlink20.rb +3 -0
  203. data/test/regression/test_hyperlink21.rb +3 -0
  204. data/test/regression/test_hyperlink22.rb +3 -0
  205. data/test/regression/test_hyperlink23.rb +3 -0
  206. data/test/regression/test_hyperlink24.rb +3 -0
  207. data/test/regression/test_hyperlink25.rb +3 -0
  208. data/test/regression/test_hyperlink26.rb +3 -0
  209. data/test/regression/test_hyperlink27.rb +27 -0
  210. data/test/regression/test_hyperlink28.rb +50 -0
  211. data/test/regression/test_hyperlink29.rb +27 -0
  212. data/test/regression/test_hyperlink30.rb +36 -0
  213. data/test/regression/test_image08.rb +5 -4
  214. data/test/regression/test_image15.rb +4 -2
  215. data/test/regression/test_image28.rb +1 -1
  216. data/test/regression/test_image35.rb +26 -0
  217. data/test/regression/test_image36.rb +26 -0
  218. data/test/regression/test_image44.rb +28 -0
  219. data/test/regression/test_image45.rb +28 -0
  220. data/test/regression/test_image46.rb +29 -0
  221. data/test/regression/test_image47.rb +28 -0
  222. data/test/regression/test_object_position01.rb +26 -0
  223. data/test/regression/test_object_position02.rb +26 -0
  224. data/test/regression/test_object_position03.rb +26 -0
  225. data/test/regression/test_object_position04.rb +44 -0
  226. data/test/regression/test_object_position06.rb +28 -0
  227. data/test/regression/test_object_position07.rb +28 -0
  228. data/test/regression/test_object_position08.rb +47 -0
  229. data/test/regression/test_object_position09.rb +50 -0
  230. data/test/regression/test_object_position10.rb +28 -0
  231. data/test/regression/test_properties01.rb +1 -4
  232. data/test/regression/test_properties02.rb +1 -4
  233. data/test/regression/test_properties03.rb +26 -0
  234. data/test/regression/test_properties04.rb +61 -0
  235. data/test/regression/test_properties05.rb +30 -0
  236. data/test/regression/test_shape_connect01.rb +4 -2
  237. data/test/regression/test_table03.rb +3 -0
  238. data/test/regression/test_table04.rb +3 -0
  239. data/test/regression/test_table05.rb +3 -0
  240. data/test/regression/test_table06.rb +3 -0
  241. data/test/regression/test_table20.rb +34 -0
  242. data/test/regression/test_table21.rb +36 -0
  243. data/test/regression/test_table22.rb +32 -0
  244. data/test/regression/test_table23.rb +56 -0
  245. data/test/regression/test_utf8_11.rb +23 -0
  246. data/test/regression/xlsx_files/array_formula03.xlsx +0 -0
  247. data/test/regression/xlsx_files/autofilter08.xlsx +0 -0
  248. data/test/regression/xlsx_files/autofilter09.xlsx +0 -0
  249. data/test/regression/xlsx_files/autofilter10.xlsx +0 -0
  250. data/test/regression/xlsx_files/chart_axis26.xlsx +0 -0
  251. data/test/regression/xlsx_files/chart_axis27.xlsx +0 -0
  252. data/test/regression/xlsx_files/chart_axis28.xlsx +0 -0
  253. data/test/regression/xlsx_files/chart_axis29.xlsx +0 -0
  254. data/test/regression/xlsx_files/chart_axis33.xlsx +0 -0
  255. data/test/regression/xlsx_files/chart_axis42.xlsx +0 -0
  256. data/test/regression/xlsx_files/chart_axis43.xlsx +0 -0
  257. data/test/regression/xlsx_files/chart_axis44.xlsx +0 -0
  258. data/test/regression/xlsx_files/chart_axis45.xlsx +0 -0
  259. data/test/regression/xlsx_files/chart_axis46.xlsx +0 -0
  260. data/test/regression/xlsx_files/chart_chartarea05.xlsx +0 -0
  261. data/test/regression/xlsx_files/chart_chartarea06.xlsx +0 -0
  262. data/test/regression/xlsx_files/chart_combined10.xlsx +0 -0
  263. data/test/regression/xlsx_files/chart_combined11.xlsx +0 -0
  264. data/test/regression/xlsx_files/chart_data_labels25.xlsx +0 -0
  265. data/test/regression/xlsx_files/chart_doughnut07.xlsx +0 -0
  266. data/test/regression/xlsx_files/chart_font09.xlsx +0 -0
  267. data/test/regression/xlsx_files/chart_format26.xlsx +0 -0
  268. data/test/regression/xlsx_files/chart_format27.xlsx +0 -0
  269. data/test/regression/xlsx_files/chart_format28.xlsx +0 -0
  270. data/test/regression/xlsx_files/chart_format29.xlsx +0 -0
  271. data/test/regression/xlsx_files/chart_format30.xlsx +0 -0
  272. data/test/regression/xlsx_files/chart_format31.xlsx +0 -0
  273. data/test/regression/xlsx_files/chart_legend03.xlsx +0 -0
  274. data/test/regression/xlsx_files/chart_legend04.xlsx +0 -0
  275. data/test/regression/xlsx_files/chart_legend05.xlsx +0 -0
  276. data/test/regression/xlsx_files/chart_legend06.xlsx +0 -0
  277. data/test/regression/xlsx_files/chart_legend07.xlsx +0 -0
  278. data/test/regression/xlsx_files/chart_table03.xlsx +0 -0
  279. data/test/regression/xlsx_files/comment13.xlsx +0 -0
  280. data/test/regression/xlsx_files/comment14.xlsx +0 -0
  281. data/test/regression/xlsx_files/cond_format14.xlsx +0 -0
  282. data/test/regression/xlsx_files/cond_format15.xlsx +0 -0
  283. data/test/regression/xlsx_files/cond_format16.xlsx +0 -0
  284. data/test/regression/xlsx_files/cond_format17.xlsx +0 -0
  285. data/test/regression/xlsx_files/cond_format18.xlsx +0 -0
  286. data/test/regression/xlsx_files/cond_format19.xlsx +0 -0
  287. data/test/regression/xlsx_files/cond_format20.xlsx +0 -0
  288. data/test/regression/xlsx_files/date_1904_01.xlsx +0 -0
  289. data/test/regression/xlsx_files/format15.xlsx +0 -0
  290. data/test/regression/xlsx_files/hyperlink27.xlsx +0 -0
  291. data/test/regression/xlsx_files/hyperlink28.xlsx +0 -0
  292. data/test/regression/xlsx_files/hyperlink29.xlsx +0 -0
  293. data/test/regression/xlsx_files/hyperlink30.xlsx +0 -0
  294. data/test/regression/xlsx_files/hyperlink31.xlsx +0 -0
  295. data/test/regression/xlsx_files/image35.xlsx +0 -0
  296. data/test/regression/xlsx_files/image36.xlsx +0 -0
  297. data/test/regression/xlsx_files/image44.xlsx +0 -0
  298. data/test/regression/xlsx_files/image45.xlsx +0 -0
  299. data/test/regression/xlsx_files/image46.xlsx +0 -0
  300. data/test/regression/xlsx_files/image47.xlsx +0 -0
  301. data/test/regression/xlsx_files/object_position01.xlsx +0 -0
  302. data/test/regression/xlsx_files/object_position02.xlsx +0 -0
  303. data/test/regression/xlsx_files/object_position03.xlsx +0 -0
  304. data/test/regression/xlsx_files/object_position04.xlsx +0 -0
  305. data/test/regression/xlsx_files/object_position06.xlsx +0 -0
  306. data/test/regression/xlsx_files/object_position07.xlsx +0 -0
  307. data/test/regression/xlsx_files/object_position08.xlsx +0 -0
  308. data/test/regression/xlsx_files/object_position09.xlsx +0 -0
  309. data/test/regression/xlsx_files/object_position10.xlsx +0 -0
  310. data/test/regression/xlsx_files/properties03.xlsx +0 -0
  311. data/test/regression/xlsx_files/properties04.xlsx +0 -0
  312. data/test/regression/xlsx_files/properties05.xlsx +0 -0
  313. data/test/regression/xlsx_files/table21.xlsx +0 -0
  314. data/test/regression/xlsx_files/table22.xlsx +0 -0
  315. data/test/regression/xlsx_files/table23.xlsx +0 -0
  316. data/test/regression/xlsx_files/utf8_11.xlsx +0 -0
  317. data/test/test_example_match.rb +836 -771
  318. data/test/workbook/test_check_sheetname.rb +61 -0
  319. data/test/workbook/test_worksheet_by_name.rb +35 -0
  320. data/test/workbook/test_write_workbook_view.rb +117 -0
  321. data/test/worksheet/test_cond_format_22.rb +266 -0
  322. data/test/worksheet/test_cond_format_23.rb +242 -0
  323. data/test/worksheet/test_cond_format_24.rb +303 -0
  324. data/test/worksheet/test_data_bar_01.rb +53 -0
  325. data/test/worksheet/test_data_bar_02.rb +79 -0
  326. data/test/worksheet/test_data_bar_03.rb +147 -0
  327. data/test/worksheet/test_data_bar_04.rb +145 -0
  328. data/test/worksheet/test_data_bar_05.rb +147 -0
  329. data/test/worksheet/test_data_bar_06.rb +145 -0
  330. data/test/worksheet/test_data_bar_07.rb +146 -0
  331. data/test/worksheet/test_data_bar_08.rb +54 -0
  332. data/test/worksheet/test_data_bar_09.rb +80 -0
  333. data/test/worksheet/test_data_bar_10.rb +165 -0
  334. data/test/worksheet/test_data_bar_11.rb +167 -0
  335. data/test/worksheet/test_data_bar_12.rb +104 -0
  336. data/test/worksheet/test_write_data_validation_02.rb +44 -0
  337. data/test/worksheet/test_write_hyperlink.rb +0 -7
  338. data/test/worksheet/test_write_sheet_view.rb +19 -1
  339. metadata +308 -5
  340. data/test/package/comments/test_write_text_t.rb +0 -44
@@ -14,28 +14,29 @@ class Comment
14
14
  DEFAULT_HEIGHT = 74
15
15
 
16
16
  attr_reader :row, :col, :string, :color, :vertices
17
+ attr_reader :font_size, :font_family
17
18
  attr_accessor :author, :visible
18
19
 
19
20
  def initialize(workbook, worksheet, row, col, string, options = {})
20
21
  options ||= {}
21
- @workbook = workbook
22
- @worksheet = worksheet
23
- @row, @col = row, col
22
+ @workbook = workbook
23
+ @worksheet = worksheet
24
+ @row, @col = row, col
24
25
  options_parse(row, col, options)
25
- @string = string[0, STR_MAX]
26
- @start_row ||= default_start_row(row)
27
- @start_col ||= default_start_col(col)
28
- @visible = options[:visible]
29
- @x_offset = options[:x_offset] || default_x_offset(col)
30
- @y_offset = options[:y_offset] || default_y_offset(row)
31
- @x_scale = options[:x_scale] || 1
32
- @y_scale = options[:y_scale] || 1
33
- @width = (0.5 + (options[:width] || DEFAULT_WIDTH) * @x_scale).to_i
34
- @height = (0.5 + (options[:height] || DEFAULT_HEIGHT) * @y_scale).to_i
35
- @vertices = @worksheet.position_object_pixels(
36
- @start_col, @start_row, @x_offset, @y_offset,
37
- @width, @height
38
- ) << [@width, @height]
26
+ @string = string[0, STR_MAX]
27
+ @start_row ||= default_start_row(row)
28
+ @start_col ||= default_start_col(col)
29
+ @visible = options[:visible]
30
+ @x_offset = options[:x_offset] || default_x_offset(col)
31
+ @y_offset = options[:y_offset] || default_y_offset(row)
32
+ @x_scale = options[:x_scale] || 1
33
+ @y_scale = options[:y_scale] || 1
34
+ @width = (0.5 + (options[:width] || DEFAULT_WIDTH) * @x_scale).to_i
35
+ @height = (0.5 + (options[:height] || DEFAULT_HEIGHT) * @y_scale).to_i
36
+ @vertices = @worksheet.position_object_pixels(
37
+ @start_col, @start_row, @x_offset, @y_offset,
38
+ @width, @height
39
+ ) << [@width, @height]
39
40
  end
40
41
 
41
42
  def backgrount_color(color)
@@ -213,24 +214,31 @@ def writer=(w)
213
214
  @writer = w
214
215
  end
215
216
 
217
+ def font_name
218
+ @font
219
+ end
220
+
216
221
  private
217
222
 
218
223
  def options_parse(row, col, options)
219
- @color = backgrount_color(options[:color] || DEFAULT_COLOR)
220
- @author = options[:author]
221
- @start_cell = options[:start_cell]
224
+ @color = backgrount_color(options[:color] || DEFAULT_COLOR)
225
+ @author = options[:author]
226
+ @start_cell = options[:start_cell]
222
227
  @start_row, @start_col = if @start_cell
223
228
  substitute_cellref(@start_cell)
224
229
  else
225
230
  [ options[:start_row], options[:start_col] ]
226
231
  end
227
- @visible = options[:visible]
228
- @x_offset = options[:x_offset] || default_x_offset(col)
229
- @y_offset = options[:y_offset] || default_y_offset(row)
230
- @x_scale = options[:x_scale] || 1
231
- @y_scale = options[:y_scale] || 1
232
- @width = (0.5 + (options[:width] || DEFAULT_WIDTH) * @x_scale).to_i
233
- @height = (0.5 + (options[:height] || DEFAULT_HEIGHT) * @y_scale).to_i
232
+ @visible = options[:visible]
233
+ @x_offset = options[:x_offset] || default_x_offset(col)
234
+ @y_offset = options[:y_offset] || default_y_offset(row)
235
+ @x_scale = options[:x_scale] || 1
236
+ @y_scale = options[:y_scale] || 1
237
+ @font = options[:font] || 'Tahoma'
238
+ @font_size = options[:font_size] || 8
239
+ @font_family = options[:font_family] || 2
240
+ @width = (0.5 + (options[:width] || DEFAULT_WIDTH) * @x_scale).to_i
241
+ @height = (0.5 + (options[:height] || DEFAULT_HEIGHT) * @y_scale).to_i
234
242
  end
235
243
  end
236
244
 
@@ -249,13 +257,9 @@ def [](row)
249
257
  @comments[row]
250
258
  end
251
259
 
252
- def add(comment)
253
- if @comments[comment.row]
254
- @comments[comment.row][comment.col] = comment
255
- else
256
- @comments[comment.row] = {}
257
- @comments[comment.row][comment.col] = comment
258
- end
260
+ def add(workbook, worksheet, row, col, string, options)
261
+ @comments[row] ||= {}
262
+ @comments[row][col] = [workbook, worksheet, row, col, string, options]
259
263
  end
260
264
 
261
265
  def empty?
@@ -285,6 +289,10 @@ def sorted_comments
285
289
  # We sort the comments by row and column but that isn't strictly required.
286
290
  @comments.keys.sort.each do |row|
287
291
  @comments[row].keys.sort.each do |col|
292
+ user_options = @comments[row][col]
293
+ comment = Comment.new(*user_options)
294
+ @comments[row][col] = comment
295
+
288
296
  # Set comment visibility if required and not already user defined.
289
297
  @comments[row][col].visible ||= 1 if comments_visible?
290
298
 
@@ -366,36 +374,37 @@ def write_comment(comment)
366
374
  attributes << ['authorId', author_id]
367
375
 
368
376
  @writer.tag_elements('comment', attributes) do
369
- write_text(comment.string)
377
+ write_text(comment)
370
378
  end
371
379
  end
372
380
 
373
381
  #
374
382
  # Write the <text> element.
375
383
  #
376
- def write_text(text)
384
+ def write_text(comment)
377
385
  @writer.tag_elements('text') do
378
386
  # Write the text r element.
379
- write_text_r(text)
387
+ write_text_r(comment)
380
388
  end
381
389
  end
382
390
 
383
391
  #
384
392
  # Write the <r> element.
385
393
  #
386
- def write_text_r(text)
394
+ def write_text_r(comment)
387
395
  @writer.tag_elements('r') do
388
396
  # Write the rPr element.
389
- write_r_pr
397
+ write_r_pr(comment)
390
398
  # Write the text r element.
391
- write_text_t(text)
399
+ write_text_t(comment)
392
400
  end
393
401
  end
394
402
 
395
403
  #
396
404
  # Write the text <t> element.
397
405
  #
398
- def write_text_t(text)
406
+ def write_text_t(comment)
407
+ text = comment.string
399
408
  attributes = []
400
409
 
401
410
  attributes << ['xml:space', 'preserve'] if text =~ /^\s/ || text =~ /\s$/
@@ -406,25 +415,23 @@ def write_text_t(text)
406
415
  #
407
416
  # Write the <rPr> element.
408
417
  #
409
- def write_r_pr
418
+ def write_r_pr(comment)
410
419
  @writer.tag_elements('rPr') do
411
420
  # Write the sz element.
412
- write_sz
421
+ write_sz(comment.font_size)
413
422
  # Write the color element.
414
423
  write_color
415
424
  # Write the rFont element.
416
- write_r_font
425
+ write_r_font(comment.font_name)
417
426
  # Write the family element.
418
- write_family
427
+ write_family(comment.font_family)
419
428
  end
420
429
  end
421
430
 
422
431
  #
423
432
  # Write the <sz> element.
424
433
  #
425
- def write_sz
426
- val = 8
427
-
434
+ def write_sz(val)
428
435
  attributes = [ ['val', val] ]
429
436
 
430
437
  @writer.empty_tag('sz', attributes)
@@ -440,9 +447,7 @@ def write_color
440
447
  #
441
448
  # Write the <rFont> element.
442
449
  #
443
- def write_r_font
444
- val = 'Tahoma'
445
-
450
+ def write_r_font(val)
446
451
  attributes = [ ['val', val] ]
447
452
 
448
453
  @writer.empty_tag('rFont', attributes)
@@ -451,9 +456,7 @@ def write_r_font
451
456
  #
452
457
  # Write the <family> element.
453
458
  #
454
- def write_family
455
- val = 2
456
-
459
+ def write_family(val)
457
460
  attributes = [ ['val', val] ]
458
461
 
459
462
  @writer.empty_tag('family', attributes)
@@ -7,8 +7,8 @@ class ConditionalFormat
7
7
 
8
8
  def self.factory(worksheet, *args)
9
9
  range, param =
10
- Package::ConditionalFormat.new(worksheet, nil, nil).
11
- range_param_for_conditional_formatting(*args)
10
+ Package::ConditionalFormat.new(worksheet, nil, nil).
11
+ range_param_for_conditional_formatting(*args)
12
12
 
13
13
  case param[:type]
14
14
  when 'cellIs'
@@ -29,6 +29,8 @@ def self.factory(worksheet, *args)
29
29
  DataBarFormat.new(worksheet, range, param)
30
30
  when 'expression'
31
31
  ExpressionFormat.new(worksheet, range, param)
32
+ when 'iconSet'
33
+ IconSetFormat.new(worksheet, range, param)
32
34
  else # when 'duplicateValues', 'uniqueValues'
33
35
  ConditionalFormat.new(worksheet, range, param)
34
36
  end
@@ -59,11 +61,13 @@ def write_formula_tag(data) #:nodoc:
59
61
  #
60
62
  # Write the <cfvo> element.
61
63
  #
62
- def write_cfvo(type, val)
63
- @writer.empty_tag('cfvo', [
64
- ['type', type],
65
- ['val', val]
66
- ])
64
+ def write_cfvo(type, value, criteria = nil)
65
+ attributes = [ ['type', type] ]
66
+ attributes << [ 'val', value] if value
67
+
68
+ attributes << ['gte', 0] if ptrue?(criteria)
69
+
70
+ @writer.empty_tag('cfvo', attributes)
67
71
  end
68
72
 
69
73
  def attributes
@@ -154,6 +158,54 @@ def bar_color
154
158
  @param[:bar_color]
155
159
  end
156
160
 
161
+ def bar_border_color
162
+ @param[:bar_border_color]
163
+ end
164
+
165
+ def bar_negative_color
166
+ @param[:bar_negative_color]
167
+ end
168
+
169
+ def bar_negative_color_same
170
+ @param[:bar_negative_color_same]
171
+ end
172
+
173
+ def bar_no_border
174
+ @param[:bar_no_border]
175
+ end
176
+
177
+ def bar_axis_position
178
+ @param[:bar_axis_position]
179
+ end
180
+
181
+ def bar_axis_color
182
+ @param[:bar_axis_color]
183
+ end
184
+
185
+ def icon_style
186
+ @param[:icon_style]
187
+ end
188
+
189
+ def total_icons
190
+ @param[:total_icons]
191
+ end
192
+
193
+ def icons
194
+ @param[:icons]
195
+ end
196
+
197
+ def icons_only
198
+ @param[:icons_only]
199
+ end
200
+
201
+ def reverse_icons
202
+ @param[:reverse_icons]
203
+ end
204
+
205
+ def bar_only
206
+ @param[:bar_only]
207
+ end
208
+
157
209
  def range_param_for_conditional_formatting(*args) # :nodoc:
158
210
  range_start_cell_for_conditional_formatting(*args)
159
211
  param_for_conditional_formatting(*args)
@@ -274,17 +326,68 @@ def handling_of_blanks_error_types
274
326
  @param[:mid_color] = palette_color(@param[:mid_color])
275
327
  @param[:min_color] = palette_color(@param[:min_color])
276
328
  when 'dataBar'
277
- # Color scales don't use any additional formatting.
329
+ # Excel 2007 data bars don't use any additional formatting.
278
330
  @param[:format] = nil
279
331
 
280
- @param[:min_type] ||= 'min'
281
- @param[:max_type] ||= 'max'
282
- @param[:min_value] ||= 0
283
- @param[:max_value] ||= 0
284
- @param[:bar_color] ||= '#638EC6'
332
+ if !@param[:min_type]
333
+ @param[:min_type] = 'min'
334
+ @param[:x14_min_type] = 'autoMin'
335
+ else
336
+ @param[:x14_min_type] = @param[:min_type]
337
+ end
338
+ if !@param[:max_type]
339
+ @param[:max_type] = 'max'
340
+ @param[:x14_max_type] = 'autoMax'
341
+ else
342
+ @param[:x14_max_type] = @param[:max_type]
343
+ end
344
+
345
+ @param[:min_value] ||= 0
346
+ @param[:max_value] ||= 0
347
+ @param[:bar_color] ||= '#638EC6'
348
+ @param[:bar_border_color] ||= @param[:bar_color]
349
+ @param[:bar_only] ||= 0
350
+ @param[:bar_no_border] ||= 0
351
+ @param[:bar_solid] ||= 0
352
+ @param[:bar_direction] ||= ''
353
+ @param[:bar_negative_color] ||= '#FF0000'
354
+ @param[:bar_negative_border_color] ||= '#FF0000'
355
+ @param[:bar_negative_color_same] ||= 0
356
+ @param[:bar_negative_border_color_same] ||= 0
357
+ @param[:bar_axis_position] ||= ''
358
+ @param[:bar_axis_color] ||= '#000000'
359
+
360
+ @param[:bar_color] =
361
+ palette_color(@param[:bar_color])
362
+ @param[:bar_border_color] =
363
+ palette_color(@param[:bar_border_color])
364
+ @param[:bar_negative_color] =
365
+ palette_color(@param[:bar_negative_color])
366
+ @param[:bar_negative_border_color] =
367
+ palette_color(@param[:bar_negative_border_color])
368
+ @param[:bar_axis_color] =
369
+ palette_color(@param[:bar_axis_color])
370
+ end
371
+
372
+ # Adjust for 2010 style data_bar parameters.
373
+ if ptrue?(@param[:is_data_bar_2010])
374
+ @worksheet.excel_version = 2010
285
375
 
286
- @param[:bar_color] = palette_color(@param[:bar_color])
376
+ if @param[:min_type] == 'min' && @param[:min_value] == 0
377
+ @param[:min_value] = nil
378
+ end
379
+ if @param[:max_type] == 'max' && @param[:max_value] == 0
380
+ @param[:max_value] = nil
381
+ end
382
+
383
+ # Store range for Excel 2010 data bars.
384
+ @param[:range] = range
287
385
  end
386
+
387
+ # Strip the leading = from formulas.
388
+ @param[:min_value] = @param[:min_value].to_s.sub(/^=/, '') if @param[:min_value]
389
+ @param[:mid_value] = @param[:mid_value].to_s.sub(/^=/, '') if @param[:mid_value]
390
+ @param[:max_value] = @param[:max_value].to_s.sub(/^=/, '') if @param[:max_value]
288
391
  end
289
392
 
290
393
  def palette_color(index)
@@ -293,7 +396,7 @@ def palette_color(index)
293
396
 
294
397
  def range_start_cell_for_conditional_formatting(*args) # :nodoc:
295
398
  row1, row2, col1, col2, user_range, param =
296
- row_col_param_for_conditional_formatting(*args)
399
+ row_col_param_for_conditional_formatting(*args)
297
400
  # If the first and last cell are the same write a single cell.
298
401
  if row1 == row2 && col1 == col2
299
402
  range = xl_rowcol_to_cell(row1, col1)
@@ -336,19 +439,32 @@ def row_col_param_for_conditional_formatting(*args)
336
439
 
337
440
  def param_for_conditional_formatting(*args) # :nodoc:
338
441
  dummy, dummy, dummy, dummy, dummy, @param =
339
- row_col_param_for_conditional_formatting(*args)
442
+ row_col_param_for_conditional_formatting(*args)
340
443
  check_conditional_formatting_parameters(@param)
341
444
 
342
445
  @param[:format] = @param[:format].get_dxf_index if @param[:format]
343
446
  @param[:priority] = @worksheet.dxf_priority
447
+
448
+ # Check for 2010 style data_bar parameters.
449
+ %i(data_bar_2010 bar_solid bar_border_color bar_negative_color
450
+ bar_negative_color_same bar_negative_border_color
451
+ bar_negative_border_color_same bar_no_border
452
+ bar_axis_position bar_axis_color bar_direction
453
+ ).each do |key|
454
+ if @param[key]
455
+ @param[:is_data_bar_2010] = 1
456
+ break
457
+ end
458
+ end
459
+
344
460
  @worksheet.dxf_priority += 1
345
461
  end
346
462
 
347
463
  def check_conditional_formatting_parameters(param) # :nodoc:
348
464
  # Check for valid input parameters.
349
- unless (param.keys.uniq - valid_parameter_for_conditional_formatting).empty? &&
350
- param.has_key?(:type) &&
351
- valid_type_for_conditional_formatting.has_key?(param[:type].downcase)
465
+ if !(param.keys.uniq - valid_parameter_for_conditional_formatting).empty? ||
466
+ !param.has_key?(:type) ||
467
+ !valid_type_for_conditional_formatting.has_key?(param[:type].downcase)
352
468
  raise WriteXLSXOptionParameterError, "Invalid type : #{param[:type]}"
353
469
  end
354
470
 
@@ -369,6 +485,32 @@ def check_conditional_formatting_parameters(param) # :nodoc:
369
485
  param[:maximum] = convert_date_time_if_required(param[:maximum])
370
486
  end
371
487
 
488
+ # Set properties for icon sets.
489
+ if param[:type] == 'iconSet'
490
+ if !param[:icon_style]
491
+ raise "The 'icon_style' parameter must be specified when " +
492
+ "'type' == 'icon_set' in conditional_formatting()"
493
+ end
494
+
495
+ # Check for valid icon styles.
496
+ if !icon_set_styles[param[:icon_style]]
497
+ raise "Unknown icon style '$param->{icon_style}' for parameter " +
498
+ "'icon_style' in conditional_formatting()"
499
+ else
500
+ param[:icon_style] = icon_set_styles[param[:icon_style]]
501
+ end
502
+
503
+ # Set the number of icons for the icon style.
504
+ param[:total_icons] = 3
505
+ if param[:icon_style] =~ /^4/
506
+ param[:total_icons] = 4
507
+ elsif param[:icon_style] =~ /^5/
508
+ param[:total_icons] = 5
509
+ end
510
+
511
+ param[:icons] = set_icon_properties(param[:total_icons], param[:icons])
512
+ end
513
+
372
514
  # 'Between' and 'Not between' criteria require 2 values.
373
515
  if param[:criteria] == 'between' || param[:criteria] == 'notBetween'
374
516
  unless param.has_key?(:minimum) || param.has_key?(:maximum)
@@ -400,23 +542,39 @@ def convert_date_time_if_required(val)
400
542
  # List of valid input parameters for conditional_formatting.
401
543
  def valid_parameter_for_conditional_formatting
402
544
  [
403
- :type,
404
- :format,
405
- :criteria,
406
- :value,
407
- :minimum,
408
- :maximum,
409
- :stop_if_true,
410
- :min_type,
411
- :mid_type,
412
- :max_type,
413
- :min_value,
414
- :mid_value,
415
- :max_value,
416
- :min_color,
417
- :mid_color,
418
- :max_color,
419
- :bar_color
545
+ :type,
546
+ :format,
547
+ :criteria,
548
+ :value,
549
+ :minimum,
550
+ :maximum,
551
+ :stop_if_true,
552
+ :min_type,
553
+ :mid_type,
554
+ :max_type,
555
+ :min_value,
556
+ :mid_value,
557
+ :max_value,
558
+ :min_color,
559
+ :mid_color,
560
+ :max_color,
561
+ :bar_color,
562
+ :bar_negative_color,
563
+ :bar_negative_color_same,
564
+ :bar_solid,
565
+ :bar_border_color,
566
+ :bar_negative_border_color,
567
+ :bar_negative_border_color_same,
568
+ :bar_no_border,
569
+ :bar_direction,
570
+ :bar_axis_position,
571
+ :bar_axis_color,
572
+ :bar_only,
573
+ :icon_style,
574
+ :reverse_icons,
575
+ :icons_only,
576
+ :icons,
577
+ :data_bar_2010
420
578
  ]
421
579
  end
422
580
 
@@ -440,7 +598,8 @@ def valid_type_for_conditional_formatting
440
598
  '2_color_scale' => '2_color_scale',
441
599
  '3_color_scale' => '3_color_scale',
442
600
  'data_bar' => 'dataBar',
443
- 'formula' => 'expression'
601
+ 'formula' => 'expression',
602
+ 'icon_set' => 'iconSet'
444
603
  }
445
604
  end
446
605
 
@@ -479,6 +638,100 @@ def valid_criteria_type_for_conditional_formatting
479
638
  }
480
639
  end
481
640
 
641
+ # List of valid icon styles.
642
+ def icon_set_styles
643
+ {
644
+ "3_arrows" => "3Arrows", # 1
645
+ "3_flags" => "3Flags", # 2
646
+ "3_traffic_lights_rimmed" => "3TrafficLights2", # 3
647
+ "3_symbols_circled" => "3Symbols", # 4
648
+ "4_arrows" => "4Arrows", # 5
649
+ "4_red_to_black" => "4RedToBlack", # 6
650
+ "4_traffic_lights" => "4TrafficLights", # 7
651
+ "5_arrows_gray" => "5ArrowsGray", # 8
652
+ "5_quarters" => "5Quarters", # 9
653
+ "3_arrows_gray" => "3ArrowsGray", # 10
654
+ "3_traffic_lights" => "3TrafficLights", # 11
655
+ "3_signs" => "3Signs", # 12
656
+ "3_symbols" => "3Symbols2", # 13
657
+ "4_arrows_gray" => "4ArrowsGray", # 14
658
+ "4_ratings" => "4Rating", # 15
659
+ "5_arrows" => "5Arrows", # 16
660
+ "5_ratings" => "5Rating", # 17
661
+ }
662
+ end
663
+
664
+ #
665
+ # Set the sub-properites for icons.
666
+ #
667
+ def set_icon_properties(total_icons, user_props)
668
+ props = []
669
+
670
+ # Set the default icon properties.
671
+ total_icons.times do
672
+ props << {
673
+ :criteria => 0,
674
+ :value => 0,
675
+ :type => 'percent'
676
+ }
677
+ end
678
+
679
+ # Set the default icon values based on the number of icons.
680
+ if total_icons == 3
681
+ props[0][:value] = 67
682
+ props[1][:value] = 33
683
+ elsif total_icons == 4
684
+ props[0][:value] = 75
685
+ props[1][:value] = 50
686
+ props[2][:value] = 25
687
+ elsif total_icons == 5
688
+ props[0][:value] = 80
689
+ props[1][:value] = 60
690
+ props[2][:value] = 40
691
+ props[3][:value] = 20
692
+ end
693
+
694
+ # Overwrite default properties with user defined properties.
695
+ if user_props
696
+
697
+ # Ensure we don't set user properties for lowest icon.
698
+ max_data = user_props.size
699
+ max_data = total_icons -1 if max_data >= total_icons
700
+
701
+ (0..max_data - 1).each do |i|
702
+ # Set the user defined 'value' property.
703
+ if user_props[i][:value]
704
+ props[i][:value] = user_props[i][:value].to_s.sub(/^=/, '')
705
+ end
706
+
707
+ # Set the user defined 'type' property.
708
+ if user_props[i][:type]
709
+
710
+ type = user_props[i][:type]
711
+
712
+ if type != 'percent' && type != 'percentile' &&
713
+ type != 'number' && type != 'formula'
714
+ raise "Unknown icon property type '$props->{type}' for sub-" +
715
+ "property 'type' in conditional_formatting()"
716
+ else
717
+ props[i][:type] = type
718
+
719
+ if props[i][:type] == 'number'
720
+ props[i][:type] = 'num'
721
+ end
722
+ end
723
+ end
724
+
725
+ # Set the user defined 'criteria' property.
726
+ if user_props[i][:criteria] && user_props[i][:criteria] == '>'
727
+ props[i][:criteria] = 1
728
+ end
729
+
730
+ end
731
+ end
732
+ props
733
+ end
734
+
482
735
  def date_1904?
483
736
  @worksheet.date_1904?
484
737
  end
@@ -496,7 +749,15 @@ def write_cf_rule
496
749
  write_formula_tag(maximum)
497
750
  end
498
751
  else
499
- write_cf_rule_formula_tag(value)
752
+ quoted_value = value.to_s
753
+ numeric_regex = /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/
754
+ # String "Cell" values must be quoted, apart from ranges.
755
+ if !(quoted_value =~ /(\$?)([A-Z]{1,3})(\$?)(\d+)/) &&
756
+ !(quoted_value =~ numeric_regex) &&
757
+ !(quoted_value =~ /^".*"$/)
758
+ quoted_value = (%Q!"#{value}"!)
759
+ end
760
+ write_cf_rule_formula_tag(quoted_value)
500
761
  end
501
762
  end
502
763
  end
@@ -578,6 +839,9 @@ class DataBarFormat < ConditionalFormat
578
839
  def write_cf_rule
579
840
  @writer.tag_elements('cfRule', attributes) do
580
841
  write_data_bar
842
+ if ptrue?(@param[:is_data_bar_2010])
843
+ write_data_bar_ext(@param)
844
+ end
581
845
  end
582
846
  end
583
847
 
@@ -585,13 +849,42 @@ def write_cf_rule
585
849
  # Write the <dataBar> element.
586
850
  #
587
851
  def write_data_bar
588
- @writer.tag_elements('dataBar') do
852
+ attributes = []
853
+
854
+ if ptrue?(bar_only)
855
+ attributes << ['showValue', 0]
856
+ end
857
+ @writer.tag_elements('dataBar',attributes) do
589
858
  write_cfvo(min_type, min_value)
590
859
  write_cfvo(max_type, max_value)
591
860
 
592
861
  write_color(@writer, 'rgb', bar_color)
593
862
  end
594
863
  end
864
+
865
+ #
866
+ # Write the <extLst> dataBar extension element.
867
+ #
868
+ def write_data_bar_ext(param)
869
+ # Create a pseudo GUID for each unique Excel 2010 data bar.
870
+ worksheet_count = @worksheet.index + 1
871
+ data_bar_count = @worksheet.data_bars_2010.size + 1
872
+
873
+ guid = sprintf(
874
+ "{DA7ABA51-AAAA-BBBB-%04X-%012X}",
875
+ worksheet_count, data_bar_count
876
+ )
877
+
878
+ # Store the 2010 data bar parameters to write the extLst elements.
879
+ param[:guid] = guid
880
+ @worksheet.data_bars_2010 << param
881
+
882
+ @writer.tag_elements('extLst') do
883
+ @worksheet.write_ext('{B025F937-C7B1-47D3-B67F-A62EFF666E3E}') do
884
+ @writer.data_element('x14:id', guid)
885
+ end
886
+ end
887
+ end
595
888
  end
596
889
 
597
890
  class ExpressionFormat < ConditionalFormat
@@ -599,5 +892,33 @@ def write_cf_rule
599
892
  write_cf_rule_formula_tag(criteria)
600
893
  end
601
894
  end
895
+
896
+ class IconSetFormat < ConditionalFormat
897
+ def write_cf_rule
898
+ @writer.tag_elements('cfRule', attributes) do
899
+ write_icon_set
900
+ end
901
+ end
902
+
903
+ #
904
+ # Write the <iconSet> element.
905
+ #
906
+ def write_icon_set
907
+ attributes = []
908
+ # Don't set attribute for default style.
909
+ attributes = [ ['iconSet', icon_style] ] if icon_style != '3TrafficLights'
910
+ attributes << ['showValue', 0] if icons_only
911
+ attributes << ['reverse', 1] if reverse_icons
912
+
913
+ @writer.tag_elements('iconSet', attributes) do
914
+ # Write the properties for different icon styles.
915
+ if icons
916
+ icons.reverse.each do |icon|
917
+ write_cfvo(icon[:type], icon[:value], icon[:criteria])
918
+ end
919
+ end
920
+ end
921
+ end
922
+ end
602
923
  end
603
924
  end