write_xlsx 0.99.0 → 1.07.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 (314) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +0 -1
  4. data/Changes +70 -0
  5. data/README.md +1 -1
  6. data/examples/a_simple.rb +1 -1
  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_labels.rb +320 -0
  15. data/examples/chart_data_table.rb +9 -3
  16. data/examples/chart_data_tools.rb +25 -7
  17. data/examples/chart_doughnut.rb +17 -5
  18. data/examples/chart_gauge.rb +73 -0
  19. data/examples/chart_line.rb +90 -12
  20. data/examples/chart_pareto.rb +1 -1
  21. data/examples/chart_pie.rb +9 -3
  22. data/examples/chart_radar.rb +13 -4
  23. data/examples/chart_scatter.rb +5 -2
  24. data/examples/chart_secondary_axis.rb +5 -2
  25. data/examples/chart_stock.rb +1 -1
  26. data/examples/chart_styles.rb +1 -1
  27. data/examples/colors.rb +1 -1
  28. data/examples/data_validate.rb +1 -1
  29. data/examples/date_time.rb +1 -1
  30. data/examples/demo.rb +4 -1
  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 +1 -1
  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 +78 -43
  67. data/lib/write_xlsx/chart.rb +163 -34
  68. data/lib/write_xlsx/chart/area.rb +1 -1
  69. data/lib/write_xlsx/chart/bar.rb +1 -1
  70. data/lib/write_xlsx/chart/column.rb +1 -1
  71. data/lib/write_xlsx/chart/doughnut.rb +1 -1
  72. data/lib/write_xlsx/chart/line.rb +16 -2
  73. data/lib/write_xlsx/chart/pie.rb +21 -8
  74. data/lib/write_xlsx/chart/radar.rb +1 -1
  75. data/lib/write_xlsx/chart/scatter.rb +1 -1
  76. data/lib/write_xlsx/chart/series.rb +100 -0
  77. data/lib/write_xlsx/chart/stock.rb +1 -1
  78. data/lib/write_xlsx/chartsheet.rb +5 -5
  79. data/lib/write_xlsx/drawing.rb +86 -30
  80. data/lib/write_xlsx/format.rb +5 -5
  81. data/lib/write_xlsx/package/comments.rb +11 -11
  82. data/lib/write_xlsx/package/relationships.rb +4 -4
  83. data/lib/write_xlsx/package/styles.rb +26 -8
  84. data/lib/write_xlsx/package/table.rb +8 -7
  85. data/lib/write_xlsx/package/vml.rb +20 -19
  86. data/lib/write_xlsx/shape.rb +4 -3
  87. data/lib/write_xlsx/sheets.rb +18 -16
  88. data/lib/write_xlsx/sparkline.rb +1 -1
  89. data/lib/write_xlsx/utility.rb +40 -7
  90. data/lib/write_xlsx/version.rb +1 -1
  91. data/lib/write_xlsx/workbook.rb +69 -44
  92. data/lib/write_xlsx/worksheet.rb +206 -138
  93. data/lib/write_xlsx/worksheet/hyperlink.rb +16 -37
  94. data/test/drawing/test_drawing_chart_01.rb +6 -2
  95. data/test/drawing/test_drawing_image_01.rb +12 -3
  96. data/test/drawing/test_drawing_shape_01.rb +8 -5
  97. data/test/drawing/test_drawing_shape_02.rb +12 -5
  98. data/test/drawing/test_drawing_shape_03.rb +8 -5
  99. data/test/drawing/test_drawing_shape_04.rb +8 -24
  100. data/test/drawing/test_drawing_shape_05.rb +8 -5
  101. data/test/drawing/test_drawing_shape_06.rb +11 -6
  102. data/test/drawing/test_drawing_shape_07.rb +11 -6
  103. data/test/drawing/test_write_a_graphic_frame_locks.rb +1 -1
  104. data/test/drawing/test_write_c_chart.rb +1 -1
  105. data/test/drawing/test_write_c_nv_graphic_frame_pr.rb +1 -1
  106. data/test/drawing/test_write_c_nv_pr.rb +1 -1
  107. data/test/drawing/test_write_col.rb +1 -1
  108. data/test/drawing/test_write_col_off.rb +1 -1
  109. data/test/drawing/test_write_ext.rb +1 -1
  110. data/test/drawing/test_write_pos.rb +1 -1
  111. data/test/drawing/test_write_row.rb +1 -1
  112. data/test/drawing/test_write_row_off.rb +1 -1
  113. data/test/drawing/test_write_xfrm_extension.rb +1 -1
  114. data/test/drawing/test_write_xfrm_offset.rb +1 -1
  115. data/test/perl_output/chart_data_labels.xlsx +0 -0
  116. data/test/perl_output/chart_gauge.xlsx +0 -0
  117. data/test/perl_output/chart_line.xlsx +0 -0
  118. data/test/perl_output/comments2.xlsx +0 -0
  119. data/test/perl_output/tables.xlsx +0 -0
  120. data/test/regression/images/red2.png +0 -0
  121. data/test/regression/test_array_formula04.rb +31 -0
  122. data/test/regression/test_chart_axis26.rb +10 -8
  123. data/test/regression/test_chart_axis27.rb +1 -1
  124. data/test/regression/test_chart_axis28.rb +1 -1
  125. data/test/regression/test_chart_axis29.rb +1 -1
  126. data/test/regression/test_chart_axis33.rb +1 -1
  127. data/test/regression/test_chart_axis44.rb +54 -0
  128. data/test/regression/test_chart_axis45.rb +54 -0
  129. data/test/regression/test_chart_axis46.rb +54 -0
  130. data/test/regression/test_chart_combined10.rb +43 -0
  131. data/test/regression/test_chart_combined11.rb +63 -0
  132. data/test/regression/test_chart_data_labels25.rb +1 -1
  133. data/test/regression/test_chart_data_labels26.rb +44 -0
  134. data/test/regression/test_chart_data_labels27.rb +44 -0
  135. data/test/regression/test_chart_data_labels28.rb +52 -0
  136. data/test/regression/test_chart_data_labels29.rb +43 -0
  137. data/test/regression/test_chart_data_labels30.rb +46 -0
  138. data/test/regression/test_chart_data_labels31.rb +49 -0
  139. data/test/regression/test_chart_data_labels32.rb +54 -0
  140. data/test/regression/test_chart_data_labels33.rb +52 -0
  141. data/test/regression/test_chart_data_labels34.rb +54 -0
  142. data/test/regression/test_chart_data_labels35.rb +46 -0
  143. data/test/regression/test_chart_data_labels36.rb +54 -0
  144. data/test/regression/test_chart_data_labels37.rb +51 -0
  145. data/test/regression/test_chart_data_labels38.rb +54 -0
  146. data/test/regression/test_chart_data_labels39.rb +53 -0
  147. data/test/regression/test_chart_data_labels40.rb +53 -0
  148. data/test/regression/test_chart_data_labels41.rb +54 -0
  149. data/test/regression/test_chart_data_labels42.rb +58 -0
  150. data/test/regression/test_chart_data_labels43.rb +58 -0
  151. data/test/regression/test_chart_data_labels44.rb +56 -0
  152. data/test/regression/test_chart_data_labels45.rb +57 -0
  153. data/test/regression/test_chart_data_labels46.rb +61 -0
  154. data/test/regression/test_chart_data_labels47.rb +61 -0
  155. data/test/regression/test_chart_doughnut07.rb +37 -0
  156. data/test/regression/test_chart_font09.rb +1 -1
  157. data/test/regression/test_chart_line05.rb +43 -0
  158. data/test/regression/test_chart_line06.rb +43 -0
  159. data/test/regression/test_chart_size03.rb +4 -1
  160. data/test/regression/test_comment14.rb +29 -0
  161. data/test/regression/test_comment15.rb +28 -0
  162. data/test/regression/test_comment16.rb +34 -0
  163. data/test/regression/test_header_image15.rb +36 -0
  164. data/test/regression/test_header_image16.rb +42 -0
  165. data/test/regression/test_header_image17.rb +46 -0
  166. data/test/regression/test_header_image18.rb +48 -0
  167. data/test/regression/test_header_image19.rb +36 -0
  168. data/test/regression/test_hyperlink32.rb +27 -0
  169. data/test/regression/test_hyperlink33.rb +28 -0
  170. data/test/regression/test_hyperlink34.rb +33 -0
  171. data/test/regression/test_hyperlink35.rb +39 -0
  172. data/test/regression/test_hyperlink36.rb +34 -0
  173. data/test/regression/test_hyperlink37.rb +33 -0
  174. data/test/regression/test_hyperlink38.rb +27 -0
  175. data/test/regression/test_hyperlink39.rb +27 -0
  176. data/test/regression/test_hyperlink40.rb +27 -0
  177. data/test/regression/test_hyperlink41.rb +27 -0
  178. data/test/regression/test_hyperlink42.rb +27 -0
  179. data/test/regression/test_hyperlink43.rb +27 -0
  180. data/test/regression/test_hyperlink44.rb +27 -0
  181. data/test/regression/test_hyperlink45.rb +27 -0
  182. data/test/regression/test_hyperlink47.rb +27 -0
  183. data/test/regression/test_hyperlink48.rb +31 -0
  184. data/test/regression/test_hyperlink49.rb +29 -0
  185. data/test/regression/test_image06.rb +5 -5
  186. data/test/regression/test_image08.rb +5 -4
  187. data/test/regression/test_image15.rb +4 -2
  188. data/test/regression/test_image28.rb +1 -1
  189. data/test/regression/test_image44.rb +28 -0
  190. data/test/regression/test_image45.rb +29 -0
  191. data/test/regression/test_image46.rb +29 -0
  192. data/test/regression/test_image47.rb +28 -0
  193. data/test/regression/test_image48.rb +32 -0
  194. data/test/regression/test_image49.rb +38 -0
  195. data/test/regression/test_image50.rb +24 -0
  196. data/test/regression/test_image51.rb +30 -0
  197. data/test/regression/test_object_position01.rb +26 -0
  198. data/test/regression/test_object_position02.rb +26 -0
  199. data/test/regression/test_object_position03.rb +26 -0
  200. data/test/regression/test_object_position04.rb +44 -0
  201. data/test/regression/test_object_position06.rb +28 -0
  202. data/test/regression/test_object_position07.rb +28 -0
  203. data/test/regression/test_object_position08.rb +47 -0
  204. data/test/regression/test_object_position09.rb +50 -0
  205. data/test/regression/test_object_position10.rb +28 -0
  206. data/test/regression/test_object_position12.rb +25 -0
  207. data/test/regression/test_object_position13.rb +25 -0
  208. data/test/regression/test_object_position14.rb +25 -0
  209. data/test/regression/test_object_position15.rb +29 -0
  210. data/test/regression/test_object_position16.rb +29 -0
  211. data/test/regression/test_object_position17.rb +29 -0
  212. data/test/regression/test_object_position18.rb +29 -0
  213. data/test/regression/test_object_position19.rb +29 -0
  214. data/test/regression/test_object_position20.rb +29 -0
  215. data/test/regression/test_shape_connect01.rb +4 -2
  216. data/test/regression/test_table24.rb +27 -0
  217. data/test/regression/test_table25.rb +27 -0
  218. data/test/regression/xlsx_files/array_formula04.xlsx +0 -0
  219. data/test/regression/xlsx_files/chart_axis26.xlsx +0 -0
  220. data/test/regression/xlsx_files/chart_axis27.xlsx +0 -0
  221. data/test/regression/xlsx_files/chart_axis28.xlsx +0 -0
  222. data/test/regression/xlsx_files/chart_axis29.xlsx +0 -0
  223. data/test/regression/xlsx_files/chart_axis33.xlsx +0 -0
  224. data/test/regression/xlsx_files/chart_axis44.xlsx +0 -0
  225. data/test/regression/xlsx_files/chart_axis45.xlsx +0 -0
  226. data/test/regression/xlsx_files/chart_axis46.xlsx +0 -0
  227. data/test/regression/xlsx_files/chart_combined10.xlsx +0 -0
  228. data/test/regression/xlsx_files/chart_combined11.xlsx +0 -0
  229. data/test/regression/xlsx_files/chart_data_labels25.xlsx +0 -0
  230. data/test/regression/xlsx_files/chart_data_labels26.xlsx +0 -0
  231. data/test/regression/xlsx_files/chart_data_labels27.xlsx +0 -0
  232. data/test/regression/xlsx_files/chart_data_labels28.xlsx +0 -0
  233. data/test/regression/xlsx_files/chart_data_labels29.xlsx +0 -0
  234. data/test/regression/xlsx_files/chart_data_labels30.xlsx +0 -0
  235. data/test/regression/xlsx_files/chart_data_labels31.xlsx +0 -0
  236. data/test/regression/xlsx_files/chart_data_labels32.xlsx +0 -0
  237. data/test/regression/xlsx_files/chart_data_labels33.xlsx +0 -0
  238. data/test/regression/xlsx_files/chart_data_labels34.xlsx +0 -0
  239. data/test/regression/xlsx_files/chart_data_labels35.xlsx +0 -0
  240. data/test/regression/xlsx_files/chart_data_labels36.xlsx +0 -0
  241. data/test/regression/xlsx_files/chart_data_labels37.xlsx +0 -0
  242. data/test/regression/xlsx_files/chart_data_labels38.xlsx +0 -0
  243. data/test/regression/xlsx_files/chart_data_labels39.xlsx +0 -0
  244. data/test/regression/xlsx_files/chart_data_labels40.xlsx +0 -0
  245. data/test/regression/xlsx_files/chart_data_labels41.xlsx +0 -0
  246. data/test/regression/xlsx_files/chart_data_labels42.xlsx +0 -0
  247. data/test/regression/xlsx_files/chart_data_labels43.xlsx +0 -0
  248. data/test/regression/xlsx_files/chart_data_labels44.xlsx +0 -0
  249. data/test/regression/xlsx_files/chart_data_labels45.xlsx +0 -0
  250. data/test/regression/xlsx_files/chart_data_labels46.xlsx +0 -0
  251. data/test/regression/xlsx_files/chart_data_labels47.xlsx +0 -0
  252. data/test/regression/xlsx_files/chart_doughnut07.xlsx +0 -0
  253. data/test/regression/xlsx_files/chart_font09.xlsx +0 -0
  254. data/test/regression/xlsx_files/chart_line05.xlsx +0 -0
  255. data/test/regression/xlsx_files/chart_line06.xlsx +0 -0
  256. data/test/regression/xlsx_files/comment14.xlsx +0 -0
  257. data/test/regression/xlsx_files/comment15.xlsx +0 -0
  258. data/test/regression/xlsx_files/comment16.xlsx +0 -0
  259. data/test/regression/xlsx_files/header_image15.xlsx +0 -0
  260. data/test/regression/xlsx_files/header_image16.xlsx +0 -0
  261. data/test/regression/xlsx_files/header_image17.xlsx +0 -0
  262. data/test/regression/xlsx_files/header_image18.xlsx +0 -0
  263. data/test/regression/xlsx_files/header_image19.xlsx +0 -0
  264. data/test/regression/xlsx_files/hyperlink32.xlsx +0 -0
  265. data/test/regression/xlsx_files/hyperlink33.xlsx +0 -0
  266. data/test/regression/xlsx_files/hyperlink34.xlsx +0 -0
  267. data/test/regression/xlsx_files/hyperlink35.xlsx +0 -0
  268. data/test/regression/xlsx_files/hyperlink36.xlsx +0 -0
  269. data/test/regression/xlsx_files/hyperlink37.xlsx +0 -0
  270. data/test/regression/xlsx_files/hyperlink38.xlsx +0 -0
  271. data/test/regression/xlsx_files/hyperlink39.xlsx +0 -0
  272. data/test/regression/xlsx_files/hyperlink40.xlsx +0 -0
  273. data/test/regression/xlsx_files/hyperlink41.xlsx +0 -0
  274. data/test/regression/xlsx_files/hyperlink42.xlsx +0 -0
  275. data/test/regression/xlsx_files/hyperlink43.xlsx +0 -0
  276. data/test/regression/xlsx_files/hyperlink44.xlsx +0 -0
  277. data/test/regression/xlsx_files/hyperlink45.xlsx +0 -0
  278. data/test/regression/xlsx_files/hyperlink46.xlsx +0 -0
  279. data/test/regression/xlsx_files/hyperlink47.xlsx +0 -0
  280. data/test/regression/xlsx_files/hyperlink48.xlsx +0 -0
  281. data/test/regression/xlsx_files/hyperlink49.xlsx +0 -0
  282. data/test/regression/xlsx_files/image06.xlsx +0 -0
  283. data/test/regression/xlsx_files/image44.xlsx +0 -0
  284. data/test/regression/xlsx_files/image45.xlsx +0 -0
  285. data/test/regression/xlsx_files/image46.xlsx +0 -0
  286. data/test/regression/xlsx_files/image47.xlsx +0 -0
  287. data/test/regression/xlsx_files/image48.xlsx +0 -0
  288. data/test/regression/xlsx_files/image49.xlsx +0 -0
  289. data/test/regression/xlsx_files/image50.xlsx +0 -0
  290. data/test/regression/xlsx_files/image51.xlsx +0 -0
  291. data/test/regression/xlsx_files/object_position01.xlsx +0 -0
  292. data/test/regression/xlsx_files/object_position02.xlsx +0 -0
  293. data/test/regression/xlsx_files/object_position03.xlsx +0 -0
  294. data/test/regression/xlsx_files/object_position04.xlsx +0 -0
  295. data/test/regression/xlsx_files/object_position06.xlsx +0 -0
  296. data/test/regression/xlsx_files/object_position07.xlsx +0 -0
  297. data/test/regression/xlsx_files/object_position08.xlsx +0 -0
  298. data/test/regression/xlsx_files/object_position09.xlsx +0 -0
  299. data/test/regression/xlsx_files/object_position10.xlsx +0 -0
  300. data/test/regression/xlsx_files/object_position12.xlsx +0 -0
  301. data/test/regression/xlsx_files/object_position13.xlsx +0 -0
  302. data/test/regression/xlsx_files/object_position14.xlsx +0 -0
  303. data/test/regression/xlsx_files/object_position15.xlsx +0 -0
  304. data/test/regression/xlsx_files/object_position16.xlsx +0 -0
  305. data/test/regression/xlsx_files/object_position17.xlsx +0 -0
  306. data/test/regression/xlsx_files/object_position18.xlsx +0 -0
  307. data/test/regression/xlsx_files/object_position19.xlsx +0 -0
  308. data/test/regression/xlsx_files/object_position20.xlsx +0 -0
  309. data/test/regression/xlsx_files/table24.xlsx +0 -0
  310. data/test/regression/xlsx_files/table25.xlsx +0 -0
  311. data/test/test_example_match.rb +1268 -780
  312. data/test/workbook/test_check_sheetname.rb +51 -0
  313. data/write_xlsx.gemspec +1 -0
  314. metadata +367 -5
@@ -36,9 +36,9 @@ def test_a_simple
36
36
 
37
37
  # Write a hyperlink
38
38
  hyperlink_format = workbook.add_format(
39
- :color => 'blue',
40
- :underline => 1
41
- )
39
+ :color => 'blue',
40
+ :underline => 1
41
+ )
42
42
 
43
43
  worksheet.write(10, 0, 'http://www.ruby-lang.org/', hyperlink_format)
44
44
 
@@ -242,6 +242,381 @@ def test_autofilter
242
242
  compare_xlsx(File.join(@perl_output, @xlsx), @tempfile.path)
243
243
  end
244
244
 
245
+ def test_chart_data_labels
246
+ @xlsx = 'chart_data_labels.xlsx'
247
+ workbook = WriteXLSX.new(@io)
248
+
249
+ worksheet = workbook.add_worksheet
250
+ bold = workbook.add_format(:bold => 1)
251
+
252
+ # Add the worksheet data that the charts will refer to.
253
+ headings = ['Number', 'Data', 'Text']
254
+ data = [
255
+ [ 2, 3, 4, 5, 6, 7 ],
256
+ [20, 10, 20, 30, 40, 30 ],
257
+ ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
258
+ ]
259
+
260
+ worksheet.write('A1', headings, bold)
261
+ worksheet.write('A2', data)
262
+
263
+
264
+ #######################################################################
265
+ #
266
+ # Example with standard data labels.
267
+ #
268
+
269
+ # Create a Column chart.
270
+ chart1 = workbook.add_chart(:type => 'column', :embedded => 1)
271
+
272
+ # Configure the data series and add the data labels.
273
+ chart1.add_series(
274
+ :categories => '=Sheet1!$A$2:$A$7',
275
+ :values => '=Sheet1!$B$2:$B$7',
276
+ :data_labels => { :value => 1 }
277
+ )
278
+
279
+ # Add a chart title.
280
+ chart1.set_title(:name => 'Chart with standard data labels')
281
+
282
+ # Turn off the chart legend.
283
+ chart1.set_legend(:none => 1)
284
+
285
+ # Insert the chart into the worksheet (with an offset).
286
+ worksheet.insert_chart('D2', chart1, { :x_offset => 25, :y_offset => 10 })
287
+
288
+
289
+ #######################################################################
290
+ #
291
+ # Example with value and category data labels.
292
+ #
293
+
294
+ # Create a Column chart.
295
+ chart2 = workbook.add_chart(:type => 'column', :embedded => 1)
296
+
297
+ # Configure the data series and add the data labels.
298
+ chart2.add_series(
299
+ :categories => '=Sheet1!$A$2:$A$7',
300
+ :values => '=Sheet1!$B$2:$B$7',
301
+ :data_labels => { :value => 1, :category => 1 }
302
+ )
303
+
304
+ # Add a chart title.
305
+ chart2.set_title(:name => 'Category and Value data labels')
306
+
307
+ # Turn off the chart legend.
308
+ chart2.set_legend(:none => 1)
309
+
310
+ # Insert the chart into the worksheet (with an offset).
311
+ worksheet.insert_chart('D18', chart2, { :x_offset => 25, :y_offset => 10 })
312
+
313
+
314
+ #######################################################################
315
+ #
316
+ # Example with standard data labels with different font.
317
+ #
318
+
319
+ # Create a Column chart.
320
+ chart3 = workbook.add_chart(:type => 'column', :embedded => 1)
321
+
322
+ # Configure the data series and add the data labels.
323
+ chart3.add_series(
324
+ :categories => '=Sheet1!$A$2:$A$7',
325
+ :values => '=Sheet1!$B$2:$B$7',
326
+ :data_labels => { :value => 1,
327
+ :font => {:bold => 1,
328
+ :color => 'red',
329
+ :rotation => -30}
330
+ }
331
+ )
332
+
333
+ # Add a chart title.
334
+ chart3.set_title(:name => 'Data labels with user defined font')
335
+
336
+ # Turn off the chart legend.
337
+ chart3.set_legend(:none => 1)
338
+
339
+ # Insert the chart into the worksheet (with an offset).
340
+ worksheet.insert_chart('D34', chart3, { :x_offset => 25, :y_offset => 10 })
341
+
342
+
343
+ #######################################################################
344
+ #
345
+ # Example with custom string data labels.
346
+ #
347
+
348
+ # Create a Column chart.
349
+ chart4 = workbook.add_chart(:type => 'column', :embedded => 1)
350
+
351
+ # Configure the data series and add the data labels.
352
+ chart4.add_series(
353
+ :categories => '=Sheet1!$A$2:$A$7',
354
+ :values => '=Sheet1!$B$2:$B$7',
355
+ :data_labels => {
356
+ :value => 1,
357
+ :border => {:color => 'red'},
358
+ :fill => {:color => 'yellow'}
359
+ }
360
+ )
361
+
362
+ # Add a chart title.
363
+ chart4.set_title(:name => 'Data labels with formatting')
364
+
365
+ # Turn off the chart legend.
366
+ chart4.set_legend(:none => 1)
367
+
368
+ # Insert the chart into the worksheet (with an offset).
369
+ worksheet.insert_chart('D50', chart4, { :x_offset => 25, :y_offset => 10 })
370
+
371
+
372
+ #######################################################################
373
+ #
374
+ # Example with custom string data labels.
375
+ #
376
+
377
+ # Create a Column chart.
378
+ chart5 = workbook.add_chart( :type => 'column', :embedded => 1 )
379
+
380
+ # Some custom labels.
381
+ custom_labels = [
382
+ { :value => 'Amy' },
383
+ { :value => 'Bea' },
384
+ { :value => 'Eva' },
385
+ { :value => 'Fay' },
386
+ { :value => 'Liv' },
387
+ { :value => 'Una' }
388
+ ]
389
+
390
+ # Configure the data series and add the data labels.
391
+ chart5.add_series(
392
+ :categories => '=Sheet1!$A$2:$A$7',
393
+ :values => '=Sheet1!$B$2:$B$7',
394
+ :data_labels => { :value => 1, :custom => custom_labels }
395
+ )
396
+
397
+ # Add a chart title.
398
+ chart5.set_title(:name => 'Chart with custom string data labels')
399
+
400
+ # Turn off the chart legend.
401
+ chart5.set_legend(:none => 1)
402
+
403
+ # Insert the chart into the worksheet (with an offset).
404
+ worksheet.insert_chart('D66', chart5, { :x_offset => 25, :y_offset => 10 })
405
+
406
+
407
+ #######################################################################
408
+ #
409
+ # Example with custom data labels from cells.
410
+ #
411
+
412
+ # Create a Column chart.
413
+ chart6 = workbook.add_chart(:type => 'column', :embedded => 1)
414
+
415
+ # Some custom labels.
416
+ custom_labels = [
417
+ { :value => '=Sheet1!$C$2' },
418
+ { :value => '=Sheet1!$C$3' },
419
+ { :value => '=Sheet1!$C$4' },
420
+ { :value => '=Sheet1!$C$5' },
421
+ { :value => '=Sheet1!$C$6' },
422
+ { :value => '=Sheet1!$C$7' }
423
+ ]
424
+
425
+
426
+ # Configure the data series and add the data labels.
427
+ chart6.add_series(
428
+ :categories => '=Sheet1!$A$2:$A$7',
429
+ :values => '=Sheet1!$B$2:$B$7',
430
+ :data_labels => { :value => 1, :custom => custom_labels }
431
+ )
432
+
433
+ # Add a chart title.
434
+ chart6.set_title(:name => 'Chart with custom data labels from cells')
435
+
436
+ # Turn off the chart legend.
437
+ chart6.set_legend(:none => 1)
438
+
439
+ # Insert the chart into the worksheet (with an offset).
440
+ worksheet.insert_chart('D82', chart6, { :x_offset => 25, :y_offset => 10 })
441
+
442
+
443
+ #######################################################################
444
+ #
445
+ # Example with custom and default data labels.
446
+ #
447
+
448
+ # Create a Column chart.
449
+ chart7 = workbook.add_chart(:type => 'column', :embedded => 1)
450
+
451
+ # Some custom labels. The nil items will get the default value.
452
+ # We also set a font for the custom items as an extra example.
453
+ custom_labels = [
454
+ { :value => '=Sheet1!$C$2', :font => { :color => 'red' } },
455
+ nil,
456
+ { :value => '=Sheet1!$C$4', :font => { :color => 'red' } },
457
+ { :value => '=Sheet1!$C$5', :font => { :color => 'red' } }
458
+ ]
459
+
460
+
461
+ # Configure the data series and add the data labels.
462
+ chart7.add_series(
463
+ :categories => '=Sheet1!$A$2:$A$7',
464
+ :values => '=Sheet1!$B$2:$B$7',
465
+ :data_labels => { :value => 1, :custom => custom_labels }
466
+ )
467
+
468
+ # Add a chart title.
469
+ chart7.set_title(:name => 'Mixed custom and default data labels')
470
+
471
+ # Turn off the chart legend.
472
+ chart7.set_legend(:none => 1)
473
+
474
+ # Insert the chart into the worksheet (with an offset).
475
+ worksheet.insert_chart('D98', chart7, { :x_offset => 25, :y_offset => 10 })
476
+
477
+
478
+ #######################################################################
479
+ #
480
+ # Example with deleted custom data labels.
481
+ #
482
+
483
+ # Create a Column chart.
484
+ chart8 = workbook.add_chart(:type => 'column', :embedded => 1)
485
+
486
+ # Some deleted custom labels and defaults (nil). This allows us to
487
+ # highlight certain values such as the minimum and maximum.
488
+ custom_labels = [
489
+ { :delete => 1 },
490
+ nil,
491
+ { :delete => 1 },
492
+ { :delete => 1 },
493
+ nil,
494
+ { :delete => 1 }
495
+ ]
496
+
497
+ # Configure the data series and add the data labels.
498
+ chart8.add_series(
499
+ :categories => '=Sheet1!$A$2:$A$7',
500
+ :values => '=Sheet1!$B$2:$B$7',
501
+ :data_labels => { :value => 1, :custom => custom_labels }
502
+ )
503
+
504
+ # Add a chart title.
505
+ chart8.set_title(:name => 'Chart with deleted data labels')
506
+
507
+ # Turn off the chart legend.
508
+ chart8.set_legend(:none => 1)
509
+
510
+ # Insert the chart into the worksheet (with an offset).
511
+ worksheet.insert_chart('D114', chart8, { :x_offset => 25, :y_offset => 10 })
512
+
513
+ #######################################################################
514
+ #
515
+ # Example with custom string data labels and formatting.
516
+ #
517
+
518
+ # Create a Column chart.
519
+ chart9 = workbook.add_chart( :type => 'column', :embedded => 1 )
520
+
521
+ # Some custom labels.
522
+ custom_labels = [
523
+ { :value => 'Amy', :border => {:color => 'blue'} },
524
+ { :value => 'Bea' },
525
+ { :value => 'Eva' },
526
+ { :value => 'Fay' },
527
+ { :value => 'Liv' },
528
+ { :value => 'Una', :fill => {:color => 'green'} }
529
+ ]
530
+
531
+
532
+ # Configure the data series and add the data labels.
533
+ chart9.add_series(
534
+ :categories => '=Sheet1!$A$2:$A$7',
535
+ :values => '=Sheet1!$B$2:$B$7',
536
+ :data_labels => {
537
+ :value => 1,
538
+ :custom => custom_labels,
539
+ :border => {:color => 'red'},
540
+ :fill => {:color => 'yellow'}
541
+ }
542
+ )
543
+
544
+ # Add a chart title.
545
+ chart9.set_title( :name => 'Chart with custom labels and formatting' )
546
+
547
+ # Turn off the chart legend.
548
+ chart9.set_legend( :none => 1 )
549
+
550
+ # Insert the chart into the worksheet (with an offset).
551
+ worksheet.insert_chart( 'D130', chart9, { :x_offset => 25, :y_offset => 10 } )
552
+
553
+ workbook.close
554
+ store_to_tempfile
555
+ compare_xlsx(File.join(@perl_output, @xlsx), @tempfile.path)
556
+ end
557
+
558
+ def test_chart_gauge
559
+ @xlsx = 'chart_gauge.xlsx'
560
+ workbook = WriteXLSX.new(@io)
561
+ worksheet = workbook.add_worksheet
562
+
563
+ chart_doughnut = workbook.add_chart(:type => 'doughnut', :embedded => 1)
564
+ chart_pie = workbook.add_chart(:type => 'pie', :embedded => 1)
565
+
566
+ # Add some data for the Doughnut and Pie charts. This is set up so the
567
+ # gauge goes from 0-100. It is initially set at 75%.
568
+ worksheet.write_col('H2', ['Donut', 25, 50, 25, 100])
569
+ worksheet.write_col('I2', ['Pie', 75, 1, '=200-I4-I3'])
570
+
571
+ # Configure the doughnut chart as the background for the gauge.
572
+ chart_doughnut.add_series(
573
+ :name => '=Sheet1!$H$2',
574
+ :values => '=Sheet1!$H$3:$H$6',
575
+ :points => [
576
+ { :fill => { :color => 'green' } },
577
+ { :fill => { :color => 'yellow' } },
578
+ { :fill => { :color => 'red' } },
579
+ { :fill => { :none => 1 } }
580
+ ]
581
+ )
582
+
583
+ # Rotate chart so the gauge parts are above the horizontal.
584
+ chart_doughnut.set_rotation(270)
585
+
586
+ # Turn off the chart legend.
587
+ chart_doughnut.set_legend(:none => 1)
588
+
589
+ # Turn off the chart fill and border.
590
+ chart_doughnut.set_chartarea(
591
+ :border => { :none => 1 },
592
+ :fill => { :none => 1 }
593
+ )
594
+
595
+ # Configure the pie chart as the needle for the gauge.
596
+ chart_pie.add_series(
597
+ :name => '=Sheet1!$I$2',
598
+ :values => '=Sheet1!$I$3:$I$6',
599
+ :points => [
600
+ { :fill => { :none => 1 } },
601
+ { :fill => { :color => 'black' } },
602
+ { :fill => { :none => 1 } }
603
+ ]
604
+ )
605
+
606
+ # Rotate the pie chart/needle to align with the doughnut/gauge.
607
+ chart_pie.set_rotation(270)
608
+
609
+ # Combine the pie and doughnut charts.
610
+ chart_doughnut.combine(chart_pie)
611
+
612
+ # Insert the chart into the worksheet.
613
+ worksheet.insert_chart('A1', chart_doughnut)
614
+
615
+ workbook.close
616
+ store_to_tempfile
617
+ compare_xlsx(File.join(@perl_output, @xlsx), @tempfile.path)
618
+ end
619
+
245
620
  def test_chart_scatter06
246
621
  @xlsx = 'chart_scatter06.xlsx'
247
622
  workbook = WriteXLSX.new(@io)
@@ -252,23 +627,23 @@ def test_chart_scatter06
252
627
  chart.instance_variable_set(:@axis_ids, [57708544, 44297600])
253
628
 
254
629
  data = [
255
- [ 1, 2, 3, 4, 5 ],
256
- [ 2, 4, 6, 8, 10 ],
257
- [ 3, 6, 9, 12, 15 ]
630
+ [ 1, 2, 3, 4, 5 ],
631
+ [ 2, 4, 6, 8, 10 ],
632
+ [ 3, 6, 9, 12, 15 ]
258
633
 
259
- ]
634
+ ]
260
635
 
261
636
  worksheet.write('A1', data)
262
637
 
263
638
  chart.add_series(
264
- :categories => '=Sheet1!$A$1:$A$5',
265
- :values => '=Sheet1!$B$1:$B$5'
266
- )
639
+ :categories => '=Sheet1!$A$1:$A$5',
640
+ :values => '=Sheet1!$B$1:$B$5'
641
+ )
267
642
 
268
643
  chart.add_series(
269
- :categories => '=Sheet1!$A$1:$A$5',
270
- :values => '=Sheet1!$C$1:$C$5'
271
- )
644
+ :categories => '=Sheet1!$A$1:$A$5',
645
+ :values => '=Sheet1!$C$1:$C$5'
646
+ )
272
647
 
273
648
  chart.set_x_axis(:minor_unit => 1, :major_unit => 3)
274
649
  chart.set_y_axis(:minor_unit => 2, :major_unit => 4)
@@ -281,7 +656,7 @@ def test_chart_scatter06
281
656
  end
282
657
 
283
658
  def autofilter_data
284
- <<EOS
659
+ <<EOS
285
660
  Region Item Volume Month
286
661
  East Apple 9000 July
287
662
  East Apple 5000 July
@@ -345,10 +720,10 @@ def test_chart_area
345
720
  # Add the worksheet data that the charts will refer to.
346
721
  headings = [ 'Number', 'Batch 1', 'Batch 2' ]
347
722
  data = [
348
- [ 2, 3, 4, 5, 6, 7 ],
349
- [ 40, 40, 50, 30, 25, 50 ],
350
- [ 30, 25, 30, 10, 5, 10 ]
351
- ]
723
+ [ 2, 3, 4, 5, 6, 7 ],
724
+ [ 40, 40, 50, 30, 25, 50 ],
725
+ [ 30, 25, 30, 10, 5, 10 ]
726
+ ]
352
727
 
353
728
  worksheet.write('A1', headings, bold)
354
729
  worksheet.write('A2', data)
@@ -358,18 +733,18 @@ def test_chart_area
358
733
 
359
734
  # Configure the first series.
360
735
  chart.add_series(
361
- :name => '=Sheet1!$B$1',
362
- :categories => '=Sheet1!$A$2:$A$7',
363
- :values => '=Sheet1!$B$2:$B$7'
364
- )
736
+ :name => '=Sheet1!$B$1',
737
+ :categories => '=Sheet1!$A$2:$A$7',
738
+ :values => '=Sheet1!$B$2:$B$7'
739
+ )
365
740
 
366
741
  # Configure second series. Note alternative use of array ref to define
367
742
  # ranges: [ sheetname, row_start, row_end, col_start, col_end ].
368
743
  chart.add_series(
369
- :name => '=Sheet1!$C$1',
370
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
371
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
372
- )
744
+ :name => '=Sheet1!$C$1',
745
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
746
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
747
+ )
373
748
 
374
749
  # Add a chart title and some axis labels.
375
750
  chart.set_title(:name => 'Results of sample analysis')
@@ -396,9 +771,9 @@ def test_chart_bar
396
771
  # Add the worksheet data that the charts will refer to.
397
772
  headings = [ 'Number', 'Batch 1', 'Batch 2' ]
398
773
  data = [
399
- [ 2, 3, 4, 5, 6, 7 ],
400
- [ 10, 40, 50, 20, 10, 50 ],
401
- [ 30, 60, 70, 50, 40, 30 ]
774
+ [ 2, 3, 4, 5, 6, 7 ],
775
+ [ 10, 40, 50, 20, 10, 50 ],
776
+ [ 30, 60, 70, 50, 40, 30 ]
402
777
  ]
403
778
 
404
779
  worksheet.write('A1', headings, bold)
@@ -409,17 +784,17 @@ def test_chart_bar
409
784
 
410
785
  # Configure the first series.
411
786
  chart.add_series(
412
- :name => '=Sheet1!$B$1',
413
- :categories => '=Sheet1!$A$2:$A$7',
414
- :values => '=Sheet1!$B$2:$B$7'
787
+ :name => '=Sheet1!$B$1',
788
+ :categories => '=Sheet1!$A$2:$A$7',
789
+ :values => '=Sheet1!$B$2:$B$7'
415
790
  )
416
791
 
417
792
  # Configure second series. Note alternative use of array ref to define
418
793
  # ranges: [ sheetname, row_start, row_end, col_start, col_end ].
419
794
  chart.add_series(
420
- :name => '=Sheet1!$C$1',
421
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
422
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
795
+ :name => '=Sheet1!$C$1',
796
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
797
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
423
798
  )
424
799
 
425
800
  # Add a chart title and some axis labels.
@@ -447,9 +822,9 @@ def test_chart_column
447
822
  # Add the worksheet data that the charts will refer to.
448
823
  headings = [ 'Number', 'Batch 1', 'Batch 2' ]
449
824
  data = [
450
- [ 2, 3, 4, 5, 6, 7 ],
451
- [ 10, 40, 50, 20, 10, 50 ],
452
- [ 30, 60, 70, 50, 40, 30 ]
825
+ [ 2, 3, 4, 5, 6, 7 ],
826
+ [ 10, 40, 50, 20, 10, 50 ],
827
+ [ 30, 60, 70, 50, 40, 30 ]
453
828
  ]
454
829
 
455
830
  worksheet.write('A1', headings, bold)
@@ -460,17 +835,17 @@ def test_chart_column
460
835
 
461
836
  # Configure the first series.
462
837
  chart.add_series(
463
- :name => '=Sheet1!$B$1',
464
- :categories => '=Sheet1!$A$2:$A$7',
465
- :values => '=Sheet1!$B$2:$B$7'
838
+ :name => '=Sheet1!$B$1',
839
+ :categories => '=Sheet1!$A$2:$A$7',
840
+ :values => '=Sheet1!$B$2:$B$7'
466
841
  )
467
842
 
468
843
  # Configure second series. Note alternative use of array ref to define
469
844
  # ranges: [ sheetname, row_start, row_end, col_start, col_end ].
470
845
  chart.add_series(
471
- :name => '=Sheet1!$C$1',
472
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
473
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
846
+ :name => '=Sheet1!$C$1',
847
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
848
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
474
849
  )
475
850
 
476
851
  # Add a chart title and some axis labels.
@@ -498,9 +873,9 @@ def test_chart_doughnut
498
873
  # Add the worksheet data that the charts will refer to.
499
874
  headings = [ 'Category', 'Values' ]
500
875
  data = [
501
- [ 'Glazed', 'Chocolate', 'Cream' ],
502
- [ 50, 35, 15 ]
503
- ]
876
+ [ 'Glazed', 'Chocolate', 'Cream' ],
877
+ [ 50, 35, 15 ]
878
+ ]
504
879
 
505
880
  worksheet.write('A1', headings, bold)
506
881
  worksheet.write('A2', data)
@@ -512,10 +887,10 @@ def test_chart_doughnut
512
887
  # [ $sheetname, $row_start, $row_end, $col_start, $col_end ].
513
888
  # See below for an alternative syntax.
514
889
  chart1.add_series(
515
- :name => 'Doughnut sales data',
516
- :categories => [ 'Sheet1', 1, 3, 0, 0 ],
517
- :values => [ 'Sheet1', 1, 3, 1, 1 ]
518
- );
890
+ :name => 'Doughnut sales data',
891
+ :categories => [ 'Sheet1', 1, 3, 0, 0 ],
892
+ :values => [ 'Sheet1', 1, 3, 1, 1 ]
893
+ )
519
894
 
520
895
  # Add a title.
521
896
  chart1.set_title(:name => 'Popular Doughnut Types')
@@ -536,15 +911,15 @@ def test_chart_doughnut
536
911
 
537
912
  # Configure the series and add user defined segment colours.
538
913
  chart2.add_series(
539
- :name => 'Doughnut sales data',
540
- :categories => '=Sheet1!$A$2:$A$4',
541
- :values => '=Sheet1!$B$2:$B$4',
542
- :points => [
543
- { :fill => { :color => '#FA58D0' } },
544
- { :fill => { :color => '#61210B' } },
545
- { :fill => { :color => '#F5F6CE' } }
546
- ]
547
- )
914
+ :name => 'Doughnut sales data',
915
+ :categories => '=Sheet1!$A$2:$A$4',
916
+ :values => '=Sheet1!$B$2:$B$4',
917
+ :points => [
918
+ { :fill => { :color => '#FA58D0' } },
919
+ { :fill => { :color => '#61210B' } },
920
+ { :fill => { :color => '#F5F6CE' } }
921
+ ]
922
+ )
548
923
 
549
924
  # Add a title.
550
925
  chart2.set_title(:name => 'Doughnut Chart with user defined colors')
@@ -563,10 +938,10 @@ def test_chart_doughnut
563
938
 
564
939
  # Configure the series.
565
940
  chart3.add_series(
566
- :name => 'Doughnut sales data',
567
- :categories => '=Sheet1!$A$2:$A$4',
568
- :values => '=Sheet1!$B$2:$B$4'
569
- )
941
+ :name => 'Doughnut sales data',
942
+ :categories => '=Sheet1!$A$2:$A$4',
943
+ :values => '=Sheet1!$B$2:$B$4'
944
+ )
570
945
 
571
946
  # Add a title.
572
947
  chart3.set_title(:name => 'Doughnut Chart with segment rotation')
@@ -587,10 +962,10 @@ def test_chart_doughnut
587
962
 
588
963
  # Configure the series.
589
964
  chart4.add_series(
590
- :name => 'Doughnut sales data',
591
- :categories => '=Sheet1!$A$2:$A$4',
592
- :values => '=Sheet1!$B$2:$B$4'
593
- )
965
+ :name => 'Doughnut sales data',
966
+ :categories => '=Sheet1!$A$2:$A$4',
967
+ :values => '=Sheet1!$B$2:$B$4'
968
+ )
594
969
 
595
970
  # Add a title.
596
971
  chart4.set_title(:name => 'Doughnut Chart with user defined hole size')
@@ -615,9 +990,9 @@ def test_chart_line
615
990
  # Add the worksheet data that the charts will refer to.
616
991
  headings = [ 'Number', 'Batch 1', 'Batch 2' ]
617
992
  data = [
618
- [ 2, 3, 4, 5, 6, 7 ],
619
- [ 10, 40, 50, 20, 10, 50 ],
620
- [ 30, 60, 70, 50, 40, 30 ]
993
+ [ 2, 3, 4, 5, 6, 7 ],
994
+ [ 10, 40, 50, 20, 10, 50 ],
995
+ [ 30, 60, 70, 50, 40, 30 ]
621
996
  ]
622
997
 
623
998
  worksheet.write('A1', headings, bold)
@@ -628,17 +1003,17 @@ def test_chart_line
628
1003
 
629
1004
  # Configure the first series.
630
1005
  chart.add_series(
631
- :name => '=Sheet1!$B$1',
632
- :categories => '=Sheet1!$A$2:$A$7',
633
- :values => '=Sheet1!$B$2:$B$7'
1006
+ :name => '=Sheet1!$B$1',
1007
+ :categories => '=Sheet1!$A$2:$A$7',
1008
+ :values => '=Sheet1!$B$2:$B$7'
634
1009
  )
635
1010
 
636
1011
  # Configure second series. Note alternative use of array ref to define
637
1012
  # ranges: [ sheetname, row_start, row_end, col_start, col_end ].
638
1013
  chart.add_series(
639
- :name => '=Sheet1!$C$1',
640
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
641
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
1014
+ :name => '=Sheet1!$C$1',
1015
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
1016
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
642
1017
  )
643
1018
 
644
1019
  # Add a chart title and some axis labels.
@@ -652,6 +1027,81 @@ def test_chart_line
652
1027
  # Insert the chart into the worksheet (with an offset).
653
1028
  worksheet.insert_chart('D2', chart, 25, 10)
654
1029
 
1030
+ #
1031
+ # Create a stacked chart sub-type
1032
+ #
1033
+ chart2 = workbook.add_chart(
1034
+ :type => 'line',
1035
+ :embedded => 1,
1036
+ :subtype => 'stacked'
1037
+ )
1038
+
1039
+ # Configure the first series.
1040
+ chart2.add_series(
1041
+ :name => '=Sheet1!$B$1',
1042
+ :categories => '=Sheet1!$A$2:$A$7',
1043
+ :values => '=Sheet1!$B$2:$B$7'
1044
+ )
1045
+
1046
+ # Configure second series.
1047
+ chart2.add_series(
1048
+ :name => '=Sheet1!$C$1',
1049
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
1050
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
1051
+ )
1052
+
1053
+ # Add a chart title and some axis labels.
1054
+ chart2.set_title( :name => 'Stacked Chart' )
1055
+ chart2.set_x_axis( :name => 'Test number' )
1056
+ chart2.set_y_axis( :name => 'Sample length (mm)' )
1057
+
1058
+ # Set an Excel chart style. Blue colors with white outline and shadow.
1059
+ chart2.set_style( 12 )
1060
+
1061
+ # Insert the chart into the worksheet (with an offset).
1062
+ worksheet.insert_chart(
1063
+ 'D18', chart2,
1064
+ { :x_offset => 25, :y_offset => 10 }
1065
+ )
1066
+
1067
+
1068
+ #
1069
+ # Create a percent stacked chart sub-type
1070
+ #
1071
+ chart3 = workbook.add_chart(
1072
+ :type => 'line',
1073
+ :embedded => 1,
1074
+ :subtype => 'percent_stacked'
1075
+ )
1076
+
1077
+ # Configure the first series.
1078
+ chart3.add_series(
1079
+ :name => '=Sheet1!$B$1',
1080
+ :categories => '=Sheet1!$A$2:$A$7',
1081
+ :values => '=Sheet1!$B$2:$B$7'
1082
+ )
1083
+
1084
+ # Configure second series.
1085
+ chart3.add_series(
1086
+ :name => '=Sheet1!$C$1',
1087
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
1088
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
1089
+ )
1090
+
1091
+ # Add a chart title and some axis labels.
1092
+ chart3.set_title( :name => 'Percent Stacked Chart' )
1093
+ chart3.set_x_axis( :name => 'Test number' )
1094
+ chart3.set_y_axis( :name => 'Sample length (mm)' )
1095
+
1096
+ # Set an Excel chart style. Blue colors with white outline and shadow.
1097
+ chart3.set_style( 13 )
1098
+
1099
+ # Insert the chart into the worksheet (with an offset).
1100
+ worksheet.insert_chart(
1101
+ 'D34', chart3,
1102
+ { :x_offset => 25, :y_offset => 10 }
1103
+ )
1104
+
655
1105
  workbook.close
656
1106
  store_to_tempfile
657
1107
  compare_xlsx(File.join(@perl_output, @xlsx), @tempfile.path)
@@ -666,9 +1116,9 @@ def test_chart_pie
666
1116
  # Add the worksheet data that the charts will refer to.
667
1117
  headings = [ 'Category', 'Values' ]
668
1118
  data = [
669
- [ 'Apple', 'Cherry', 'Pecan' ],
670
- [ 60, 30, 10 ]
671
- ]
1119
+ [ 'Apple', 'Cherry', 'Pecan' ],
1120
+ [ 60, 30, 10 ]
1121
+ ]
672
1122
 
673
1123
  worksheet.write('A1', headings, bold)
674
1124
  worksheet.write('A2', data)
@@ -680,10 +1130,10 @@ def test_chart_pie
680
1130
  # [ $sheetname, $row_start, $row_end, $col_start, $col_end ].
681
1131
  # See below for an alternative syntax.
682
1132
  chart1.add_series(
683
- :name => 'Pie sales data',
684
- :categories => [ 'Sheet1', 1, 3, 0, 0 ],
685
- :values => [ 'Sheet1', 1, 3, 1, 1 ]
686
- )
1133
+ :name => 'Pie sales data',
1134
+ :categories => [ 'Sheet1', 1, 3, 0, 0 ],
1135
+ :values => [ 'Sheet1', 1, 3, 1, 1 ]
1136
+ )
687
1137
 
688
1138
  # Add a title.
689
1139
  chart1.set_title(:name => 'Popular Pie Types')
@@ -703,15 +1153,15 @@ def test_chart_pie
703
1153
 
704
1154
  # Configure the series and add user defined segment colours.
705
1155
  chart2.add_series(
706
- :name => 'Pie sales data',
707
- :categories => '=Sheet1!$A$2:$A$4',
708
- :values => '=Sheet1!$B$2:$B$4',
709
- :points => [
710
- { :fill => { :color => '#5ABA10' } },
711
- { :fill => { :color => '#FE110E' } },
712
- { :fill => { :color => '#CA5C05' } }
713
- ]
714
- )
1156
+ :name => 'Pie sales data',
1157
+ :categories => '=Sheet1!$A$2:$A$4',
1158
+ :values => '=Sheet1!$B$2:$B$4',
1159
+ :points => [
1160
+ { :fill => { :color => '#5ABA10' } },
1161
+ { :fill => { :color => '#FE110E' } },
1162
+ { :fill => { :color => '#CA5C05' } }
1163
+ ]
1164
+ )
715
1165
 
716
1166
  # Add a title.
717
1167
  chart2.set_title(:name => 'Pie Chart with user defined colors')
@@ -733,10 +1183,10 @@ def test_chart_radar
733
1183
  # Add the worksheet data that the charts will refer to.
734
1184
  headings = [ 'Number', 'Batch 1', 'Batch 2' ]
735
1185
  data = [
736
- [ 2, 3, 4, 5, 6, 7 ],
737
- [ 30, 60, 70, 50, 40, 30 ],
738
- [ 25, 40, 50, 30, 50, 40 ]
739
- ]
1186
+ [ 2, 3, 4, 5, 6, 7 ],
1187
+ [ 30, 60, 70, 50, 40, 30 ],
1188
+ [ 25, 40, 50, 30, 50, 40 ]
1189
+ ]
740
1190
 
741
1191
  worksheet.write('A1', headings, bold)
742
1192
  worksheet.write('A2', data)
@@ -746,18 +1196,18 @@ def test_chart_radar
746
1196
 
747
1197
  # Configure the first series.
748
1198
  chart1.add_series(
749
- :name => '=Sheet1!$B$1',
750
- :categories => '=Sheet1!$A$2:$A$7',
751
- :values => '=Sheet1!$B$2:$B$7'
752
- )
1199
+ :name => '=Sheet1!$B$1',
1200
+ :categories => '=Sheet1!$A$2:$A$7',
1201
+ :values => '=Sheet1!$B$2:$B$7'
1202
+ )
753
1203
 
754
1204
  # Configure second series. Note alternative use of array ref to define
755
1205
  # ranges: [ sheetname, row_start, row_end, col_start, col_end ].
756
1206
  chart1.add_series(
757
- :name => '=Sheet1!$C$1',
758
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
759
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
760
- )
1207
+ :name => '=Sheet1!$C$1',
1208
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
1209
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
1210
+ )
761
1211
 
762
1212
  # Add a chart title and some axis labels.
763
1213
  chart1.set_title(:name => 'Results of sample analysis')
@@ -774,24 +1224,24 @@ def test_chart_radar
774
1224
  # Create a with_markers chart sub-type
775
1225
  #
776
1226
  chart2 = workbook.add_chart(
777
- :type => 'radar',
778
- :embedded => 1,
779
- :subtype => 'with_markers'
780
- )
1227
+ :type => 'radar',
1228
+ :embedded => 1,
1229
+ :subtype => 'with_markers'
1230
+ )
781
1231
 
782
1232
  # Configure the first series.
783
1233
  chart2.add_series(
784
- :name => '=Sheet1!$B$1',
785
- :categories => '=Sheet1!$A$2:$A$7',
786
- :values => '=Sheet1!$B$2:$B$7'
787
- )
1234
+ :name => '=Sheet1!$B$1',
1235
+ :categories => '=Sheet1!$A$2:$A$7',
1236
+ :values => '=Sheet1!$B$2:$B$7'
1237
+ )
788
1238
 
789
1239
  # Configure second series.
790
1240
  chart2.add_series(
791
- :name => '=Sheet1!$C$1',
792
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
793
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
794
- )
1241
+ :name => '=Sheet1!$C$1',
1242
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
1243
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
1244
+ )
795
1245
 
796
1246
  # Add a chart title and some axis labels.
797
1247
  chart2.set_title(:name => 'Stacked Chart')
@@ -808,24 +1258,24 @@ def test_chart_radar
808
1258
  # Create a filled chart sub-type
809
1259
  #
810
1260
  chart3 = workbook.add_chart(
811
- :type => 'radar',
812
- :embedded => 1,
813
- :subtype => 'filled'
814
- )
1261
+ :type => 'radar',
1262
+ :embedded => 1,
1263
+ :subtype => 'filled'
1264
+ )
815
1265
 
816
1266
  # Configure the first series.
817
1267
  chart3.add_series(
818
- :name => '=Sheet1!$B$1',
819
- :categories => '=Sheet1!$A$2:$A$7',
820
- :values => '=Sheet1!$B$2:$B$7'
821
- )
1268
+ :name => '=Sheet1!$B$1',
1269
+ :categories => '=Sheet1!$A$2:$A$7',
1270
+ :values => '=Sheet1!$B$2:$B$7'
1271
+ )
822
1272
 
823
1273
  # Configure second series.
824
1274
  chart3.add_series(
825
- :name => '=Sheet1!$C$1',
826
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
827
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
828
- )
1275
+ :name => '=Sheet1!$C$1',
1276
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
1277
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
1278
+ )
829
1279
 
830
1280
  # Add a chart title and some axis labels.
831
1281
  chart3.set_title(:name => 'Percent Stacked Chart')
@@ -852,9 +1302,9 @@ def test_chart_scatter
852
1302
  # Add the worksheet data that the charts will refer to.
853
1303
  headings = [ 'Number', 'Batch 1', 'Batch 2' ]
854
1304
  data = [
855
- [ 2, 3, 4, 5, 6, 7 ],
856
- [ 10, 40, 50, 20, 10, 50 ],
857
- [ 30, 60, 70, 50, 40, 30 ]
1305
+ [ 2, 3, 4, 5, 6, 7 ],
1306
+ [ 10, 40, 50, 20, 10, 50 ],
1307
+ [ 30, 60, 70, 50, 40, 30 ]
858
1308
  ]
859
1309
 
860
1310
  worksheet.write('A1', headings, bold)
@@ -865,17 +1315,17 @@ def test_chart_scatter
865
1315
 
866
1316
  # Configure the first series.
867
1317
  chart.add_series(
868
- :name => '=Sheet1!$B$1',
869
- :categories => '=Sheet1!$A$2:$A$7',
870
- :values => '=Sheet1!$B$2:$B$7'
1318
+ :name => '=Sheet1!$B$1',
1319
+ :categories => '=Sheet1!$A$2:$A$7',
1320
+ :values => '=Sheet1!$B$2:$B$7'
871
1321
  )
872
1322
 
873
1323
  # Configure second series. Note alternative use of array ref to define
874
1324
  # ranges: [ $sheetname, $row_start, $row_end, $col_start, $col_end ].$chart->add_series(
875
1325
  chart.add_series(
876
- :name => '=Sheet1!$C$1',
877
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
878
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
1326
+ :name => '=Sheet1!$C$1',
1327
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
1328
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
879
1329
  )
880
1330
 
881
1331
  # Add a chart title and some axis labels.
@@ -906,19 +1356,19 @@ def test_chart_stock
906
1356
  # Add the worksheet data that the charts will refer to.
907
1357
  headings = [ 'Date', 'High', 'Low', 'Close' ]
908
1358
  data = [
909
- [ '2007-01-01T', '2007-01-02T', '2007-01-03T', '2007-01-04T', '2007-01-05T' ],
910
- [ 27.2, 25.03, 19.05, 20.34, 18.5 ],
911
- [ 23.49, 19.55, 15.12, 17.84, 16.34 ],
912
- [ 25.45, 23.05, 17.32, 20.45, 17.34 ]
1359
+ [ '2007-01-01T', '2007-01-02T', '2007-01-03T', '2007-01-04T', '2007-01-05T' ],
1360
+ [ 27.2, 25.03, 19.05, 20.34, 18.5 ],
1361
+ [ 23.49, 19.55, 15.12, 17.84, 16.34 ],
1362
+ [ 25.45, 23.05, 17.32, 20.45, 17.34 ]
913
1363
  ]
914
1364
 
915
1365
  worksheet.write('A1', headings, bold)
916
1366
 
917
1367
  (0 .. 4).each do |row|
918
- worksheet.write_date_time(row + 1, 0, data[0][row], date_format)
919
- worksheet.write(row + 1, 1, data[1][row])
920
- worksheet.write(row + 1, 2, data[2][row])
921
- worksheet.write(row + 1, 3, data[3][row])
1368
+ worksheet.write_date_time(row + 1, 0, data[0][row], date_format)
1369
+ worksheet.write(row + 1, 1, data[1][row])
1370
+ worksheet.write(row + 1, 2, data[2][row])
1371
+ worksheet.write(row + 1, 3, data[3][row])
922
1372
  end
923
1373
 
924
1374
  worksheet.set_column('A:D', 11)
@@ -960,9 +1410,9 @@ def test_chart_secondary_axis
960
1410
  # Add the worksheet data that the charts will refer to.
961
1411
  headings = [ 'Aliens', 'Humans']
962
1412
  data = [
963
- [ 2, 3, 4, 5, 6, 7 ],
964
- [ 10, 40, 50, 20, 10, 50 ]
965
- ]
1413
+ [ 2, 3, 4, 5, 6, 7 ],
1414
+ [ 10, 40, 50, 20, 10, 50 ]
1415
+ ]
966
1416
 
967
1417
  worksheet.write('A1', headings, bold)
968
1418
  worksheet.write('A2', data)
@@ -972,15 +1422,15 @@ def test_chart_secondary_axis
972
1422
 
973
1423
  # Configure the first series.
974
1424
  chart.add_series(
975
- :name => '=Sheet1!$A$1',
976
- :values => '=Sheet1!$A$2:$A$7',
977
- :y2_axis => 1
978
- )
1425
+ :name => '=Sheet1!$A$1',
1426
+ :values => '=Sheet1!$A$2:$A$7',
1427
+ :y2_axis => 1
1428
+ )
979
1429
 
980
1430
  chart.add_series(
981
- :name => '=Sheet1!$B$1',
982
- :values => '=Sheet1!$B$2:$B$7'
983
- )
1431
+ :name => '=Sheet1!$B$1',
1432
+ :values => '=Sheet1!$B$2:$B$7'
1433
+ )
984
1434
 
985
1435
  chart.set_legend(:position => 'right')
986
1436
 
@@ -1258,7 +1708,7 @@ def test_comments2
1258
1708
  comment = 'Hello.'
1259
1709
 
1260
1710
  worksheet6.write( 'C9', cell_text, text_wrap )
1261
- worksheet6.write_comment( 'C9', comment, :color => 0x35 )
1711
+ worksheet6.write_comment( 'C9', comment, :color => '#FF6600' )
1262
1712
 
1263
1713
 
1264
1714
  ###############################################################################
@@ -1275,7 +1725,7 @@ def test_comments2
1275
1725
  cell = 'C3'
1276
1726
 
1277
1727
  cell_text = "Move the mouse over this cell and you will see 'Cell commented " +
1278
- "by #{author}' (blank) in the status bar at the bottom"
1728
+ "by #{author}' (blank) in the status bar at the bottom"
1279
1729
 
1280
1730
  comment = 'Hello.'
1281
1731
 
@@ -1286,7 +1736,7 @@ def test_comments2
1286
1736
  author = 'Ruby'
1287
1737
  cell = 'C6'
1288
1738
  cell_text = "Move the mouse over this cell and you will see 'Cell commented " +
1289
- "by #{author}' in the status bar at the bottom"
1739
+ "by #{author}' in the status bar at the bottom"
1290
1740
 
1291
1741
  comment = 'Hello.'
1292
1742
 
@@ -1297,7 +1747,7 @@ def test_comments2
1297
1747
  author = '€'
1298
1748
  cell = 'C9'
1299
1749
  cell_text = "Move the mouse over this cell and you will see 'Cell commented " +
1300
- "by #{author}' in the status bar at the bottom"
1750
+ "by #{author}' in the status bar at the bottom"
1301
1751
  comment = 'Hello.'
1302
1752
 
1303
1753
  worksheet7.write( cell, cell_text, text_wrap )
@@ -1361,36 +1811,36 @@ def test_conditional_format
1361
1811
 
1362
1812
  # Light red fill with dark red text.
1363
1813
  format1 = workbook.add_format(
1364
- :bg_color => '#FFC7CE',
1365
- :color => '#9C0006'
1366
- )
1814
+ :bg_color => '#FFC7CE',
1815
+ :color => '#9C0006'
1816
+ )
1367
1817
 
1368
1818
  # Green fill with dark green text.
1369
1819
  format2 = workbook.add_format(
1370
- :bg_color => '#C6EFCE',
1371
- :color => '#006100'
1372
- )
1820
+ :bg_color => '#C6EFCE',
1821
+ :color => '#006100'
1822
+ )
1373
1823
 
1374
1824
  # Some sample data to run the conditional formatting against.
1375
1825
  data = [
1376
- [ 34, 72, 38, 30, 75, 48, 75, 66, 84, 86 ],
1377
- [ 6, 24, 1, 84, 54, 62, 60, 3, 26, 59 ],
1378
- [ 28, 79, 97, 13, 85, 93, 93, 22, 5, 14 ],
1379
- [ 27, 71, 40, 17, 18, 79, 90, 93, 29, 47 ],
1380
- [ 88, 25, 33, 23, 67, 1, 59, 79, 47, 36 ],
1381
- [ 24, 100, 20, 88, 29, 33, 38, 54, 54, 88 ],
1382
- [ 6, 57, 88, 28, 10, 26, 37, 7, 41, 48 ],
1383
- [ 52, 78, 1, 96, 26, 45, 47, 33, 96, 36 ],
1384
- [ 60, 54, 81, 66, 81, 90, 80, 93, 12, 55 ],
1385
- [ 70, 5, 46, 14, 71, 19, 66, 36, 41, 21 ]
1386
- ]
1826
+ [ 34, 72, 38, 30, 75, 48, 75, 66, 84, 86 ],
1827
+ [ 6, 24, 1, 84, 54, 62, 60, 3, 26, 59 ],
1828
+ [ 28, 79, 97, 13, 85, 93, 93, 22, 5, 14 ],
1829
+ [ 27, 71, 40, 17, 18, 79, 90, 93, 29, 47 ],
1830
+ [ 88, 25, 33, 23, 67, 1, 59, 79, 47, 36 ],
1831
+ [ 24, 100, 20, 88, 29, 33, 38, 54, 54, 88 ],
1832
+ [ 6, 57, 88, 28, 10, 26, 37, 7, 41, 48 ],
1833
+ [ 52, 78, 1, 96, 26, 45, 47, 33, 96, 36 ],
1834
+ [ 60, 54, 81, 66, 81, 90, 80, 93, 12, 55 ],
1835
+ [ 70, 5, 46, 14, 71, 19, 66, 36, 41, 21 ]
1836
+ ]
1387
1837
 
1388
1838
  ###############################################################################
1389
1839
  #
1390
1840
  # Example 1.
1391
1841
  #
1392
1842
  caption = 'Cells with values >= 50 are in light red. ' +
1393
- 'Values < 50 are in light green.'
1843
+ 'Values < 50 are in light green.'
1394
1844
 
1395
1845
  # Write the data.
1396
1846
  worksheet1.write('A1', caption)
@@ -1404,7 +1854,7 @@ def test_conditional_format
1404
1854
  :value => 50,
1405
1855
  :format => format1
1406
1856
  }
1407
- )
1857
+ )
1408
1858
 
1409
1859
  # Write another conditional format over the same range.
1410
1860
  worksheet1.conditional_formatting('B3:K12',
@@ -1414,7 +1864,7 @@ def test_conditional_format
1414
1864
  :value => 50,
1415
1865
  :format => format2
1416
1866
  }
1417
- )
1867
+ )
1418
1868
 
1419
1869
 
1420
1870
  ###############################################################################
@@ -1422,7 +1872,7 @@ def test_conditional_format
1422
1872
  # Example 2.
1423
1873
  #
1424
1874
  caption = 'Values between 30 and 70 are in light red. ' +
1425
- 'Values outside that range are in light green.'
1875
+ 'Values outside that range are in light green.'
1426
1876
 
1427
1877
  worksheet2.write('A1', caption)
1428
1878
  worksheet2.write_col('B3', data)
@@ -1435,7 +1885,7 @@ def test_conditional_format
1435
1885
  :maximum => 70,
1436
1886
  :format => format1
1437
1887
  }
1438
- )
1888
+ )
1439
1889
 
1440
1890
  worksheet2.conditional_formatting('B3:K12',
1441
1891
  {
@@ -1445,7 +1895,7 @@ def test_conditional_format
1445
1895
  :maximum => 70,
1446
1896
  :format => format2
1447
1897
  }
1448
- )
1898
+ )
1449
1899
 
1450
1900
 
1451
1901
  ###############################################################################
@@ -1453,7 +1903,7 @@ def test_conditional_format
1453
1903
  # Example 3.
1454
1904
  #
1455
1905
  caption = 'Duplicate values are in light red. ' +
1456
- 'Unique values are in light green.'
1906
+ 'Unique values are in light green.'
1457
1907
 
1458
1908
  worksheet3.write('A1', caption)
1459
1909
  worksheet3.write_col('B3', data)
@@ -1463,14 +1913,14 @@ def test_conditional_format
1463
1913
  :type => 'duplicate',
1464
1914
  :format => format1,
1465
1915
  }
1466
- )
1916
+ )
1467
1917
 
1468
1918
  worksheet3.conditional_formatting('B3:K12',
1469
1919
  {
1470
1920
  :type => 'unique',
1471
1921
  :format => format2,
1472
1922
  }
1473
- )
1923
+ )
1474
1924
 
1475
1925
 
1476
1926
  ###############################################################################
@@ -1478,7 +1928,7 @@ def test_conditional_format
1478
1928
  # Example 4.
1479
1929
  #
1480
1930
  caption = 'Above average values are in light red. ' +
1481
- 'Below average values are in light green.'
1931
+ 'Below average values are in light green.'
1482
1932
 
1483
1933
  worksheet4.write('A1', caption)
1484
1934
  worksheet4.write_col('B3', data)
@@ -1489,7 +1939,7 @@ def test_conditional_format
1489
1939
  :criteria => 'above',
1490
1940
  :format => format1
1491
1941
  }
1492
- )
1942
+ )
1493
1943
 
1494
1944
  worksheet4.conditional_formatting('B3:K12',
1495
1945
  {
@@ -1497,7 +1947,7 @@ def test_conditional_format
1497
1947
  :criteria => 'below',
1498
1948
  :format => format2
1499
1949
  }
1500
- )
1950
+ )
1501
1951
 
1502
1952
 
1503
1953
  ###############################################################################
@@ -1505,7 +1955,7 @@ def test_conditional_format
1505
1955
  # Example 5.
1506
1956
  #
1507
1957
  caption = 'Top 10 values are in light red. ' +
1508
- 'Bottom 10 values are in light green.'
1958
+ 'Bottom 10 values are in light green.'
1509
1959
 
1510
1960
  worksheet5.write('A1', caption)
1511
1961
  worksheet5.write_col('B3', data)
@@ -1516,7 +1966,7 @@ def test_conditional_format
1516
1966
  :value => '10',
1517
1967
  :format => format1
1518
1968
  }
1519
- )
1969
+ )
1520
1970
 
1521
1971
  worksheet5.conditional_formatting('B3:K12',
1522
1972
  {
@@ -1524,7 +1974,7 @@ def test_conditional_format
1524
1974
  :value => '10',
1525
1975
  :format => format2
1526
1976
  }
1527
- )
1977
+ )
1528
1978
 
1529
1979
 
1530
1980
  ###############################################################################
@@ -1532,7 +1982,7 @@ def test_conditional_format
1532
1982
  # Example 6.
1533
1983
  #
1534
1984
  caption = 'Cells with values >= 50 are in light red. ' +
1535
- 'Values < 50 are in light green. Non-contiguous ranges.'
1985
+ 'Values < 50 are in light green. Non-contiguous ranges.'
1536
1986
 
1537
1987
  # Write the data.
1538
1988
  worksheet6.write('A1', caption)
@@ -1546,7 +1996,7 @@ def test_conditional_format
1546
1996
  :value => 50,
1547
1997
  :format => format1
1548
1998
  }
1549
- )
1999
+ )
1550
2000
 
1551
2001
  # Write another conditional format over the same range.
1552
2002
  worksheet6.conditional_formatting('B3:K6,B9:K12',
@@ -1556,7 +2006,7 @@ def test_conditional_format
1556
2006
  :value => 50,
1557
2007
  :format => format2
1558
2008
  }
1559
- )
2009
+ )
1560
2010
 
1561
2011
 
1562
2012
  ###############################################################################
@@ -1583,19 +2033,19 @@ def test_conditional_format
1583
2033
  {
1584
2034
  :type => '2_color_scale'
1585
2035
  }
1586
- )
2036
+ )
1587
2037
 
1588
2038
  worksheet7.conditional_formatting('D3:D14',
1589
2039
  {
1590
2040
  :type => '3_color_scale'
1591
2041
  }
1592
- )
2042
+ )
1593
2043
 
1594
2044
  worksheet7.conditional_formatting('F3:F14',
1595
2045
  {
1596
2046
  :type => 'data_bar'
1597
2047
  }
1598
- )
2048
+ )
1599
2049
 
1600
2050
 
1601
2051
  ###############################################################################
@@ -1624,7 +2074,7 @@ def test_conditional_format
1624
2074
  :min_color => "#FF0000",
1625
2075
  :max_color => "#00FF00"
1626
2076
  }
1627
- )
2077
+ )
1628
2078
 
1629
2079
  worksheet8.conditional_formatting('D3:D14',
1630
2080
  {
@@ -1633,14 +2083,14 @@ def test_conditional_format
1633
2083
  :mid_color => "#8DB4E3",
1634
2084
  :max_color => "#538ED5"
1635
2085
  }
1636
- )
2086
+ )
1637
2087
 
1638
2088
  worksheet8.conditional_formatting('F3:F14',
1639
2089
  {
1640
2090
  :type => 'data_bar',
1641
2091
  :bar_color => '#63C384'
1642
2092
  }
1643
- )
2093
+ )
1644
2094
 
1645
2095
  workbook.close
1646
2096
  store_to_tempfile
@@ -1654,13 +2104,13 @@ def test_data_validate
1654
2104
 
1655
2105
  # Add a format for the header cells.
1656
2106
  header_format = workbook.add_format(
1657
- :border => 1,
1658
- :bg_color => 43,
1659
- :bold => 1,
1660
- :text_wrap => 1,
1661
- :valign => 'vcenter',
1662
- :indent => 1
1663
- )
2107
+ :border => 1,
2108
+ :bg_color => 43,
2109
+ :bold => 1,
2110
+ :text_wrap => 1,
2111
+ :valign => 'vcenter',
2112
+ :indent => 1
2113
+ )
1664
2114
 
1665
2115
  # Set up layout of the worksheet.
1666
2116
  worksheet.set_column('A:A', 68)
@@ -1932,32 +2382,32 @@ def test_date_time
1932
2382
  # the format codes change the appearance of the date.
1933
2383
  #
1934
2384
  date_formats = [
1935
- 'dd/mm/yy',
1936
- 'mm/dd/yy',
1937
- '',
1938
- 'd mm yy',
1939
- 'dd mm yy',
1940
- '',
1941
- 'dd m yy',
1942
- 'dd mm yy',
1943
- 'dd mmm yy',
1944
- 'dd mmmm yy',
1945
- '',
1946
- 'dd mm y',
1947
- 'dd mm yyy',
1948
- 'dd mm yyyy',
1949
- '',
1950
- 'd mmmm yyyy',
1951
- '',
1952
- 'dd/mm/yy',
1953
- 'dd/mm/yy hh:mm',
1954
- 'dd/mm/yy hh:mm:ss',
1955
- 'dd/mm/yy hh:mm:ss.000',
1956
- '',
1957
- 'hh:mm',
1958
- 'hh:mm:ss',
1959
- 'hh:mm:ss.000'
1960
- ]
2385
+ 'dd/mm/yy',
2386
+ 'mm/dd/yy',
2387
+ '',
2388
+ 'd mm yy',
2389
+ 'dd mm yy',
2390
+ '',
2391
+ 'dd m yy',
2392
+ 'dd mm yy',
2393
+ 'dd mmm yy',
2394
+ 'dd mmmm yy',
2395
+ '',
2396
+ 'dd mm y',
2397
+ 'dd mm yyy',
2398
+ 'dd mm yyyy',
2399
+ '',
2400
+ 'd mmmm yyyy',
2401
+ '',
2402
+ 'dd/mm/yy',
2403
+ 'dd/mm/yy hh:mm',
2404
+ 'dd/mm/yy hh:mm:ss',
2405
+ 'dd/mm/yy hh:mm:ss.000',
2406
+ '',
2407
+ 'hh:mm',
2408
+ 'hh:mm:ss',
2409
+ 'hh:mm:ss.000'
2410
+ ]
1961
2411
 
1962
2412
  # Write the same date and time using each of the above formats. The empty
1963
2413
  # string formats create a blank line to make the example clearer.
@@ -1969,9 +2419,9 @@ def test_date_time
1969
2419
 
1970
2420
  # Create a format for the date or time.
1971
2421
  format = workbook.add_format(
1972
- :num_format => date_format,
1973
- :align => 'left'
1974
- )
2422
+ :num_format => date_format,
2423
+ :align => 'left'
2424
+ )
1975
2425
 
1976
2426
  # Write the same date using different formats.
1977
2427
  worksheet.write_date_time(row, 0, '2004-08-01T12:30:45.123', format)
@@ -2036,17 +2486,17 @@ def test_demo
2036
2486
  worksheet.set_row(0, 40)
2037
2487
 
2038
2488
  heading = workbook.add_format(
2039
- :bold => 1,
2040
- :color => 'blue',
2041
- :size => 16,
2042
- :merge => 1,
2043
- :align => 'vcenter'
2044
- )
2489
+ :bold => 1,
2490
+ :color => 'blue',
2491
+ :size => 16,
2492
+ :merge => 1,
2493
+ :align => 'vcenter'
2494
+ )
2045
2495
 
2046
2496
  hyperlink_format = workbook.add_format(
2047
- :color => 'blue',
2048
- :underline => 1
2049
- )
2497
+ :color => 'blue',
2498
+ :underline => 1
2499
+ )
2050
2500
 
2051
2501
  headings = ['Features of WriteXLSX', '']
2052
2502
  worksheet.write_row('A1', headings, heading)
@@ -2056,12 +2506,12 @@ def test_demo
2056
2506
  # Some text examples
2057
2507
  #
2058
2508
  text_format = workbook.add_format(
2059
- :bold => 1,
2060
- :italic => 1,
2061
- :color => 'red',
2062
- :size => 18,
2063
- :font => 'Lucida Calligraphy'
2064
- )
2509
+ :bold => 1,
2510
+ :italic => 1,
2511
+ :color => 'red',
2512
+ :size => 18,
2513
+ :font => 'Lucida Calligraphy'
2514
+ )
2065
2515
 
2066
2516
  worksheet.write('A2', "Text")
2067
2517
  worksheet.write('B2', "Hello Excel")
@@ -2104,7 +2554,10 @@ def test_demo
2104
2554
  # Images
2105
2555
  #
2106
2556
  worksheet.write('A10', "Images")
2107
- worksheet.insert_image('B10', File.join(@test_dir, 'republic.png'), 16, 8)
2557
+ worksheet.insert_image(
2558
+ 'B10', File.join(@test_dir, 'republic.png'),
2559
+ :x_offset => 16, :y_offset => 8
2560
+ )
2108
2561
 
2109
2562
  #######################################################################
2110
2563
  #
@@ -2129,10 +2582,10 @@ def test_diag_border
2129
2582
  format3 = workbook.add_format(:diag_type => 3)
2130
2583
 
2131
2584
  format4 = workbook.add_format(
2132
- :diag_type => 3,
2133
- :diag_border => 7,
2134
- :diag_color => 'red'
2135
- )
2585
+ :diag_type => 3,
2586
+ :diag_border => 7,
2587
+ :diag_color => 'red'
2588
+ )
2136
2589
 
2137
2590
  worksheet.write('B3', 'Text', format1)
2138
2591
  worksheet.write('B6', 'Text', format2)
@@ -2218,9 +2671,9 @@ def intro(workbook, center, heading, colors)
2218
2671
  format2.set_color('blue')
2219
2672
 
2220
2673
  format3 = workbook.add_format(
2221
- :color => 'blue',
2222
- :underline => 1
2223
- )
2674
+ :color => 'blue',
2675
+ :underline => 1
2676
+ )
2224
2677
 
2225
2678
  worksheet.write(2, 0, 'This workbook demonstrates some of', format)
2226
2679
  worksheet.write(3, 0, 'the formatting options provided by', format)
@@ -2233,16 +2686,16 @@ def intro(workbook, center, heading, colors)
2233
2686
  'Named colors', format3)
2234
2687
 
2235
2688
  worksheet.write(
2236
- 'A10',
2237
- "internal:'Standard colors'!A1",
2238
- 'Standard colors', format3
2239
- )
2689
+ 'A10',
2690
+ "internal:'Standard colors'!A1",
2691
+ 'Standard colors', format3
2692
+ )
2240
2693
 
2241
2694
  worksheet.write(
2242
- 'A11',
2243
- "internal:'Numeric formats'!A1",
2244
- 'Numeric formats', format3
2245
- )
2695
+ 'A11',
2696
+ "internal:'Numeric formats'!A1",
2697
+ 'Numeric formats', format3
2698
+ )
2246
2699
 
2247
2700
  worksheet.write('A12', "internal:Borders!A1", 'Borders', format3)
2248
2701
  worksheet.write('A13', "internal:Patterns!A1", 'Patterns', format3)
@@ -2272,10 +2725,10 @@ def named_colors(workbook, center, heading, colors)
2272
2725
  [33, 11, 53, 17, 22, 18, 13, 16, 23, 9, 12, 15, 14, 20, 8, 10].each do |index|
2273
2726
  color = colors[index]
2274
2727
  format = workbook.add_format(
2275
- :bg_color => color,
2276
- :pattern => 1,
2277
- :border => 1
2278
- )
2728
+ :bg_color => color,
2729
+ :pattern => 1,
2730
+ :border => 1
2731
+ )
2279
2732
 
2280
2733
  worksheet.write(i + 1, 0, index, center)
2281
2734
  worksheet.write(i + 1, 1, sprintf("0x%02X", index), center)
@@ -2302,10 +2755,10 @@ def standard_colors(workbook, center, heading, colors)
2302
2755
 
2303
2756
  (8 .. 63).each do |i|
2304
2757
  format = workbook.add_format(
2305
- :bg_color => i,
2306
- :pattern => 1,
2307
- :border => 1
2308
- )
2758
+ :bg_color => i,
2759
+ :pattern => 1,
2760
+ :border => 1
2761
+ )
2309
2762
 
2310
2763
  worksheet.write((i - 7), 0, i, center)
2311
2764
  worksheet.write((i - 7), 1, sprintf("0x%02X", i), center)
@@ -2787,17 +3240,17 @@ def test_hyperlink
2787
3240
 
2788
3241
  # Add the standard url link format.
2789
3242
  url_format = workbook.add_format(
2790
- :color => 'blue',
2791
- :underline => 1
2792
- )
3243
+ :color => 'blue',
3244
+ :underline => 1
3245
+ )
2793
3246
 
2794
3247
  # Add a sample format.
2795
3248
  red_format = workbook.add_format(
2796
- :color => 'red',
2797
- :bold => 1,
2798
- :underline => 1,
2799
- :size => 12
2800
- )
3249
+ :color => 'red',
3250
+ :bold => 1,
3251
+ :underline => 1,
3252
+ :size => 12
3253
+ )
2801
3254
 
2802
3255
  # Add an alternate description string to the URL.
2803
3256
  str = 'Perl home.'
@@ -2873,16 +3326,16 @@ def test_merge2
2873
3326
 
2874
3327
  # Create a merged format
2875
3328
  format = workbook.add_format(
2876
- :center_across => 1,
2877
- :bold => 1,
2878
- :size => 15,
2879
- :pattern => 1,
2880
- :border => 6,
2881
- :color => 'white',
2882
- :fg_color => 'green',
2883
- :border_color => 'yellow',
2884
- :align => 'vcenter'
2885
- )
3329
+ :center_across => 1,
3330
+ :bold => 1,
3331
+ :size => 15,
3332
+ :pattern => 1,
3333
+ :border => 6,
3334
+ :color => 'white',
3335
+ :fg_color => 'green',
3336
+ :border_color => 'yellow',
3337
+ :align => 'vcenter'
3338
+ )
2886
3339
 
2887
3340
  # Only one cell should contain text, the others should be blank.
2888
3341
  worksheet.write(2, 1, "Center across selection", format)
@@ -2909,12 +3362,12 @@ def test_merge3
2909
3362
  # Example: Merge cells containing a hyperlink using merge_range().
2910
3363
  #
2911
3364
  format = workbook.add_format(
2912
- :border => 1,
2913
- :underline => 1,
2914
- :color => 'blue',
2915
- :align => 'center',
2916
- :valign => 'vcenter'
2917
- )
3365
+ :border => 1,
3366
+ :underline => 1,
3367
+ :color => 'blue',
3368
+ :align => 'center',
3369
+ :valign => 'vcenter'
3370
+ )
2918
3371
 
2919
3372
  # Merge 3 cells
2920
3373
  worksheet.merge_range('B4:D4', 'http://www.perl.com', format)
@@ -2942,12 +3395,12 @@ def test_merge4
2942
3395
  # Example 1: Text centered vertically and horizontally
2943
3396
  #
2944
3397
  format1 = workbook.add_format(
2945
- :border => 6,
2946
- :bold => 1,
2947
- :color => 'red',
2948
- :valign => 'vcenter',
2949
- :align => 'center'
2950
- )
3398
+ :border => 6,
3399
+ :bold => 1,
3400
+ :color => 'red',
3401
+ :valign => 'vcenter',
3402
+ :align => 'center'
3403
+ )
2951
3404
 
2952
3405
  worksheet.merge_range('B2:D3', 'Vertical and horizontal', format1)
2953
3406
 
@@ -2956,12 +3409,12 @@ def test_merge4
2956
3409
  # Example 2: Text aligned to the top and left
2957
3410
  #
2958
3411
  format2 = workbook.add_format(
2959
- :border => 6,
2960
- :bold => 1,
2961
- :color => 'red',
2962
- :valign => 'top',
2963
- :align => 'left'
2964
- )
3412
+ :border => 6,
3413
+ :bold => 1,
3414
+ :color => 'red',
3415
+ :valign => 'top',
3416
+ :align => 'left'
3417
+ )
2965
3418
 
2966
3419
  worksheet.merge_range('B5:D6', 'Aligned to the top and left', format2)
2967
3420
 
@@ -2970,12 +3423,12 @@ def test_merge4
2970
3423
  # Example 3: Text aligned to the bottom and right
2971
3424
  #
2972
3425
  format3 = workbook.add_format(
2973
- :border => 6,
2974
- :bold => 1,
2975
- :color => 'red',
2976
- :valign => 'bottom',
2977
- :align => 'right'
2978
- )
3426
+ :border => 6,
3427
+ :bold => 1,
3428
+ :color => 'red',
3429
+ :valign => 'bottom',
3430
+ :align => 'right'
3431
+ )
2979
3432
 
2980
3433
  worksheet.merge_range('B8:D9', 'Aligned to the bottom and right', format3)
2981
3434
 
@@ -2984,12 +3437,12 @@ def test_merge4
2984
3437
  # Example 4: Text justified (i.e. wrapped) in the cell
2985
3438
  #
2986
3439
  format4 = workbook.add_format(
2987
- :border => 6,
2988
- :bold => 1,
2989
- :color => 'red',
2990
- :valign => 'top',
2991
- :align => 'justify'
2992
- )
3440
+ :border => 6,
3441
+ :bold => 1,
3442
+ :color => 'red',
3443
+ :valign => 'top',
3444
+ :align => 'justify'
3445
+ )
2993
3446
 
2994
3447
  worksheet.merge_range('B11:D12', 'Justified: ' << 'so on and ' * 18, format4)
2995
3448
 
@@ -3013,13 +3466,13 @@ def test_merge5
3013
3466
  # Rotation 1, letters run from top to bottom
3014
3467
  #
3015
3468
  format1 = workbook.add_format(
3016
- :border => 6,
3017
- :bold => 1,
3018
- :color => 'red',
3019
- :valign => 'vcentre',
3020
- :align => 'centre',
3021
- :rotation => 270
3022
- )
3469
+ :border => 6,
3470
+ :bold => 1,
3471
+ :color => 'red',
3472
+ :valign => 'vcentre',
3473
+ :align => 'centre',
3474
+ :rotation => 270
3475
+ )
3023
3476
 
3024
3477
  worksheet.merge_range( 'B4:B9', 'Rotation 270', format1 )
3025
3478
 
@@ -3028,13 +3481,13 @@ def test_merge5
3028
3481
  # Rotation 2, 90ー anticlockwise
3029
3482
  #
3030
3483
  format2 = workbook.add_format(
3031
- :border => 6,
3032
- :bold => 1,
3033
- :color => 'red',
3034
- :valign => 'vcentre',
3035
- :align => 'centre',
3036
- :rotation => 90
3037
- )
3484
+ :border => 6,
3485
+ :bold => 1,
3486
+ :color => 'red',
3487
+ :valign => 'vcentre',
3488
+ :align => 'centre',
3489
+ :rotation => 90
3490
+ )
3038
3491
 
3039
3492
  worksheet.merge_range( 'D4:D9', 'Rotation 90°', format2 )
3040
3493
 
@@ -3043,13 +3496,13 @@ def test_merge5
3043
3496
  # Rotation 3, 90ー clockwise
3044
3497
  #
3045
3498
  format3 = workbook.add_format(
3046
- :border => 6,
3047
- :bold => 1,
3048
- :color => 'red',
3049
- :valign => 'vcentre',
3050
- :align => 'centre',
3051
- :rotation => -90
3052
- )
3499
+ :border => 6,
3500
+ :bold => 1,
3501
+ :color => 'red',
3502
+ :valign => 'vcentre',
3503
+ :align => 'centre',
3504
+ :rotation => -90
3505
+ )
3053
3506
 
3054
3507
  worksheet.merge_range( 'F4:F9', 'Rotation -90°', format3 )
3055
3508
 
@@ -3070,14 +3523,14 @@ def test_merge6
3070
3523
 
3071
3524
  # Format for the merged cells.
3072
3525
  format = workbook.add_format(
3073
- :border => 6,
3074
- :bold => 1,
3075
- :color => 'red',
3076
- :size => 20,
3077
- :valign => 'vcentre',
3078
- :align => 'left',
3079
- :indent => 1
3080
- )
3526
+ :border => 6,
3527
+ :bold => 1,
3528
+ :color => 'red',
3529
+ :size => 20,
3530
+ :valign => 'vcentre',
3531
+ :align => 'left',
3532
+ :indent => 1
3533
+ )
3081
3534
 
3082
3535
  ###############################################################################
3083
3536
  #
@@ -3234,12 +3687,12 @@ def test_outline
3234
3687
  # Example 3: Create a worksheet with outlined columns.
3235
3688
  #
3236
3689
  data = [
3237
- [ 'Month', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', ' Total' ],
3238
- [ 'North', 50, 20, 15, 25, 65, 80, '=SUM(B2:G2)' ],
3239
- [ 'South', 10, 20, 30, 50, 50, 50, '=SUM(B3:G3)' ],
3240
- [ 'East', 45, 75, 50, 15, 75, 100, '=SUM(B4:G4)' ],
3241
- [ 'West', 15, 15, 55, 35, 20, 50, '=SUM(B5:G5)' ],
3242
- ]
3690
+ [ 'Month', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', ' Total' ],
3691
+ [ 'North', 50, 20, 15, 25, 65, 80, '=SUM(B2:G2)' ],
3692
+ [ 'South', 10, 20, 30, 50, 50, 50, '=SUM(B3:G3)' ],
3693
+ [ 'East', 45, 75, 50, 15, 75, 100, '=SUM(B4:G4)' ],
3694
+ [ 'West', 15, 15, 55, 35, 20, 50, '=SUM(B5:G5)' ],
3695
+ ]
3243
3696
 
3244
3697
  # Add bold format to the first row
3245
3698
  worksheet3.set_row(0, nil, bold)
@@ -3259,10 +3712,10 @@ def test_outline
3259
3712
  # Example 4: Show all possible outline levels.
3260
3713
  #
3261
3714
  levels = [
3262
- "Level 1", "Level 2", "Level 3", "Level 4", "Level 5", "Level 6",
3263
- "Level 7", "Level 6", "Level 5", "Level 4", "Level 3", "Level 2",
3264
- "Level 1"
3265
- ]
3715
+ "Level 1", "Level 2", "Level 3", "Level 4", "Level 5", "Level 6",
3716
+ "Level 7", "Level 6", "Level 5", "Level 4", "Level 3", "Level 2",
3717
+ "Level 1"
3718
+ ]
3266
3719
 
3267
3720
 
3268
3721
  worksheet4.write_col('A1', levels)
@@ -3393,12 +3846,12 @@ def test_outline_collapsed
3393
3846
  # Example 5: Create a worksheet with outlined columns.
3394
3847
  #
3395
3848
  data = [
3396
- [ 'Month', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Total' ],
3397
- [ 'North', 50, 20, 15, 25, 65, 80, '=SUM(B2:G2)' ],
3398
- [ 'South', 10, 20, 30, 50, 50, 50, '=SUM(B3:G3)' ],
3399
- [ 'East', 45, 75, 50, 15, 75, 100, '=SUM(B4:G4)' ],
3400
- [ 'West', 15, 15, 55, 35, 20, 50, '=SUM(B5:G6)' ]
3401
- ]
3849
+ [ 'Month', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Total' ],
3850
+ [ 'North', 50, 20, 15, 25, 65, 80, '=SUM(B2:G2)' ],
3851
+ [ 'South', 10, 20, 30, 50, 50, 50, '=SUM(B3:G3)' ],
3852
+ [ 'East', 45, 75, 50, 15, 75, 100, '=SUM(B4:G4)' ],
3853
+ [ 'West', 15, 15, 55, 35, 20, 50, '=SUM(B5:G6)' ]
3854
+ ]
3402
3855
 
3403
3856
  # Add bold format to the first row
3404
3857
  worksheet5.set_row(0, nil, bold)
@@ -3499,10 +3952,10 @@ def test_panes
3499
3952
  #
3500
3953
 
3501
3954
  header = workbook.add_format(
3502
- :align => 'center',
3503
- :valign => 'vcenter',
3504
- :fg_color => 0x2A
3505
- )
3955
+ :align => 'center',
3956
+ :valign => 'vcenter',
3957
+ :fg_color => 0x2A
3958
+ )
3506
3959
 
3507
3960
  center = workbook.add_format(:align => 'center')
3508
3961
 
@@ -3598,16 +4051,16 @@ def test_properties
3598
4051
  worksheet = workbook.add_worksheet
3599
4052
 
3600
4053
  workbook.set_properties(
3601
- :title => 'This is an example spreadsheet',
3602
- :subject => 'With document properties',
3603
- :author => 'John McNamara',
3604
- :manager => 'Dr. Heinz Doofenshmirtz',
3605
- :company => 'of Wolves',
3606
- :category => 'Example spreadsheets',
3607
- :keywords => 'Sample, Example, Properties',
3608
- :comments => 'Created with Perl and Excel::Writer::XLSX',
3609
- :status => 'Quo'
3610
- )
4054
+ :title => 'This is an example spreadsheet',
4055
+ :subject => 'With document properties',
4056
+ :author => 'John McNamara',
4057
+ :manager => 'Dr. Heinz Doofenshmirtz',
4058
+ :company => 'of Wolves',
4059
+ :category => 'Example spreadsheets',
4060
+ :keywords => 'Sample, Example, Properties',
4061
+ :comments => 'Created with Perl and Excel::Writer::XLSX',
4062
+ :status => 'Quo'
4063
+ )
3611
4064
 
3612
4065
  worksheet.set_column('A:A', 70)
3613
4066
  worksheet.write('A1', "Select 'Office Button -> Prepare -> Properties' to see the file properties.")
@@ -3708,16 +4161,16 @@ def test_rich_strings
3708
4161
 
3709
4162
  # Write some strings with multiple formats.
3710
4163
  worksheet.write_rich_string('A1',
3711
- 'This is ', bold, 'bold', ' and this is ', italic, 'italic')
4164
+ 'This is ', bold, 'bold', ' and this is ', italic, 'italic')
3712
4165
 
3713
4166
  worksheet.write_rich_string('A3',
3714
- 'This is ', red, 'red', ' and this is ', blue, 'blue')
4167
+ 'This is ', red, 'red', ' and this is ', blue, 'blue')
3715
4168
 
3716
4169
  worksheet.write_rich_string('A5',
3717
- 'Some ', bold, 'bold text', ' centered', center)
4170
+ 'Some ', bold, 'bold text', ' centered', center)
3718
4171
 
3719
4172
  worksheet.write_rich_string('A7',
3720
- italic, 'j = k', superc, '(n-1)', center)
4173
+ italic, 'j = k', superc, '(n-1)', center)
3721
4174
 
3722
4175
  workbook.close
3723
4176
  store_to_tempfile
@@ -3750,7 +4203,7 @@ def test_shape1
3750
4203
  :text => "Hello\nWorld",
3751
4204
  :width => 60,
3752
4205
  :height => 60
3753
- )
4206
+ )
3754
4207
 
3755
4208
  worksheet.insert_shape('A1', ellipse, 50, 50)
3756
4209
 
@@ -3775,12 +4228,12 @@ def test_shape2
3775
4228
  :text => "Plain",
3776
4229
  :width => 100,
3777
4230
  :height => 100
3778
- )
4231
+ )
3779
4232
 
3780
4233
  bbformat = workbook.add_format(
3781
4234
  :color => 'red',
3782
4235
  :font => 'Lucida Calligraphy'
3783
- )
4236
+ )
3784
4237
 
3785
4238
  bbformat.set_bold
3786
4239
  bbformat.set_underline
@@ -3797,7 +4250,7 @@ def test_shape2
3797
4250
  :line_weight => 3,
3798
4251
  :fill => 'FFFF00',
3799
4252
  :line => '3366FF'
3800
- )
4253
+ )
3801
4254
 
3802
4255
  worksheet.insert_shape('A1', plain, 50, 50)
3803
4256
  worksheet.insert_shape('A1', decor, 250, 50)
@@ -3818,7 +4271,7 @@ def test_shape3
3818
4271
  :text => 'Normal',
3819
4272
  :width => 100,
3820
4273
  :height => 100
3821
- )
4274
+ )
3822
4275
 
3823
4276
  worksheet.insert_shape('A1', normal, 50, 50)
3824
4277
  normal.text = 'Scaled 3w x 2h'
@@ -3841,7 +4294,7 @@ def test_shape4
3841
4294
  :type => type,
3842
4295
  :width => 90,
3843
4296
  :height => 90
3844
- )
4297
+ )
3845
4298
 
3846
4299
  (1..10).each do |n|
3847
4300
  # Change the last 5 rectangles to stars. Previously
@@ -3857,7 +4310,7 @@ def test_shape4
3857
4310
  :width => 90,
3858
4311
  :height => 90,
3859
4312
  :text => 'started as a box'
3860
- )
4313
+ )
3861
4314
  worksheet.insert_shape('A1', stencil, 100, 150)
3862
4315
 
3863
4316
  stencil.stencil = 0
@@ -3884,14 +4337,14 @@ def test_shape5
3884
4337
  :type => 'ellipse',
3885
4338
  :width => 60,
3886
4339
  :height => 60
3887
- )
4340
+ )
3888
4341
  worksheet.insert_shape('A1', s1, 50, 50)
3889
4342
 
3890
4343
  s2 = workbook.add_shape(
3891
4344
  :type => 'plus',
3892
4345
  :width => 20,
3893
4346
  :height => 20
3894
- )
4347
+ )
3895
4348
  worksheet.insert_shape('A1', s2, 250, 200)
3896
4349
 
3897
4350
  # Create a connector to link the two shapes.
@@ -3923,14 +4376,14 @@ def test_shape6
3923
4376
  :type => 'chevron',
3924
4377
  :width => 60,
3925
4378
  :height => 60
3926
- )
4379
+ )
3927
4380
  worksheet.insert_shape('A1', s1, 50, 50)
3928
4381
 
3929
4382
  s2 = workbook.add_shape(
3930
4383
  :type => 'pentagon',
3931
4384
  :width => 20,
3932
4385
  :height => 20
3933
- )
4386
+ )
3934
4387
  worksheet.insert_shape('A1', s2, 250, 200)
3935
4388
 
3936
4389
  # Create a connector to link the two shapes.
@@ -3970,7 +4423,7 @@ def test_shape7
3970
4423
  :text => "Hello\nWorld",
3971
4424
  :width => cw,
3972
4425
  :height => ch
3973
- )
4426
+ )
3974
4427
  worksheet.insert_shape('A1', ellipse, cx, cy)
3975
4428
 
3976
4429
  # Add a plus sign at 4 different positions around the circle.
@@ -3984,7 +4437,7 @@ def test_shape7
3984
4437
  :id => 3,
3985
4438
  :width => pw,
3986
4439
  :height => ph
3987
- )
4440
+ )
3988
4441
 
3989
4442
  p1 = worksheet.insert_shape('A1', plus, 350, 350)
3990
4443
  p2 = worksheet.insert_shape('A1', plus, 150, 350)
@@ -4035,7 +4488,7 @@ def test_shape8
4035
4488
  :text => "Hello\nWorld",
4036
4489
  :width => cw,
4037
4490
  :height => ch
4038
- )
4491
+ )
4039
4492
  worksheet.insert_shape('A1', ellipse, cx, cy)
4040
4493
 
4041
4494
  # Add a plus sign at 4 different positionos around the circle.
@@ -4049,7 +4502,7 @@ def test_shape8
4049
4502
  :id => 3,
4050
4503
  :width => pw,
4051
4504
  :height => ph
4052
- )
4505
+ )
4053
4506
 
4054
4507
  p1 = worksheet.insert_shape('A1', plus, 350, 150)
4055
4508
  p2 = worksheet.insert_shape('A1', plus, 350, 350)
@@ -4100,11 +4553,11 @@ def test_shape_all
4100
4553
  end
4101
4554
  last_sheet = sheet
4102
4555
  shape = workbook.add_shape(
4103
- :type => name,
4104
- :text => name,
4105
- :width => 90,
4106
- :height => 90
4107
- )
4556
+ :type => name,
4557
+ :text => name,
4558
+ :width => 90,
4559
+ :height => 90
4560
+ )
4108
4561
 
4109
4562
  # Connectors can not have labels, so write the connector name in the cell
4110
4563
  # to the left.
@@ -4530,17 +4983,18 @@ def test_tables
4530
4983
  worksheet10 = workbook.add_worksheet
4531
4984
  worksheet11 = workbook.add_worksheet
4532
4985
  worksheet12 = workbook.add_worksheet
4986
+ worksheet13 = workbook.add_worksheet
4533
4987
 
4534
4988
  currency_format = workbook.add_format(:num_format => '$#,##0')
4535
4989
 
4536
4990
 
4537
4991
  # Some sample data for the table.
4538
4992
  data = [
4539
- [ 'Apples', 10000, 5000, 8000, 6000 ],
4540
- [ 'Pears', 2000, 3000, 4000, 5000 ],
4541
- [ 'Bananas', 6000, 6000, 6500, 6000 ],
4542
- [ 'Oranges', 500, 300, 200, 700 ]
4543
- ]
4993
+ [ 'Apples', 10000, 5000, 8000, 6000 ],
4994
+ [ 'Pears', 2000, 3000, 4000, 5000 ],
4995
+ [ 'Bananas', 6000, 6000, 6500, 6000 ],
4996
+ [ 'Oranges', 500, 300, 200, 700 ]
4997
+ ]
4544
4998
 
4545
4999
  ###############################################################################
4546
5000
  #
@@ -4561,7 +5015,7 @@ def test_tables
4561
5015
  #
4562
5016
  # Example 2.
4563
5017
  #
4564
- caption = 'Default table with data.';
5018
+ caption = 'Default table with data.'
4565
5019
 
4566
5020
  # Set the columns widths.
4567
5021
  worksheet2.set_column('B:G', 12)
@@ -4630,7 +5084,7 @@ def test_tables
4630
5084
  #
4631
5085
  # Example 6.
4632
5086
  #
4633
- caption = 'Table with banded columns but without default banded rows.';
5087
+ caption = 'Table with banded columns but without default banded rows.'
4634
5088
 
4635
5089
  # Set the columns widths.
4636
5090
  worksheet6.set_column('B:G', 12)
@@ -4648,7 +5102,7 @@ def test_tables
4648
5102
  #
4649
5103
  # Example 7.
4650
5104
  #
4651
- caption = 'Table with user defined column headers';
5105
+ caption = 'Table with user defined column headers'
4652
5106
 
4653
5107
  # Set the columns widths.
4654
5108
  worksheet7.set_column('B:G', 12)
@@ -4658,24 +5112,24 @@ def test_tables
4658
5112
 
4659
5113
  # Add a table to the worksheet.
4660
5114
  worksheet7.add_table(
4661
- 'B3:F7',
4662
- {
4663
- :data => data,
4664
- :columns => [
4665
- { :header => 'Product' },
4666
- { :header => 'Quarter 1' },
4667
- { :header => 'Quarter 2' },
4668
- { :header => 'Quarter 3' },
4669
- { :header => 'Quarter 4' }
4670
- ]
4671
- }
4672
- )
5115
+ 'B3:F7',
5116
+ {
5117
+ :data => data,
5118
+ :columns => [
5119
+ { :header => 'Product' },
5120
+ { :header => 'Quarter 1' },
5121
+ { :header => 'Quarter 2' },
5122
+ { :header => 'Quarter 3' },
5123
+ { :header => 'Quarter 4' }
5124
+ ]
5125
+ }
5126
+ )
4673
5127
 
4674
5128
  ###############################################################################
4675
5129
  #
4676
5130
  # Example 8.
4677
5131
  #
4678
- caption = 'Table with user defined column headers';
5132
+ caption = 'Table with user defined column headers'
4679
5133
 
4680
5134
  # Set the columns widths.
4681
5135
  worksheet8.set_column('B:G', 12)
@@ -4685,29 +5139,29 @@ def test_tables
4685
5139
 
4686
5140
  # Add a table to the worksheet.
4687
5141
  worksheet8.add_table(
4688
- 'B3:G7',
4689
- {
4690
- :data => data,
4691
- :columns => [
4692
- { :header => 'Product' },
4693
- { :header => 'Quarter 1' },
4694
- { :header => 'Quarter 2' },
4695
- { :header => 'Quarter 3' },
4696
- { :header => 'Quarter 4' },
4697
- {
4698
- :header => 'Year',
4699
- :formula => '=SUM(Table8[@[Quarter 1]:[Quarter 4]])'
4700
- }
4701
- ]
4702
- }
4703
- )
5142
+ 'B3:G7',
5143
+ {
5144
+ :data => data,
5145
+ :columns => [
5146
+ { :header => 'Product' },
5147
+ { :header => 'Quarter 1' },
5148
+ { :header => 'Quarter 2' },
5149
+ { :header => 'Quarter 3' },
5150
+ { :header => 'Quarter 4' },
5151
+ {
5152
+ :header => 'Year',
5153
+ :formula => '=SUM(Table8[@[Quarter 1]:[Quarter 4]])'
5154
+ }
5155
+ ]
5156
+ }
5157
+ )
4704
5158
 
4705
5159
 
4706
5160
  ###############################################################################
4707
5161
  #
4708
5162
  # Example 9.
4709
5163
  #
4710
- caption = 'Table with totals row (but no caption or totals).';
5164
+ caption = 'Table with totals row (but no caption or totals).'
4711
5165
 
4712
5166
  # Set the columns widths.
4713
5167
  worksheet9.set_column('B:G', 12)
@@ -4717,29 +5171,29 @@ def test_tables
4717
5171
 
4718
5172
  # Add a table to the worksheet.
4719
5173
  worksheet9.add_table(
4720
- 'B3:G8',
4721
- {
4722
- :data => data,
4723
- :total_row => 1,
4724
- :columns => [
4725
- { :header => 'Product' },
4726
- { :header => 'Quarter 1' },
4727
- { :header => 'Quarter 2' },
4728
- { :header => 'Quarter 3' },
4729
- { :header => 'Quarter 4' },
4730
- {
4731
- :header => 'Year',
4732
- :formula => '=SUM(Table8[@[Quarter 1]:[Quarter 4]])'
4733
- }
4734
- ]
4735
- }
4736
- )
5174
+ 'B3:G8',
5175
+ {
5176
+ :data => data,
5177
+ :total_row => 1,
5178
+ :columns => [
5179
+ { :header => 'Product' },
5180
+ { :header => 'Quarter 1' },
5181
+ { :header => 'Quarter 2' },
5182
+ { :header => 'Quarter 3' },
5183
+ { :header => 'Quarter 4' },
5184
+ {
5185
+ :header => 'Year',
5186
+ :formula => '=SUM(Table8[@[Quarter 1]:[Quarter 4]])'
5187
+ }
5188
+ ]
5189
+ }
5190
+ )
4737
5191
 
4738
5192
  ###############################################################################
4739
5193
  #
4740
5194
  # Example 10.
4741
5195
  #
4742
- caption = 'Table with totals row with user captions and functions.';
5196
+ caption = 'Table with totals row with user captions and functions.'
4743
5197
 
4744
5198
  # Set the columns widths.
4745
5199
  worksheet10.set_column('B:G', 12)
@@ -4749,30 +5203,30 @@ def test_tables
4749
5203
 
4750
5204
  # Add a table to the worksheet.
4751
5205
  worksheet10.add_table(
4752
- 'B3:G8',
4753
- {
4754
- :data => data,
4755
- :total_row => 1,
4756
- :columns => [
4757
- { :header => 'Product', :total_string => 'Totals' },
4758
- { :header => 'Quarter 1', :total_function => 'sum' },
4759
- { :header => 'Quarter 2', :total_function => 'sum' },
4760
- { :header => 'Quarter 3', :total_function => 'sum' },
4761
- { :header => 'Quarter 4', :total_function => 'sum' },
4762
- {
4763
- :header => 'Year',
4764
- :formula => '=SUM(Table8[@[Quarter 1]:[Quarter 4]])',
4765
- :total_function => 'sum'
4766
- }
4767
- ]
4768
- }
4769
- )
5206
+ 'B3:G8',
5207
+ {
5208
+ :data => data,
5209
+ :total_row => 1,
5210
+ :columns => [
5211
+ { :header => 'Product', :total_string => 'Totals' },
5212
+ { :header => 'Quarter 1', :total_function => 'sum' },
5213
+ { :header => 'Quarter 2', :total_function => 'sum' },
5214
+ { :header => 'Quarter 3', :total_function => 'sum' },
5215
+ { :header => 'Quarter 4', :total_function => 'sum' },
5216
+ {
5217
+ :header => 'Year',
5218
+ :formula => '=SUM(Table8[@[Quarter 1]:[Quarter 4]])',
5219
+ :total_function => 'sum'
5220
+ }
5221
+ ]
5222
+ }
5223
+ )
4770
5224
 
4771
5225
  ###############################################################################
4772
5226
  #
4773
5227
  # Example 11.
4774
5228
  #
4775
- caption = 'Table with alternative Excel style.';
5229
+ caption = 'Table with alternative Excel style.'
4776
5230
 
4777
5231
  # Set the columns widths.
4778
5232
  worksheet11.set_column('B:G', 12)
@@ -4782,31 +5236,31 @@ def test_tables
4782
5236
 
4783
5237
  # Add a table to the worksheet.
4784
5238
  worksheet11.add_table(
4785
- 'B3:G8',
4786
- {
4787
- :data => data,
4788
- :style => 'Table Style Light 11',
4789
- :total_row => 1,
4790
- :columns => [
4791
- { :header => 'Product', :total_string => 'Totals' },
4792
- { :header => 'Quarter 1', :total_function => 'sum' },
4793
- { :header => 'Quarter 2', :total_function => 'sum' },
4794
- { :header => 'Quarter 3', :total_function => 'sum' },
4795
- { :header => 'Quarter 4', :total_function => 'sum' },
4796
- {
4797
- :header => 'Year',
4798
- :formula => '=SUM(Table8[@[Quarter 1]:[Quarter 4]])',
4799
- :total_function => 'sum'
4800
- }
4801
- ]
4802
- }
4803
- )
5239
+ 'B3:G8',
5240
+ {
5241
+ :data => data,
5242
+ :style => 'Table Style Light 11',
5243
+ :total_row => 1,
5244
+ :columns => [
5245
+ { :header => 'Product', :total_string => 'Totals' },
5246
+ { :header => 'Quarter 1', :total_function => 'sum' },
5247
+ { :header => 'Quarter 2', :total_function => 'sum' },
5248
+ { :header => 'Quarter 3', :total_function => 'sum' },
5249
+ { :header => 'Quarter 4', :total_function => 'sum' },
5250
+ {
5251
+ :header => 'Year',
5252
+ :formula => '=SUM(Table8[@[Quarter 1]:[Quarter 4]])',
5253
+ :total_function => 'sum'
5254
+ }
5255
+ ]
5256
+ }
5257
+ )
4804
5258
 
4805
5259
  ###############################################################################
4806
5260
  #
4807
5261
  # Example 12.
4808
5262
  #
4809
- caption = 'Table with column formats.';
5263
+ caption = 'Table with no Excel style.'
4810
5264
 
4811
5265
  # Set the columns widths.
4812
5266
  worksheet12.set_column('B:G', 12)
@@ -4816,41 +5270,75 @@ def test_tables
4816
5270
 
4817
5271
  # Add a table to the worksheet.
4818
5272
  worksheet12.add_table(
4819
- 'B3:G8',
4820
- {
4821
- :data => data,
4822
- :total_row => 1,
4823
- :columns => [
4824
- { :header => 'Product', :total_string => 'Totals' },
4825
- {
4826
- :header => 'Quarter 1',
4827
- :total_function => 'sum',
4828
- :format => currency_format,
4829
- },
4830
- {
4831
- :header => 'Quarter 2',
4832
- :total_function => 'sum',
4833
- :format => currency_format,
4834
- },
4835
- {
4836
- :header => 'Quarter 3',
4837
- :total_function => 'sum',
4838
- :format => currency_format,
4839
- },
4840
- {
4841
- :header => 'Quarter 4',
4842
- :total_function => 'sum',
4843
- :format => currency_format,
4844
- },
4845
- {
4846
- :header => 'Year',
4847
- :formula => '=SUM(Table8[@[Quarter 1]:[Quarter 4]])',
4848
- :total_function => 'sum',
4849
- :format => currency_format,
4850
- }
4851
- ]
4852
- }
4853
- )
5273
+ 'B3:G8',
5274
+ {
5275
+ :data => data,
5276
+ :style => 'None',
5277
+ :total_row => 1,
5278
+ :columns => [
5279
+ { :header => 'Product', :total_string => 'Totals' },
5280
+ { :header => 'Quarter 1', :total_function => 'sum' },
5281
+ { :header => 'Quarter 2', :total_function => 'sum' },
5282
+ { :header => 'Quarter 3', :total_function => 'sum' },
5283
+ { :header => 'Quarter 4', :total_function => 'sum' },
5284
+ {
5285
+ :header => 'Year',
5286
+ :formula => '=SUM(Table12[@[Quarter 1]:[Quarter 4]])',
5287
+ :total_function => 'sum'
5288
+ }
5289
+ ]
5290
+ }
5291
+ )
5292
+
5293
+ ###############################################################################
5294
+ #
5295
+ # Example 13.
5296
+ #
5297
+ caption = 'Table with column formats.'
5298
+
5299
+ # Set the columns widths.
5300
+ worksheet13.set_column('B:G', 12)
5301
+
5302
+ # Write the caption.
5303
+ worksheet13.write('B1', caption)
5304
+
5305
+ # Add a table to the worksheet.
5306
+ worksheet13.add_table(
5307
+ 'B3:G8',
5308
+ {
5309
+ :data => data,
5310
+ :total_row => 1,
5311
+ :columns => [
5312
+ { :header => 'Product', :total_string => 'Totals' },
5313
+ {
5314
+ :header => 'Quarter 1',
5315
+ :total_function => 'sum',
5316
+ :format => currency_format,
5317
+ },
5318
+ {
5319
+ :header => 'Quarter 2',
5320
+ :total_function => 'sum',
5321
+ :format => currency_format,
5322
+ },
5323
+ {
5324
+ :header => 'Quarter 3',
5325
+ :total_function => 'sum',
5326
+ :format => currency_format,
5327
+ },
5328
+ {
5329
+ :header => 'Quarter 4',
5330
+ :total_function => 'sum',
5331
+ :format => currency_format,
5332
+ },
5333
+ {
5334
+ :header => 'Year',
5335
+ :formula => '=SUM(Table8[@[Quarter 1]:[Quarter 4]])',
5336
+ :total_function => 'sum',
5337
+ :format => currency_format,
5338
+ }
5339
+ ]
5340
+ }
5341
+ )
4854
5342
 
4855
5343
  workbook.close
4856
5344
  store_to_tempfile
@@ -4864,42 +5352,42 @@ def test_sparklines1
4864
5352
 
4865
5353
  # Some sample data to plot.
4866
5354
  data = [
4867
- [ -2, 2, 3, -1, 0 ],
4868
- [ 30, 20, 33, 20, 15 ],
4869
- [ 1, -1, -1, 1, -1 ]
4870
- ]
5355
+ [ -2, 2, 3, -1, 0 ],
5356
+ [ 30, 20, 33, 20, 15 ],
5357
+ [ 1, -1, -1, 1, -1 ]
5358
+ ]
4871
5359
 
4872
5360
  # Write the sample data to the worksheet.
4873
5361
  worksheet.write_col('A1', data)
4874
5362
 
4875
5363
  # Add a line sparkline (the default) with markers.
4876
5364
  worksheet.add_sparkline(
4877
- {
4878
- :location => 'F1',
4879
- :range => 'Sheet1!A1:E1',
4880
- :markers => 1
4881
- }
4882
- )
5365
+ {
5366
+ :location => 'F1',
5367
+ :range => 'Sheet1!A1:E1',
5368
+ :markers => 1
5369
+ }
5370
+ )
4883
5371
 
4884
5372
  # Add a column sparkline with non-default style.
4885
5373
  worksheet.add_sparkline(
4886
- {
4887
- :location => 'F2',
4888
- :range => 'Sheet1!A2:E2',
4889
- :type => 'column',
4890
- :style => 12
4891
- }
4892
- )
5374
+ {
5375
+ :location => 'F2',
5376
+ :range => 'Sheet1!A2:E2',
5377
+ :type => 'column',
5378
+ :style => 12
5379
+ }
5380
+ )
4893
5381
 
4894
5382
  # Add a win/loss sparkline with negative values highlighted.
4895
5383
  worksheet.add_sparkline(
4896
- {
4897
- :location => 'F3',
4898
- :range => 'Sheet1!A3:E3',
4899
- :type => 'win_loss',
4900
- :negative_points => 1
4901
- }
4902
- )
5384
+ {
5385
+ :location => 'F3',
5386
+ :range => 'Sheet1!A3:E3',
5387
+ :type => 'win_loss',
5388
+ :negative_points => 1
5389
+ }
5390
+ )
4903
5391
 
4904
5392
  workbook.close
4905
5393
  store_to_tempfile
@@ -4928,11 +5416,11 @@ def test_sparklines2
4928
5416
  str = 'A default "line" sparkline.'
4929
5417
 
4930
5418
  worksheet1.add_sparkline(
4931
- {
4932
- :location => 'A2',
4933
- :range => 'Sheet2!A1:J1'
4934
- }
4935
- )
5419
+ {
5420
+ :location => 'A2',
5421
+ :range => 'Sheet2!A1:J1'
5422
+ }
5423
+ )
4936
5424
 
4937
5425
  worksheet1.write(row, 1, str)
4938
5426
  row += 1
@@ -4942,12 +5430,12 @@ def test_sparklines2
4942
5430
  str = 'A default "column" sparkline.'
4943
5431
 
4944
5432
  worksheet1.add_sparkline(
4945
- {
4946
- :location => 'A3',
4947
- :range => 'Sheet2!A2:J2',
4948
- :type => 'column'
4949
- }
4950
- )
5433
+ {
5434
+ :location => 'A3',
5435
+ :range => 'Sheet2!A2:J2',
5436
+ :type => 'column'
5437
+ }
5438
+ )
4951
5439
 
4952
5440
  worksheet1.write(row, 1, str)
4953
5441
  row += 1
@@ -4957,12 +5445,12 @@ def test_sparklines2
4957
5445
  str = 'A default "win/loss" sparkline.'
4958
5446
 
4959
5447
  worksheet1.add_sparkline(
4960
- {
4961
- :location => 'A4',
4962
- :range => 'Sheet2!A3:J3',
4963
- :type => 'win_loss'
4964
- }
4965
- )
5448
+ {
5449
+ :location => 'A4',
5450
+ :range => 'Sheet2!A3:J3',
5451
+ :type => 'win_loss'
5452
+ }
5453
+ )
4966
5454
 
4967
5455
  worksheet1.write(row, 1, str)
4968
5456
  row += 2
@@ -4972,12 +5460,12 @@ def test_sparklines2
4972
5460
  str = 'Line with markers.'
4973
5461
 
4974
5462
  worksheet1.add_sparkline(
4975
- {
4976
- :location => 'A6',
4977
- :range => 'Sheet2!A1:J1',
4978
- :markers => 1
4979
- }
4980
- )
5463
+ {
5464
+ :location => 'A6',
5465
+ :range => 'Sheet2!A1:J1',
5466
+ :markers => 1
5467
+ }
5468
+ )
4981
5469
 
4982
5470
  worksheet1.write(row, 1, str)
4983
5471
  row += 1
@@ -4987,13 +5475,13 @@ def test_sparklines2
4987
5475
  str = 'Line with high and low points.'
4988
5476
 
4989
5477
  worksheet1.add_sparkline(
4990
- {
4991
- :location => 'A7',
4992
- :range => 'Sheet2!A1:J1',
4993
- :high_point => 1,
4994
- :low_point => 1
4995
- }
4996
- )
5478
+ {
5479
+ :location => 'A7',
5480
+ :range => 'Sheet2!A1:J1',
5481
+ :high_point => 1,
5482
+ :low_point => 1
5483
+ }
5484
+ )
4997
5485
 
4998
5486
  worksheet1.write(row, 1, str)
4999
5487
  row += 1
@@ -5003,13 +5491,13 @@ def test_sparklines2
5003
5491
  str = 'Line with first and last point markers.'
5004
5492
 
5005
5493
  worksheet1.add_sparkline(
5006
- {
5007
- :location => 'A8',
5008
- :range => 'Sheet2!A1:J1',
5009
- :first_point => 1,
5010
- :last_point => 1
5011
- }
5012
- )
5494
+ {
5495
+ :location => 'A8',
5496
+ :range => 'Sheet2!A1:J1',
5497
+ :first_point => 1,
5498
+ :last_point => 1
5499
+ }
5500
+ )
5013
5501
 
5014
5502
  worksheet1.write(row, 1, str)
5015
5503
  row += 1
@@ -5019,12 +5507,12 @@ def test_sparklines2
5019
5507
  str = 'Line with negative point markers.'
5020
5508
 
5021
5509
  worksheet1.add_sparkline(
5022
- {
5023
- :location => 'A9',
5024
- :range => 'Sheet2!A1:J1',
5025
- :negative_points => 1
5026
- }
5027
- )
5510
+ {
5511
+ :location => 'A9',
5512
+ :range => 'Sheet2!A1:J1',
5513
+ :negative_points => 1
5514
+ }
5515
+ )
5028
5516
 
5029
5517
  worksheet1.write(row, 1, str)
5030
5518
  row += 1
@@ -5034,12 +5522,12 @@ def test_sparklines2
5034
5522
  str = 'Line with axis.'
5035
5523
 
5036
5524
  worksheet1.add_sparkline(
5037
- {
5038
- :location => 'A10',
5039
- :range => 'Sheet2!A1:J1',
5040
- :axis => 1
5041
- }
5042
- )
5525
+ {
5526
+ :location => 'A10',
5527
+ :range => 'Sheet2!A1:J1',
5528
+ :axis => 1
5529
+ }
5530
+ )
5043
5531
 
5044
5532
  worksheet1.write(row, 1, str)
5045
5533
  row += 2
@@ -5049,12 +5537,12 @@ def test_sparklines2
5049
5537
  str = 'Column with default style (1).'
5050
5538
 
5051
5539
  worksheet1.add_sparkline(
5052
- {
5053
- :location => 'A12',
5054
- :range => 'Sheet2!A2:J2',
5055
- :type => 'column'
5056
- }
5057
- )
5540
+ {
5541
+ :location => 'A12',
5542
+ :range => 'Sheet2!A2:J2',
5543
+ :type => 'column'
5544
+ }
5545
+ )
5058
5546
 
5059
5547
  worksheet1.write(row, 1, str)
5060
5548
  row += 1
@@ -5064,13 +5552,13 @@ def test_sparklines2
5064
5552
  str = 'Column with style 2.'
5065
5553
 
5066
5554
  worksheet1.add_sparkline(
5067
- {
5068
- :location => 'A13',
5069
- :range => 'Sheet2!A2:J2',
5070
- :type => 'column',
5071
- :style => 2
5072
- }
5073
- )
5555
+ {
5556
+ :location => 'A13',
5557
+ :range => 'Sheet2!A2:J2',
5558
+ :type => 'column',
5559
+ :style => 2
5560
+ }
5561
+ )
5074
5562
 
5075
5563
  worksheet1.write(row, 1, str)
5076
5564
  row += 1
@@ -5080,13 +5568,13 @@ def test_sparklines2
5080
5568
  str = 'Column with style 3.'
5081
5569
 
5082
5570
  worksheet1.add_sparkline(
5083
- {
5084
- :location => 'A14',
5085
- :range => 'Sheet2!A2:J2',
5086
- :type => 'column',
5087
- :style => 3
5088
- }
5089
- )
5571
+ {
5572
+ :location => 'A14',
5573
+ :range => 'Sheet2!A2:J2',
5574
+ :type => 'column',
5575
+ :style => 3
5576
+ }
5577
+ )
5090
5578
 
5091
5579
  worksheet1.write(row, 1, str)
5092
5580
  row += 1
@@ -5096,13 +5584,13 @@ def test_sparklines2
5096
5584
  str = 'Column with style 4.'
5097
5585
 
5098
5586
  worksheet1.add_sparkline(
5099
- {
5100
- :location => 'A15',
5101
- :range => 'Sheet2!A2:J2',
5102
- :type => 'column',
5103
- :style => 4
5104
- }
5105
- )
5587
+ {
5588
+ :location => 'A15',
5589
+ :range => 'Sheet2!A2:J2',
5590
+ :type => 'column',
5591
+ :style => 4
5592
+ }
5593
+ )
5106
5594
 
5107
5595
  worksheet1.write(row, 1, str)
5108
5596
  row += 1
@@ -5112,13 +5600,13 @@ def test_sparklines2
5112
5600
  str = 'Column with style 5.'
5113
5601
 
5114
5602
  worksheet1.add_sparkline(
5115
- {
5116
- :location => 'A16',
5117
- :range => 'Sheet2!A2:J2',
5118
- :type => 'column',
5119
- :style => 5
5120
- }
5121
- )
5603
+ {
5604
+ :location => 'A16',
5605
+ :range => 'Sheet2!A2:J2',
5606
+ :type => 'column',
5607
+ :style => 5
5608
+ }
5609
+ )
5122
5610
 
5123
5611
  worksheet1.write(row, 1, str)
5124
5612
  row += 1
@@ -5128,13 +5616,13 @@ def test_sparklines2
5128
5616
  str = 'Column with style 6.'
5129
5617
 
5130
5618
  worksheet1.add_sparkline(
5131
- {
5132
- :location => 'A17',
5133
- :range => 'Sheet2!A2:J2',
5134
- :type => 'column',
5135
- :style => 6
5136
- }
5137
- )
5619
+ {
5620
+ :location => 'A17',
5621
+ :range => 'Sheet2!A2:J2',
5622
+ :type => 'column',
5623
+ :style => 6
5624
+ }
5625
+ )
5138
5626
 
5139
5627
  worksheet1.write(row, 1, str)
5140
5628
  row += 1
@@ -5144,13 +5632,13 @@ def test_sparklines2
5144
5632
  str = 'Column with a user defined colour.'
5145
5633
 
5146
5634
  worksheet1.add_sparkline(
5147
- {
5148
- :location => 'A18',
5149
- :range => 'Sheet2!A2:J2',
5150
- :type => 'column',
5151
- :series_color => '#E965E0'
5152
- }
5153
- )
5635
+ {
5636
+ :location => 'A18',
5637
+ :range => 'Sheet2!A2:J2',
5638
+ :type => 'column',
5639
+ :series_color => '#E965E0'
5640
+ }
5641
+ )
5154
5642
 
5155
5643
  worksheet1.write(row, 1, str)
5156
5644
  row += 2
@@ -5160,12 +5648,12 @@ def test_sparklines2
5160
5648
  str = 'A win/loss sparkline.'
5161
5649
 
5162
5650
  worksheet1.add_sparkline(
5163
- {
5164
- :location => 'A20',
5165
- :range => 'Sheet2!A3:J3',
5166
- :type => 'win_loss'
5167
- }
5168
- )
5651
+ {
5652
+ :location => 'A20',
5653
+ :range => 'Sheet2!A3:J3',
5654
+ :type => 'win_loss'
5655
+ }
5656
+ )
5169
5657
 
5170
5658
  worksheet1.write(row, 1, str)
5171
5659
  row += 1
@@ -5175,13 +5663,13 @@ def test_sparklines2
5175
5663
  str = 'A win/loss sparkline with negative points highlighted.'
5176
5664
 
5177
5665
  worksheet1.add_sparkline(
5178
- {
5179
- :location => 'A21',
5180
- :range => 'Sheet2!A3:J3',
5181
- :type => 'win_loss',
5182
- :negative_points => 1
5183
- }
5184
- )
5666
+ {
5667
+ :location => 'A21',
5668
+ :range => 'Sheet2!A3:J3',
5669
+ :type => 'win_loss',
5670
+ :negative_points => 1
5671
+ }
5672
+ )
5185
5673
 
5186
5674
  worksheet1.write(row, 1, str)
5187
5675
  row += 2
@@ -5191,13 +5679,13 @@ def test_sparklines2
5191
5679
  str = 'A left to right column (the default).'
5192
5680
 
5193
5681
  worksheet1.add_sparkline(
5194
- {
5195
- :location => 'A23',
5196
- :range => 'Sheet2!A4:J4',
5197
- :type => 'column',
5198
- :style => 20
5199
- }
5200
- )
5682
+ {
5683
+ :location => 'A23',
5684
+ :range => 'Sheet2!A4:J4',
5685
+ :type => 'column',
5686
+ :style => 20
5687
+ }
5688
+ )
5201
5689
 
5202
5690
  worksheet1.write(row, 1, str)
5203
5691
  row += 1
@@ -5207,14 +5695,14 @@ def test_sparklines2
5207
5695
  str = 'A right to left column.'
5208
5696
 
5209
5697
  worksheet1.add_sparkline(
5210
- {
5211
- :location => 'A24',
5212
- :range => 'Sheet2!A4:J4',
5213
- :type => 'column',
5214
- :style => 20,
5215
- :reverse => 1
5216
- }
5217
- )
5698
+ {
5699
+ :location => 'A24',
5700
+ :range => 'Sheet2!A4:J4',
5701
+ :type => 'column',
5702
+ :style => 20,
5703
+ :reverse => 1
5704
+ }
5705
+ )
5218
5706
 
5219
5707
  worksheet1.write(row, 1, str)
5220
5708
  row += 1
@@ -5224,13 +5712,13 @@ def test_sparklines2
5224
5712
  str = 'Sparkline and text in one cell.'
5225
5713
 
5226
5714
  worksheet1.add_sparkline(
5227
- {
5228
- :location => 'A25',
5229
- :range => 'Sheet2!A4:J4',
5230
- :type => 'column',
5231
- :style => 20
5232
- }
5233
- )
5715
+ {
5716
+ :location => 'A25',
5717
+ :range => 'Sheet2!A4:J4',
5718
+ :type => 'column',
5719
+ :style => 20
5720
+ }
5721
+ )
5234
5722
 
5235
5723
  worksheet1.write(row, 0, 'Growth')
5236
5724
  worksheet1.write(row, 1, str)
@@ -5241,12 +5729,12 @@ def test_sparklines2
5241
5729
  str = 'A grouped sparkline. Changes are applied to all three.'
5242
5730
 
5243
5731
  worksheet1.add_sparkline(
5244
- {
5245
- :location => [ 'A27', 'A28', 'A29' ],
5246
- :range => [ 'Sheet2!A5:J5', 'Sheet2!A6:J6', 'Sheet2!A7:J7' ],
5247
- :markers => 1
5248
- }
5249
- )
5732
+ {
5733
+ :location => [ 'A27', 'A28', 'A29' ],
5734
+ :range => [ 'Sheet2!A5:J5', 'Sheet2!A6:J6', 'Sheet2!A7:J7' ],
5735
+ :markers => 1
5736
+ }
5737
+ )
5250
5738
 
5251
5739
  worksheet1.write(row, 1, str)
5252
5740
  row += 1
@@ -5258,23 +5746,23 @@ def test_sparklines2
5258
5746
  worksheet2.set_column('A:J', 11)
5259
5747
 
5260
5748
  data = [
5261
- # Simple line data.
5262
- [ -2, 2, 3, -1, 0, -2, 3, 2, 1, 0 ],
5749
+ # Simple line data.
5750
+ [ -2, 2, 3, -1, 0, -2, 3, 2, 1, 0 ],
5263
5751
 
5264
- # Simple column data.
5265
- [ 30, 20, 33, 20, 15, 5, 5, 15, 10, 15 ],
5752
+ # Simple column data.
5753
+ [ 30, 20, 33, 20, 15, 5, 5, 15, 10, 15 ],
5266
5754
 
5267
- # Simple win/loss data.
5268
- [ 1, 1, -1, -1, 1, -1, 1, 1, 1, -1 ],
5755
+ # Simple win/loss data.
5756
+ [ 1, 1, -1, -1, 1, -1, 1, 1, 1, -1 ],
5269
5757
 
5270
- # Unbalanced histogram.
5271
- [ 5, 6, 7, 10, 15, 20, 30, 50, 70, 100 ],
5758
+ # Unbalanced histogram.
5759
+ [ 5, 6, 7, 10, 15, 20, 30, 50, 70, 100 ],
5272
5760
 
5273
- # Data for the grouped sparkline example.
5274
- [ -2, 2, 3, -1, 0, -2, 3, 2, 1, 0 ],
5275
- [ 3, -1, 0, -2, 3, 2, 1, 0, 2, 1 ],
5276
- [ 0, -2, 3, 2, 1, 0, 1, 2, 3, 1 ]
5277
- ]
5761
+ # Data for the grouped sparkline example.
5762
+ [ -2, 2, 3, -1, 0, -2, 3, 2, 1, 0 ],
5763
+ [ 3, -1, 0, -2, 3, 2, 1, 0, 2, 1 ],
5764
+ [ 0, -2, 3, 2, 1, 0, 1, 2, 3, 1 ]
5765
+ ]
5278
5766
 
5279
5767
  # Write the sample data to the worksheet.
5280
5768
  worksheet2.write_col('A1', data)
@@ -5339,10 +5827,10 @@ def test_chart_data_table
5339
5827
  # Add the worksheet data that the charts will refer to.
5340
5828
  headings = [ 'Number', 'Batch 1', 'Batch 2' ]
5341
5829
  data = [
5342
- [ 2, 3, 4, 5, 6, 7 ],
5343
- [ 10, 40, 50, 20, 10, 50 ],
5344
- [ 30, 60, 70, 50, 40, 30 ]
5345
- ]
5830
+ [ 2, 3, 4, 5, 6, 7 ],
5831
+ [ 10, 40, 50, 20, 10, 50 ],
5832
+ [ 30, 60, 70, 50, 40, 30 ]
5833
+ ]
5346
5834
 
5347
5835
  worksheet.write('A1', headings, bold)
5348
5836
  worksheet.write('A2', data)
@@ -5352,18 +5840,18 @@ def test_chart_data_table
5352
5840
 
5353
5841
  # Configure the first series.
5354
5842
  chart1.add_series(
5355
- :name => '=Sheet1!$B$1',
5356
- :categories => '=Sheet1!$A$2:$A$7',
5357
- :values => '=Sheet1!$B$2:$B$7'
5358
- )
5843
+ :name => '=Sheet1!$B$1',
5844
+ :categories => '=Sheet1!$A$2:$A$7',
5845
+ :values => '=Sheet1!$B$2:$B$7'
5846
+ )
5359
5847
 
5360
5848
  # Configure second series. Note alternative use of array ref to define
5361
5849
  # ranges: [ sheetname, row_start, row_end, col_start, col_end ].
5362
5850
  chart1.add_series(
5363
- :name => '=Sheet1!$C$1',
5364
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
5365
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
5366
- )
5851
+ :name => '=Sheet1!$C$1',
5852
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
5853
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
5854
+ )
5367
5855
 
5368
5856
  # Add a chart title and some axis labels.
5369
5857
  chart1.set_title(:name => 'Chart with Data Table')
@@ -5383,18 +5871,18 @@ def test_chart_data_table
5383
5871
 
5384
5872
  # Configure the first series.
5385
5873
  chart2.add_series(
5386
- :name => '=Sheet1!$B$1',
5387
- :categories => '=Sheet1!$A$2:$A$7',
5388
- :values => '=Sheet1!$B$2:$B$7'
5389
- )
5874
+ :name => '=Sheet1!$B$1',
5875
+ :categories => '=Sheet1!$A$2:$A$7',
5876
+ :values => '=Sheet1!$B$2:$B$7'
5877
+ )
5390
5878
 
5391
5879
  # Configure second series. Note alternative use of array ref to define
5392
5880
  # ranges: [ sheetname, row_start, row_end, col_start, col_end ].
5393
5881
  chart2.add_series(
5394
- :name => '=Sheet1!$C$1',
5395
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
5396
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
5397
- )
5882
+ :name => '=Sheet1!$C$1',
5883
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
5884
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
5885
+ )
5398
5886
 
5399
5887
  # Add a chart title and some axis labels.
5400
5888
  chart2.set_title(:name => 'Data Table with legend keys')
@@ -5424,10 +5912,10 @@ def test_chart_data_tools
5424
5912
  # Add the worksheet data that the charts will refer to.
5425
5913
  headings = [ 'Number', 'Data 1', 'Data 2' ]
5426
5914
  data = [
5427
- [ 2, 3, 4, 5, 6, 7 ],
5428
- [ 10, 40, 50, 20, 10, 50 ],
5429
- [ 30, 60, 70, 50, 40, 30 ]
5430
- ]
5915
+ [ 2, 3, 4, 5, 6, 7 ],
5916
+ [ 10, 40, 50, 20, 10, 50 ],
5917
+ [ 30, 60, 70, 50, 40, 30 ]
5918
+ ]
5431
5919
 
5432
5920
  worksheet.write('A1', headings, bold)
5433
5921
  worksheet.write('A2', data)
@@ -5443,20 +5931,20 @@ def test_chart_data_tools
5443
5931
 
5444
5932
  # Configure the first series with a polynomial trendline.
5445
5933
  chart1.add_series(
5446
- :categories => '=Sheet1!$A$2:$A$7',
5447
- :values => '=Sheet1!$B$2:$B$7',
5448
- :trendline => {
5449
- :type => 'polynomial',
5450
- :order => 3,
5451
- }
5452
- )
5934
+ :categories => '=Sheet1!$A$2:$A$7',
5935
+ :values => '=Sheet1!$B$2:$B$7',
5936
+ :trendline => {
5937
+ :type => 'polynomial',
5938
+ :order => 3,
5939
+ }
5940
+ )
5453
5941
 
5454
5942
  # Configure the second series with a moving average trendline.
5455
5943
  chart1.add_series(
5456
- :categories => '=Sheet1!$A$2:$A$7',
5457
- :values => '=Sheet1!$C$2:$C$7',
5458
- :trendline => { :type => 'linear' }
5459
- )
5944
+ :categories => '=Sheet1!$A$2:$A$7',
5945
+ :values => '=Sheet1!$C$2:$C$7',
5946
+ :trendline => { :type => 'linear' }
5947
+ )
5460
5948
 
5461
5949
  # Add a chart title. and some axis labels.
5462
5950
  chart1.set_title(:name => 'Chart with Trendlines')
@@ -5474,17 +5962,17 @@ def test_chart_data_tools
5474
5962
 
5475
5963
  # Configure the first series.
5476
5964
  chart2.add_series(
5477
- :categories => '=Sheet1!$A$2:$A$7',
5478
- :values => '=Sheet1!$B$2:$B$7',
5479
- :data_labels => { :value => 1 },
5480
- :marker => { :type => 'automatic' }
5481
- )
5965
+ :categories => '=Sheet1!$A$2:$A$7',
5966
+ :values => '=Sheet1!$B$2:$B$7',
5967
+ :data_labels => { :value => 1 },
5968
+ :marker => { :type => 'automatic' }
5969
+ )
5482
5970
 
5483
5971
  # Configure the second series.
5484
5972
  chart2.add_series(
5485
- :categories => '=Sheet1!$A$2:$A$7',
5486
- :values => '=Sheet1!$C$2:$C$7'
5487
- )
5973
+ :categories => '=Sheet1!$A$2:$A$7',
5974
+ :values => '=Sheet1!$C$2:$C$7'
5975
+ )
5488
5976
 
5489
5977
  # Add a chart title. and some axis labels.
5490
5978
  chart2.set_title(:name => 'Chart with Data Labels and Markers')
@@ -5502,16 +5990,16 @@ def test_chart_data_tools
5502
5990
 
5503
5991
  # Configure the first series.
5504
5992
  chart3.add_series(
5505
- :categories => '=Sheet1!$A$2:$A$7',
5506
- :values => '=Sheet1!$B$2:$B$7',
5507
- :y_error_bars => { :type => 'standard_error' }
5508
- )
5993
+ :categories => '=Sheet1!$A$2:$A$7',
5994
+ :values => '=Sheet1!$B$2:$B$7',
5995
+ :y_error_bars => { :type => 'standard_error' }
5996
+ )
5509
5997
 
5510
5998
  # Configure the second series.
5511
5999
  chart3.add_series(
5512
- :categories => '=Sheet1!$A$2:$A$7',
5513
- :values => '=Sheet1!$C$2:$C$7'
5514
- )
6000
+ :categories => '=Sheet1!$A$2:$A$7',
6001
+ :values => '=Sheet1!$C$2:$C$7'
6002
+ )
5515
6003
 
5516
6004
  # Add a chart title. and some axis labels.
5517
6005
  chart3.set_title(:name => 'Chart with Error Bars')
@@ -5532,15 +6020,15 @@ def test_chart_data_tools
5532
6020
 
5533
6021
  # Configure the first series.
5534
6022
  chart4.add_series(
5535
- :categories => '=Sheet1!$A$2:$A$7',
5536
- :values => '=Sheet1!$B$2:$B$7'
5537
- )
6023
+ :categories => '=Sheet1!$A$2:$A$7',
6024
+ :values => '=Sheet1!$B$2:$B$7'
6025
+ )
5538
6026
 
5539
6027
  # Configure the second series.
5540
6028
  chart4.add_series(
5541
- :categories => '=Sheet1!$A$2:$A$7',
5542
- :values => '=Sheet1!$C$2:$C$7'
5543
- )
6029
+ :categories => '=Sheet1!$A$2:$A$7',
6030
+ :values => '=Sheet1!$C$2:$C$7'
6031
+ )
5544
6032
 
5545
6033
  # Add a chart title. and some axis labels.
5546
6034
  chart4.set_title(:name => 'Chart with Up-Down Bars')
@@ -5561,15 +6049,15 @@ def test_chart_data_tools
5561
6049
 
5562
6050
  # Configure the first series.
5563
6051
  chart5.add_series(
5564
- :categories => '=Sheet1!$A$2:$A$7',
5565
- :values => '=Sheet1!$B$2:$B$7'
5566
- )
6052
+ :categories => '=Sheet1!$A$2:$A$7',
6053
+ :values => '=Sheet1!$B$2:$B$7'
6054
+ )
5567
6055
 
5568
6056
  # Configure the second series.
5569
6057
  chart5.add_series(
5570
- :categories => '=Sheet1!$A$2:$A$7',
5571
- :values => '=Sheet1!$C$2:$C$7'
5572
- )
6058
+ :categories => '=Sheet1!$A$2:$A$7',
6059
+ :values => '=Sheet1!$C$2:$C$7'
6060
+ )
5573
6061
 
5574
6062
  # Add a chart title. and some axis labels.
5575
6063
  chart5.set_title(:name => 'Chart with High-Low Lines')
@@ -5590,15 +6078,15 @@ def test_chart_data_tools
5590
6078
 
5591
6079
  # Configure the first series.
5592
6080
  chart6.add_series(
5593
- :categories => '=Sheet1!$A$2:$A$7',
5594
- :values => '=Sheet1!$B$2:$B$7'
5595
- )
6081
+ :categories => '=Sheet1!$A$2:$A$7',
6082
+ :values => '=Sheet1!$B$2:$B$7'
6083
+ )
5596
6084
 
5597
6085
  # Configure the second series.
5598
6086
  chart6.add_series(
5599
- :categories => '=Sheet1!$A$2:$A$7',
5600
- :values => '=Sheet1!$C$2:$C$7'
5601
- )
6087
+ :categories => '=Sheet1!$A$2:$A$7',
6088
+ :values => '=Sheet1!$C$2:$C$7'
6089
+ )
5602
6090
 
5603
6091
  # Add a chart title. and some axis labels.
5604
6092
  chart6.set_title(:name => 'Chart with Drop Lines')