write_xlsx 0.97.0 → 1.04.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 (313) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Changes +78 -0
  4. data/LICENSE.txt +1 -1
  5. data/README.md +2 -2
  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_table.rb +9 -3
  15. data/examples/chart_data_tools.rb +25 -7
  16. data/examples/chart_doughnut.rb +17 -5
  17. data/examples/chart_gauge.rb +73 -0
  18. data/examples/chart_line.rb +90 -12
  19. data/examples/chart_pareto.rb +1 -1
  20. data/examples/chart_pie.rb +9 -3
  21. data/examples/chart_radar.rb +13 -4
  22. data/examples/chart_scatter.rb +5 -2
  23. data/examples/chart_secondary_axis.rb +5 -2
  24. data/examples/chart_stock.rb +1 -1
  25. data/examples/chart_styles.rb +1 -1
  26. data/examples/colors.rb +1 -1
  27. data/examples/data_validate.rb +1 -1
  28. data/examples/date_time.rb +1 -1
  29. data/examples/demo.rb +4 -1
  30. data/examples/formats.rb +1 -1
  31. data/examples/headers.rb +1 -1
  32. data/examples/hide_row_col.rb +1 -1
  33. data/examples/hide_sheet.rb +1 -1
  34. data/examples/hyperlink1.rb +1 -1
  35. data/examples/indent.rb +1 -1
  36. data/examples/macros.rb +1 -1
  37. data/examples/merge1.rb +1 -1
  38. data/examples/merge2.rb +1 -1
  39. data/examples/merge3.rb +1 -1
  40. data/examples/merge4.rb +1 -1
  41. data/examples/merge5.rb +1 -1
  42. data/examples/merge6.rb +1 -1
  43. data/examples/outline.rb +1 -1
  44. data/examples/outline_collapsed.rb +1 -1
  45. data/examples/panes.rb +1 -1
  46. data/examples/properties.rb +1 -1
  47. data/examples/regions.rb +1 -1
  48. data/examples/rich_strings.rb +1 -1
  49. data/examples/right_to_left.rb +1 -1
  50. data/examples/shape1.rb +1 -1
  51. data/examples/shape2.rb +1 -1
  52. data/examples/shape3.rb +1 -1
  53. data/examples/shape4.rb +1 -1
  54. data/examples/shape5.rb +1 -1
  55. data/examples/shape6.rb +1 -1
  56. data/examples/shape7.rb +1 -1
  57. data/examples/shape8.rb +1 -1
  58. data/examples/shape_all.rb +1 -1
  59. data/examples/sparklines1.rb +1 -1
  60. data/examples/sparklines2.rb +1 -1
  61. data/examples/stats.rb +1 -1
  62. data/examples/stats_ext.rb +1 -1
  63. data/examples/stocks.rb +1 -1
  64. data/examples/tab_colors.rb +1 -1
  65. data/examples/tables.rb +78 -43
  66. data/lib/write_xlsx/chart.rb +43 -35
  67. data/lib/write_xlsx/chart/area.rb +1 -1
  68. data/lib/write_xlsx/chart/axis.rb +2 -2
  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/legend.rb +14 -0
  73. data/lib/write_xlsx/chart/line.rb +16 -2
  74. data/lib/write_xlsx/chart/pie.rb +30 -15
  75. data/lib/write_xlsx/chart/radar.rb +1 -1
  76. data/lib/write_xlsx/chart/scatter.rb +1 -1
  77. data/lib/write_xlsx/chart/stock.rb +1 -1
  78. data/lib/write_xlsx/chartsheet.rb +35 -7
  79. data/lib/write_xlsx/drawing.rb +86 -30
  80. data/lib/write_xlsx/format.rb +9 -9
  81. data/lib/write_xlsx/package/comments.rb +61 -58
  82. data/lib/write_xlsx/package/conditional_format.rb +9 -1
  83. data/lib/write_xlsx/package/relationships.rb +4 -4
  84. data/lib/write_xlsx/package/styles.rb +26 -8
  85. data/lib/write_xlsx/package/table.rb +13 -7
  86. data/lib/write_xlsx/package/vml.rb +20 -19
  87. data/lib/write_xlsx/shape.rb +4 -3
  88. data/lib/write_xlsx/sheets.rb +18 -16
  89. data/lib/write_xlsx/sparkline.rb +1 -1
  90. data/lib/write_xlsx/utility.rb +96 -7
  91. data/lib/write_xlsx/version.rb +1 -1
  92. data/lib/write_xlsx/workbook.rb +99 -49
  93. data/lib/write_xlsx/worksheet.rb +225 -145
  94. data/lib/write_xlsx/worksheet/data_validation.rb +10 -14
  95. data/lib/write_xlsx/worksheet/hyperlink.rb +16 -37
  96. data/test/chart/test_write_legend_pos.rb +9 -1
  97. data/test/chartsheet/test_write_sheet_protection.rb +91 -0
  98. data/test/drawing/test_drawing_chart_01.rb +6 -2
  99. data/test/drawing/test_drawing_image_01.rb +12 -3
  100. data/test/drawing/test_drawing_shape_01.rb +8 -5
  101. data/test/drawing/test_drawing_shape_02.rb +12 -5
  102. data/test/drawing/test_drawing_shape_03.rb +8 -5
  103. data/test/drawing/test_drawing_shape_04.rb +8 -24
  104. data/test/drawing/test_drawing_shape_05.rb +8 -5
  105. data/test/drawing/test_drawing_shape_06.rb +11 -6
  106. data/test/drawing/test_drawing_shape_07.rb +11 -6
  107. data/test/drawing/test_write_a_graphic_frame_locks.rb +1 -1
  108. data/test/drawing/test_write_c_chart.rb +1 -1
  109. data/test/drawing/test_write_c_nv_graphic_frame_pr.rb +1 -1
  110. data/test/drawing/test_write_c_nv_pr.rb +1 -1
  111. data/test/drawing/test_write_col.rb +1 -1
  112. data/test/drawing/test_write_col_off.rb +1 -1
  113. data/test/drawing/test_write_ext.rb +1 -1
  114. data/test/drawing/test_write_pos.rb +1 -1
  115. data/test/drawing/test_write_row.rb +1 -1
  116. data/test/drawing/test_write_row_off.rb +1 -1
  117. data/test/drawing/test_write_xfrm_extension.rb +1 -1
  118. data/test/drawing/test_write_xfrm_offset.rb +1 -1
  119. data/test/package/comments/test_comments_01.rb +54 -0
  120. data/test/package/comments/test_comments_02.rb +54 -0
  121. data/test/perl_output/chart_gauge.xlsx +0 -0
  122. data/test/perl_output/chart_line.xlsx +0 -0
  123. data/test/perl_output/comments2.xlsx +0 -0
  124. data/test/perl_output/formats.xlsx +0 -0
  125. data/test/perl_output/tables.xlsx +0 -0
  126. data/test/regression/images/happy.jpg +0 -0
  127. data/test/regression/images/red2.png +0 -0
  128. data/test/regression/test_array_formula03.rb +36 -0
  129. data/test/regression/test_autofilter08.rb +110 -0
  130. data/test/regression/test_autofilter09.rb +110 -0
  131. data/test/regression/test_autofilter10.rb +110 -0
  132. data/test/regression/test_chart_axis26.rb +10 -8
  133. data/test/regression/test_chart_axis27.rb +1 -1
  134. data/test/regression/test_chart_axis28.rb +1 -1
  135. data/test/regression/test_chart_axis29.rb +1 -1
  136. data/test/regression/test_chart_axis33.rb +1 -1
  137. data/test/regression/test_chart_axis42.rb +44 -0
  138. data/test/regression/test_chart_axis43.rb +44 -0
  139. data/test/regression/test_chart_axis44.rb +54 -0
  140. data/test/regression/test_chart_axis45.rb +54 -0
  141. data/test/regression/test_chart_axis46.rb +54 -0
  142. data/test/regression/test_chart_combined10.rb +43 -0
  143. data/test/regression/test_chart_combined11.rb +63 -0
  144. data/test/regression/test_chart_data_labels25.rb +1 -1
  145. data/test/regression/test_chart_doughnut07.rb +37 -0
  146. data/test/regression/test_chart_font09.rb +1 -1
  147. data/test/regression/test_chart_legend03.rb +41 -0
  148. data/test/regression/test_chart_legend04.rb +41 -0
  149. data/test/regression/test_chart_legend05.rb +41 -0
  150. data/test/regression/test_chart_legend06.rb +41 -0
  151. data/test/regression/test_chart_legend07.rb +38 -0
  152. data/test/regression/test_chart_line05.rb +43 -0
  153. data/test/regression/test_chart_line06.rb +43 -0
  154. data/test/regression/test_chart_size03.rb +4 -1
  155. data/test/regression/test_comment13.rb +36 -0
  156. data/test/regression/test_comment14.rb +29 -0
  157. data/test/regression/test_comment15.rb +28 -0
  158. data/test/regression/test_comment16.rb +34 -0
  159. data/test/regression/test_cond_format19.rb +64 -0
  160. data/test/regression/test_cond_format20.rb +43 -0
  161. data/test/regression/test_format15.rb +26 -0
  162. data/test/regression/test_header_image15.rb +36 -0
  163. data/test/regression/test_header_image16.rb +42 -0
  164. data/test/regression/test_header_image17.rb +46 -0
  165. data/test/regression/test_header_image18.rb +48 -0
  166. data/test/regression/test_header_image19.rb +36 -0
  167. data/test/regression/test_hyperlink32.rb +27 -0
  168. data/test/regression/test_hyperlink33.rb +28 -0
  169. data/test/regression/test_hyperlink34.rb +33 -0
  170. data/test/regression/test_hyperlink35.rb +39 -0
  171. data/test/regression/test_hyperlink36.rb +34 -0
  172. data/test/regression/test_hyperlink37.rb +33 -0
  173. data/test/regression/test_hyperlink38.rb +27 -0
  174. data/test/regression/test_hyperlink39.rb +27 -0
  175. data/test/regression/test_hyperlink40.rb +27 -0
  176. data/test/regression/test_hyperlink41.rb +27 -0
  177. data/test/regression/test_hyperlink42.rb +27 -0
  178. data/test/regression/test_hyperlink43.rb +27 -0
  179. data/test/regression/test_hyperlink44.rb +27 -0
  180. data/test/regression/test_hyperlink45.rb +27 -0
  181. data/test/regression/test_hyperlink47.rb +27 -0
  182. data/test/regression/test_hyperlink48.rb +31 -0
  183. data/test/regression/test_hyperlink49.rb +29 -0
  184. data/test/regression/test_image06.rb +5 -5
  185. data/test/regression/test_image08.rb +5 -4
  186. data/test/regression/test_image15.rb +4 -2
  187. data/test/regression/test_image28.rb +1 -1
  188. data/test/regression/test_image36.rb +26 -0
  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_table23.rb +56 -0
  217. data/test/regression/test_table24.rb +27 -0
  218. data/test/regression/test_table25.rb +27 -0
  219. data/test/regression/xlsx_files/array_formula03.xlsx +0 -0
  220. data/test/regression/xlsx_files/autofilter08.xlsx +0 -0
  221. data/test/regression/xlsx_files/autofilter09.xlsx +0 -0
  222. data/test/regression/xlsx_files/autofilter10.xlsx +0 -0
  223. data/test/regression/xlsx_files/chart_axis26.xlsx +0 -0
  224. data/test/regression/xlsx_files/chart_axis27.xlsx +0 -0
  225. data/test/regression/xlsx_files/chart_axis28.xlsx +0 -0
  226. data/test/regression/xlsx_files/chart_axis29.xlsx +0 -0
  227. data/test/regression/xlsx_files/chart_axis33.xlsx +0 -0
  228. data/test/regression/xlsx_files/chart_axis42.xlsx +0 -0
  229. data/test/regression/xlsx_files/chart_axis43.xlsx +0 -0
  230. data/test/regression/xlsx_files/chart_axis44.xlsx +0 -0
  231. data/test/regression/xlsx_files/chart_axis45.xlsx +0 -0
  232. data/test/regression/xlsx_files/chart_axis46.xlsx +0 -0
  233. data/test/regression/xlsx_files/chart_combined10.xlsx +0 -0
  234. data/test/regression/xlsx_files/chart_combined11.xlsx +0 -0
  235. data/test/regression/xlsx_files/chart_data_labels25.xlsx +0 -0
  236. data/test/regression/xlsx_files/chart_doughnut07.xlsx +0 -0
  237. data/test/regression/xlsx_files/chart_font09.xlsx +0 -0
  238. data/test/regression/xlsx_files/chart_legend03.xlsx +0 -0
  239. data/test/regression/xlsx_files/chart_legend04.xlsx +0 -0
  240. data/test/regression/xlsx_files/chart_legend05.xlsx +0 -0
  241. data/test/regression/xlsx_files/chart_legend06.xlsx +0 -0
  242. data/test/regression/xlsx_files/chart_legend07.xlsx +0 -0
  243. data/test/regression/xlsx_files/chart_line05.xlsx +0 -0
  244. data/test/regression/xlsx_files/chart_line06.xlsx +0 -0
  245. data/test/regression/xlsx_files/comment13.xlsx +0 -0
  246. data/test/regression/xlsx_files/comment14.xlsx +0 -0
  247. data/test/regression/xlsx_files/comment15.xlsx +0 -0
  248. data/test/regression/xlsx_files/comment16.xlsx +0 -0
  249. data/test/regression/xlsx_files/cond_format19.xlsx +0 -0
  250. data/test/regression/xlsx_files/cond_format20.xlsx +0 -0
  251. data/test/regression/xlsx_files/format15.xlsx +0 -0
  252. data/test/regression/xlsx_files/header_image15.xlsx +0 -0
  253. data/test/regression/xlsx_files/header_image16.xlsx +0 -0
  254. data/test/regression/xlsx_files/header_image17.xlsx +0 -0
  255. data/test/regression/xlsx_files/header_image18.xlsx +0 -0
  256. data/test/regression/xlsx_files/header_image19.xlsx +0 -0
  257. data/test/regression/xlsx_files/hyperlink32.xlsx +0 -0
  258. data/test/regression/xlsx_files/hyperlink33.xlsx +0 -0
  259. data/test/regression/xlsx_files/hyperlink34.xlsx +0 -0
  260. data/test/regression/xlsx_files/hyperlink35.xlsx +0 -0
  261. data/test/regression/xlsx_files/hyperlink36.xlsx +0 -0
  262. data/test/regression/xlsx_files/hyperlink37.xlsx +0 -0
  263. data/test/regression/xlsx_files/hyperlink38.xlsx +0 -0
  264. data/test/regression/xlsx_files/hyperlink39.xlsx +0 -0
  265. data/test/regression/xlsx_files/hyperlink40.xlsx +0 -0
  266. data/test/regression/xlsx_files/hyperlink41.xlsx +0 -0
  267. data/test/regression/xlsx_files/hyperlink42.xlsx +0 -0
  268. data/test/regression/xlsx_files/hyperlink43.xlsx +0 -0
  269. data/test/regression/xlsx_files/hyperlink44.xlsx +0 -0
  270. data/test/regression/xlsx_files/hyperlink45.xlsx +0 -0
  271. data/test/regression/xlsx_files/hyperlink46.xlsx +0 -0
  272. data/test/regression/xlsx_files/hyperlink47.xlsx +0 -0
  273. data/test/regression/xlsx_files/hyperlink48.xlsx +0 -0
  274. data/test/regression/xlsx_files/hyperlink49.xlsx +0 -0
  275. data/test/regression/xlsx_files/image06.xlsx +0 -0
  276. data/test/regression/xlsx_files/image36.xlsx +0 -0
  277. data/test/regression/xlsx_files/image44.xlsx +0 -0
  278. data/test/regression/xlsx_files/image45.xlsx +0 -0
  279. data/test/regression/xlsx_files/image46.xlsx +0 -0
  280. data/test/regression/xlsx_files/image47.xlsx +0 -0
  281. data/test/regression/xlsx_files/image48.xlsx +0 -0
  282. data/test/regression/xlsx_files/image49.xlsx +0 -0
  283. data/test/regression/xlsx_files/image50.xlsx +0 -0
  284. data/test/regression/xlsx_files/image51.xlsx +0 -0
  285. data/test/regression/xlsx_files/object_position01.xlsx +0 -0
  286. data/test/regression/xlsx_files/object_position02.xlsx +0 -0
  287. data/test/regression/xlsx_files/object_position03.xlsx +0 -0
  288. data/test/regression/xlsx_files/object_position04.xlsx +0 -0
  289. data/test/regression/xlsx_files/object_position06.xlsx +0 -0
  290. data/test/regression/xlsx_files/object_position07.xlsx +0 -0
  291. data/test/regression/xlsx_files/object_position08.xlsx +0 -0
  292. data/test/regression/xlsx_files/object_position09.xlsx +0 -0
  293. data/test/regression/xlsx_files/object_position10.xlsx +0 -0
  294. data/test/regression/xlsx_files/object_position12.xlsx +0 -0
  295. data/test/regression/xlsx_files/object_position13.xlsx +0 -0
  296. data/test/regression/xlsx_files/object_position14.xlsx +0 -0
  297. data/test/regression/xlsx_files/object_position15.xlsx +0 -0
  298. data/test/regression/xlsx_files/object_position16.xlsx +0 -0
  299. data/test/regression/xlsx_files/object_position17.xlsx +0 -0
  300. data/test/regression/xlsx_files/object_position18.xlsx +0 -0
  301. data/test/regression/xlsx_files/object_position19.xlsx +0 -0
  302. data/test/regression/xlsx_files/object_position20.xlsx +0 -0
  303. data/test/regression/xlsx_files/table23.xlsx +0 -0
  304. data/test/regression/xlsx_files/table24.xlsx +0 -0
  305. data/test/regression/xlsx_files/table25.xlsx +0 -0
  306. data/test/test_example_match.rb +955 -780
  307. data/test/workbook/test_check_sheetname.rb +51 -0
  308. data/test/workbook/test_write_workbook_view.rb +36 -0
  309. data/test/worksheet/test_write_data_validation_02.rb +17 -0
  310. data/test/worksheet/test_write_sheet_view.rb +19 -1
  311. data/write_xlsx.gemspec +1 -0
  312. metadata +349 -7
  313. data/test/package/comments/test_write_text_t.rb +0 -44
@@ -0,0 +1,29 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionObjectPosition19 < Minitest::Test
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ @tempfile.close(true)
11
+ end
12
+
13
+ def test_object_position19
14
+ @xlsx = 'object_position19.xlsx'
15
+ workbook = WriteXLSX.new(@io)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ worksheet.set_column(1, 1, nil, nil, 1)
19
+
20
+ # Same as testcase test_object_position13 except with an offset.
21
+ worksheet.insert_image(
22
+ 'B9', 'test/regression/images/red.png',
23
+ :x_offset => 128
24
+ )
25
+
26
+ workbook.close
27
+ compare_for_regression
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionObjectPosition20 < Minitest::Test
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ @tempfile.close(true)
11
+ end
12
+
13
+ def test_object_position20
14
+ @xlsx = 'object_position20.xlsx'
15
+ workbook = WriteXLSX.new(@io)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ worksheet.set_column(1, 1, 5, nil, 1)
19
+
20
+ # Same as testcase test_object_position14 except with an offset.
21
+ worksheet.insert_image(
22
+ 'B9', 'test/regression/images/red.png',
23
+ :x_offset => 128
24
+ )
25
+
26
+ workbook.close
27
+ compare_for_regression
28
+ end
29
+ end
@@ -17,8 +17,10 @@ def test_shape_connect01
17
17
  format = workbook.add_format(:font => 'Arial', :size => 8)
18
18
 
19
19
  # Add a circle, with centered text
20
- ellipse = workbook.add_shape(:type => 'ellipse', :text => "Hello\nWorld",
21
- :width => 60, :height => 60, :format => format)
20
+ ellipse = workbook.add_shape(
21
+ :type => 'ellipse', :text => "Hello\nWorld",
22
+ :width => 60, :height => 60, :format => format
23
+ )
22
24
  worksheet.insert_shape('A1', ellipse, 50, 50)
23
25
 
24
26
  # Add a plus
@@ -0,0 +1,56 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionTable23 < Minitest::Test
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ @tempfile.close(true) if @tempfile
11
+ end
12
+
13
+ def test_table23
14
+ @xlsx = 'table23.xlsx'
15
+ workbook = WriteXLSX.new(@io)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ # Set the column width to match the target worksheet.
19
+ worksheet.set_column('B:F', 10.288)
20
+
21
+ # Write some strings to order the string table.
22
+ worksheet.write_string('A1', 'Column1')
23
+ worksheet.write_string('F1', 'Total')
24
+ worksheet.write_string('B1', "Column'")
25
+ worksheet.write_string('C1', 'Column#')
26
+ worksheet.write_string('D1', 'Column[')
27
+ worksheet.write_string('E1', 'Column]')
28
+
29
+ # Populate the data range.
30
+ # data = [0, 0, 0, nil, nil, 0, 0, 0, 0, 0]
31
+ # worksheet.write_row('B4', data)
32
+ # worksheet.write_row('B5', data)
33
+
34
+
35
+ # Add the table.
36
+ worksheet.add_table(
37
+ 'B3:F9',
38
+ {
39
+ :total_row => 1,
40
+ :columns => [
41
+ { :header => 'Column1', :total_string => 'Total' },
42
+ { :header => "Column'", :total_function => 'sum' },
43
+ { :header => 'Column#', :total_function => 'sum' },
44
+ { :header => 'Column[', :total_function => 'sum' },
45
+ { :header => 'Column]', :total_function => 'sum' },
46
+ ]
47
+ }
48
+ )
49
+
50
+ workbook.close
51
+ compare_for_regression(
52
+ [ 'xl/calcChain.xml', '[Content_Types].xml', 'xl/_rels/workbook.xml.rels' ],
53
+ { 'xl/workbook.xml' => ['<workbookView'] }
54
+ )
55
+ end
56
+ end
@@ -0,0 +1,27 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionTable24 < Minitest::Test
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ @tempfile.close(true) if @tempfile
11
+ end
12
+
13
+ def test_table24
14
+ @xlsx = 'table24.xlsx'
15
+ workbook = WriteXLSX.new(@io)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ # Set the column width to match the target worksheet.
19
+ worksheet.set_column('C:F', 10.288)
20
+
21
+ # Add the table.
22
+ worksheet.add_table('C3:F13', {:style => 'Table Style Medium 10'})
23
+
24
+ workbook.close
25
+ compare_for_regression
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionTable25 < Minitest::Test
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ @tempfile.close(true) if @tempfile
11
+ end
12
+
13
+ def test_table25
14
+ @xlsx = 'table25.xlsx'
15
+ workbook = WriteXLSX.new(@io)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ # Set the column width to match the target worksheet.
19
+ worksheet.set_column('C:F', 10.288)
20
+
21
+ # Add the table.
22
+ worksheet.add_table('C3:F13', {:style => 'None'})
23
+
24
+ workbook.close
25
+ compare_for_regression
26
+ end
27
+ end
@@ -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,68 @@ def test_autofilter
242
242
  compare_xlsx(File.join(@perl_output, @xlsx), @tempfile.path)
243
243
  end
244
244
 
245
+ def test_chart_gauge
246
+ @xlsx = 'chart_gauge.xlsx'
247
+ workbook = WriteXLSX.new(@io)
248
+ worksheet = workbook.add_worksheet
249
+
250
+ chart_doughnut = workbook.add_chart(:type => 'doughnut', :embedded => 1)
251
+ chart_pie = workbook.add_chart(:type => 'pie', :embedded => 1)
252
+
253
+ # Add some data for the Doughnut and Pie charts. This is set up so the
254
+ # gauge goes from 0-100. It is initially set at 75%.
255
+ worksheet.write_col('H2', ['Donut', 25, 50, 25, 100])
256
+ worksheet.write_col('I2', ['Pie', 75, 1, '=200-I4-I3'])
257
+
258
+ # Configure the doughnut chart as the background for the gauge.
259
+ chart_doughnut.add_series(
260
+ :name => '=Sheet1!$H$2',
261
+ :values => '=Sheet1!$H$3:$H$6',
262
+ :points => [
263
+ { :fill => { :color => 'green' } },
264
+ { :fill => { :color => 'yellow' } },
265
+ { :fill => { :color => 'red' } },
266
+ { :fill => { :none => 1 } }
267
+ ]
268
+ )
269
+
270
+ # Rotate chart so the gauge parts are above the horizontal.
271
+ chart_doughnut.set_rotation(270)
272
+
273
+ # Turn off the chart legend.
274
+ chart_doughnut.set_legend(:none => 1)
275
+
276
+ # Turn off the chart fill and border.
277
+ chart_doughnut.set_chartarea(
278
+ :border => { :none => 1 },
279
+ :fill => { :none => 1 }
280
+ )
281
+
282
+ # Configure the pie chart as the needle for the gauge.
283
+ chart_pie.add_series(
284
+ :name => '=Sheet1!$I$2',
285
+ :values => '=Sheet1!$I$3:$I$6',
286
+ :points => [
287
+ { :fill => { :none => 1 } },
288
+ { :fill => { :color => 'black' } },
289
+ { :fill => { :none => 1 } }
290
+ ]
291
+ )
292
+
293
+ # Rotate the pie chart/needle to align with the doughnut/gauge.
294
+ chart_pie.set_rotation(270)
295
+
296
+ # Combine the pie and doughnut charts.
297
+ chart_doughnut.combine(chart_pie)
298
+
299
+ # Insert the chart into the worksheet.
300
+ worksheet.insert_chart('A1', chart_doughnut)
301
+
302
+ workbook.close
303
+ store_to_tempfile
304
+ compare_xlsx(File.join(@perl_output, @xlsx), @tempfile.path)
305
+ end
306
+
245
307
  def test_chart_scatter06
246
308
  @xlsx = 'chart_scatter06.xlsx'
247
309
  workbook = WriteXLSX.new(@io)
@@ -252,23 +314,23 @@ def test_chart_scatter06
252
314
  chart.instance_variable_set(:@axis_ids, [57708544, 44297600])
253
315
 
254
316
  data = [
255
- [ 1, 2, 3, 4, 5 ],
256
- [ 2, 4, 6, 8, 10 ],
257
- [ 3, 6, 9, 12, 15 ]
317
+ [ 1, 2, 3, 4, 5 ],
318
+ [ 2, 4, 6, 8, 10 ],
319
+ [ 3, 6, 9, 12, 15 ]
258
320
 
259
- ]
321
+ ]
260
322
 
261
323
  worksheet.write('A1', data)
262
324
 
263
325
  chart.add_series(
264
- :categories => '=Sheet1!$A$1:$A$5',
265
- :values => '=Sheet1!$B$1:$B$5'
266
- )
326
+ :categories => '=Sheet1!$A$1:$A$5',
327
+ :values => '=Sheet1!$B$1:$B$5'
328
+ )
267
329
 
268
330
  chart.add_series(
269
- :categories => '=Sheet1!$A$1:$A$5',
270
- :values => '=Sheet1!$C$1:$C$5'
271
- )
331
+ :categories => '=Sheet1!$A$1:$A$5',
332
+ :values => '=Sheet1!$C$1:$C$5'
333
+ )
272
334
 
273
335
  chart.set_x_axis(:minor_unit => 1, :major_unit => 3)
274
336
  chart.set_y_axis(:minor_unit => 2, :major_unit => 4)
@@ -281,7 +343,7 @@ def test_chart_scatter06
281
343
  end
282
344
 
283
345
  def autofilter_data
284
- <<EOS
346
+ <<EOS
285
347
  Region Item Volume Month
286
348
  East Apple 9000 July
287
349
  East Apple 5000 July
@@ -345,10 +407,10 @@ def test_chart_area
345
407
  # Add the worksheet data that the charts will refer to.
346
408
  headings = [ 'Number', 'Batch 1', 'Batch 2' ]
347
409
  data = [
348
- [ 2, 3, 4, 5, 6, 7 ],
349
- [ 40, 40, 50, 30, 25, 50 ],
350
- [ 30, 25, 30, 10, 5, 10 ]
351
- ]
410
+ [ 2, 3, 4, 5, 6, 7 ],
411
+ [ 40, 40, 50, 30, 25, 50 ],
412
+ [ 30, 25, 30, 10, 5, 10 ]
413
+ ]
352
414
 
353
415
  worksheet.write('A1', headings, bold)
354
416
  worksheet.write('A2', data)
@@ -358,18 +420,18 @@ def test_chart_area
358
420
 
359
421
  # Configure the first series.
360
422
  chart.add_series(
361
- :name => '=Sheet1!$B$1',
362
- :categories => '=Sheet1!$A$2:$A$7',
363
- :values => '=Sheet1!$B$2:$B$7'
364
- )
423
+ :name => '=Sheet1!$B$1',
424
+ :categories => '=Sheet1!$A$2:$A$7',
425
+ :values => '=Sheet1!$B$2:$B$7'
426
+ )
365
427
 
366
428
  # Configure second series. Note alternative use of array ref to define
367
429
  # ranges: [ sheetname, row_start, row_end, col_start, col_end ].
368
430
  chart.add_series(
369
- :name => '=Sheet1!$C$1',
370
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
371
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
372
- )
431
+ :name => '=Sheet1!$C$1',
432
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
433
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
434
+ )
373
435
 
374
436
  # Add a chart title and some axis labels.
375
437
  chart.set_title(:name => 'Results of sample analysis')
@@ -396,9 +458,9 @@ def test_chart_bar
396
458
  # Add the worksheet data that the charts will refer to.
397
459
  headings = [ 'Number', 'Batch 1', 'Batch 2' ]
398
460
  data = [
399
- [ 2, 3, 4, 5, 6, 7 ],
400
- [ 10, 40, 50, 20, 10, 50 ],
401
- [ 30, 60, 70, 50, 40, 30 ]
461
+ [ 2, 3, 4, 5, 6, 7 ],
462
+ [ 10, 40, 50, 20, 10, 50 ],
463
+ [ 30, 60, 70, 50, 40, 30 ]
402
464
  ]
403
465
 
404
466
  worksheet.write('A1', headings, bold)
@@ -409,17 +471,17 @@ def test_chart_bar
409
471
 
410
472
  # Configure the first series.
411
473
  chart.add_series(
412
- :name => '=Sheet1!$B$1',
413
- :categories => '=Sheet1!$A$2:$A$7',
414
- :values => '=Sheet1!$B$2:$B$7'
474
+ :name => '=Sheet1!$B$1',
475
+ :categories => '=Sheet1!$A$2:$A$7',
476
+ :values => '=Sheet1!$B$2:$B$7'
415
477
  )
416
478
 
417
479
  # Configure second series. Note alternative use of array ref to define
418
480
  # ranges: [ sheetname, row_start, row_end, col_start, col_end ].
419
481
  chart.add_series(
420
- :name => '=Sheet1!$C$1',
421
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
422
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
482
+ :name => '=Sheet1!$C$1',
483
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
484
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
423
485
  )
424
486
 
425
487
  # Add a chart title and some axis labels.
@@ -447,9 +509,9 @@ def test_chart_column
447
509
  # Add the worksheet data that the charts will refer to.
448
510
  headings = [ 'Number', 'Batch 1', 'Batch 2' ]
449
511
  data = [
450
- [ 2, 3, 4, 5, 6, 7 ],
451
- [ 10, 40, 50, 20, 10, 50 ],
452
- [ 30, 60, 70, 50, 40, 30 ]
512
+ [ 2, 3, 4, 5, 6, 7 ],
513
+ [ 10, 40, 50, 20, 10, 50 ],
514
+ [ 30, 60, 70, 50, 40, 30 ]
453
515
  ]
454
516
 
455
517
  worksheet.write('A1', headings, bold)
@@ -460,17 +522,17 @@ def test_chart_column
460
522
 
461
523
  # Configure the first series.
462
524
  chart.add_series(
463
- :name => '=Sheet1!$B$1',
464
- :categories => '=Sheet1!$A$2:$A$7',
465
- :values => '=Sheet1!$B$2:$B$7'
525
+ :name => '=Sheet1!$B$1',
526
+ :categories => '=Sheet1!$A$2:$A$7',
527
+ :values => '=Sheet1!$B$2:$B$7'
466
528
  )
467
529
 
468
530
  # Configure second series. Note alternative use of array ref to define
469
531
  # ranges: [ sheetname, row_start, row_end, col_start, col_end ].
470
532
  chart.add_series(
471
- :name => '=Sheet1!$C$1',
472
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
473
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
533
+ :name => '=Sheet1!$C$1',
534
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
535
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
474
536
  )
475
537
 
476
538
  # Add a chart title and some axis labels.
@@ -498,9 +560,9 @@ def test_chart_doughnut
498
560
  # Add the worksheet data that the charts will refer to.
499
561
  headings = [ 'Category', 'Values' ]
500
562
  data = [
501
- [ 'Glazed', 'Chocolate', 'Cream' ],
502
- [ 50, 35, 15 ]
503
- ]
563
+ [ 'Glazed', 'Chocolate', 'Cream' ],
564
+ [ 50, 35, 15 ]
565
+ ]
504
566
 
505
567
  worksheet.write('A1', headings, bold)
506
568
  worksheet.write('A2', data)
@@ -512,10 +574,10 @@ def test_chart_doughnut
512
574
  # [ $sheetname, $row_start, $row_end, $col_start, $col_end ].
513
575
  # See below for an alternative syntax.
514
576
  chart1.add_series(
515
- :name => 'Doughnut sales data',
516
- :categories => [ 'Sheet1', 1, 3, 0, 0 ],
517
- :values => [ 'Sheet1', 1, 3, 1, 1 ]
518
- );
577
+ :name => 'Doughnut sales data',
578
+ :categories => [ 'Sheet1', 1, 3, 0, 0 ],
579
+ :values => [ 'Sheet1', 1, 3, 1, 1 ]
580
+ );
519
581
 
520
582
  # Add a title.
521
583
  chart1.set_title(:name => 'Popular Doughnut Types')
@@ -536,15 +598,15 @@ def test_chart_doughnut
536
598
 
537
599
  # Configure the series and add user defined segment colours.
538
600
  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
- )
601
+ :name => 'Doughnut sales data',
602
+ :categories => '=Sheet1!$A$2:$A$4',
603
+ :values => '=Sheet1!$B$2:$B$4',
604
+ :points => [
605
+ { :fill => { :color => '#FA58D0' } },
606
+ { :fill => { :color => '#61210B' } },
607
+ { :fill => { :color => '#F5F6CE' } }
608
+ ]
609
+ )
548
610
 
549
611
  # Add a title.
550
612
  chart2.set_title(:name => 'Doughnut Chart with user defined colors')
@@ -563,10 +625,10 @@ def test_chart_doughnut
563
625
 
564
626
  # Configure the series.
565
627
  chart3.add_series(
566
- :name => 'Doughnut sales data',
567
- :categories => '=Sheet1!$A$2:$A$4',
568
- :values => '=Sheet1!$B$2:$B$4'
569
- )
628
+ :name => 'Doughnut sales data',
629
+ :categories => '=Sheet1!$A$2:$A$4',
630
+ :values => '=Sheet1!$B$2:$B$4'
631
+ )
570
632
 
571
633
  # Add a title.
572
634
  chart3.set_title(:name => 'Doughnut Chart with segment rotation')
@@ -587,10 +649,10 @@ def test_chart_doughnut
587
649
 
588
650
  # Configure the series.
589
651
  chart4.add_series(
590
- :name => 'Doughnut sales data',
591
- :categories => '=Sheet1!$A$2:$A$4',
592
- :values => '=Sheet1!$B$2:$B$4'
593
- )
652
+ :name => 'Doughnut sales data',
653
+ :categories => '=Sheet1!$A$2:$A$4',
654
+ :values => '=Sheet1!$B$2:$B$4'
655
+ )
594
656
 
595
657
  # Add a title.
596
658
  chart4.set_title(:name => 'Doughnut Chart with user defined hole size')
@@ -615,9 +677,9 @@ def test_chart_line
615
677
  # Add the worksheet data that the charts will refer to.
616
678
  headings = [ 'Number', 'Batch 1', 'Batch 2' ]
617
679
  data = [
618
- [ 2, 3, 4, 5, 6, 7 ],
619
- [ 10, 40, 50, 20, 10, 50 ],
620
- [ 30, 60, 70, 50, 40, 30 ]
680
+ [ 2, 3, 4, 5, 6, 7 ],
681
+ [ 10, 40, 50, 20, 10, 50 ],
682
+ [ 30, 60, 70, 50, 40, 30 ]
621
683
  ]
622
684
 
623
685
  worksheet.write('A1', headings, bold)
@@ -628,17 +690,17 @@ def test_chart_line
628
690
 
629
691
  # Configure the first series.
630
692
  chart.add_series(
631
- :name => '=Sheet1!$B$1',
632
- :categories => '=Sheet1!$A$2:$A$7',
633
- :values => '=Sheet1!$B$2:$B$7'
693
+ :name => '=Sheet1!$B$1',
694
+ :categories => '=Sheet1!$A$2:$A$7',
695
+ :values => '=Sheet1!$B$2:$B$7'
634
696
  )
635
697
 
636
698
  # Configure second series. Note alternative use of array ref to define
637
699
  # ranges: [ sheetname, row_start, row_end, col_start, col_end ].
638
700
  chart.add_series(
639
- :name => '=Sheet1!$C$1',
640
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
641
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
701
+ :name => '=Sheet1!$C$1',
702
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
703
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
642
704
  )
643
705
 
644
706
  # Add a chart title and some axis labels.
@@ -652,6 +714,81 @@ def test_chart_line
652
714
  # Insert the chart into the worksheet (with an offset).
653
715
  worksheet.insert_chart('D2', chart, 25, 10)
654
716
 
717
+ #
718
+ # Create a stacked chart sub-type
719
+ #
720
+ chart2 = workbook.add_chart(
721
+ :type => 'line',
722
+ :embedded => 1,
723
+ :subtype => 'stacked'
724
+ )
725
+
726
+ # Configure the first series.
727
+ chart2.add_series(
728
+ :name => '=Sheet1!$B$1',
729
+ :categories => '=Sheet1!$A$2:$A$7',
730
+ :values => '=Sheet1!$B$2:$B$7'
731
+ )
732
+
733
+ # Configure second series.
734
+ chart2.add_series(
735
+ :name => '=Sheet1!$C$1',
736
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
737
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
738
+ )
739
+
740
+ # Add a chart title and some axis labels.
741
+ chart2.set_title( :name => 'Stacked Chart' )
742
+ chart2.set_x_axis( :name => 'Test number' )
743
+ chart2.set_y_axis( :name => 'Sample length (mm)' )
744
+
745
+ # Set an Excel chart style. Blue colors with white outline and shadow.
746
+ chart2.set_style( 12 )
747
+
748
+ # Insert the chart into the worksheet (with an offset).
749
+ worksheet.insert_chart(
750
+ 'D18', chart2,
751
+ { :x_offset => 25, :y_offset => 10 }
752
+ )
753
+
754
+
755
+ #
756
+ # Create a percent stacked chart sub-type
757
+ #
758
+ chart3 = workbook.add_chart(
759
+ :type => 'line',
760
+ :embedded => 1,
761
+ :subtype => 'percent_stacked'
762
+ )
763
+
764
+ # Configure the first series.
765
+ chart3.add_series(
766
+ :name => '=Sheet1!$B$1',
767
+ :categories => '=Sheet1!$A$2:$A$7',
768
+ :values => '=Sheet1!$B$2:$B$7'
769
+ )
770
+
771
+ # Configure second series.
772
+ chart3.add_series(
773
+ :name => '=Sheet1!$C$1',
774
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
775
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
776
+ )
777
+
778
+ # Add a chart title and some axis labels.
779
+ chart3.set_title( :name => 'Percent Stacked Chart' )
780
+ chart3.set_x_axis( :name => 'Test number' )
781
+ chart3.set_y_axis( :name => 'Sample length (mm)' )
782
+
783
+ # Set an Excel chart style. Blue colors with white outline and shadow.
784
+ chart3.set_style( 13 )
785
+
786
+ # Insert the chart into the worksheet (with an offset).
787
+ worksheet.insert_chart(
788
+ 'D34', chart3,
789
+ { :x_offset => 25, :y_offset => 10 }
790
+ )
791
+
655
792
  workbook.close
656
793
  store_to_tempfile
657
794
  compare_xlsx(File.join(@perl_output, @xlsx), @tempfile.path)
@@ -666,9 +803,9 @@ def test_chart_pie
666
803
  # Add the worksheet data that the charts will refer to.
667
804
  headings = [ 'Category', 'Values' ]
668
805
  data = [
669
- [ 'Apple', 'Cherry', 'Pecan' ],
670
- [ 60, 30, 10 ]
671
- ]
806
+ [ 'Apple', 'Cherry', 'Pecan' ],
807
+ [ 60, 30, 10 ]
808
+ ]
672
809
 
673
810
  worksheet.write('A1', headings, bold)
674
811
  worksheet.write('A2', data)
@@ -680,10 +817,10 @@ def test_chart_pie
680
817
  # [ $sheetname, $row_start, $row_end, $col_start, $col_end ].
681
818
  # See below for an alternative syntax.
682
819
  chart1.add_series(
683
- :name => 'Pie sales data',
684
- :categories => [ 'Sheet1', 1, 3, 0, 0 ],
685
- :values => [ 'Sheet1', 1, 3, 1, 1 ]
686
- )
820
+ :name => 'Pie sales data',
821
+ :categories => [ 'Sheet1', 1, 3, 0, 0 ],
822
+ :values => [ 'Sheet1', 1, 3, 1, 1 ]
823
+ )
687
824
 
688
825
  # Add a title.
689
826
  chart1.set_title(:name => 'Popular Pie Types')
@@ -703,15 +840,15 @@ def test_chart_pie
703
840
 
704
841
  # Configure the series and add user defined segment colours.
705
842
  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
- )
843
+ :name => 'Pie sales data',
844
+ :categories => '=Sheet1!$A$2:$A$4',
845
+ :values => '=Sheet1!$B$2:$B$4',
846
+ :points => [
847
+ { :fill => { :color => '#5ABA10' } },
848
+ { :fill => { :color => '#FE110E' } },
849
+ { :fill => { :color => '#CA5C05' } }
850
+ ]
851
+ )
715
852
 
716
853
  # Add a title.
717
854
  chart2.set_title(:name => 'Pie Chart with user defined colors')
@@ -733,10 +870,10 @@ def test_chart_radar
733
870
  # Add the worksheet data that the charts will refer to.
734
871
  headings = [ 'Number', 'Batch 1', 'Batch 2' ]
735
872
  data = [
736
- [ 2, 3, 4, 5, 6, 7 ],
737
- [ 30, 60, 70, 50, 40, 30 ],
738
- [ 25, 40, 50, 30, 50, 40 ]
739
- ]
873
+ [ 2, 3, 4, 5, 6, 7 ],
874
+ [ 30, 60, 70, 50, 40, 30 ],
875
+ [ 25, 40, 50, 30, 50, 40 ]
876
+ ]
740
877
 
741
878
  worksheet.write('A1', headings, bold)
742
879
  worksheet.write('A2', data)
@@ -746,18 +883,18 @@ def test_chart_radar
746
883
 
747
884
  # Configure the first series.
748
885
  chart1.add_series(
749
- :name => '=Sheet1!$B$1',
750
- :categories => '=Sheet1!$A$2:$A$7',
751
- :values => '=Sheet1!$B$2:$B$7'
752
- )
886
+ :name => '=Sheet1!$B$1',
887
+ :categories => '=Sheet1!$A$2:$A$7',
888
+ :values => '=Sheet1!$B$2:$B$7'
889
+ )
753
890
 
754
891
  # Configure second series. Note alternative use of array ref to define
755
892
  # ranges: [ sheetname, row_start, row_end, col_start, col_end ].
756
893
  chart1.add_series(
757
- :name => '=Sheet1!$C$1',
758
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
759
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
760
- )
894
+ :name => '=Sheet1!$C$1',
895
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
896
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
897
+ )
761
898
 
762
899
  # Add a chart title and some axis labels.
763
900
  chart1.set_title(:name => 'Results of sample analysis')
@@ -774,24 +911,24 @@ def test_chart_radar
774
911
  # Create a with_markers chart sub-type
775
912
  #
776
913
  chart2 = workbook.add_chart(
777
- :type => 'radar',
778
- :embedded => 1,
779
- :subtype => 'with_markers'
780
- )
914
+ :type => 'radar',
915
+ :embedded => 1,
916
+ :subtype => 'with_markers'
917
+ )
781
918
 
782
919
  # Configure the first series.
783
920
  chart2.add_series(
784
- :name => '=Sheet1!$B$1',
785
- :categories => '=Sheet1!$A$2:$A$7',
786
- :values => '=Sheet1!$B$2:$B$7'
787
- )
921
+ :name => '=Sheet1!$B$1',
922
+ :categories => '=Sheet1!$A$2:$A$7',
923
+ :values => '=Sheet1!$B$2:$B$7'
924
+ )
788
925
 
789
926
  # Configure second series.
790
927
  chart2.add_series(
791
- :name => '=Sheet1!$C$1',
792
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
793
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
794
- )
928
+ :name => '=Sheet1!$C$1',
929
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
930
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
931
+ )
795
932
 
796
933
  # Add a chart title and some axis labels.
797
934
  chart2.set_title(:name => 'Stacked Chart')
@@ -808,24 +945,24 @@ def test_chart_radar
808
945
  # Create a filled chart sub-type
809
946
  #
810
947
  chart3 = workbook.add_chart(
811
- :type => 'radar',
812
- :embedded => 1,
813
- :subtype => 'filled'
814
- )
948
+ :type => 'radar',
949
+ :embedded => 1,
950
+ :subtype => 'filled'
951
+ )
815
952
 
816
953
  # Configure the first series.
817
954
  chart3.add_series(
818
- :name => '=Sheet1!$B$1',
819
- :categories => '=Sheet1!$A$2:$A$7',
820
- :values => '=Sheet1!$B$2:$B$7'
821
- )
955
+ :name => '=Sheet1!$B$1',
956
+ :categories => '=Sheet1!$A$2:$A$7',
957
+ :values => '=Sheet1!$B$2:$B$7'
958
+ )
822
959
 
823
960
  # Configure second series.
824
961
  chart3.add_series(
825
- :name => '=Sheet1!$C$1',
826
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
827
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
828
- )
962
+ :name => '=Sheet1!$C$1',
963
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
964
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
965
+ )
829
966
 
830
967
  # Add a chart title and some axis labels.
831
968
  chart3.set_title(:name => 'Percent Stacked Chart')
@@ -852,9 +989,9 @@ def test_chart_scatter
852
989
  # Add the worksheet data that the charts will refer to.
853
990
  headings = [ 'Number', 'Batch 1', 'Batch 2' ]
854
991
  data = [
855
- [ 2, 3, 4, 5, 6, 7 ],
856
- [ 10, 40, 50, 20, 10, 50 ],
857
- [ 30, 60, 70, 50, 40, 30 ]
992
+ [ 2, 3, 4, 5, 6, 7 ],
993
+ [ 10, 40, 50, 20, 10, 50 ],
994
+ [ 30, 60, 70, 50, 40, 30 ]
858
995
  ]
859
996
 
860
997
  worksheet.write('A1', headings, bold)
@@ -865,17 +1002,17 @@ def test_chart_scatter
865
1002
 
866
1003
  # Configure the first series.
867
1004
  chart.add_series(
868
- :name => '=Sheet1!$B$1',
869
- :categories => '=Sheet1!$A$2:$A$7',
870
- :values => '=Sheet1!$B$2:$B$7'
1005
+ :name => '=Sheet1!$B$1',
1006
+ :categories => '=Sheet1!$A$2:$A$7',
1007
+ :values => '=Sheet1!$B$2:$B$7'
871
1008
  )
872
1009
 
873
1010
  # Configure second series. Note alternative use of array ref to define
874
1011
  # ranges: [ $sheetname, $row_start, $row_end, $col_start, $col_end ].$chart->add_series(
875
1012
  chart.add_series(
876
- :name => '=Sheet1!$C$1',
877
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
878
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
1013
+ :name => '=Sheet1!$C$1',
1014
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
1015
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
879
1016
  )
880
1017
 
881
1018
  # Add a chart title and some axis labels.
@@ -906,19 +1043,19 @@ def test_chart_stock
906
1043
  # Add the worksheet data that the charts will refer to.
907
1044
  headings = [ 'Date', 'High', 'Low', 'Close' ]
908
1045
  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 ]
1046
+ [ '2007-01-01T', '2007-01-02T', '2007-01-03T', '2007-01-04T', '2007-01-05T' ],
1047
+ [ 27.2, 25.03, 19.05, 20.34, 18.5 ],
1048
+ [ 23.49, 19.55, 15.12, 17.84, 16.34 ],
1049
+ [ 25.45, 23.05, 17.32, 20.45, 17.34 ]
913
1050
  ]
914
1051
 
915
1052
  worksheet.write('A1', headings, bold)
916
1053
 
917
1054
  (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])
1055
+ worksheet.write_date_time(row + 1, 0, data[0][row], date_format)
1056
+ worksheet.write(row + 1, 1, data[1][row])
1057
+ worksheet.write(row + 1, 2, data[2][row])
1058
+ worksheet.write(row + 1, 3, data[3][row])
922
1059
  end
923
1060
 
924
1061
  worksheet.set_column('A:D', 11)
@@ -960,9 +1097,9 @@ def test_chart_secondary_axis
960
1097
  # Add the worksheet data that the charts will refer to.
961
1098
  headings = [ 'Aliens', 'Humans']
962
1099
  data = [
963
- [ 2, 3, 4, 5, 6, 7 ],
964
- [ 10, 40, 50, 20, 10, 50 ]
965
- ]
1100
+ [ 2, 3, 4, 5, 6, 7 ],
1101
+ [ 10, 40, 50, 20, 10, 50 ]
1102
+ ]
966
1103
 
967
1104
  worksheet.write('A1', headings, bold)
968
1105
  worksheet.write('A2', data)
@@ -972,15 +1109,15 @@ def test_chart_secondary_axis
972
1109
 
973
1110
  # Configure the first series.
974
1111
  chart.add_series(
975
- :name => '=Sheet1!$A$1',
976
- :values => '=Sheet1!$A$2:$A$7',
977
- :y2_axis => 1
978
- )
1112
+ :name => '=Sheet1!$A$1',
1113
+ :values => '=Sheet1!$A$2:$A$7',
1114
+ :y2_axis => 1
1115
+ )
979
1116
 
980
1117
  chart.add_series(
981
- :name => '=Sheet1!$B$1',
982
- :values => '=Sheet1!$B$2:$B$7'
983
- )
1118
+ :name => '=Sheet1!$B$1',
1119
+ :values => '=Sheet1!$B$2:$B$7'
1120
+ )
984
1121
 
985
1122
  chart.set_legend(:position => 'right')
986
1123
 
@@ -1258,7 +1395,7 @@ def test_comments2
1258
1395
  comment = 'Hello.'
1259
1396
 
1260
1397
  worksheet6.write( 'C9', cell_text, text_wrap )
1261
- worksheet6.write_comment( 'C9', comment, :color => 0x35 )
1398
+ worksheet6.write_comment( 'C9', comment, :color => '#FF6600' )
1262
1399
 
1263
1400
 
1264
1401
  ###############################################################################
@@ -1275,7 +1412,7 @@ def test_comments2
1275
1412
  cell = 'C3'
1276
1413
 
1277
1414
  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"
1415
+ "by #{author}' (blank) in the status bar at the bottom"
1279
1416
 
1280
1417
  comment = 'Hello.'
1281
1418
 
@@ -1286,7 +1423,7 @@ def test_comments2
1286
1423
  author = 'Ruby'
1287
1424
  cell = 'C6'
1288
1425
  cell_text = "Move the mouse over this cell and you will see 'Cell commented " +
1289
- "by #{author}' in the status bar at the bottom"
1426
+ "by #{author}' in the status bar at the bottom"
1290
1427
 
1291
1428
  comment = 'Hello.'
1292
1429
 
@@ -1297,7 +1434,7 @@ def test_comments2
1297
1434
  author = '€'
1298
1435
  cell = 'C9'
1299
1436
  cell_text = "Move the mouse over this cell and you will see 'Cell commented " +
1300
- "by #{author}' in the status bar at the bottom"
1437
+ "by #{author}' in the status bar at the bottom"
1301
1438
  comment = 'Hello.'
1302
1439
 
1303
1440
  worksheet7.write( cell, cell_text, text_wrap )
@@ -1361,36 +1498,36 @@ def test_conditional_format
1361
1498
 
1362
1499
  # Light red fill with dark red text.
1363
1500
  format1 = workbook.add_format(
1364
- :bg_color => '#FFC7CE',
1365
- :color => '#9C0006'
1366
- )
1501
+ :bg_color => '#FFC7CE',
1502
+ :color => '#9C0006'
1503
+ )
1367
1504
 
1368
1505
  # Green fill with dark green text.
1369
1506
  format2 = workbook.add_format(
1370
- :bg_color => '#C6EFCE',
1371
- :color => '#006100'
1372
- )
1507
+ :bg_color => '#C6EFCE',
1508
+ :color => '#006100'
1509
+ )
1373
1510
 
1374
1511
  # Some sample data to run the conditional formatting against.
1375
1512
  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
- ]
1513
+ [ 34, 72, 38, 30, 75, 48, 75, 66, 84, 86 ],
1514
+ [ 6, 24, 1, 84, 54, 62, 60, 3, 26, 59 ],
1515
+ [ 28, 79, 97, 13, 85, 93, 93, 22, 5, 14 ],
1516
+ [ 27, 71, 40, 17, 18, 79, 90, 93, 29, 47 ],
1517
+ [ 88, 25, 33, 23, 67, 1, 59, 79, 47, 36 ],
1518
+ [ 24, 100, 20, 88, 29, 33, 38, 54, 54, 88 ],
1519
+ [ 6, 57, 88, 28, 10, 26, 37, 7, 41, 48 ],
1520
+ [ 52, 78, 1, 96, 26, 45, 47, 33, 96, 36 ],
1521
+ [ 60, 54, 81, 66, 81, 90, 80, 93, 12, 55 ],
1522
+ [ 70, 5, 46, 14, 71, 19, 66, 36, 41, 21 ]
1523
+ ]
1387
1524
 
1388
1525
  ###############################################################################
1389
1526
  #
1390
1527
  # Example 1.
1391
1528
  #
1392
1529
  caption = 'Cells with values >= 50 are in light red. ' +
1393
- 'Values < 50 are in light green.'
1530
+ 'Values < 50 are in light green.'
1394
1531
 
1395
1532
  # Write the data.
1396
1533
  worksheet1.write('A1', caption)
@@ -1404,7 +1541,7 @@ def test_conditional_format
1404
1541
  :value => 50,
1405
1542
  :format => format1
1406
1543
  }
1407
- )
1544
+ )
1408
1545
 
1409
1546
  # Write another conditional format over the same range.
1410
1547
  worksheet1.conditional_formatting('B3:K12',
@@ -1414,7 +1551,7 @@ def test_conditional_format
1414
1551
  :value => 50,
1415
1552
  :format => format2
1416
1553
  }
1417
- )
1554
+ )
1418
1555
 
1419
1556
 
1420
1557
  ###############################################################################
@@ -1422,7 +1559,7 @@ def test_conditional_format
1422
1559
  # Example 2.
1423
1560
  #
1424
1561
  caption = 'Values between 30 and 70 are in light red. ' +
1425
- 'Values outside that range are in light green.'
1562
+ 'Values outside that range are in light green.'
1426
1563
 
1427
1564
  worksheet2.write('A1', caption)
1428
1565
  worksheet2.write_col('B3', data)
@@ -1435,7 +1572,7 @@ def test_conditional_format
1435
1572
  :maximum => 70,
1436
1573
  :format => format1
1437
1574
  }
1438
- )
1575
+ )
1439
1576
 
1440
1577
  worksheet2.conditional_formatting('B3:K12',
1441
1578
  {
@@ -1445,7 +1582,7 @@ def test_conditional_format
1445
1582
  :maximum => 70,
1446
1583
  :format => format2
1447
1584
  }
1448
- )
1585
+ )
1449
1586
 
1450
1587
 
1451
1588
  ###############################################################################
@@ -1453,7 +1590,7 @@ def test_conditional_format
1453
1590
  # Example 3.
1454
1591
  #
1455
1592
  caption = 'Duplicate values are in light red. ' +
1456
- 'Unique values are in light green.'
1593
+ 'Unique values are in light green.'
1457
1594
 
1458
1595
  worksheet3.write('A1', caption)
1459
1596
  worksheet3.write_col('B3', data)
@@ -1463,14 +1600,14 @@ def test_conditional_format
1463
1600
  :type => 'duplicate',
1464
1601
  :format => format1,
1465
1602
  }
1466
- )
1603
+ )
1467
1604
 
1468
1605
  worksheet3.conditional_formatting('B3:K12',
1469
1606
  {
1470
1607
  :type => 'unique',
1471
1608
  :format => format2,
1472
1609
  }
1473
- )
1610
+ )
1474
1611
 
1475
1612
 
1476
1613
  ###############################################################################
@@ -1478,7 +1615,7 @@ def test_conditional_format
1478
1615
  # Example 4.
1479
1616
  #
1480
1617
  caption = 'Above average values are in light red. ' +
1481
- 'Below average values are in light green.'
1618
+ 'Below average values are in light green.'
1482
1619
 
1483
1620
  worksheet4.write('A1', caption)
1484
1621
  worksheet4.write_col('B3', data)
@@ -1489,7 +1626,7 @@ def test_conditional_format
1489
1626
  :criteria => 'above',
1490
1627
  :format => format1
1491
1628
  }
1492
- )
1629
+ )
1493
1630
 
1494
1631
  worksheet4.conditional_formatting('B3:K12',
1495
1632
  {
@@ -1497,7 +1634,7 @@ def test_conditional_format
1497
1634
  :criteria => 'below',
1498
1635
  :format => format2
1499
1636
  }
1500
- )
1637
+ )
1501
1638
 
1502
1639
 
1503
1640
  ###############################################################################
@@ -1505,7 +1642,7 @@ def test_conditional_format
1505
1642
  # Example 5.
1506
1643
  #
1507
1644
  caption = 'Top 10 values are in light red. ' +
1508
- 'Bottom 10 values are in light green.'
1645
+ 'Bottom 10 values are in light green.'
1509
1646
 
1510
1647
  worksheet5.write('A1', caption)
1511
1648
  worksheet5.write_col('B3', data)
@@ -1516,7 +1653,7 @@ def test_conditional_format
1516
1653
  :value => '10',
1517
1654
  :format => format1
1518
1655
  }
1519
- )
1656
+ )
1520
1657
 
1521
1658
  worksheet5.conditional_formatting('B3:K12',
1522
1659
  {
@@ -1524,7 +1661,7 @@ def test_conditional_format
1524
1661
  :value => '10',
1525
1662
  :format => format2
1526
1663
  }
1527
- )
1664
+ )
1528
1665
 
1529
1666
 
1530
1667
  ###############################################################################
@@ -1532,7 +1669,7 @@ def test_conditional_format
1532
1669
  # Example 6.
1533
1670
  #
1534
1671
  caption = 'Cells with values >= 50 are in light red. ' +
1535
- 'Values < 50 are in light green. Non-contiguous ranges.'
1672
+ 'Values < 50 are in light green. Non-contiguous ranges.'
1536
1673
 
1537
1674
  # Write the data.
1538
1675
  worksheet6.write('A1', caption)
@@ -1546,7 +1683,7 @@ def test_conditional_format
1546
1683
  :value => 50,
1547
1684
  :format => format1
1548
1685
  }
1549
- )
1686
+ )
1550
1687
 
1551
1688
  # Write another conditional format over the same range.
1552
1689
  worksheet6.conditional_formatting('B3:K6,B9:K12',
@@ -1556,7 +1693,7 @@ def test_conditional_format
1556
1693
  :value => 50,
1557
1694
  :format => format2
1558
1695
  }
1559
- )
1696
+ )
1560
1697
 
1561
1698
 
1562
1699
  ###############################################################################
@@ -1583,19 +1720,19 @@ def test_conditional_format
1583
1720
  {
1584
1721
  :type => '2_color_scale'
1585
1722
  }
1586
- )
1723
+ )
1587
1724
 
1588
1725
  worksheet7.conditional_formatting('D3:D14',
1589
1726
  {
1590
1727
  :type => '3_color_scale'
1591
1728
  }
1592
- )
1729
+ )
1593
1730
 
1594
1731
  worksheet7.conditional_formatting('F3:F14',
1595
1732
  {
1596
1733
  :type => 'data_bar'
1597
1734
  }
1598
- )
1735
+ )
1599
1736
 
1600
1737
 
1601
1738
  ###############################################################################
@@ -1624,7 +1761,7 @@ def test_conditional_format
1624
1761
  :min_color => "#FF0000",
1625
1762
  :max_color => "#00FF00"
1626
1763
  }
1627
- )
1764
+ )
1628
1765
 
1629
1766
  worksheet8.conditional_formatting('D3:D14',
1630
1767
  {
@@ -1633,14 +1770,14 @@ def test_conditional_format
1633
1770
  :mid_color => "#8DB4E3",
1634
1771
  :max_color => "#538ED5"
1635
1772
  }
1636
- )
1773
+ )
1637
1774
 
1638
1775
  worksheet8.conditional_formatting('F3:F14',
1639
1776
  {
1640
1777
  :type => 'data_bar',
1641
1778
  :bar_color => '#63C384'
1642
1779
  }
1643
- )
1780
+ )
1644
1781
 
1645
1782
  workbook.close
1646
1783
  store_to_tempfile
@@ -1654,13 +1791,13 @@ def test_data_validate
1654
1791
 
1655
1792
  # Add a format for the header cells.
1656
1793
  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
- )
1794
+ :border => 1,
1795
+ :bg_color => 43,
1796
+ :bold => 1,
1797
+ :text_wrap => 1,
1798
+ :valign => 'vcenter',
1799
+ :indent => 1
1800
+ )
1664
1801
 
1665
1802
  # Set up layout of the worksheet.
1666
1803
  worksheet.set_column('A:A', 68)
@@ -1932,32 +2069,32 @@ def test_date_time
1932
2069
  # the format codes change the appearance of the date.
1933
2070
  #
1934
2071
  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
- ]
2072
+ 'dd/mm/yy',
2073
+ 'mm/dd/yy',
2074
+ '',
2075
+ 'd mm yy',
2076
+ 'dd mm yy',
2077
+ '',
2078
+ 'dd m yy',
2079
+ 'dd mm yy',
2080
+ 'dd mmm yy',
2081
+ 'dd mmmm yy',
2082
+ '',
2083
+ 'dd mm y',
2084
+ 'dd mm yyy',
2085
+ 'dd mm yyyy',
2086
+ '',
2087
+ 'd mmmm yyyy',
2088
+ '',
2089
+ 'dd/mm/yy',
2090
+ 'dd/mm/yy hh:mm',
2091
+ 'dd/mm/yy hh:mm:ss',
2092
+ 'dd/mm/yy hh:mm:ss.000',
2093
+ '',
2094
+ 'hh:mm',
2095
+ 'hh:mm:ss',
2096
+ 'hh:mm:ss.000'
2097
+ ]
1961
2098
 
1962
2099
  # Write the same date and time using each of the above formats. The empty
1963
2100
  # string formats create a blank line to make the example clearer.
@@ -1969,9 +2106,9 @@ def test_date_time
1969
2106
 
1970
2107
  # Create a format for the date or time.
1971
2108
  format = workbook.add_format(
1972
- :num_format => date_format,
1973
- :align => 'left'
1974
- )
2109
+ :num_format => date_format,
2110
+ :align => 'left'
2111
+ )
1975
2112
 
1976
2113
  # Write the same date using different formats.
1977
2114
  worksheet.write_date_time(row, 0, '2004-08-01T12:30:45.123', format)
@@ -2036,17 +2173,17 @@ def test_demo
2036
2173
  worksheet.set_row(0, 40)
2037
2174
 
2038
2175
  heading = workbook.add_format(
2039
- :bold => 1,
2040
- :color => 'blue',
2041
- :size => 16,
2042
- :merge => 1,
2043
- :align => 'vcenter'
2044
- )
2176
+ :bold => 1,
2177
+ :color => 'blue',
2178
+ :size => 16,
2179
+ :merge => 1,
2180
+ :align => 'vcenter'
2181
+ )
2045
2182
 
2046
2183
  hyperlink_format = workbook.add_format(
2047
- :color => 'blue',
2048
- :underline => 1
2049
- )
2184
+ :color => 'blue',
2185
+ :underline => 1
2186
+ )
2050
2187
 
2051
2188
  headings = ['Features of WriteXLSX', '']
2052
2189
  worksheet.write_row('A1', headings, heading)
@@ -2056,12 +2193,12 @@ def test_demo
2056
2193
  # Some text examples
2057
2194
  #
2058
2195
  text_format = workbook.add_format(
2059
- :bold => 1,
2060
- :italic => 1,
2061
- :color => 'red',
2062
- :size => 18,
2063
- :font => 'Lucida Calligraphy'
2064
- )
2196
+ :bold => 1,
2197
+ :italic => 1,
2198
+ :color => 'red',
2199
+ :size => 18,
2200
+ :font => 'Lucida Calligraphy'
2201
+ )
2065
2202
 
2066
2203
  worksheet.write('A2', "Text")
2067
2204
  worksheet.write('B2', "Hello Excel")
@@ -2104,7 +2241,10 @@ def test_demo
2104
2241
  # Images
2105
2242
  #
2106
2243
  worksheet.write('A10', "Images")
2107
- worksheet.insert_image('B10', File.join(@test_dir, 'republic.png'), 16, 8)
2244
+ worksheet.insert_image(
2245
+ 'B10', File.join(@test_dir, 'republic.png'),
2246
+ :x_offset => 16, :y_offset => 8
2247
+ )
2108
2248
 
2109
2249
  #######################################################################
2110
2250
  #
@@ -2129,10 +2269,10 @@ def test_diag_border
2129
2269
  format3 = workbook.add_format(:diag_type => 3)
2130
2270
 
2131
2271
  format4 = workbook.add_format(
2132
- :diag_type => 3,
2133
- :diag_border => 7,
2134
- :diag_color => 'red'
2135
- )
2272
+ :diag_type => 3,
2273
+ :diag_border => 7,
2274
+ :diag_color => 'red'
2275
+ )
2136
2276
 
2137
2277
  worksheet.write('B3', 'Text', format1)
2138
2278
  worksheet.write('B6', 'Text', format2)
@@ -2218,9 +2358,9 @@ def intro(workbook, center, heading, colors)
2218
2358
  format2.set_color('blue')
2219
2359
 
2220
2360
  format3 = workbook.add_format(
2221
- :color => 'blue',
2222
- :underline => 1
2223
- )
2361
+ :color => 'blue',
2362
+ :underline => 1
2363
+ )
2224
2364
 
2225
2365
  worksheet.write(2, 0, 'This workbook demonstrates some of', format)
2226
2366
  worksheet.write(3, 0, 'the formatting options provided by', format)
@@ -2233,16 +2373,16 @@ def intro(workbook, center, heading, colors)
2233
2373
  'Named colors', format3)
2234
2374
 
2235
2375
  worksheet.write(
2236
- 'A10',
2237
- "internal:'Standard colors'!A1",
2238
- 'Standard colors', format3
2239
- )
2376
+ 'A10',
2377
+ "internal:'Standard colors'!A1",
2378
+ 'Standard colors', format3
2379
+ )
2240
2380
 
2241
2381
  worksheet.write(
2242
- 'A11',
2243
- "internal:'Numeric formats'!A1",
2244
- 'Numeric formats', format3
2245
- )
2382
+ 'A11',
2383
+ "internal:'Numeric formats'!A1",
2384
+ 'Numeric formats', format3
2385
+ )
2246
2386
 
2247
2387
  worksheet.write('A12', "internal:Borders!A1", 'Borders', format3)
2248
2388
  worksheet.write('A13', "internal:Patterns!A1", 'Patterns', format3)
@@ -2272,10 +2412,10 @@ def named_colors(workbook, center, heading, colors)
2272
2412
  [33, 11, 53, 17, 22, 18, 13, 16, 23, 9, 12, 15, 14, 20, 8, 10].each do |index|
2273
2413
  color = colors[index]
2274
2414
  format = workbook.add_format(
2275
- :bg_color => color,
2276
- :pattern => 1,
2277
- :border => 1
2278
- )
2415
+ :bg_color => color,
2416
+ :pattern => 1,
2417
+ :border => 1
2418
+ )
2279
2419
 
2280
2420
  worksheet.write(i + 1, 0, index, center)
2281
2421
  worksheet.write(i + 1, 1, sprintf("0x%02X", index), center)
@@ -2302,10 +2442,10 @@ def standard_colors(workbook, center, heading, colors)
2302
2442
 
2303
2443
  (8 .. 63).each do |i|
2304
2444
  format = workbook.add_format(
2305
- :bg_color => i,
2306
- :pattern => 1,
2307
- :border => 1
2308
- )
2445
+ :bg_color => i,
2446
+ :pattern => 1,
2447
+ :border => 1
2448
+ )
2309
2449
 
2310
2450
  worksheet.write((i - 7), 0, i, center)
2311
2451
  worksheet.write((i - 7), 1, sprintf("0x%02X", i), center)
@@ -2787,17 +2927,17 @@ def test_hyperlink
2787
2927
 
2788
2928
  # Add the standard url link format.
2789
2929
  url_format = workbook.add_format(
2790
- :color => 'blue',
2791
- :underline => 1
2792
- )
2930
+ :color => 'blue',
2931
+ :underline => 1
2932
+ )
2793
2933
 
2794
2934
  # Add a sample format.
2795
2935
  red_format = workbook.add_format(
2796
- :color => 'red',
2797
- :bold => 1,
2798
- :underline => 1,
2799
- :size => 12
2800
- )
2936
+ :color => 'red',
2937
+ :bold => 1,
2938
+ :underline => 1,
2939
+ :size => 12
2940
+ )
2801
2941
 
2802
2942
  # Add an alternate description string to the URL.
2803
2943
  str = 'Perl home.'
@@ -2873,16 +3013,16 @@ def test_merge2
2873
3013
 
2874
3014
  # Create a merged format
2875
3015
  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
- )
3016
+ :center_across => 1,
3017
+ :bold => 1,
3018
+ :size => 15,
3019
+ :pattern => 1,
3020
+ :border => 6,
3021
+ :color => 'white',
3022
+ :fg_color => 'green',
3023
+ :border_color => 'yellow',
3024
+ :align => 'vcenter'
3025
+ )
2886
3026
 
2887
3027
  # Only one cell should contain text, the others should be blank.
2888
3028
  worksheet.write(2, 1, "Center across selection", format)
@@ -2909,12 +3049,12 @@ def test_merge3
2909
3049
  # Example: Merge cells containing a hyperlink using merge_range().
2910
3050
  #
2911
3051
  format = workbook.add_format(
2912
- :border => 1,
2913
- :underline => 1,
2914
- :color => 'blue',
2915
- :align => 'center',
2916
- :valign => 'vcenter'
2917
- )
3052
+ :border => 1,
3053
+ :underline => 1,
3054
+ :color => 'blue',
3055
+ :align => 'center',
3056
+ :valign => 'vcenter'
3057
+ )
2918
3058
 
2919
3059
  # Merge 3 cells
2920
3060
  worksheet.merge_range('B4:D4', 'http://www.perl.com', format)
@@ -2942,12 +3082,12 @@ def test_merge4
2942
3082
  # Example 1: Text centered vertically and horizontally
2943
3083
  #
2944
3084
  format1 = workbook.add_format(
2945
- :border => 6,
2946
- :bold => 1,
2947
- :color => 'red',
2948
- :valign => 'vcenter',
2949
- :align => 'center'
2950
- )
3085
+ :border => 6,
3086
+ :bold => 1,
3087
+ :color => 'red',
3088
+ :valign => 'vcenter',
3089
+ :align => 'center'
3090
+ )
2951
3091
 
2952
3092
  worksheet.merge_range('B2:D3', 'Vertical and horizontal', format1)
2953
3093
 
@@ -2956,12 +3096,12 @@ def test_merge4
2956
3096
  # Example 2: Text aligned to the top and left
2957
3097
  #
2958
3098
  format2 = workbook.add_format(
2959
- :border => 6,
2960
- :bold => 1,
2961
- :color => 'red',
2962
- :valign => 'top',
2963
- :align => 'left'
2964
- )
3099
+ :border => 6,
3100
+ :bold => 1,
3101
+ :color => 'red',
3102
+ :valign => 'top',
3103
+ :align => 'left'
3104
+ )
2965
3105
 
2966
3106
  worksheet.merge_range('B5:D6', 'Aligned to the top and left', format2)
2967
3107
 
@@ -2970,12 +3110,12 @@ def test_merge4
2970
3110
  # Example 3: Text aligned to the bottom and right
2971
3111
  #
2972
3112
  format3 = workbook.add_format(
2973
- :border => 6,
2974
- :bold => 1,
2975
- :color => 'red',
2976
- :valign => 'bottom',
2977
- :align => 'right'
2978
- )
3113
+ :border => 6,
3114
+ :bold => 1,
3115
+ :color => 'red',
3116
+ :valign => 'bottom',
3117
+ :align => 'right'
3118
+ )
2979
3119
 
2980
3120
  worksheet.merge_range('B8:D9', 'Aligned to the bottom and right', format3)
2981
3121
 
@@ -2984,12 +3124,12 @@ def test_merge4
2984
3124
  # Example 4: Text justified (i.e. wrapped) in the cell
2985
3125
  #
2986
3126
  format4 = workbook.add_format(
2987
- :border => 6,
2988
- :bold => 1,
2989
- :color => 'red',
2990
- :valign => 'top',
2991
- :align => 'justify'
2992
- )
3127
+ :border => 6,
3128
+ :bold => 1,
3129
+ :color => 'red',
3130
+ :valign => 'top',
3131
+ :align => 'justify'
3132
+ )
2993
3133
 
2994
3134
  worksheet.merge_range('B11:D12', 'Justified: ' << 'so on and ' * 18, format4)
2995
3135
 
@@ -3013,13 +3153,13 @@ def test_merge5
3013
3153
  # Rotation 1, letters run from top to bottom
3014
3154
  #
3015
3155
  format1 = workbook.add_format(
3016
- :border => 6,
3017
- :bold => 1,
3018
- :color => 'red',
3019
- :valign => 'vcentre',
3020
- :align => 'centre',
3021
- :rotation => 270
3022
- )
3156
+ :border => 6,
3157
+ :bold => 1,
3158
+ :color => 'red',
3159
+ :valign => 'vcentre',
3160
+ :align => 'centre',
3161
+ :rotation => 270
3162
+ )
3023
3163
 
3024
3164
  worksheet.merge_range( 'B4:B9', 'Rotation 270', format1 )
3025
3165
 
@@ -3028,13 +3168,13 @@ def test_merge5
3028
3168
  # Rotation 2, 90ー anticlockwise
3029
3169
  #
3030
3170
  format2 = workbook.add_format(
3031
- :border => 6,
3032
- :bold => 1,
3033
- :color => 'red',
3034
- :valign => 'vcentre',
3035
- :align => 'centre',
3036
- :rotation => 90
3037
- )
3171
+ :border => 6,
3172
+ :bold => 1,
3173
+ :color => 'red',
3174
+ :valign => 'vcentre',
3175
+ :align => 'centre',
3176
+ :rotation => 90
3177
+ )
3038
3178
 
3039
3179
  worksheet.merge_range( 'D4:D9', 'Rotation 90°', format2 )
3040
3180
 
@@ -3043,13 +3183,13 @@ def test_merge5
3043
3183
  # Rotation 3, 90ー clockwise
3044
3184
  #
3045
3185
  format3 = workbook.add_format(
3046
- :border => 6,
3047
- :bold => 1,
3048
- :color => 'red',
3049
- :valign => 'vcentre',
3050
- :align => 'centre',
3051
- :rotation => -90
3052
- )
3186
+ :border => 6,
3187
+ :bold => 1,
3188
+ :color => 'red',
3189
+ :valign => 'vcentre',
3190
+ :align => 'centre',
3191
+ :rotation => -90
3192
+ )
3053
3193
 
3054
3194
  worksheet.merge_range( 'F4:F9', 'Rotation -90°', format3 )
3055
3195
 
@@ -3070,14 +3210,14 @@ def test_merge6
3070
3210
 
3071
3211
  # Format for the merged cells.
3072
3212
  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
- )
3213
+ :border => 6,
3214
+ :bold => 1,
3215
+ :color => 'red',
3216
+ :size => 20,
3217
+ :valign => 'vcentre',
3218
+ :align => 'left',
3219
+ :indent => 1
3220
+ )
3081
3221
 
3082
3222
  ###############################################################################
3083
3223
  #
@@ -3234,12 +3374,12 @@ def test_outline
3234
3374
  # Example 3: Create a worksheet with outlined columns.
3235
3375
  #
3236
3376
  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
- ]
3377
+ [ 'Month', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', ' Total' ],
3378
+ [ 'North', 50, 20, 15, 25, 65, 80, '=SUM(B2:G2)' ],
3379
+ [ 'South', 10, 20, 30, 50, 50, 50, '=SUM(B3:G3)' ],
3380
+ [ 'East', 45, 75, 50, 15, 75, 100, '=SUM(B4:G4)' ],
3381
+ [ 'West', 15, 15, 55, 35, 20, 50, '=SUM(B5:G5)' ],
3382
+ ]
3243
3383
 
3244
3384
  # Add bold format to the first row
3245
3385
  worksheet3.set_row(0, nil, bold)
@@ -3259,10 +3399,10 @@ def test_outline
3259
3399
  # Example 4: Show all possible outline levels.
3260
3400
  #
3261
3401
  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
- ]
3402
+ "Level 1", "Level 2", "Level 3", "Level 4", "Level 5", "Level 6",
3403
+ "Level 7", "Level 6", "Level 5", "Level 4", "Level 3", "Level 2",
3404
+ "Level 1"
3405
+ ]
3266
3406
 
3267
3407
 
3268
3408
  worksheet4.write_col('A1', levels)
@@ -3393,12 +3533,12 @@ def test_outline_collapsed
3393
3533
  # Example 5: Create a worksheet with outlined columns.
3394
3534
  #
3395
3535
  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
- ]
3536
+ [ 'Month', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Total' ],
3537
+ [ 'North', 50, 20, 15, 25, 65, 80, '=SUM(B2:G2)' ],
3538
+ [ 'South', 10, 20, 30, 50, 50, 50, '=SUM(B3:G3)' ],
3539
+ [ 'East', 45, 75, 50, 15, 75, 100, '=SUM(B4:G4)' ],
3540
+ [ 'West', 15, 15, 55, 35, 20, 50, '=SUM(B5:G6)' ]
3541
+ ]
3402
3542
 
3403
3543
  # Add bold format to the first row
3404
3544
  worksheet5.set_row(0, nil, bold)
@@ -3499,10 +3639,10 @@ def test_panes
3499
3639
  #
3500
3640
 
3501
3641
  header = workbook.add_format(
3502
- :align => 'center',
3503
- :valign => 'vcenter',
3504
- :fg_color => 0x2A
3505
- )
3642
+ :align => 'center',
3643
+ :valign => 'vcenter',
3644
+ :fg_color => 0x2A
3645
+ )
3506
3646
 
3507
3647
  center = workbook.add_format(:align => 'center')
3508
3648
 
@@ -3598,16 +3738,16 @@ def test_properties
3598
3738
  worksheet = workbook.add_worksheet
3599
3739
 
3600
3740
  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
- )
3741
+ :title => 'This is an example spreadsheet',
3742
+ :subject => 'With document properties',
3743
+ :author => 'John McNamara',
3744
+ :manager => 'Dr. Heinz Doofenshmirtz',
3745
+ :company => 'of Wolves',
3746
+ :category => 'Example spreadsheets',
3747
+ :keywords => 'Sample, Example, Properties',
3748
+ :comments => 'Created with Perl and Excel::Writer::XLSX',
3749
+ :status => 'Quo'
3750
+ )
3611
3751
 
3612
3752
  worksheet.set_column('A:A', 70)
3613
3753
  worksheet.write('A1', "Select 'Office Button -> Prepare -> Properties' to see the file properties.")
@@ -3708,16 +3848,16 @@ def test_rich_strings
3708
3848
 
3709
3849
  # Write some strings with multiple formats.
3710
3850
  worksheet.write_rich_string('A1',
3711
- 'This is ', bold, 'bold', ' and this is ', italic, 'italic')
3851
+ 'This is ', bold, 'bold', ' and this is ', italic, 'italic')
3712
3852
 
3713
3853
  worksheet.write_rich_string('A3',
3714
- 'This is ', red, 'red', ' and this is ', blue, 'blue')
3854
+ 'This is ', red, 'red', ' and this is ', blue, 'blue')
3715
3855
 
3716
3856
  worksheet.write_rich_string('A5',
3717
- 'Some ', bold, 'bold text', ' centered', center)
3857
+ 'Some ', bold, 'bold text', ' centered', center)
3718
3858
 
3719
3859
  worksheet.write_rich_string('A7',
3720
- italic, 'j = k', superc, '(n-1)', center)
3860
+ italic, 'j = k', superc, '(n-1)', center)
3721
3861
 
3722
3862
  workbook.close
3723
3863
  store_to_tempfile
@@ -3750,7 +3890,7 @@ def test_shape1
3750
3890
  :text => "Hello\nWorld",
3751
3891
  :width => 60,
3752
3892
  :height => 60
3753
- )
3893
+ )
3754
3894
 
3755
3895
  worksheet.insert_shape('A1', ellipse, 50, 50)
3756
3896
 
@@ -3775,12 +3915,12 @@ def test_shape2
3775
3915
  :text => "Plain",
3776
3916
  :width => 100,
3777
3917
  :height => 100
3778
- )
3918
+ )
3779
3919
 
3780
3920
  bbformat = workbook.add_format(
3781
3921
  :color => 'red',
3782
3922
  :font => 'Lucida Calligraphy'
3783
- )
3923
+ )
3784
3924
 
3785
3925
  bbformat.set_bold
3786
3926
  bbformat.set_underline
@@ -3797,7 +3937,7 @@ def test_shape2
3797
3937
  :line_weight => 3,
3798
3938
  :fill => 'FFFF00',
3799
3939
  :line => '3366FF'
3800
- )
3940
+ )
3801
3941
 
3802
3942
  worksheet.insert_shape('A1', plain, 50, 50)
3803
3943
  worksheet.insert_shape('A1', decor, 250, 50)
@@ -3818,7 +3958,7 @@ def test_shape3
3818
3958
  :text => 'Normal',
3819
3959
  :width => 100,
3820
3960
  :height => 100
3821
- )
3961
+ )
3822
3962
 
3823
3963
  worksheet.insert_shape('A1', normal, 50, 50)
3824
3964
  normal.text = 'Scaled 3w x 2h'
@@ -3841,7 +3981,7 @@ def test_shape4
3841
3981
  :type => type,
3842
3982
  :width => 90,
3843
3983
  :height => 90
3844
- )
3984
+ )
3845
3985
 
3846
3986
  (1..10).each do |n|
3847
3987
  # Change the last 5 rectangles to stars. Previously
@@ -3857,7 +3997,7 @@ def test_shape4
3857
3997
  :width => 90,
3858
3998
  :height => 90,
3859
3999
  :text => 'started as a box'
3860
- )
4000
+ )
3861
4001
  worksheet.insert_shape('A1', stencil, 100, 150)
3862
4002
 
3863
4003
  stencil.stencil = 0
@@ -3884,14 +4024,14 @@ def test_shape5
3884
4024
  :type => 'ellipse',
3885
4025
  :width => 60,
3886
4026
  :height => 60
3887
- )
4027
+ )
3888
4028
  worksheet.insert_shape('A1', s1, 50, 50)
3889
4029
 
3890
4030
  s2 = workbook.add_shape(
3891
4031
  :type => 'plus',
3892
4032
  :width => 20,
3893
4033
  :height => 20
3894
- )
4034
+ )
3895
4035
  worksheet.insert_shape('A1', s2, 250, 200)
3896
4036
 
3897
4037
  # Create a connector to link the two shapes.
@@ -3923,14 +4063,14 @@ def test_shape6
3923
4063
  :type => 'chevron',
3924
4064
  :width => 60,
3925
4065
  :height => 60
3926
- )
4066
+ )
3927
4067
  worksheet.insert_shape('A1', s1, 50, 50)
3928
4068
 
3929
4069
  s2 = workbook.add_shape(
3930
4070
  :type => 'pentagon',
3931
4071
  :width => 20,
3932
4072
  :height => 20
3933
- )
4073
+ )
3934
4074
  worksheet.insert_shape('A1', s2, 250, 200)
3935
4075
 
3936
4076
  # Create a connector to link the two shapes.
@@ -3970,7 +4110,7 @@ def test_shape7
3970
4110
  :text => "Hello\nWorld",
3971
4111
  :width => cw,
3972
4112
  :height => ch
3973
- )
4113
+ )
3974
4114
  worksheet.insert_shape('A1', ellipse, cx, cy)
3975
4115
 
3976
4116
  # Add a plus sign at 4 different positions around the circle.
@@ -3984,7 +4124,7 @@ def test_shape7
3984
4124
  :id => 3,
3985
4125
  :width => pw,
3986
4126
  :height => ph
3987
- )
4127
+ )
3988
4128
 
3989
4129
  p1 = worksheet.insert_shape('A1', plus, 350, 350)
3990
4130
  p2 = worksheet.insert_shape('A1', plus, 150, 350)
@@ -4035,7 +4175,7 @@ def test_shape8
4035
4175
  :text => "Hello\nWorld",
4036
4176
  :width => cw,
4037
4177
  :height => ch
4038
- )
4178
+ )
4039
4179
  worksheet.insert_shape('A1', ellipse, cx, cy)
4040
4180
 
4041
4181
  # Add a plus sign at 4 different positionos around the circle.
@@ -4049,7 +4189,7 @@ def test_shape8
4049
4189
  :id => 3,
4050
4190
  :width => pw,
4051
4191
  :height => ph
4052
- )
4192
+ )
4053
4193
 
4054
4194
  p1 = worksheet.insert_shape('A1', plus, 350, 150)
4055
4195
  p2 = worksheet.insert_shape('A1', plus, 350, 350)
@@ -4100,11 +4240,11 @@ def test_shape_all
4100
4240
  end
4101
4241
  last_sheet = sheet
4102
4242
  shape = workbook.add_shape(
4103
- :type => name,
4104
- :text => name,
4105
- :width => 90,
4106
- :height => 90
4107
- )
4243
+ :type => name,
4244
+ :text => name,
4245
+ :width => 90,
4246
+ :height => 90
4247
+ )
4108
4248
 
4109
4249
  # Connectors can not have labels, so write the connector name in the cell
4110
4250
  # to the left.
@@ -4530,17 +4670,18 @@ def test_tables
4530
4670
  worksheet10 = workbook.add_worksheet
4531
4671
  worksheet11 = workbook.add_worksheet
4532
4672
  worksheet12 = workbook.add_worksheet
4673
+ worksheet13 = workbook.add_worksheet
4533
4674
 
4534
4675
  currency_format = workbook.add_format(:num_format => '$#,##0')
4535
4676
 
4536
4677
 
4537
4678
  # Some sample data for the table.
4538
4679
  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
- ]
4680
+ [ 'Apples', 10000, 5000, 8000, 6000 ],
4681
+ [ 'Pears', 2000, 3000, 4000, 5000 ],
4682
+ [ 'Bananas', 6000, 6000, 6500, 6000 ],
4683
+ [ 'Oranges', 500, 300, 200, 700 ]
4684
+ ]
4544
4685
 
4545
4686
  ###############################################################################
4546
4687
  #
@@ -4561,7 +4702,7 @@ def test_tables
4561
4702
  #
4562
4703
  # Example 2.
4563
4704
  #
4564
- caption = 'Default table with data.';
4705
+ caption = 'Default table with data.'
4565
4706
 
4566
4707
  # Set the columns widths.
4567
4708
  worksheet2.set_column('B:G', 12)
@@ -4630,7 +4771,7 @@ def test_tables
4630
4771
  #
4631
4772
  # Example 6.
4632
4773
  #
4633
- caption = 'Table with banded columns but without default banded rows.';
4774
+ caption = 'Table with banded columns but without default banded rows.'
4634
4775
 
4635
4776
  # Set the columns widths.
4636
4777
  worksheet6.set_column('B:G', 12)
@@ -4648,7 +4789,7 @@ def test_tables
4648
4789
  #
4649
4790
  # Example 7.
4650
4791
  #
4651
- caption = 'Table with user defined column headers';
4792
+ caption = 'Table with user defined column headers'
4652
4793
 
4653
4794
  # Set the columns widths.
4654
4795
  worksheet7.set_column('B:G', 12)
@@ -4658,24 +4799,24 @@ def test_tables
4658
4799
 
4659
4800
  # Add a table to the worksheet.
4660
4801
  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
- )
4802
+ 'B3:F7',
4803
+ {
4804
+ :data => data,
4805
+ :columns => [
4806
+ { :header => 'Product' },
4807
+ { :header => 'Quarter 1' },
4808
+ { :header => 'Quarter 2' },
4809
+ { :header => 'Quarter 3' },
4810
+ { :header => 'Quarter 4' }
4811
+ ]
4812
+ }
4813
+ )
4673
4814
 
4674
4815
  ###############################################################################
4675
4816
  #
4676
4817
  # Example 8.
4677
4818
  #
4678
- caption = 'Table with user defined column headers';
4819
+ caption = 'Table with user defined column headers'
4679
4820
 
4680
4821
  # Set the columns widths.
4681
4822
  worksheet8.set_column('B:G', 12)
@@ -4685,29 +4826,29 @@ def test_tables
4685
4826
 
4686
4827
  # Add a table to the worksheet.
4687
4828
  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
- )
4829
+ 'B3:G7',
4830
+ {
4831
+ :data => data,
4832
+ :columns => [
4833
+ { :header => 'Product' },
4834
+ { :header => 'Quarter 1' },
4835
+ { :header => 'Quarter 2' },
4836
+ { :header => 'Quarter 3' },
4837
+ { :header => 'Quarter 4' },
4838
+ {
4839
+ :header => 'Year',
4840
+ :formula => '=SUM(Table8[@[Quarter 1]:[Quarter 4]])'
4841
+ }
4842
+ ]
4843
+ }
4844
+ )
4704
4845
 
4705
4846
 
4706
4847
  ###############################################################################
4707
4848
  #
4708
4849
  # Example 9.
4709
4850
  #
4710
- caption = 'Table with totals row (but no caption or totals).';
4851
+ caption = 'Table with totals row (but no caption or totals).'
4711
4852
 
4712
4853
  # Set the columns widths.
4713
4854
  worksheet9.set_column('B:G', 12)
@@ -4717,29 +4858,29 @@ def test_tables
4717
4858
 
4718
4859
  # Add a table to the worksheet.
4719
4860
  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
- )
4861
+ 'B3:G8',
4862
+ {
4863
+ :data => data,
4864
+ :total_row => 1,
4865
+ :columns => [
4866
+ { :header => 'Product' },
4867
+ { :header => 'Quarter 1' },
4868
+ { :header => 'Quarter 2' },
4869
+ { :header => 'Quarter 3' },
4870
+ { :header => 'Quarter 4' },
4871
+ {
4872
+ :header => 'Year',
4873
+ :formula => '=SUM(Table8[@[Quarter 1]:[Quarter 4]])'
4874
+ }
4875
+ ]
4876
+ }
4877
+ )
4737
4878
 
4738
4879
  ###############################################################################
4739
4880
  #
4740
4881
  # Example 10.
4741
4882
  #
4742
- caption = 'Table with totals row with user captions and functions.';
4883
+ caption = 'Table with totals row with user captions and functions.'
4743
4884
 
4744
4885
  # Set the columns widths.
4745
4886
  worksheet10.set_column('B:G', 12)
@@ -4749,30 +4890,30 @@ def test_tables
4749
4890
 
4750
4891
  # Add a table to the worksheet.
4751
4892
  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
- )
4893
+ 'B3:G8',
4894
+ {
4895
+ :data => data,
4896
+ :total_row => 1,
4897
+ :columns => [
4898
+ { :header => 'Product', :total_string => 'Totals' },
4899
+ { :header => 'Quarter 1', :total_function => 'sum' },
4900
+ { :header => 'Quarter 2', :total_function => 'sum' },
4901
+ { :header => 'Quarter 3', :total_function => 'sum' },
4902
+ { :header => 'Quarter 4', :total_function => 'sum' },
4903
+ {
4904
+ :header => 'Year',
4905
+ :formula => '=SUM(Table8[@[Quarter 1]:[Quarter 4]])',
4906
+ :total_function => 'sum'
4907
+ }
4908
+ ]
4909
+ }
4910
+ )
4770
4911
 
4771
4912
  ###############################################################################
4772
4913
  #
4773
4914
  # Example 11.
4774
4915
  #
4775
- caption = 'Table with alternative Excel style.';
4916
+ caption = 'Table with alternative Excel style.'
4776
4917
 
4777
4918
  # Set the columns widths.
4778
4919
  worksheet11.set_column('B:G', 12)
@@ -4782,31 +4923,31 @@ def test_tables
4782
4923
 
4783
4924
  # Add a table to the worksheet.
4784
4925
  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
- )
4926
+ 'B3:G8',
4927
+ {
4928
+ :data => data,
4929
+ :style => 'Table Style Light 11',
4930
+ :total_row => 1,
4931
+ :columns => [
4932
+ { :header => 'Product', :total_string => 'Totals' },
4933
+ { :header => 'Quarter 1', :total_function => 'sum' },
4934
+ { :header => 'Quarter 2', :total_function => 'sum' },
4935
+ { :header => 'Quarter 3', :total_function => 'sum' },
4936
+ { :header => 'Quarter 4', :total_function => 'sum' },
4937
+ {
4938
+ :header => 'Year',
4939
+ :formula => '=SUM(Table8[@[Quarter 1]:[Quarter 4]])',
4940
+ :total_function => 'sum'
4941
+ }
4942
+ ]
4943
+ }
4944
+ )
4804
4945
 
4805
4946
  ###############################################################################
4806
4947
  #
4807
4948
  # Example 12.
4808
4949
  #
4809
- caption = 'Table with column formats.';
4950
+ caption = 'Table with no Excel style.'
4810
4951
 
4811
4952
  # Set the columns widths.
4812
4953
  worksheet12.set_column('B:G', 12)
@@ -4816,41 +4957,75 @@ def test_tables
4816
4957
 
4817
4958
  # Add a table to the worksheet.
4818
4959
  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
- )
4960
+ 'B3:G8',
4961
+ {
4962
+ :data => data,
4963
+ :style => 'None',
4964
+ :total_row => 1,
4965
+ :columns => [
4966
+ { :header => 'Product', :total_string => 'Totals' },
4967
+ { :header => 'Quarter 1', :total_function => 'sum' },
4968
+ { :header => 'Quarter 2', :total_function => 'sum' },
4969
+ { :header => 'Quarter 3', :total_function => 'sum' },
4970
+ { :header => 'Quarter 4', :total_function => 'sum' },
4971
+ {
4972
+ :header => 'Year',
4973
+ :formula => '=SUM(Table12[@[Quarter 1]:[Quarter 4]])',
4974
+ :total_function => 'sum'
4975
+ }
4976
+ ]
4977
+ }
4978
+ )
4979
+
4980
+ ###############################################################################
4981
+ #
4982
+ # Example 13.
4983
+ #
4984
+ caption = 'Table with column formats.'
4985
+
4986
+ # Set the columns widths.
4987
+ worksheet13.set_column('B:G', 12)
4988
+
4989
+ # Write the caption.
4990
+ worksheet13.write('B1', caption)
4991
+
4992
+ # Add a table to the worksheet.
4993
+ worksheet13.add_table(
4994
+ 'B3:G8',
4995
+ {
4996
+ :data => data,
4997
+ :total_row => 1,
4998
+ :columns => [
4999
+ { :header => 'Product', :total_string => 'Totals' },
5000
+ {
5001
+ :header => 'Quarter 1',
5002
+ :total_function => 'sum',
5003
+ :format => currency_format,
5004
+ },
5005
+ {
5006
+ :header => 'Quarter 2',
5007
+ :total_function => 'sum',
5008
+ :format => currency_format,
5009
+ },
5010
+ {
5011
+ :header => 'Quarter 3',
5012
+ :total_function => 'sum',
5013
+ :format => currency_format,
5014
+ },
5015
+ {
5016
+ :header => 'Quarter 4',
5017
+ :total_function => 'sum',
5018
+ :format => currency_format,
5019
+ },
5020
+ {
5021
+ :header => 'Year',
5022
+ :formula => '=SUM(Table8[@[Quarter 1]:[Quarter 4]])',
5023
+ :total_function => 'sum',
5024
+ :format => currency_format,
5025
+ }
5026
+ ]
5027
+ }
5028
+ )
4854
5029
 
4855
5030
  workbook.close
4856
5031
  store_to_tempfile
@@ -4864,42 +5039,42 @@ def test_sparklines1
4864
5039
 
4865
5040
  # Some sample data to plot.
4866
5041
  data = [
4867
- [ -2, 2, 3, -1, 0 ],
4868
- [ 30, 20, 33, 20, 15 ],
4869
- [ 1, -1, -1, 1, -1 ]
4870
- ]
5042
+ [ -2, 2, 3, -1, 0 ],
5043
+ [ 30, 20, 33, 20, 15 ],
5044
+ [ 1, -1, -1, 1, -1 ]
5045
+ ]
4871
5046
 
4872
5047
  # Write the sample data to the worksheet.
4873
5048
  worksheet.write_col('A1', data)
4874
5049
 
4875
5050
  # Add a line sparkline (the default) with markers.
4876
5051
  worksheet.add_sparkline(
4877
- {
4878
- :location => 'F1',
4879
- :range => 'Sheet1!A1:E1',
4880
- :markers => 1
4881
- }
4882
- )
5052
+ {
5053
+ :location => 'F1',
5054
+ :range => 'Sheet1!A1:E1',
5055
+ :markers => 1
5056
+ }
5057
+ )
4883
5058
 
4884
5059
  # Add a column sparkline with non-default style.
4885
5060
  worksheet.add_sparkline(
4886
- {
4887
- :location => 'F2',
4888
- :range => 'Sheet1!A2:E2',
4889
- :type => 'column',
4890
- :style => 12
4891
- }
4892
- )
5061
+ {
5062
+ :location => 'F2',
5063
+ :range => 'Sheet1!A2:E2',
5064
+ :type => 'column',
5065
+ :style => 12
5066
+ }
5067
+ )
4893
5068
 
4894
5069
  # Add a win/loss sparkline with negative values highlighted.
4895
5070
  worksheet.add_sparkline(
4896
- {
4897
- :location => 'F3',
4898
- :range => 'Sheet1!A3:E3',
4899
- :type => 'win_loss',
4900
- :negative_points => 1
4901
- }
4902
- )
5071
+ {
5072
+ :location => 'F3',
5073
+ :range => 'Sheet1!A3:E3',
5074
+ :type => 'win_loss',
5075
+ :negative_points => 1
5076
+ }
5077
+ )
4903
5078
 
4904
5079
  workbook.close
4905
5080
  store_to_tempfile
@@ -4928,11 +5103,11 @@ def test_sparklines2
4928
5103
  str = 'A default "line" sparkline.'
4929
5104
 
4930
5105
  worksheet1.add_sparkline(
4931
- {
4932
- :location => 'A2',
4933
- :range => 'Sheet2!A1:J1'
4934
- }
4935
- )
5106
+ {
5107
+ :location => 'A2',
5108
+ :range => 'Sheet2!A1:J1'
5109
+ }
5110
+ )
4936
5111
 
4937
5112
  worksheet1.write(row, 1, str)
4938
5113
  row += 1
@@ -4942,12 +5117,12 @@ def test_sparklines2
4942
5117
  str = 'A default "column" sparkline.'
4943
5118
 
4944
5119
  worksheet1.add_sparkline(
4945
- {
4946
- :location => 'A3',
4947
- :range => 'Sheet2!A2:J2',
4948
- :type => 'column'
4949
- }
4950
- )
5120
+ {
5121
+ :location => 'A3',
5122
+ :range => 'Sheet2!A2:J2',
5123
+ :type => 'column'
5124
+ }
5125
+ )
4951
5126
 
4952
5127
  worksheet1.write(row, 1, str)
4953
5128
  row += 1
@@ -4957,12 +5132,12 @@ def test_sparklines2
4957
5132
  str = 'A default "win/loss" sparkline.'
4958
5133
 
4959
5134
  worksheet1.add_sparkline(
4960
- {
4961
- :location => 'A4',
4962
- :range => 'Sheet2!A3:J3',
4963
- :type => 'win_loss'
4964
- }
4965
- )
5135
+ {
5136
+ :location => 'A4',
5137
+ :range => 'Sheet2!A3:J3',
5138
+ :type => 'win_loss'
5139
+ }
5140
+ )
4966
5141
 
4967
5142
  worksheet1.write(row, 1, str)
4968
5143
  row += 2
@@ -4972,12 +5147,12 @@ def test_sparklines2
4972
5147
  str = 'Line with markers.'
4973
5148
 
4974
5149
  worksheet1.add_sparkline(
4975
- {
4976
- :location => 'A6',
4977
- :range => 'Sheet2!A1:J1',
4978
- :markers => 1
4979
- }
4980
- )
5150
+ {
5151
+ :location => 'A6',
5152
+ :range => 'Sheet2!A1:J1',
5153
+ :markers => 1
5154
+ }
5155
+ )
4981
5156
 
4982
5157
  worksheet1.write(row, 1, str)
4983
5158
  row += 1
@@ -4987,13 +5162,13 @@ def test_sparklines2
4987
5162
  str = 'Line with high and low points.'
4988
5163
 
4989
5164
  worksheet1.add_sparkline(
4990
- {
4991
- :location => 'A7',
4992
- :range => 'Sheet2!A1:J1',
4993
- :high_point => 1,
4994
- :low_point => 1
4995
- }
4996
- )
5165
+ {
5166
+ :location => 'A7',
5167
+ :range => 'Sheet2!A1:J1',
5168
+ :high_point => 1,
5169
+ :low_point => 1
5170
+ }
5171
+ )
4997
5172
 
4998
5173
  worksheet1.write(row, 1, str)
4999
5174
  row += 1
@@ -5003,13 +5178,13 @@ def test_sparklines2
5003
5178
  str = 'Line with first and last point markers.'
5004
5179
 
5005
5180
  worksheet1.add_sparkline(
5006
- {
5007
- :location => 'A8',
5008
- :range => 'Sheet2!A1:J1',
5009
- :first_point => 1,
5010
- :last_point => 1
5011
- }
5012
- )
5181
+ {
5182
+ :location => 'A8',
5183
+ :range => 'Sheet2!A1:J1',
5184
+ :first_point => 1,
5185
+ :last_point => 1
5186
+ }
5187
+ )
5013
5188
 
5014
5189
  worksheet1.write(row, 1, str)
5015
5190
  row += 1
@@ -5019,12 +5194,12 @@ def test_sparklines2
5019
5194
  str = 'Line with negative point markers.'
5020
5195
 
5021
5196
  worksheet1.add_sparkline(
5022
- {
5023
- :location => 'A9',
5024
- :range => 'Sheet2!A1:J1',
5025
- :negative_points => 1
5026
- }
5027
- )
5197
+ {
5198
+ :location => 'A9',
5199
+ :range => 'Sheet2!A1:J1',
5200
+ :negative_points => 1
5201
+ }
5202
+ )
5028
5203
 
5029
5204
  worksheet1.write(row, 1, str)
5030
5205
  row += 1
@@ -5034,12 +5209,12 @@ def test_sparklines2
5034
5209
  str = 'Line with axis.'
5035
5210
 
5036
5211
  worksheet1.add_sparkline(
5037
- {
5038
- :location => 'A10',
5039
- :range => 'Sheet2!A1:J1',
5040
- :axis => 1
5041
- }
5042
- )
5212
+ {
5213
+ :location => 'A10',
5214
+ :range => 'Sheet2!A1:J1',
5215
+ :axis => 1
5216
+ }
5217
+ )
5043
5218
 
5044
5219
  worksheet1.write(row, 1, str)
5045
5220
  row += 2
@@ -5049,12 +5224,12 @@ def test_sparklines2
5049
5224
  str = 'Column with default style (1).'
5050
5225
 
5051
5226
  worksheet1.add_sparkline(
5052
- {
5053
- :location => 'A12',
5054
- :range => 'Sheet2!A2:J2',
5055
- :type => 'column'
5056
- }
5057
- )
5227
+ {
5228
+ :location => 'A12',
5229
+ :range => 'Sheet2!A2:J2',
5230
+ :type => 'column'
5231
+ }
5232
+ )
5058
5233
 
5059
5234
  worksheet1.write(row, 1, str)
5060
5235
  row += 1
@@ -5064,13 +5239,13 @@ def test_sparklines2
5064
5239
  str = 'Column with style 2.'
5065
5240
 
5066
5241
  worksheet1.add_sparkline(
5067
- {
5068
- :location => 'A13',
5069
- :range => 'Sheet2!A2:J2',
5070
- :type => 'column',
5071
- :style => 2
5072
- }
5073
- )
5242
+ {
5243
+ :location => 'A13',
5244
+ :range => 'Sheet2!A2:J2',
5245
+ :type => 'column',
5246
+ :style => 2
5247
+ }
5248
+ )
5074
5249
 
5075
5250
  worksheet1.write(row, 1, str)
5076
5251
  row += 1
@@ -5080,13 +5255,13 @@ def test_sparklines2
5080
5255
  str = 'Column with style 3.'
5081
5256
 
5082
5257
  worksheet1.add_sparkline(
5083
- {
5084
- :location => 'A14',
5085
- :range => 'Sheet2!A2:J2',
5086
- :type => 'column',
5087
- :style => 3
5088
- }
5089
- )
5258
+ {
5259
+ :location => 'A14',
5260
+ :range => 'Sheet2!A2:J2',
5261
+ :type => 'column',
5262
+ :style => 3
5263
+ }
5264
+ )
5090
5265
 
5091
5266
  worksheet1.write(row, 1, str)
5092
5267
  row += 1
@@ -5096,13 +5271,13 @@ def test_sparklines2
5096
5271
  str = 'Column with style 4.'
5097
5272
 
5098
5273
  worksheet1.add_sparkline(
5099
- {
5100
- :location => 'A15',
5101
- :range => 'Sheet2!A2:J2',
5102
- :type => 'column',
5103
- :style => 4
5104
- }
5105
- )
5274
+ {
5275
+ :location => 'A15',
5276
+ :range => 'Sheet2!A2:J2',
5277
+ :type => 'column',
5278
+ :style => 4
5279
+ }
5280
+ )
5106
5281
 
5107
5282
  worksheet1.write(row, 1, str)
5108
5283
  row += 1
@@ -5112,13 +5287,13 @@ def test_sparklines2
5112
5287
  str = 'Column with style 5.'
5113
5288
 
5114
5289
  worksheet1.add_sparkline(
5115
- {
5116
- :location => 'A16',
5117
- :range => 'Sheet2!A2:J2',
5118
- :type => 'column',
5119
- :style => 5
5120
- }
5121
- )
5290
+ {
5291
+ :location => 'A16',
5292
+ :range => 'Sheet2!A2:J2',
5293
+ :type => 'column',
5294
+ :style => 5
5295
+ }
5296
+ )
5122
5297
 
5123
5298
  worksheet1.write(row, 1, str)
5124
5299
  row += 1
@@ -5128,13 +5303,13 @@ def test_sparklines2
5128
5303
  str = 'Column with style 6.'
5129
5304
 
5130
5305
  worksheet1.add_sparkline(
5131
- {
5132
- :location => 'A17',
5133
- :range => 'Sheet2!A2:J2',
5134
- :type => 'column',
5135
- :style => 6
5136
- }
5137
- )
5306
+ {
5307
+ :location => 'A17',
5308
+ :range => 'Sheet2!A2:J2',
5309
+ :type => 'column',
5310
+ :style => 6
5311
+ }
5312
+ )
5138
5313
 
5139
5314
  worksheet1.write(row, 1, str)
5140
5315
  row += 1
@@ -5144,13 +5319,13 @@ def test_sparklines2
5144
5319
  str = 'Column with a user defined colour.'
5145
5320
 
5146
5321
  worksheet1.add_sparkline(
5147
- {
5148
- :location => 'A18',
5149
- :range => 'Sheet2!A2:J2',
5150
- :type => 'column',
5151
- :series_color => '#E965E0'
5152
- }
5153
- )
5322
+ {
5323
+ :location => 'A18',
5324
+ :range => 'Sheet2!A2:J2',
5325
+ :type => 'column',
5326
+ :series_color => '#E965E0'
5327
+ }
5328
+ )
5154
5329
 
5155
5330
  worksheet1.write(row, 1, str)
5156
5331
  row += 2
@@ -5160,12 +5335,12 @@ def test_sparklines2
5160
5335
  str = 'A win/loss sparkline.'
5161
5336
 
5162
5337
  worksheet1.add_sparkline(
5163
- {
5164
- :location => 'A20',
5165
- :range => 'Sheet2!A3:J3',
5166
- :type => 'win_loss'
5167
- }
5168
- )
5338
+ {
5339
+ :location => 'A20',
5340
+ :range => 'Sheet2!A3:J3',
5341
+ :type => 'win_loss'
5342
+ }
5343
+ )
5169
5344
 
5170
5345
  worksheet1.write(row, 1, str)
5171
5346
  row += 1
@@ -5175,13 +5350,13 @@ def test_sparklines2
5175
5350
  str = 'A win/loss sparkline with negative points highlighted.'
5176
5351
 
5177
5352
  worksheet1.add_sparkline(
5178
- {
5179
- :location => 'A21',
5180
- :range => 'Sheet2!A3:J3',
5181
- :type => 'win_loss',
5182
- :negative_points => 1
5183
- }
5184
- )
5353
+ {
5354
+ :location => 'A21',
5355
+ :range => 'Sheet2!A3:J3',
5356
+ :type => 'win_loss',
5357
+ :negative_points => 1
5358
+ }
5359
+ )
5185
5360
 
5186
5361
  worksheet1.write(row, 1, str)
5187
5362
  row += 2
@@ -5191,13 +5366,13 @@ def test_sparklines2
5191
5366
  str = 'A left to right column (the default).'
5192
5367
 
5193
5368
  worksheet1.add_sparkline(
5194
- {
5195
- :location => 'A23',
5196
- :range => 'Sheet2!A4:J4',
5197
- :type => 'column',
5198
- :style => 20
5199
- }
5200
- )
5369
+ {
5370
+ :location => 'A23',
5371
+ :range => 'Sheet2!A4:J4',
5372
+ :type => 'column',
5373
+ :style => 20
5374
+ }
5375
+ )
5201
5376
 
5202
5377
  worksheet1.write(row, 1, str)
5203
5378
  row += 1
@@ -5207,14 +5382,14 @@ def test_sparklines2
5207
5382
  str = 'A right to left column.'
5208
5383
 
5209
5384
  worksheet1.add_sparkline(
5210
- {
5211
- :location => 'A24',
5212
- :range => 'Sheet2!A4:J4',
5213
- :type => 'column',
5214
- :style => 20,
5215
- :reverse => 1
5216
- }
5217
- )
5385
+ {
5386
+ :location => 'A24',
5387
+ :range => 'Sheet2!A4:J4',
5388
+ :type => 'column',
5389
+ :style => 20,
5390
+ :reverse => 1
5391
+ }
5392
+ )
5218
5393
 
5219
5394
  worksheet1.write(row, 1, str)
5220
5395
  row += 1
@@ -5224,13 +5399,13 @@ def test_sparklines2
5224
5399
  str = 'Sparkline and text in one cell.'
5225
5400
 
5226
5401
  worksheet1.add_sparkline(
5227
- {
5228
- :location => 'A25',
5229
- :range => 'Sheet2!A4:J4',
5230
- :type => 'column',
5231
- :style => 20
5232
- }
5233
- )
5402
+ {
5403
+ :location => 'A25',
5404
+ :range => 'Sheet2!A4:J4',
5405
+ :type => 'column',
5406
+ :style => 20
5407
+ }
5408
+ )
5234
5409
 
5235
5410
  worksheet1.write(row, 0, 'Growth')
5236
5411
  worksheet1.write(row, 1, str)
@@ -5241,12 +5416,12 @@ def test_sparklines2
5241
5416
  str = 'A grouped sparkline. Changes are applied to all three.'
5242
5417
 
5243
5418
  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
- )
5419
+ {
5420
+ :location => [ 'A27', 'A28', 'A29' ],
5421
+ :range => [ 'Sheet2!A5:J5', 'Sheet2!A6:J6', 'Sheet2!A7:J7' ],
5422
+ :markers => 1
5423
+ }
5424
+ )
5250
5425
 
5251
5426
  worksheet1.write(row, 1, str)
5252
5427
  row += 1
@@ -5258,23 +5433,23 @@ def test_sparklines2
5258
5433
  worksheet2.set_column('A:J', 11)
5259
5434
 
5260
5435
  data = [
5261
- # Simple line data.
5262
- [ -2, 2, 3, -1, 0, -2, 3, 2, 1, 0 ],
5436
+ # Simple line data.
5437
+ [ -2, 2, 3, -1, 0, -2, 3, 2, 1, 0 ],
5263
5438
 
5264
- # Simple column data.
5265
- [ 30, 20, 33, 20, 15, 5, 5, 15, 10, 15 ],
5439
+ # Simple column data.
5440
+ [ 30, 20, 33, 20, 15, 5, 5, 15, 10, 15 ],
5266
5441
 
5267
- # Simple win/loss data.
5268
- [ 1, 1, -1, -1, 1, -1, 1, 1, 1, -1 ],
5442
+ # Simple win/loss data.
5443
+ [ 1, 1, -1, -1, 1, -1, 1, 1, 1, -1 ],
5269
5444
 
5270
- # Unbalanced histogram.
5271
- [ 5, 6, 7, 10, 15, 20, 30, 50, 70, 100 ],
5445
+ # Unbalanced histogram.
5446
+ [ 5, 6, 7, 10, 15, 20, 30, 50, 70, 100 ],
5272
5447
 
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
- ]
5448
+ # Data for the grouped sparkline example.
5449
+ [ -2, 2, 3, -1, 0, -2, 3, 2, 1, 0 ],
5450
+ [ 3, -1, 0, -2, 3, 2, 1, 0, 2, 1 ],
5451
+ [ 0, -2, 3, 2, 1, 0, 1, 2, 3, 1 ]
5452
+ ]
5278
5453
 
5279
5454
  # Write the sample data to the worksheet.
5280
5455
  worksheet2.write_col('A1', data)
@@ -5339,10 +5514,10 @@ def test_chart_data_table
5339
5514
  # Add the worksheet data that the charts will refer to.
5340
5515
  headings = [ 'Number', 'Batch 1', 'Batch 2' ]
5341
5516
  data = [
5342
- [ 2, 3, 4, 5, 6, 7 ],
5343
- [ 10, 40, 50, 20, 10, 50 ],
5344
- [ 30, 60, 70, 50, 40, 30 ]
5345
- ]
5517
+ [ 2, 3, 4, 5, 6, 7 ],
5518
+ [ 10, 40, 50, 20, 10, 50 ],
5519
+ [ 30, 60, 70, 50, 40, 30 ]
5520
+ ]
5346
5521
 
5347
5522
  worksheet.write('A1', headings, bold)
5348
5523
  worksheet.write('A2', data)
@@ -5352,18 +5527,18 @@ def test_chart_data_table
5352
5527
 
5353
5528
  # Configure the first series.
5354
5529
  chart1.add_series(
5355
- :name => '=Sheet1!$B$1',
5356
- :categories => '=Sheet1!$A$2:$A$7',
5357
- :values => '=Sheet1!$B$2:$B$7'
5358
- )
5530
+ :name => '=Sheet1!$B$1',
5531
+ :categories => '=Sheet1!$A$2:$A$7',
5532
+ :values => '=Sheet1!$B$2:$B$7'
5533
+ )
5359
5534
 
5360
5535
  # Configure second series. Note alternative use of array ref to define
5361
5536
  # ranges: [ sheetname, row_start, row_end, col_start, col_end ].
5362
5537
  chart1.add_series(
5363
- :name => '=Sheet1!$C$1',
5364
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
5365
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
5366
- )
5538
+ :name => '=Sheet1!$C$1',
5539
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
5540
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
5541
+ )
5367
5542
 
5368
5543
  # Add a chart title and some axis labels.
5369
5544
  chart1.set_title(:name => 'Chart with Data Table')
@@ -5383,18 +5558,18 @@ def test_chart_data_table
5383
5558
 
5384
5559
  # Configure the first series.
5385
5560
  chart2.add_series(
5386
- :name => '=Sheet1!$B$1',
5387
- :categories => '=Sheet1!$A$2:$A$7',
5388
- :values => '=Sheet1!$B$2:$B$7'
5389
- )
5561
+ :name => '=Sheet1!$B$1',
5562
+ :categories => '=Sheet1!$A$2:$A$7',
5563
+ :values => '=Sheet1!$B$2:$B$7'
5564
+ )
5390
5565
 
5391
5566
  # Configure second series. Note alternative use of array ref to define
5392
5567
  # ranges: [ sheetname, row_start, row_end, col_start, col_end ].
5393
5568
  chart2.add_series(
5394
- :name => '=Sheet1!$C$1',
5395
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
5396
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
5397
- )
5569
+ :name => '=Sheet1!$C$1',
5570
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
5571
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
5572
+ )
5398
5573
 
5399
5574
  # Add a chart title and some axis labels.
5400
5575
  chart2.set_title(:name => 'Data Table with legend keys')
@@ -5424,10 +5599,10 @@ def test_chart_data_tools
5424
5599
  # Add the worksheet data that the charts will refer to.
5425
5600
  headings = [ 'Number', 'Data 1', 'Data 2' ]
5426
5601
  data = [
5427
- [ 2, 3, 4, 5, 6, 7 ],
5428
- [ 10, 40, 50, 20, 10, 50 ],
5429
- [ 30, 60, 70, 50, 40, 30 ]
5430
- ]
5602
+ [ 2, 3, 4, 5, 6, 7 ],
5603
+ [ 10, 40, 50, 20, 10, 50 ],
5604
+ [ 30, 60, 70, 50, 40, 30 ]
5605
+ ]
5431
5606
 
5432
5607
  worksheet.write('A1', headings, bold)
5433
5608
  worksheet.write('A2', data)
@@ -5443,20 +5618,20 @@ def test_chart_data_tools
5443
5618
 
5444
5619
  # Configure the first series with a polynomial trendline.
5445
5620
  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
- )
5621
+ :categories => '=Sheet1!$A$2:$A$7',
5622
+ :values => '=Sheet1!$B$2:$B$7',
5623
+ :trendline => {
5624
+ :type => 'polynomial',
5625
+ :order => 3,
5626
+ }
5627
+ )
5453
5628
 
5454
5629
  # Configure the second series with a moving average trendline.
5455
5630
  chart1.add_series(
5456
- :categories => '=Sheet1!$A$2:$A$7',
5457
- :values => '=Sheet1!$C$2:$C$7',
5458
- :trendline => { :type => 'linear' }
5459
- )
5631
+ :categories => '=Sheet1!$A$2:$A$7',
5632
+ :values => '=Sheet1!$C$2:$C$7',
5633
+ :trendline => { :type => 'linear' }
5634
+ )
5460
5635
 
5461
5636
  # Add a chart title. and some axis labels.
5462
5637
  chart1.set_title(:name => 'Chart with Trendlines')
@@ -5474,17 +5649,17 @@ def test_chart_data_tools
5474
5649
 
5475
5650
  # Configure the first series.
5476
5651
  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
- )
5652
+ :categories => '=Sheet1!$A$2:$A$7',
5653
+ :values => '=Sheet1!$B$2:$B$7',
5654
+ :data_labels => { :value => 1 },
5655
+ :marker => { :type => 'automatic' }
5656
+ )
5482
5657
 
5483
5658
  # Configure the second series.
5484
5659
  chart2.add_series(
5485
- :categories => '=Sheet1!$A$2:$A$7',
5486
- :values => '=Sheet1!$C$2:$C$7'
5487
- )
5660
+ :categories => '=Sheet1!$A$2:$A$7',
5661
+ :values => '=Sheet1!$C$2:$C$7'
5662
+ )
5488
5663
 
5489
5664
  # Add a chart title. and some axis labels.
5490
5665
  chart2.set_title(:name => 'Chart with Data Labels and Markers')
@@ -5502,16 +5677,16 @@ def test_chart_data_tools
5502
5677
 
5503
5678
  # Configure the first series.
5504
5679
  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
- )
5680
+ :categories => '=Sheet1!$A$2:$A$7',
5681
+ :values => '=Sheet1!$B$2:$B$7',
5682
+ :y_error_bars => { :type => 'standard_error' }
5683
+ )
5509
5684
 
5510
5685
  # Configure the second series.
5511
5686
  chart3.add_series(
5512
- :categories => '=Sheet1!$A$2:$A$7',
5513
- :values => '=Sheet1!$C$2:$C$7'
5514
- )
5687
+ :categories => '=Sheet1!$A$2:$A$7',
5688
+ :values => '=Sheet1!$C$2:$C$7'
5689
+ )
5515
5690
 
5516
5691
  # Add a chart title. and some axis labels.
5517
5692
  chart3.set_title(:name => 'Chart with Error Bars')
@@ -5532,15 +5707,15 @@ def test_chart_data_tools
5532
5707
 
5533
5708
  # Configure the first series.
5534
5709
  chart4.add_series(
5535
- :categories => '=Sheet1!$A$2:$A$7',
5536
- :values => '=Sheet1!$B$2:$B$7'
5537
- )
5710
+ :categories => '=Sheet1!$A$2:$A$7',
5711
+ :values => '=Sheet1!$B$2:$B$7'
5712
+ )
5538
5713
 
5539
5714
  # Configure the second series.
5540
5715
  chart4.add_series(
5541
- :categories => '=Sheet1!$A$2:$A$7',
5542
- :values => '=Sheet1!$C$2:$C$7'
5543
- )
5716
+ :categories => '=Sheet1!$A$2:$A$7',
5717
+ :values => '=Sheet1!$C$2:$C$7'
5718
+ )
5544
5719
 
5545
5720
  # Add a chart title. and some axis labels.
5546
5721
  chart4.set_title(:name => 'Chart with Up-Down Bars')
@@ -5561,15 +5736,15 @@ def test_chart_data_tools
5561
5736
 
5562
5737
  # Configure the first series.
5563
5738
  chart5.add_series(
5564
- :categories => '=Sheet1!$A$2:$A$7',
5565
- :values => '=Sheet1!$B$2:$B$7'
5566
- )
5739
+ :categories => '=Sheet1!$A$2:$A$7',
5740
+ :values => '=Sheet1!$B$2:$B$7'
5741
+ )
5567
5742
 
5568
5743
  # Configure the second series.
5569
5744
  chart5.add_series(
5570
- :categories => '=Sheet1!$A$2:$A$7',
5571
- :values => '=Sheet1!$C$2:$C$7'
5572
- )
5745
+ :categories => '=Sheet1!$A$2:$A$7',
5746
+ :values => '=Sheet1!$C$2:$C$7'
5747
+ )
5573
5748
 
5574
5749
  # Add a chart title. and some axis labels.
5575
5750
  chart5.set_title(:name => 'Chart with High-Low Lines')
@@ -5590,15 +5765,15 @@ def test_chart_data_tools
5590
5765
 
5591
5766
  # Configure the first series.
5592
5767
  chart6.add_series(
5593
- :categories => '=Sheet1!$A$2:$A$7',
5594
- :values => '=Sheet1!$B$2:$B$7'
5595
- )
5768
+ :categories => '=Sheet1!$A$2:$A$7',
5769
+ :values => '=Sheet1!$B$2:$B$7'
5770
+ )
5596
5771
 
5597
5772
  # Configure the second series.
5598
5773
  chart6.add_series(
5599
- :categories => '=Sheet1!$A$2:$A$7',
5600
- :values => '=Sheet1!$C$2:$C$7'
5601
- )
5774
+ :categories => '=Sheet1!$A$2:$A$7',
5775
+ :values => '=Sheet1!$C$2:$C$7'
5776
+ )
5602
5777
 
5603
5778
  # Add a chart title. and some axis labels.
5604
5779
  chart6.set_title(:name => 'Chart with Drop Lines')