write_xlsx 0.89.0 → 1.01.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (340) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Changes +98 -0
  4. data/LICENSE.txt +1 -1
  5. data/README.md +2 -2
  6. data/examples/a_simple.rb +2 -7
  7. data/examples/add_vba_project.rb +1 -1
  8. data/examples/array_formula.rb +1 -1
  9. data/examples/chart_area.rb +5 -2
  10. data/examples/chart_bar.rb +5 -2
  11. data/examples/chart_clustered.rb +1 -1
  12. data/examples/chart_column.rb +5 -2
  13. data/examples/chart_combined.rb +1 -1
  14. data/examples/chart_data_table.rb +9 -3
  15. data/examples/chart_data_tools.rb +25 -7
  16. data/examples/chart_doughnut.rb +17 -5
  17. data/examples/chart_gauge.rb +73 -0
  18. data/examples/chart_line.rb +5 -2
  19. data/examples/chart_pareto.rb +1 -1
  20. data/examples/chart_pie.rb +9 -3
  21. data/examples/chart_radar.rb +13 -4
  22. data/examples/chart_scatter.rb +5 -2
  23. data/examples/chart_secondary_axis.rb +5 -2
  24. data/examples/chart_stock.rb +1 -1
  25. data/examples/chart_styles.rb +1 -1
  26. data/examples/colors.rb +1 -1
  27. data/examples/conditional_format.rb +73 -46
  28. data/examples/data_validate.rb +1 -1
  29. data/examples/date_time.rb +1 -1
  30. data/examples/demo.rb +5 -8
  31. data/examples/formats.rb +1 -1
  32. data/examples/headers.rb +1 -1
  33. data/examples/hide_row_col.rb +1 -1
  34. data/examples/hide_sheet.rb +1 -1
  35. data/examples/hyperlink1.rb +5 -12
  36. data/examples/indent.rb +1 -1
  37. data/examples/macros.rb +1 -1
  38. data/examples/merge1.rb +1 -1
  39. data/examples/merge2.rb +1 -1
  40. data/examples/merge3.rb +1 -1
  41. data/examples/merge4.rb +1 -1
  42. data/examples/merge5.rb +1 -1
  43. data/examples/merge6.rb +1 -1
  44. data/examples/outline.rb +1 -1
  45. data/examples/outline_collapsed.rb +1 -1
  46. data/examples/panes.rb +1 -1
  47. data/examples/properties.rb +1 -1
  48. data/examples/regions.rb +1 -1
  49. data/examples/rich_strings.rb +1 -1
  50. data/examples/right_to_left.rb +1 -1
  51. data/examples/shape1.rb +1 -1
  52. data/examples/shape2.rb +1 -1
  53. data/examples/shape3.rb +1 -1
  54. data/examples/shape4.rb +1 -1
  55. data/examples/shape5.rb +1 -1
  56. data/examples/shape6.rb +1 -1
  57. data/examples/shape7.rb +1 -1
  58. data/examples/shape8.rb +1 -1
  59. data/examples/shape_all.rb +1 -1
  60. data/examples/sparklines1.rb +1 -1
  61. data/examples/sparklines2.rb +1 -1
  62. data/examples/stats.rb +1 -1
  63. data/examples/stats_ext.rb +1 -1
  64. data/examples/stocks.rb +1 -1
  65. data/examples/tab_colors.rb +1 -1
  66. data/examples/tables.rb +1 -1
  67. data/lib/write_xlsx/chart.rb +124 -240
  68. data/lib/write_xlsx/chart/area.rb +1 -1
  69. data/lib/write_xlsx/chart/axis.rb +4 -4
  70. data/lib/write_xlsx/chart/bar.rb +1 -1
  71. data/lib/write_xlsx/chart/caption.rb +3 -1
  72. data/lib/write_xlsx/chart/column.rb +1 -1
  73. data/lib/write_xlsx/chart/doughnut.rb +1 -1
  74. data/lib/write_xlsx/chart/legend.rb +14 -0
  75. data/lib/write_xlsx/chart/line.rb +1 -1
  76. data/lib/write_xlsx/chart/pie.rb +32 -15
  77. data/lib/write_xlsx/chart/radar.rb +1 -1
  78. data/lib/write_xlsx/chart/scatter.rb +1 -1
  79. data/lib/write_xlsx/chart/series.rb +11 -7
  80. data/lib/write_xlsx/chart/stock.rb +1 -1
  81. data/lib/write_xlsx/chartsheet.rb +35 -7
  82. data/lib/write_xlsx/drawing.rb +28 -8
  83. data/lib/write_xlsx/format.rb +19 -15
  84. data/lib/write_xlsx/package/comments.rb +57 -54
  85. data/lib/write_xlsx/package/conditional_format.rb +360 -39
  86. data/lib/write_xlsx/package/content_types.rb +10 -0
  87. data/lib/write_xlsx/package/core.rb +8 -6
  88. data/lib/write_xlsx/package/custom.rb +125 -0
  89. data/lib/write_xlsx/package/packager.rb +26 -0
  90. data/lib/write_xlsx/package/styles.rb +53 -21
  91. data/lib/write_xlsx/package/table.rb +16 -4
  92. data/lib/write_xlsx/shape.rb +4 -3
  93. data/lib/write_xlsx/sheets.rb +11 -1
  94. data/lib/write_xlsx/sparkline.rb +1 -1
  95. data/lib/write_xlsx/utility.rb +305 -35
  96. data/lib/write_xlsx/version.rb +1 -1
  97. data/lib/write_xlsx/workbook.rb +132 -12
  98. data/lib/write_xlsx/worksheet.rb +397 -163
  99. data/lib/write_xlsx/worksheet/data_validation.rb +10 -14
  100. data/lib/write_xlsx/worksheet/hyperlink.rb +4 -13
  101. data/test/chart/test_write_legend_pos.rb +9 -1
  102. data/test/chartsheet/test_write_sheet_protection.rb +91 -0
  103. data/test/drawing/test_drawing_chart_01.rb +6 -2
  104. data/test/drawing/test_drawing_image_01.rb +12 -3
  105. data/test/drawing/test_drawing_shape_01.rb +8 -5
  106. data/test/drawing/test_drawing_shape_02.rb +12 -5
  107. data/test/drawing/test_drawing_shape_03.rb +8 -5
  108. data/test/drawing/test_drawing_shape_04.rb +8 -24
  109. data/test/drawing/test_drawing_shape_05.rb +8 -5
  110. data/test/drawing/test_drawing_shape_06.rb +11 -6
  111. data/test/drawing/test_drawing_shape_07.rb +11 -6
  112. data/test/drawing/test_write_a_graphic_frame_locks.rb +1 -1
  113. data/test/drawing/test_write_c_chart.rb +1 -1
  114. data/test/drawing/test_write_c_nv_graphic_frame_pr.rb +1 -1
  115. data/test/drawing/test_write_c_nv_pr.rb +1 -1
  116. data/test/drawing/test_write_col.rb +1 -1
  117. data/test/drawing/test_write_col_off.rb +1 -1
  118. data/test/drawing/test_write_ext.rb +1 -1
  119. data/test/drawing/test_write_pos.rb +1 -1
  120. data/test/drawing/test_write_row.rb +1 -1
  121. data/test/drawing/test_write_row_off.rb +1 -1
  122. data/test/drawing/test_write_xfrm_extension.rb +1 -1
  123. data/test/drawing/test_write_xfrm_offset.rb +1 -1
  124. data/test/helper.rb +6 -1
  125. data/test/package/comments/test_comments_01.rb +54 -0
  126. data/test/package/comments/test_comments_02.rb +54 -0
  127. data/test/perl_output/chart_gauge.xlsx +0 -0
  128. data/test/perl_output/formats.xlsx +0 -0
  129. data/test/regression/_test_hyperlink31.rb +26 -0
  130. data/test/regression/images/happy.jpg +0 -0
  131. data/test/regression/images/zero_dpi.jpg +0 -0
  132. data/test/regression/test_array_formula03.rb +36 -0
  133. data/test/regression/test_autofilter08.rb +110 -0
  134. data/test/regression/test_autofilter09.rb +110 -0
  135. data/test/regression/test_autofilter10.rb +110 -0
  136. data/test/regression/test_chart_axis26.rb +10 -8
  137. data/test/regression/test_chart_axis27.rb +1 -1
  138. data/test/regression/test_chart_axis28.rb +1 -1
  139. data/test/regression/test_chart_axis29.rb +1 -1
  140. data/test/regression/test_chart_axis33.rb +1 -1
  141. data/test/regression/test_chart_axis42.rb +44 -0
  142. data/test/regression/test_chart_axis43.rb +44 -0
  143. data/test/regression/test_chart_axis44.rb +54 -0
  144. data/test/regression/test_chart_axis45.rb +54 -0
  145. data/test/regression/test_chart_axis46.rb +54 -0
  146. data/test/regression/test_chart_bar08.rb +3 -0
  147. data/test/regression/test_chart_bar11.rb +3 -0
  148. data/test/regression/test_chart_bar14.rb +3 -0
  149. data/test/regression/test_chart_chartarea05.rb +16 -17
  150. data/test/regression/test_chart_chartarea06.rb +49 -0
  151. data/test/regression/test_chart_combined10.rb +43 -0
  152. data/test/regression/test_chart_combined11.rb +63 -0
  153. data/test/regression/test_chart_data_labels25.rb +61 -0
  154. data/test/regression/test_chart_doughnut07.rb +37 -0
  155. data/test/regression/test_chart_font09.rb +1 -1
  156. data/test/regression/test_chart_format26.rb +48 -0
  157. data/test/regression/test_chart_format27.rb +58 -0
  158. data/test/regression/test_chart_format28.rb +52 -0
  159. data/test/regression/test_chart_format29.rb +59 -0
  160. data/test/regression/test_chart_format30.rb +53 -0
  161. data/test/regression/test_chart_format31.rb +60 -0
  162. data/test/regression/test_chart_legend03.rb +41 -0
  163. data/test/regression/test_chart_legend04.rb +41 -0
  164. data/test/regression/test_chart_legend05.rb +41 -0
  165. data/test/regression/test_chart_legend06.rb +41 -0
  166. data/test/regression/test_chart_legend07.rb +38 -0
  167. data/test/regression/test_chart_size03.rb +4 -1
  168. data/test/regression/test_chart_table03.rb +56 -0
  169. data/test/regression/test_comment13.rb +36 -0
  170. data/test/regression/test_comment14.rb +29 -0
  171. data/test/regression/test_cond_format14.rb +42 -0
  172. data/test/regression/test_cond_format15.rb +53 -0
  173. data/test/regression/test_cond_format16.rb +53 -0
  174. data/test/regression/test_cond_format17.rb +37 -0
  175. data/test/regression/test_cond_format18.rb +136 -0
  176. data/test/regression/test_cond_format19.rb +64 -0
  177. data/test/regression/test_cond_format20.rb +43 -0
  178. data/test/regression/test_date_1904_01.rb +1 -1
  179. data/test/regression/test_escapes04.rb +3 -0
  180. data/test/regression/test_escapes05.rb +3 -0
  181. data/test/regression/test_escapes07.rb +3 -0
  182. data/test/regression/test_escapes08.rb +3 -0
  183. data/test/regression/test_format15.rb +26 -0
  184. data/test/regression/test_hyperlink01.rb +3 -0
  185. data/test/regression/test_hyperlink02.rb +3 -0
  186. data/test/regression/test_hyperlink03.rb +4 -0
  187. data/test/regression/test_hyperlink04.rb +3 -0
  188. data/test/regression/test_hyperlink05.rb +3 -0
  189. data/test/regression/test_hyperlink06.rb +3 -0
  190. data/test/regression/test_hyperlink07.rb +3 -0
  191. data/test/regression/test_hyperlink08.rb +3 -0
  192. data/test/regression/test_hyperlink09.rb +3 -0
  193. data/test/regression/test_hyperlink10.rb +3 -0
  194. data/test/regression/test_hyperlink11.rb +3 -0
  195. data/test/regression/test_hyperlink12.rb +3 -0
  196. data/test/regression/test_hyperlink13.rb +3 -0
  197. data/test/regression/test_hyperlink14.rb +3 -0
  198. data/test/regression/test_hyperlink15.rb +3 -0
  199. data/test/regression/test_hyperlink16.rb +3 -0
  200. data/test/regression/test_hyperlink17.rb +3 -0
  201. data/test/regression/test_hyperlink18.rb +3 -0
  202. data/test/regression/test_hyperlink20.rb +3 -0
  203. data/test/regression/test_hyperlink21.rb +3 -0
  204. data/test/regression/test_hyperlink22.rb +3 -0
  205. data/test/regression/test_hyperlink23.rb +3 -0
  206. data/test/regression/test_hyperlink24.rb +3 -0
  207. data/test/regression/test_hyperlink25.rb +3 -0
  208. data/test/regression/test_hyperlink26.rb +3 -0
  209. data/test/regression/test_hyperlink27.rb +27 -0
  210. data/test/regression/test_hyperlink28.rb +50 -0
  211. data/test/regression/test_hyperlink29.rb +27 -0
  212. data/test/regression/test_hyperlink30.rb +36 -0
  213. data/test/regression/test_image08.rb +5 -4
  214. data/test/regression/test_image15.rb +4 -2
  215. data/test/regression/test_image28.rb +1 -1
  216. data/test/regression/test_image35.rb +26 -0
  217. data/test/regression/test_image36.rb +26 -0
  218. data/test/regression/test_image44.rb +28 -0
  219. data/test/regression/test_image45.rb +28 -0
  220. data/test/regression/test_image46.rb +29 -0
  221. data/test/regression/test_image47.rb +28 -0
  222. data/test/regression/test_object_position01.rb +26 -0
  223. data/test/regression/test_object_position02.rb +26 -0
  224. data/test/regression/test_object_position03.rb +26 -0
  225. data/test/regression/test_object_position04.rb +44 -0
  226. data/test/regression/test_object_position06.rb +28 -0
  227. data/test/regression/test_object_position07.rb +28 -0
  228. data/test/regression/test_object_position08.rb +47 -0
  229. data/test/regression/test_object_position09.rb +50 -0
  230. data/test/regression/test_object_position10.rb +28 -0
  231. data/test/regression/test_properties01.rb +1 -4
  232. data/test/regression/test_properties02.rb +1 -4
  233. data/test/regression/test_properties03.rb +26 -0
  234. data/test/regression/test_properties04.rb +61 -0
  235. data/test/regression/test_properties05.rb +30 -0
  236. data/test/regression/test_shape_connect01.rb +4 -2
  237. data/test/regression/test_table03.rb +3 -0
  238. data/test/regression/test_table04.rb +3 -0
  239. data/test/regression/test_table05.rb +3 -0
  240. data/test/regression/test_table06.rb +3 -0
  241. data/test/regression/test_table20.rb +34 -0
  242. data/test/regression/test_table21.rb +36 -0
  243. data/test/regression/test_table22.rb +32 -0
  244. data/test/regression/test_table23.rb +56 -0
  245. data/test/regression/test_utf8_11.rb +23 -0
  246. data/test/regression/xlsx_files/array_formula03.xlsx +0 -0
  247. data/test/regression/xlsx_files/autofilter08.xlsx +0 -0
  248. data/test/regression/xlsx_files/autofilter09.xlsx +0 -0
  249. data/test/regression/xlsx_files/autofilter10.xlsx +0 -0
  250. data/test/regression/xlsx_files/chart_axis26.xlsx +0 -0
  251. data/test/regression/xlsx_files/chart_axis27.xlsx +0 -0
  252. data/test/regression/xlsx_files/chart_axis28.xlsx +0 -0
  253. data/test/regression/xlsx_files/chart_axis29.xlsx +0 -0
  254. data/test/regression/xlsx_files/chart_axis33.xlsx +0 -0
  255. data/test/regression/xlsx_files/chart_axis42.xlsx +0 -0
  256. data/test/regression/xlsx_files/chart_axis43.xlsx +0 -0
  257. data/test/regression/xlsx_files/chart_axis44.xlsx +0 -0
  258. data/test/regression/xlsx_files/chart_axis45.xlsx +0 -0
  259. data/test/regression/xlsx_files/chart_axis46.xlsx +0 -0
  260. data/test/regression/xlsx_files/chart_chartarea05.xlsx +0 -0
  261. data/test/regression/xlsx_files/chart_chartarea06.xlsx +0 -0
  262. data/test/regression/xlsx_files/chart_combined10.xlsx +0 -0
  263. data/test/regression/xlsx_files/chart_combined11.xlsx +0 -0
  264. data/test/regression/xlsx_files/chart_data_labels25.xlsx +0 -0
  265. data/test/regression/xlsx_files/chart_doughnut07.xlsx +0 -0
  266. data/test/regression/xlsx_files/chart_font09.xlsx +0 -0
  267. data/test/regression/xlsx_files/chart_format26.xlsx +0 -0
  268. data/test/regression/xlsx_files/chart_format27.xlsx +0 -0
  269. data/test/regression/xlsx_files/chart_format28.xlsx +0 -0
  270. data/test/regression/xlsx_files/chart_format29.xlsx +0 -0
  271. data/test/regression/xlsx_files/chart_format30.xlsx +0 -0
  272. data/test/regression/xlsx_files/chart_format31.xlsx +0 -0
  273. data/test/regression/xlsx_files/chart_legend03.xlsx +0 -0
  274. data/test/regression/xlsx_files/chart_legend04.xlsx +0 -0
  275. data/test/regression/xlsx_files/chart_legend05.xlsx +0 -0
  276. data/test/regression/xlsx_files/chart_legend06.xlsx +0 -0
  277. data/test/regression/xlsx_files/chart_legend07.xlsx +0 -0
  278. data/test/regression/xlsx_files/chart_table03.xlsx +0 -0
  279. data/test/regression/xlsx_files/comment13.xlsx +0 -0
  280. data/test/regression/xlsx_files/comment14.xlsx +0 -0
  281. data/test/regression/xlsx_files/cond_format14.xlsx +0 -0
  282. data/test/regression/xlsx_files/cond_format15.xlsx +0 -0
  283. data/test/regression/xlsx_files/cond_format16.xlsx +0 -0
  284. data/test/regression/xlsx_files/cond_format17.xlsx +0 -0
  285. data/test/regression/xlsx_files/cond_format18.xlsx +0 -0
  286. data/test/regression/xlsx_files/cond_format19.xlsx +0 -0
  287. data/test/regression/xlsx_files/cond_format20.xlsx +0 -0
  288. data/test/regression/xlsx_files/date_1904_01.xlsx +0 -0
  289. data/test/regression/xlsx_files/format15.xlsx +0 -0
  290. data/test/regression/xlsx_files/hyperlink27.xlsx +0 -0
  291. data/test/regression/xlsx_files/hyperlink28.xlsx +0 -0
  292. data/test/regression/xlsx_files/hyperlink29.xlsx +0 -0
  293. data/test/regression/xlsx_files/hyperlink30.xlsx +0 -0
  294. data/test/regression/xlsx_files/hyperlink31.xlsx +0 -0
  295. data/test/regression/xlsx_files/image35.xlsx +0 -0
  296. data/test/regression/xlsx_files/image36.xlsx +0 -0
  297. data/test/regression/xlsx_files/image44.xlsx +0 -0
  298. data/test/regression/xlsx_files/image45.xlsx +0 -0
  299. data/test/regression/xlsx_files/image46.xlsx +0 -0
  300. data/test/regression/xlsx_files/image47.xlsx +0 -0
  301. data/test/regression/xlsx_files/object_position01.xlsx +0 -0
  302. data/test/regression/xlsx_files/object_position02.xlsx +0 -0
  303. data/test/regression/xlsx_files/object_position03.xlsx +0 -0
  304. data/test/regression/xlsx_files/object_position04.xlsx +0 -0
  305. data/test/regression/xlsx_files/object_position06.xlsx +0 -0
  306. data/test/regression/xlsx_files/object_position07.xlsx +0 -0
  307. data/test/regression/xlsx_files/object_position08.xlsx +0 -0
  308. data/test/regression/xlsx_files/object_position09.xlsx +0 -0
  309. data/test/regression/xlsx_files/object_position10.xlsx +0 -0
  310. data/test/regression/xlsx_files/properties03.xlsx +0 -0
  311. data/test/regression/xlsx_files/properties04.xlsx +0 -0
  312. data/test/regression/xlsx_files/properties05.xlsx +0 -0
  313. data/test/regression/xlsx_files/table21.xlsx +0 -0
  314. data/test/regression/xlsx_files/table22.xlsx +0 -0
  315. data/test/regression/xlsx_files/table23.xlsx +0 -0
  316. data/test/regression/xlsx_files/utf8_11.xlsx +0 -0
  317. data/test/test_example_match.rb +836 -771
  318. data/test/workbook/test_check_sheetname.rb +61 -0
  319. data/test/workbook/test_worksheet_by_name.rb +35 -0
  320. data/test/workbook/test_write_workbook_view.rb +117 -0
  321. data/test/worksheet/test_cond_format_22.rb +266 -0
  322. data/test/worksheet/test_cond_format_23.rb +242 -0
  323. data/test/worksheet/test_cond_format_24.rb +303 -0
  324. data/test/worksheet/test_data_bar_01.rb +53 -0
  325. data/test/worksheet/test_data_bar_02.rb +79 -0
  326. data/test/worksheet/test_data_bar_03.rb +147 -0
  327. data/test/worksheet/test_data_bar_04.rb +145 -0
  328. data/test/worksheet/test_data_bar_05.rb +147 -0
  329. data/test/worksheet/test_data_bar_06.rb +145 -0
  330. data/test/worksheet/test_data_bar_07.rb +146 -0
  331. data/test/worksheet/test_data_bar_08.rb +54 -0
  332. data/test/worksheet/test_data_bar_09.rb +80 -0
  333. data/test/worksheet/test_data_bar_10.rb +165 -0
  334. data/test/worksheet/test_data_bar_11.rb +167 -0
  335. data/test/worksheet/test_data_bar_12.rb +104 -0
  336. data/test/worksheet/test_write_data_validation_02.rb +44 -0
  337. data/test/worksheet/test_write_hyperlink.rb +0 -7
  338. data/test/worksheet/test_write_sheet_view.rb +19 -1
  339. metadata +308 -5
  340. data/test/package/comments/test_write_text_t.rb +0 -44
@@ -0,0 +1,36 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionTable21 < 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_table21
14
+ @xlsx = 'table21.xlsx'
15
+ workbook = WriteXLSX.new(@io)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ worksheet.write('A1', 'Column')
19
+
20
+ # Set the column width to match the taget worksheet.
21
+ worksheet.set_column('C:D', 10.288)
22
+
23
+ # Add the table.
24
+ worksheet.add_table(
25
+ 'C3:D13',
26
+ {
27
+ :columns => [
28
+ { :header => "Column" }
29
+ ]
30
+ }
31
+ )
32
+
33
+ workbook.close
34
+ compare_for_regression
35
+ end
36
+ end
@@ -0,0 +1,32 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionTable22 < 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_table22
14
+ @xlsx = 'table22.xlsx'
15
+ workbook = WriteXLSX.new(@io)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ data = [
19
+ ['apple', 'pie' ],
20
+ ['pine', 'tree']
21
+ ]
22
+
23
+ # Set the column width to match the taget worksheet.
24
+ worksheet.set_column('B:C', 10.288)
25
+
26
+ # Add the table.
27
+ worksheet.add_table('B2:C3', :data => data, :header_row => 0)
28
+
29
+ workbook.close
30
+ compare_for_regression
31
+ end
32
+ end
@@ -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,23 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionUtf8_11 < 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_utf8_11
14
+ @xlsx = 'utf8_11.xlsx'
15
+ workbook = WriteXLSX.new(@io)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ worksheet.write( 'A1', '12345' )
19
+
20
+ workbook.close
21
+ compare_for_regression
22
+ end
23
+ 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.
@@ -666,9 +728,9 @@ def test_chart_pie
666
728
  # Add the worksheet data that the charts will refer to.
667
729
  headings = [ 'Category', 'Values' ]
668
730
  data = [
669
- [ 'Apple', 'Cherry', 'Pecan' ],
670
- [ 60, 30, 10 ]
671
- ]
731
+ [ 'Apple', 'Cherry', 'Pecan' ],
732
+ [ 60, 30, 10 ]
733
+ ]
672
734
 
673
735
  worksheet.write('A1', headings, bold)
674
736
  worksheet.write('A2', data)
@@ -680,10 +742,10 @@ def test_chart_pie
680
742
  # [ $sheetname, $row_start, $row_end, $col_start, $col_end ].
681
743
  # See below for an alternative syntax.
682
744
  chart1.add_series(
683
- :name => 'Pie sales data',
684
- :categories => [ 'Sheet1', 1, 3, 0, 0 ],
685
- :values => [ 'Sheet1', 1, 3, 1, 1 ]
686
- )
745
+ :name => 'Pie sales data',
746
+ :categories => [ 'Sheet1', 1, 3, 0, 0 ],
747
+ :values => [ 'Sheet1', 1, 3, 1, 1 ]
748
+ )
687
749
 
688
750
  # Add a title.
689
751
  chart1.set_title(:name => 'Popular Pie Types')
@@ -703,15 +765,15 @@ def test_chart_pie
703
765
 
704
766
  # Configure the series and add user defined segment colours.
705
767
  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
- )
768
+ :name => 'Pie sales data',
769
+ :categories => '=Sheet1!$A$2:$A$4',
770
+ :values => '=Sheet1!$B$2:$B$4',
771
+ :points => [
772
+ { :fill => { :color => '#5ABA10' } },
773
+ { :fill => { :color => '#FE110E' } },
774
+ { :fill => { :color => '#CA5C05' } }
775
+ ]
776
+ )
715
777
 
716
778
  # Add a title.
717
779
  chart2.set_title(:name => 'Pie Chart with user defined colors')
@@ -733,10 +795,10 @@ def test_chart_radar
733
795
  # Add the worksheet data that the charts will refer to.
734
796
  headings = [ 'Number', 'Batch 1', 'Batch 2' ]
735
797
  data = [
736
- [ 2, 3, 4, 5, 6, 7 ],
737
- [ 30, 60, 70, 50, 40, 30 ],
738
- [ 25, 40, 50, 30, 50, 40 ]
739
- ]
798
+ [ 2, 3, 4, 5, 6, 7 ],
799
+ [ 30, 60, 70, 50, 40, 30 ],
800
+ [ 25, 40, 50, 30, 50, 40 ]
801
+ ]
740
802
 
741
803
  worksheet.write('A1', headings, bold)
742
804
  worksheet.write('A2', data)
@@ -746,18 +808,18 @@ def test_chart_radar
746
808
 
747
809
  # Configure the first series.
748
810
  chart1.add_series(
749
- :name => '=Sheet1!$B$1',
750
- :categories => '=Sheet1!$A$2:$A$7',
751
- :values => '=Sheet1!$B$2:$B$7'
752
- )
811
+ :name => '=Sheet1!$B$1',
812
+ :categories => '=Sheet1!$A$2:$A$7',
813
+ :values => '=Sheet1!$B$2:$B$7'
814
+ )
753
815
 
754
816
  # Configure second series. Note alternative use of array ref to define
755
817
  # ranges: [ sheetname, row_start, row_end, col_start, col_end ].
756
818
  chart1.add_series(
757
- :name => '=Sheet1!$C$1',
758
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
759
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
760
- )
819
+ :name => '=Sheet1!$C$1',
820
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
821
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
822
+ )
761
823
 
762
824
  # Add a chart title and some axis labels.
763
825
  chart1.set_title(:name => 'Results of sample analysis')
@@ -774,24 +836,24 @@ def test_chart_radar
774
836
  # Create a with_markers chart sub-type
775
837
  #
776
838
  chart2 = workbook.add_chart(
777
- :type => 'radar',
778
- :embedded => 1,
779
- :subtype => 'with_markers'
780
- )
839
+ :type => 'radar',
840
+ :embedded => 1,
841
+ :subtype => 'with_markers'
842
+ )
781
843
 
782
844
  # Configure the first series.
783
845
  chart2.add_series(
784
- :name => '=Sheet1!$B$1',
785
- :categories => '=Sheet1!$A$2:$A$7',
786
- :values => '=Sheet1!$B$2:$B$7'
787
- )
846
+ :name => '=Sheet1!$B$1',
847
+ :categories => '=Sheet1!$A$2:$A$7',
848
+ :values => '=Sheet1!$B$2:$B$7'
849
+ )
788
850
 
789
851
  # Configure second series.
790
852
  chart2.add_series(
791
- :name => '=Sheet1!$C$1',
792
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
793
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
794
- )
853
+ :name => '=Sheet1!$C$1',
854
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
855
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
856
+ )
795
857
 
796
858
  # Add a chart title and some axis labels.
797
859
  chart2.set_title(:name => 'Stacked Chart')
@@ -808,24 +870,24 @@ def test_chart_radar
808
870
  # Create a filled chart sub-type
809
871
  #
810
872
  chart3 = workbook.add_chart(
811
- :type => 'radar',
812
- :embedded => 1,
813
- :subtype => 'filled'
814
- )
873
+ :type => 'radar',
874
+ :embedded => 1,
875
+ :subtype => 'filled'
876
+ )
815
877
 
816
878
  # Configure the first series.
817
879
  chart3.add_series(
818
- :name => '=Sheet1!$B$1',
819
- :categories => '=Sheet1!$A$2:$A$7',
820
- :values => '=Sheet1!$B$2:$B$7'
821
- )
880
+ :name => '=Sheet1!$B$1',
881
+ :categories => '=Sheet1!$A$2:$A$7',
882
+ :values => '=Sheet1!$B$2:$B$7'
883
+ )
822
884
 
823
885
  # Configure second series.
824
886
  chart3.add_series(
825
- :name => '=Sheet1!$C$1',
826
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
827
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
828
- )
887
+ :name => '=Sheet1!$C$1',
888
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
889
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
890
+ )
829
891
 
830
892
  # Add a chart title and some axis labels.
831
893
  chart3.set_title(:name => 'Percent Stacked Chart')
@@ -852,9 +914,9 @@ def test_chart_scatter
852
914
  # Add the worksheet data that the charts will refer to.
853
915
  headings = [ 'Number', 'Batch 1', 'Batch 2' ]
854
916
  data = [
855
- [ 2, 3, 4, 5, 6, 7 ],
856
- [ 10, 40, 50, 20, 10, 50 ],
857
- [ 30, 60, 70, 50, 40, 30 ]
917
+ [ 2, 3, 4, 5, 6, 7 ],
918
+ [ 10, 40, 50, 20, 10, 50 ],
919
+ [ 30, 60, 70, 50, 40, 30 ]
858
920
  ]
859
921
 
860
922
  worksheet.write('A1', headings, bold)
@@ -865,17 +927,17 @@ def test_chart_scatter
865
927
 
866
928
  # Configure the first series.
867
929
  chart.add_series(
868
- :name => '=Sheet1!$B$1',
869
- :categories => '=Sheet1!$A$2:$A$7',
870
- :values => '=Sheet1!$B$2:$B$7'
930
+ :name => '=Sheet1!$B$1',
931
+ :categories => '=Sheet1!$A$2:$A$7',
932
+ :values => '=Sheet1!$B$2:$B$7'
871
933
  )
872
934
 
873
935
  # Configure second series. Note alternative use of array ref to define
874
936
  # ranges: [ $sheetname, $row_start, $row_end, $col_start, $col_end ].$chart->add_series(
875
937
  chart.add_series(
876
- :name => '=Sheet1!$C$1',
877
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
878
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
938
+ :name => '=Sheet1!$C$1',
939
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
940
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
879
941
  )
880
942
 
881
943
  # Add a chart title and some axis labels.
@@ -906,19 +968,19 @@ def test_chart_stock
906
968
  # Add the worksheet data that the charts will refer to.
907
969
  headings = [ 'Date', 'High', 'Low', 'Close' ]
908
970
  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 ]
971
+ [ '2007-01-01T', '2007-01-02T', '2007-01-03T', '2007-01-04T', '2007-01-05T' ],
972
+ [ 27.2, 25.03, 19.05, 20.34, 18.5 ],
973
+ [ 23.49, 19.55, 15.12, 17.84, 16.34 ],
974
+ [ 25.45, 23.05, 17.32, 20.45, 17.34 ]
913
975
  ]
914
976
 
915
977
  worksheet.write('A1', headings, bold)
916
978
 
917
979
  (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])
980
+ worksheet.write_date_time(row + 1, 0, data[0][row], date_format)
981
+ worksheet.write(row + 1, 1, data[1][row])
982
+ worksheet.write(row + 1, 2, data[2][row])
983
+ worksheet.write(row + 1, 3, data[3][row])
922
984
  end
923
985
 
924
986
  worksheet.set_column('A:D', 11)
@@ -960,9 +1022,9 @@ def test_chart_secondary_axis
960
1022
  # Add the worksheet data that the charts will refer to.
961
1023
  headings = [ 'Aliens', 'Humans']
962
1024
  data = [
963
- [ 2, 3, 4, 5, 6, 7 ],
964
- [ 10, 40, 50, 20, 10, 50 ]
965
- ]
1025
+ [ 2, 3, 4, 5, 6, 7 ],
1026
+ [ 10, 40, 50, 20, 10, 50 ]
1027
+ ]
966
1028
 
967
1029
  worksheet.write('A1', headings, bold)
968
1030
  worksheet.write('A2', data)
@@ -972,15 +1034,15 @@ def test_chart_secondary_axis
972
1034
 
973
1035
  # Configure the first series.
974
1036
  chart.add_series(
975
- :name => '=Sheet1!$A$1',
976
- :values => '=Sheet1!$A$2:$A$7',
977
- :y2_axis => 1
978
- )
1037
+ :name => '=Sheet1!$A$1',
1038
+ :values => '=Sheet1!$A$2:$A$7',
1039
+ :y2_axis => 1
1040
+ )
979
1041
 
980
1042
  chart.add_series(
981
- :name => '=Sheet1!$B$1',
982
- :values => '=Sheet1!$B$2:$B$7'
983
- )
1043
+ :name => '=Sheet1!$B$1',
1044
+ :values => '=Sheet1!$B$2:$B$7'
1045
+ )
984
1046
 
985
1047
  chart.set_legend(:position => 'right')
986
1048
 
@@ -1275,7 +1337,7 @@ def test_comments2
1275
1337
  cell = 'C3'
1276
1338
 
1277
1339
  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"
1340
+ "by #{author}' (blank) in the status bar at the bottom"
1279
1341
 
1280
1342
  comment = 'Hello.'
1281
1343
 
@@ -1286,7 +1348,7 @@ def test_comments2
1286
1348
  author = 'Ruby'
1287
1349
  cell = 'C6'
1288
1350
  cell_text = "Move the mouse over this cell and you will see 'Cell commented " +
1289
- "by #{author}' in the status bar at the bottom"
1351
+ "by #{author}' in the status bar at the bottom"
1290
1352
 
1291
1353
  comment = 'Hello.'
1292
1354
 
@@ -1297,7 +1359,7 @@ def test_comments2
1297
1359
  author = '€'
1298
1360
  cell = 'C9'
1299
1361
  cell_text = "Move the mouse over this cell and you will see 'Cell commented " +
1300
- "by #{author}' in the status bar at the bottom"
1362
+ "by #{author}' in the status bar at the bottom"
1301
1363
  comment = 'Hello.'
1302
1364
 
1303
1365
  worksheet7.write( cell, cell_text, text_wrap )
@@ -1361,36 +1423,36 @@ def test_conditional_format
1361
1423
 
1362
1424
  # Light red fill with dark red text.
1363
1425
  format1 = workbook.add_format(
1364
- :bg_color => '#FFC7CE',
1365
- :color => '#9C0006'
1366
- )
1426
+ :bg_color => '#FFC7CE',
1427
+ :color => '#9C0006'
1428
+ )
1367
1429
 
1368
1430
  # Green fill with dark green text.
1369
1431
  format2 = workbook.add_format(
1370
- :bg_color => '#C6EFCE',
1371
- :color => '#006100'
1372
- )
1432
+ :bg_color => '#C6EFCE',
1433
+ :color => '#006100'
1434
+ )
1373
1435
 
1374
1436
  # Some sample data to run the conditional formatting against.
1375
1437
  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
- ]
1438
+ [ 34, 72, 38, 30, 75, 48, 75, 66, 84, 86 ],
1439
+ [ 6, 24, 1, 84, 54, 62, 60, 3, 26, 59 ],
1440
+ [ 28, 79, 97, 13, 85, 93, 93, 22, 5, 14 ],
1441
+ [ 27, 71, 40, 17, 18, 79, 90, 93, 29, 47 ],
1442
+ [ 88, 25, 33, 23, 67, 1, 59, 79, 47, 36 ],
1443
+ [ 24, 100, 20, 88, 29, 33, 38, 54, 54, 88 ],
1444
+ [ 6, 57, 88, 28, 10, 26, 37, 7, 41, 48 ],
1445
+ [ 52, 78, 1, 96, 26, 45, 47, 33, 96, 36 ],
1446
+ [ 60, 54, 81, 66, 81, 90, 80, 93, 12, 55 ],
1447
+ [ 70, 5, 46, 14, 71, 19, 66, 36, 41, 21 ]
1448
+ ]
1387
1449
 
1388
1450
  ###############################################################################
1389
1451
  #
1390
1452
  # Example 1.
1391
1453
  #
1392
1454
  caption = 'Cells with values >= 50 are in light red. ' +
1393
- 'Values < 50 are in light green.'
1455
+ 'Values < 50 are in light green.'
1394
1456
 
1395
1457
  # Write the data.
1396
1458
  worksheet1.write('A1', caption)
@@ -1404,7 +1466,7 @@ def test_conditional_format
1404
1466
  :value => 50,
1405
1467
  :format => format1
1406
1468
  }
1407
- )
1469
+ )
1408
1470
 
1409
1471
  # Write another conditional format over the same range.
1410
1472
  worksheet1.conditional_formatting('B3:K12',
@@ -1414,7 +1476,7 @@ def test_conditional_format
1414
1476
  :value => 50,
1415
1477
  :format => format2
1416
1478
  }
1417
- )
1479
+ )
1418
1480
 
1419
1481
 
1420
1482
  ###############################################################################
@@ -1422,7 +1484,7 @@ def test_conditional_format
1422
1484
  # Example 2.
1423
1485
  #
1424
1486
  caption = 'Values between 30 and 70 are in light red. ' +
1425
- 'Values outside that range are in light green.'
1487
+ 'Values outside that range are in light green.'
1426
1488
 
1427
1489
  worksheet2.write('A1', caption)
1428
1490
  worksheet2.write_col('B3', data)
@@ -1435,7 +1497,7 @@ def test_conditional_format
1435
1497
  :maximum => 70,
1436
1498
  :format => format1
1437
1499
  }
1438
- )
1500
+ )
1439
1501
 
1440
1502
  worksheet2.conditional_formatting('B3:K12',
1441
1503
  {
@@ -1445,7 +1507,7 @@ def test_conditional_format
1445
1507
  :maximum => 70,
1446
1508
  :format => format2
1447
1509
  }
1448
- )
1510
+ )
1449
1511
 
1450
1512
 
1451
1513
  ###############################################################################
@@ -1453,7 +1515,7 @@ def test_conditional_format
1453
1515
  # Example 3.
1454
1516
  #
1455
1517
  caption = 'Duplicate values are in light red. ' +
1456
- 'Unique values are in light green.'
1518
+ 'Unique values are in light green.'
1457
1519
 
1458
1520
  worksheet3.write('A1', caption)
1459
1521
  worksheet3.write_col('B3', data)
@@ -1463,14 +1525,14 @@ def test_conditional_format
1463
1525
  :type => 'duplicate',
1464
1526
  :format => format1,
1465
1527
  }
1466
- )
1528
+ )
1467
1529
 
1468
1530
  worksheet3.conditional_formatting('B3:K12',
1469
1531
  {
1470
1532
  :type => 'unique',
1471
1533
  :format => format2,
1472
1534
  }
1473
- )
1535
+ )
1474
1536
 
1475
1537
 
1476
1538
  ###############################################################################
@@ -1478,7 +1540,7 @@ def test_conditional_format
1478
1540
  # Example 4.
1479
1541
  #
1480
1542
  caption = 'Above average values are in light red. ' +
1481
- 'Below average values are in light green.'
1543
+ 'Below average values are in light green.'
1482
1544
 
1483
1545
  worksheet4.write('A1', caption)
1484
1546
  worksheet4.write_col('B3', data)
@@ -1489,7 +1551,7 @@ def test_conditional_format
1489
1551
  :criteria => 'above',
1490
1552
  :format => format1
1491
1553
  }
1492
- )
1554
+ )
1493
1555
 
1494
1556
  worksheet4.conditional_formatting('B3:K12',
1495
1557
  {
@@ -1497,7 +1559,7 @@ def test_conditional_format
1497
1559
  :criteria => 'below',
1498
1560
  :format => format2
1499
1561
  }
1500
- )
1562
+ )
1501
1563
 
1502
1564
 
1503
1565
  ###############################################################################
@@ -1505,7 +1567,7 @@ def test_conditional_format
1505
1567
  # Example 5.
1506
1568
  #
1507
1569
  caption = 'Top 10 values are in light red. ' +
1508
- 'Bottom 10 values are in light green.'
1570
+ 'Bottom 10 values are in light green.'
1509
1571
 
1510
1572
  worksheet5.write('A1', caption)
1511
1573
  worksheet5.write_col('B3', data)
@@ -1516,7 +1578,7 @@ def test_conditional_format
1516
1578
  :value => '10',
1517
1579
  :format => format1
1518
1580
  }
1519
- )
1581
+ )
1520
1582
 
1521
1583
  worksheet5.conditional_formatting('B3:K12',
1522
1584
  {
@@ -1524,7 +1586,7 @@ def test_conditional_format
1524
1586
  :value => '10',
1525
1587
  :format => format2
1526
1588
  }
1527
- )
1589
+ )
1528
1590
 
1529
1591
 
1530
1592
  ###############################################################################
@@ -1532,7 +1594,7 @@ def test_conditional_format
1532
1594
  # Example 6.
1533
1595
  #
1534
1596
  caption = 'Cells with values >= 50 are in light red. ' +
1535
- 'Values < 50 are in light green. Non-contiguous ranges.'
1597
+ 'Values < 50 are in light green. Non-contiguous ranges.'
1536
1598
 
1537
1599
  # Write the data.
1538
1600
  worksheet6.write('A1', caption)
@@ -1546,7 +1608,7 @@ def test_conditional_format
1546
1608
  :value => 50,
1547
1609
  :format => format1
1548
1610
  }
1549
- )
1611
+ )
1550
1612
 
1551
1613
  # Write another conditional format over the same range.
1552
1614
  worksheet6.conditional_formatting('B3:K6,B9:K12',
@@ -1556,7 +1618,7 @@ def test_conditional_format
1556
1618
  :value => 50,
1557
1619
  :format => format2
1558
1620
  }
1559
- )
1621
+ )
1560
1622
 
1561
1623
 
1562
1624
  ###############################################################################
@@ -1583,19 +1645,19 @@ def test_conditional_format
1583
1645
  {
1584
1646
  :type => '2_color_scale'
1585
1647
  }
1586
- )
1648
+ )
1587
1649
 
1588
1650
  worksheet7.conditional_formatting('D3:D14',
1589
1651
  {
1590
1652
  :type => '3_color_scale'
1591
1653
  }
1592
- )
1654
+ )
1593
1655
 
1594
1656
  worksheet7.conditional_formatting('F3:F14',
1595
1657
  {
1596
1658
  :type => 'data_bar'
1597
1659
  }
1598
- )
1660
+ )
1599
1661
 
1600
1662
 
1601
1663
  ###############################################################################
@@ -1624,7 +1686,7 @@ def test_conditional_format
1624
1686
  :min_color => "#FF0000",
1625
1687
  :max_color => "#00FF00"
1626
1688
  }
1627
- )
1689
+ )
1628
1690
 
1629
1691
  worksheet8.conditional_formatting('D3:D14',
1630
1692
  {
@@ -1633,14 +1695,14 @@ def test_conditional_format
1633
1695
  :mid_color => "#8DB4E3",
1634
1696
  :max_color => "#538ED5"
1635
1697
  }
1636
- )
1698
+ )
1637
1699
 
1638
1700
  worksheet8.conditional_formatting('F3:F14',
1639
1701
  {
1640
1702
  :type => 'data_bar',
1641
1703
  :bar_color => '#63C384'
1642
1704
  }
1643
- )
1705
+ )
1644
1706
 
1645
1707
  workbook.close
1646
1708
  store_to_tempfile
@@ -1654,13 +1716,13 @@ def test_data_validate
1654
1716
 
1655
1717
  # Add a format for the header cells.
1656
1718
  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
- )
1719
+ :border => 1,
1720
+ :bg_color => 43,
1721
+ :bold => 1,
1722
+ :text_wrap => 1,
1723
+ :valign => 'vcenter',
1724
+ :indent => 1
1725
+ )
1664
1726
 
1665
1727
  # Set up layout of the worksheet.
1666
1728
  worksheet.set_column('A:A', 68)
@@ -1932,32 +1994,32 @@ def test_date_time
1932
1994
  # the format codes change the appearance of the date.
1933
1995
  #
1934
1996
  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
- ]
1997
+ 'dd/mm/yy',
1998
+ 'mm/dd/yy',
1999
+ '',
2000
+ 'd mm yy',
2001
+ 'dd mm yy',
2002
+ '',
2003
+ 'dd m yy',
2004
+ 'dd mm yy',
2005
+ 'dd mmm yy',
2006
+ 'dd mmmm yy',
2007
+ '',
2008
+ 'dd mm y',
2009
+ 'dd mm yyy',
2010
+ 'dd mm yyyy',
2011
+ '',
2012
+ 'd mmmm yyyy',
2013
+ '',
2014
+ 'dd/mm/yy',
2015
+ 'dd/mm/yy hh:mm',
2016
+ 'dd/mm/yy hh:mm:ss',
2017
+ 'dd/mm/yy hh:mm:ss.000',
2018
+ '',
2019
+ 'hh:mm',
2020
+ 'hh:mm:ss',
2021
+ 'hh:mm:ss.000'
2022
+ ]
1961
2023
 
1962
2024
  # Write the same date and time using each of the above formats. The empty
1963
2025
  # string formats create a blank line to make the example clearer.
@@ -1969,9 +2031,9 @@ def test_date_time
1969
2031
 
1970
2032
  # Create a format for the date or time.
1971
2033
  format = workbook.add_format(
1972
- :num_format => date_format,
1973
- :align => 'left'
1974
- )
2034
+ :num_format => date_format,
2035
+ :align => 'left'
2036
+ )
1975
2037
 
1976
2038
  # Write the same date using different formats.
1977
2039
  worksheet.write_date_time(row, 0, '2004-08-01T12:30:45.123', format)
@@ -2036,17 +2098,17 @@ def test_demo
2036
2098
  worksheet.set_row(0, 40)
2037
2099
 
2038
2100
  heading = workbook.add_format(
2039
- :bold => 1,
2040
- :color => 'blue',
2041
- :size => 16,
2042
- :merge => 1,
2043
- :align => 'vcenter'
2044
- )
2101
+ :bold => 1,
2102
+ :color => 'blue',
2103
+ :size => 16,
2104
+ :merge => 1,
2105
+ :align => 'vcenter'
2106
+ )
2045
2107
 
2046
2108
  hyperlink_format = workbook.add_format(
2047
- :color => 'blue',
2048
- :underline => 1
2049
- )
2109
+ :color => 'blue',
2110
+ :underline => 1
2111
+ )
2050
2112
 
2051
2113
  headings = ['Features of WriteXLSX', '']
2052
2114
  worksheet.write_row('A1', headings, heading)
@@ -2056,12 +2118,12 @@ def test_demo
2056
2118
  # Some text examples
2057
2119
  #
2058
2120
  text_format = workbook.add_format(
2059
- :bold => 1,
2060
- :italic => 1,
2061
- :color => 'red',
2062
- :size => 18,
2063
- :font => 'Lucida Calligraphy'
2064
- )
2121
+ :bold => 1,
2122
+ :italic => 1,
2123
+ :color => 'red',
2124
+ :size => 18,
2125
+ :font => 'Lucida Calligraphy'
2126
+ )
2065
2127
 
2066
2128
  worksheet.write('A2', "Text")
2067
2129
  worksheet.write('B2', "Hello Excel")
@@ -2104,7 +2166,10 @@ def test_demo
2104
2166
  # Images
2105
2167
  #
2106
2168
  worksheet.write('A10', "Images")
2107
- worksheet.insert_image('B10', File.join(@test_dir, 'republic.png'), 16, 8)
2169
+ worksheet.insert_image(
2170
+ 'B10', File.join(@test_dir, 'republic.png'),
2171
+ :x_offset => 16, :y_offset => 8
2172
+ )
2108
2173
 
2109
2174
  #######################################################################
2110
2175
  #
@@ -2129,10 +2194,10 @@ def test_diag_border
2129
2194
  format3 = workbook.add_format(:diag_type => 3)
2130
2195
 
2131
2196
  format4 = workbook.add_format(
2132
- :diag_type => 3,
2133
- :diag_border => 7,
2134
- :diag_color => 'red'
2135
- )
2197
+ :diag_type => 3,
2198
+ :diag_border => 7,
2199
+ :diag_color => 'red'
2200
+ )
2136
2201
 
2137
2202
  worksheet.write('B3', 'Text', format1)
2138
2203
  worksheet.write('B6', 'Text', format2)
@@ -2218,9 +2283,9 @@ def intro(workbook, center, heading, colors)
2218
2283
  format2.set_color('blue')
2219
2284
 
2220
2285
  format3 = workbook.add_format(
2221
- :color => 'blue',
2222
- :underline => 1
2223
- )
2286
+ :color => 'blue',
2287
+ :underline => 1
2288
+ )
2224
2289
 
2225
2290
  worksheet.write(2, 0, 'This workbook demonstrates some of', format)
2226
2291
  worksheet.write(3, 0, 'the formatting options provided by', format)
@@ -2233,16 +2298,16 @@ def intro(workbook, center, heading, colors)
2233
2298
  'Named colors', format3)
2234
2299
 
2235
2300
  worksheet.write(
2236
- 'A10',
2237
- "internal:'Standard colors'!A1",
2238
- 'Standard colors', format3
2239
- )
2301
+ 'A10',
2302
+ "internal:'Standard colors'!A1",
2303
+ 'Standard colors', format3
2304
+ )
2240
2305
 
2241
2306
  worksheet.write(
2242
- 'A11',
2243
- "internal:'Numeric formats'!A1",
2244
- 'Numeric formats', format3
2245
- )
2307
+ 'A11',
2308
+ "internal:'Numeric formats'!A1",
2309
+ 'Numeric formats', format3
2310
+ )
2246
2311
 
2247
2312
  worksheet.write('A12', "internal:Borders!A1", 'Borders', format3)
2248
2313
  worksheet.write('A13', "internal:Patterns!A1", 'Patterns', format3)
@@ -2272,10 +2337,10 @@ def named_colors(workbook, center, heading, colors)
2272
2337
  [33, 11, 53, 17, 22, 18, 13, 16, 23, 9, 12, 15, 14, 20, 8, 10].each do |index|
2273
2338
  color = colors[index]
2274
2339
  format = workbook.add_format(
2275
- :bg_color => color,
2276
- :pattern => 1,
2277
- :border => 1
2278
- )
2340
+ :bg_color => color,
2341
+ :pattern => 1,
2342
+ :border => 1
2343
+ )
2279
2344
 
2280
2345
  worksheet.write(i + 1, 0, index, center)
2281
2346
  worksheet.write(i + 1, 1, sprintf("0x%02X", index), center)
@@ -2302,10 +2367,10 @@ def standard_colors(workbook, center, heading, colors)
2302
2367
 
2303
2368
  (8 .. 63).each do |i|
2304
2369
  format = workbook.add_format(
2305
- :bg_color => i,
2306
- :pattern => 1,
2307
- :border => 1
2308
- )
2370
+ :bg_color => i,
2371
+ :pattern => 1,
2372
+ :border => 1
2373
+ )
2309
2374
 
2310
2375
  worksheet.write((i - 7), 0, i, center)
2311
2376
  worksheet.write((i - 7), 1, sprintf("0x%02X", i), center)
@@ -2787,17 +2852,17 @@ def test_hyperlink
2787
2852
 
2788
2853
  # Add the standard url link format.
2789
2854
  url_format = workbook.add_format(
2790
- :color => 'blue',
2791
- :underline => 1
2792
- )
2855
+ :color => 'blue',
2856
+ :underline => 1
2857
+ )
2793
2858
 
2794
2859
  # Add a sample format.
2795
2860
  red_format = workbook.add_format(
2796
- :color => 'red',
2797
- :bold => 1,
2798
- :underline => 1,
2799
- :size => 12
2800
- )
2861
+ :color => 'red',
2862
+ :bold => 1,
2863
+ :underline => 1,
2864
+ :size => 12
2865
+ )
2801
2866
 
2802
2867
  # Add an alternate description string to the URL.
2803
2868
  str = 'Perl home.'
@@ -2873,16 +2938,16 @@ def test_merge2
2873
2938
 
2874
2939
  # Create a merged format
2875
2940
  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
- )
2941
+ :center_across => 1,
2942
+ :bold => 1,
2943
+ :size => 15,
2944
+ :pattern => 1,
2945
+ :border => 6,
2946
+ :color => 'white',
2947
+ :fg_color => 'green',
2948
+ :border_color => 'yellow',
2949
+ :align => 'vcenter'
2950
+ )
2886
2951
 
2887
2952
  # Only one cell should contain text, the others should be blank.
2888
2953
  worksheet.write(2, 1, "Center across selection", format)
@@ -2909,12 +2974,12 @@ def test_merge3
2909
2974
  # Example: Merge cells containing a hyperlink using merge_range().
2910
2975
  #
2911
2976
  format = workbook.add_format(
2912
- :border => 1,
2913
- :underline => 1,
2914
- :color => 'blue',
2915
- :align => 'center',
2916
- :valign => 'vcenter'
2917
- )
2977
+ :border => 1,
2978
+ :underline => 1,
2979
+ :color => 'blue',
2980
+ :align => 'center',
2981
+ :valign => 'vcenter'
2982
+ )
2918
2983
 
2919
2984
  # Merge 3 cells
2920
2985
  worksheet.merge_range('B4:D4', 'http://www.perl.com', format)
@@ -2942,12 +3007,12 @@ def test_merge4
2942
3007
  # Example 1: Text centered vertically and horizontally
2943
3008
  #
2944
3009
  format1 = workbook.add_format(
2945
- :border => 6,
2946
- :bold => 1,
2947
- :color => 'red',
2948
- :valign => 'vcenter',
2949
- :align => 'center'
2950
- )
3010
+ :border => 6,
3011
+ :bold => 1,
3012
+ :color => 'red',
3013
+ :valign => 'vcenter',
3014
+ :align => 'center'
3015
+ )
2951
3016
 
2952
3017
  worksheet.merge_range('B2:D3', 'Vertical and horizontal', format1)
2953
3018
 
@@ -2956,12 +3021,12 @@ def test_merge4
2956
3021
  # Example 2: Text aligned to the top and left
2957
3022
  #
2958
3023
  format2 = workbook.add_format(
2959
- :border => 6,
2960
- :bold => 1,
2961
- :color => 'red',
2962
- :valign => 'top',
2963
- :align => 'left'
2964
- )
3024
+ :border => 6,
3025
+ :bold => 1,
3026
+ :color => 'red',
3027
+ :valign => 'top',
3028
+ :align => 'left'
3029
+ )
2965
3030
 
2966
3031
  worksheet.merge_range('B5:D6', 'Aligned to the top and left', format2)
2967
3032
 
@@ -2970,12 +3035,12 @@ def test_merge4
2970
3035
  # Example 3: Text aligned to the bottom and right
2971
3036
  #
2972
3037
  format3 = workbook.add_format(
2973
- :border => 6,
2974
- :bold => 1,
2975
- :color => 'red',
2976
- :valign => 'bottom',
2977
- :align => 'right'
2978
- )
3038
+ :border => 6,
3039
+ :bold => 1,
3040
+ :color => 'red',
3041
+ :valign => 'bottom',
3042
+ :align => 'right'
3043
+ )
2979
3044
 
2980
3045
  worksheet.merge_range('B8:D9', 'Aligned to the bottom and right', format3)
2981
3046
 
@@ -2984,12 +3049,12 @@ def test_merge4
2984
3049
  # Example 4: Text justified (i.e. wrapped) in the cell
2985
3050
  #
2986
3051
  format4 = workbook.add_format(
2987
- :border => 6,
2988
- :bold => 1,
2989
- :color => 'red',
2990
- :valign => 'top',
2991
- :align => 'justify'
2992
- )
3052
+ :border => 6,
3053
+ :bold => 1,
3054
+ :color => 'red',
3055
+ :valign => 'top',
3056
+ :align => 'justify'
3057
+ )
2993
3058
 
2994
3059
  worksheet.merge_range('B11:D12', 'Justified: ' << 'so on and ' * 18, format4)
2995
3060
 
@@ -3013,13 +3078,13 @@ def test_merge5
3013
3078
  # Rotation 1, letters run from top to bottom
3014
3079
  #
3015
3080
  format1 = workbook.add_format(
3016
- :border => 6,
3017
- :bold => 1,
3018
- :color => 'red',
3019
- :valign => 'vcentre',
3020
- :align => 'centre',
3021
- :rotation => 270
3022
- )
3081
+ :border => 6,
3082
+ :bold => 1,
3083
+ :color => 'red',
3084
+ :valign => 'vcentre',
3085
+ :align => 'centre',
3086
+ :rotation => 270
3087
+ )
3023
3088
 
3024
3089
  worksheet.merge_range( 'B4:B9', 'Rotation 270', format1 )
3025
3090
 
@@ -3028,13 +3093,13 @@ def test_merge5
3028
3093
  # Rotation 2, 90ー anticlockwise
3029
3094
  #
3030
3095
  format2 = workbook.add_format(
3031
- :border => 6,
3032
- :bold => 1,
3033
- :color => 'red',
3034
- :valign => 'vcentre',
3035
- :align => 'centre',
3036
- :rotation => 90
3037
- )
3096
+ :border => 6,
3097
+ :bold => 1,
3098
+ :color => 'red',
3099
+ :valign => 'vcentre',
3100
+ :align => 'centre',
3101
+ :rotation => 90
3102
+ )
3038
3103
 
3039
3104
  worksheet.merge_range( 'D4:D9', 'Rotation 90°', format2 )
3040
3105
 
@@ -3043,13 +3108,13 @@ def test_merge5
3043
3108
  # Rotation 3, 90ー clockwise
3044
3109
  #
3045
3110
  format3 = workbook.add_format(
3046
- :border => 6,
3047
- :bold => 1,
3048
- :color => 'red',
3049
- :valign => 'vcentre',
3050
- :align => 'centre',
3051
- :rotation => -90
3052
- )
3111
+ :border => 6,
3112
+ :bold => 1,
3113
+ :color => 'red',
3114
+ :valign => 'vcentre',
3115
+ :align => 'centre',
3116
+ :rotation => -90
3117
+ )
3053
3118
 
3054
3119
  worksheet.merge_range( 'F4:F9', 'Rotation -90°', format3 )
3055
3120
 
@@ -3070,14 +3135,14 @@ def test_merge6
3070
3135
 
3071
3136
  # Format for the merged cells.
3072
3137
  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
- )
3138
+ :border => 6,
3139
+ :bold => 1,
3140
+ :color => 'red',
3141
+ :size => 20,
3142
+ :valign => 'vcentre',
3143
+ :align => 'left',
3144
+ :indent => 1
3145
+ )
3081
3146
 
3082
3147
  ###############################################################################
3083
3148
  #
@@ -3234,12 +3299,12 @@ def test_outline
3234
3299
  # Example 3: Create a worksheet with outlined columns.
3235
3300
  #
3236
3301
  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
- ]
3302
+ [ 'Month', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', ' Total' ],
3303
+ [ 'North', 50, 20, 15, 25, 65, 80, '=SUM(B2:G2)' ],
3304
+ [ 'South', 10, 20, 30, 50, 50, 50, '=SUM(B3:G3)' ],
3305
+ [ 'East', 45, 75, 50, 15, 75, 100, '=SUM(B4:G4)' ],
3306
+ [ 'West', 15, 15, 55, 35, 20, 50, '=SUM(B5:G5)' ],
3307
+ ]
3243
3308
 
3244
3309
  # Add bold format to the first row
3245
3310
  worksheet3.set_row(0, nil, bold)
@@ -3259,10 +3324,10 @@ def test_outline
3259
3324
  # Example 4: Show all possible outline levels.
3260
3325
  #
3261
3326
  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
- ]
3327
+ "Level 1", "Level 2", "Level 3", "Level 4", "Level 5", "Level 6",
3328
+ "Level 7", "Level 6", "Level 5", "Level 4", "Level 3", "Level 2",
3329
+ "Level 1"
3330
+ ]
3266
3331
 
3267
3332
 
3268
3333
  worksheet4.write_col('A1', levels)
@@ -3393,12 +3458,12 @@ def test_outline_collapsed
3393
3458
  # Example 5: Create a worksheet with outlined columns.
3394
3459
  #
3395
3460
  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
- ]
3461
+ [ 'Month', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Total' ],
3462
+ [ 'North', 50, 20, 15, 25, 65, 80, '=SUM(B2:G2)' ],
3463
+ [ 'South', 10, 20, 30, 50, 50, 50, '=SUM(B3:G3)' ],
3464
+ [ 'East', 45, 75, 50, 15, 75, 100, '=SUM(B4:G4)' ],
3465
+ [ 'West', 15, 15, 55, 35, 20, 50, '=SUM(B5:G6)' ]
3466
+ ]
3402
3467
 
3403
3468
  # Add bold format to the first row
3404
3469
  worksheet5.set_row(0, nil, bold)
@@ -3499,10 +3564,10 @@ def test_panes
3499
3564
  #
3500
3565
 
3501
3566
  header = workbook.add_format(
3502
- :align => 'center',
3503
- :valign => 'vcenter',
3504
- :fg_color => 0x2A
3505
- )
3567
+ :align => 'center',
3568
+ :valign => 'vcenter',
3569
+ :fg_color => 0x2A
3570
+ )
3506
3571
 
3507
3572
  center = workbook.add_format(:align => 'center')
3508
3573
 
@@ -3598,16 +3663,16 @@ def test_properties
3598
3663
  worksheet = workbook.add_worksheet
3599
3664
 
3600
3665
  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
- )
3666
+ :title => 'This is an example spreadsheet',
3667
+ :subject => 'With document properties',
3668
+ :author => 'John McNamara',
3669
+ :manager => 'Dr. Heinz Doofenshmirtz',
3670
+ :company => 'of Wolves',
3671
+ :category => 'Example spreadsheets',
3672
+ :keywords => 'Sample, Example, Properties',
3673
+ :comments => 'Created with Perl and Excel::Writer::XLSX',
3674
+ :status => 'Quo'
3675
+ )
3611
3676
 
3612
3677
  worksheet.set_column('A:A', 70)
3613
3678
  worksheet.write('A1', "Select 'Office Button -> Prepare -> Properties' to see the file properties.")
@@ -3708,16 +3773,16 @@ def test_rich_strings
3708
3773
 
3709
3774
  # Write some strings with multiple formats.
3710
3775
  worksheet.write_rich_string('A1',
3711
- 'This is ', bold, 'bold', ' and this is ', italic, 'italic')
3776
+ 'This is ', bold, 'bold', ' and this is ', italic, 'italic')
3712
3777
 
3713
3778
  worksheet.write_rich_string('A3',
3714
- 'This is ', red, 'red', ' and this is ', blue, 'blue')
3779
+ 'This is ', red, 'red', ' and this is ', blue, 'blue')
3715
3780
 
3716
3781
  worksheet.write_rich_string('A5',
3717
- 'Some ', bold, 'bold text', ' centered', center)
3782
+ 'Some ', bold, 'bold text', ' centered', center)
3718
3783
 
3719
3784
  worksheet.write_rich_string('A7',
3720
- italic, 'j = k', superc, '(n-1)', center)
3785
+ italic, 'j = k', superc, '(n-1)', center)
3721
3786
 
3722
3787
  workbook.close
3723
3788
  store_to_tempfile
@@ -3750,7 +3815,7 @@ def test_shape1
3750
3815
  :text => "Hello\nWorld",
3751
3816
  :width => 60,
3752
3817
  :height => 60
3753
- )
3818
+ )
3754
3819
 
3755
3820
  worksheet.insert_shape('A1', ellipse, 50, 50)
3756
3821
 
@@ -3775,12 +3840,12 @@ def test_shape2
3775
3840
  :text => "Plain",
3776
3841
  :width => 100,
3777
3842
  :height => 100
3778
- )
3843
+ )
3779
3844
 
3780
3845
  bbformat = workbook.add_format(
3781
3846
  :color => 'red',
3782
3847
  :font => 'Lucida Calligraphy'
3783
- )
3848
+ )
3784
3849
 
3785
3850
  bbformat.set_bold
3786
3851
  bbformat.set_underline
@@ -3797,7 +3862,7 @@ def test_shape2
3797
3862
  :line_weight => 3,
3798
3863
  :fill => 'FFFF00',
3799
3864
  :line => '3366FF'
3800
- )
3865
+ )
3801
3866
 
3802
3867
  worksheet.insert_shape('A1', plain, 50, 50)
3803
3868
  worksheet.insert_shape('A1', decor, 250, 50)
@@ -3818,7 +3883,7 @@ def test_shape3
3818
3883
  :text => 'Normal',
3819
3884
  :width => 100,
3820
3885
  :height => 100
3821
- )
3886
+ )
3822
3887
 
3823
3888
  worksheet.insert_shape('A1', normal, 50, 50)
3824
3889
  normal.text = 'Scaled 3w x 2h'
@@ -3841,7 +3906,7 @@ def test_shape4
3841
3906
  :type => type,
3842
3907
  :width => 90,
3843
3908
  :height => 90
3844
- )
3909
+ )
3845
3910
 
3846
3911
  (1..10).each do |n|
3847
3912
  # Change the last 5 rectangles to stars. Previously
@@ -3857,7 +3922,7 @@ def test_shape4
3857
3922
  :width => 90,
3858
3923
  :height => 90,
3859
3924
  :text => 'started as a box'
3860
- )
3925
+ )
3861
3926
  worksheet.insert_shape('A1', stencil, 100, 150)
3862
3927
 
3863
3928
  stencil.stencil = 0
@@ -3884,14 +3949,14 @@ def test_shape5
3884
3949
  :type => 'ellipse',
3885
3950
  :width => 60,
3886
3951
  :height => 60
3887
- )
3952
+ )
3888
3953
  worksheet.insert_shape('A1', s1, 50, 50)
3889
3954
 
3890
3955
  s2 = workbook.add_shape(
3891
3956
  :type => 'plus',
3892
3957
  :width => 20,
3893
3958
  :height => 20
3894
- )
3959
+ )
3895
3960
  worksheet.insert_shape('A1', s2, 250, 200)
3896
3961
 
3897
3962
  # Create a connector to link the two shapes.
@@ -3923,14 +3988,14 @@ def test_shape6
3923
3988
  :type => 'chevron',
3924
3989
  :width => 60,
3925
3990
  :height => 60
3926
- )
3991
+ )
3927
3992
  worksheet.insert_shape('A1', s1, 50, 50)
3928
3993
 
3929
3994
  s2 = workbook.add_shape(
3930
3995
  :type => 'pentagon',
3931
3996
  :width => 20,
3932
3997
  :height => 20
3933
- )
3998
+ )
3934
3999
  worksheet.insert_shape('A1', s2, 250, 200)
3935
4000
 
3936
4001
  # Create a connector to link the two shapes.
@@ -3970,7 +4035,7 @@ def test_shape7
3970
4035
  :text => "Hello\nWorld",
3971
4036
  :width => cw,
3972
4037
  :height => ch
3973
- )
4038
+ )
3974
4039
  worksheet.insert_shape('A1', ellipse, cx, cy)
3975
4040
 
3976
4041
  # Add a plus sign at 4 different positions around the circle.
@@ -3984,7 +4049,7 @@ def test_shape7
3984
4049
  :id => 3,
3985
4050
  :width => pw,
3986
4051
  :height => ph
3987
- )
4052
+ )
3988
4053
 
3989
4054
  p1 = worksheet.insert_shape('A1', plus, 350, 350)
3990
4055
  p2 = worksheet.insert_shape('A1', plus, 150, 350)
@@ -4035,7 +4100,7 @@ def test_shape8
4035
4100
  :text => "Hello\nWorld",
4036
4101
  :width => cw,
4037
4102
  :height => ch
4038
- )
4103
+ )
4039
4104
  worksheet.insert_shape('A1', ellipse, cx, cy)
4040
4105
 
4041
4106
  # Add a plus sign at 4 different positionos around the circle.
@@ -4049,7 +4114,7 @@ def test_shape8
4049
4114
  :id => 3,
4050
4115
  :width => pw,
4051
4116
  :height => ph
4052
- )
4117
+ )
4053
4118
 
4054
4119
  p1 = worksheet.insert_shape('A1', plus, 350, 150)
4055
4120
  p2 = worksheet.insert_shape('A1', plus, 350, 350)
@@ -4100,11 +4165,11 @@ def test_shape_all
4100
4165
  end
4101
4166
  last_sheet = sheet
4102
4167
  shape = workbook.add_shape(
4103
- :type => name,
4104
- :text => name,
4105
- :width => 90,
4106
- :height => 90
4107
- )
4168
+ :type => name,
4169
+ :text => name,
4170
+ :width => 90,
4171
+ :height => 90
4172
+ )
4108
4173
 
4109
4174
  # Connectors can not have labels, so write the connector name in the cell
4110
4175
  # to the left.
@@ -4536,11 +4601,11 @@ def test_tables
4536
4601
 
4537
4602
  # Some sample data for the table.
4538
4603
  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
- ]
4604
+ [ 'Apples', 10000, 5000, 8000, 6000 ],
4605
+ [ 'Pears', 2000, 3000, 4000, 5000 ],
4606
+ [ 'Bananas', 6000, 6000, 6500, 6000 ],
4607
+ [ 'Oranges', 500, 300, 200, 700 ]
4608
+ ]
4544
4609
 
4545
4610
  ###############################################################################
4546
4611
  #
@@ -4658,18 +4723,18 @@ def test_tables
4658
4723
 
4659
4724
  # Add a table to the worksheet.
4660
4725
  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
- )
4726
+ 'B3:F7',
4727
+ {
4728
+ :data => data,
4729
+ :columns => [
4730
+ { :header => 'Product' },
4731
+ { :header => 'Quarter 1' },
4732
+ { :header => 'Quarter 2' },
4733
+ { :header => 'Quarter 3' },
4734
+ { :header => 'Quarter 4' }
4735
+ ]
4736
+ }
4737
+ )
4673
4738
 
4674
4739
  ###############################################################################
4675
4740
  #
@@ -4685,22 +4750,22 @@ def test_tables
4685
4750
 
4686
4751
  # Add a table to the worksheet.
4687
4752
  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
- )
4753
+ 'B3:G7',
4754
+ {
4755
+ :data => data,
4756
+ :columns => [
4757
+ { :header => 'Product' },
4758
+ { :header => 'Quarter 1' },
4759
+ { :header => 'Quarter 2' },
4760
+ { :header => 'Quarter 3' },
4761
+ { :header => 'Quarter 4' },
4762
+ {
4763
+ :header => 'Year',
4764
+ :formula => '=SUM(Table8[@[Quarter 1]:[Quarter 4]])'
4765
+ }
4766
+ ]
4767
+ }
4768
+ )
4704
4769
 
4705
4770
 
4706
4771
  ###############################################################################
@@ -4717,23 +4782,23 @@ def test_tables
4717
4782
 
4718
4783
  # Add a table to the worksheet.
4719
4784
  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
- )
4785
+ 'B3:G8',
4786
+ {
4787
+ :data => data,
4788
+ :total_row => 1,
4789
+ :columns => [
4790
+ { :header => 'Product' },
4791
+ { :header => 'Quarter 1' },
4792
+ { :header => 'Quarter 2' },
4793
+ { :header => 'Quarter 3' },
4794
+ { :header => 'Quarter 4' },
4795
+ {
4796
+ :header => 'Year',
4797
+ :formula => '=SUM(Table8[@[Quarter 1]:[Quarter 4]])'
4798
+ }
4799
+ ]
4800
+ }
4801
+ )
4737
4802
 
4738
4803
  ###############################################################################
4739
4804
  #
@@ -4749,24 +4814,24 @@ def test_tables
4749
4814
 
4750
4815
  # Add a table to the worksheet.
4751
4816
  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
- )
4817
+ 'B3:G8',
4818
+ {
4819
+ :data => data,
4820
+ :total_row => 1,
4821
+ :columns => [
4822
+ { :header => 'Product', :total_string => 'Totals' },
4823
+ { :header => 'Quarter 1', :total_function => 'sum' },
4824
+ { :header => 'Quarter 2', :total_function => 'sum' },
4825
+ { :header => 'Quarter 3', :total_function => 'sum' },
4826
+ { :header => 'Quarter 4', :total_function => 'sum' },
4827
+ {
4828
+ :header => 'Year',
4829
+ :formula => '=SUM(Table8[@[Quarter 1]:[Quarter 4]])',
4830
+ :total_function => 'sum'
4831
+ }
4832
+ ]
4833
+ }
4834
+ )
4770
4835
 
4771
4836
  ###############################################################################
4772
4837
  #
@@ -4782,25 +4847,25 @@ def test_tables
4782
4847
 
4783
4848
  # Add a table to the worksheet.
4784
4849
  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
- )
4850
+ 'B3:G8',
4851
+ {
4852
+ :data => data,
4853
+ :style => 'Table Style Light 11',
4854
+ :total_row => 1,
4855
+ :columns => [
4856
+ { :header => 'Product', :total_string => 'Totals' },
4857
+ { :header => 'Quarter 1', :total_function => 'sum' },
4858
+ { :header => 'Quarter 2', :total_function => 'sum' },
4859
+ { :header => 'Quarter 3', :total_function => 'sum' },
4860
+ { :header => 'Quarter 4', :total_function => 'sum' },
4861
+ {
4862
+ :header => 'Year',
4863
+ :formula => '=SUM(Table8[@[Quarter 1]:[Quarter 4]])',
4864
+ :total_function => 'sum'
4865
+ }
4866
+ ]
4867
+ }
4868
+ )
4804
4869
 
4805
4870
  ###############################################################################
4806
4871
  #
@@ -4816,41 +4881,41 @@ def test_tables
4816
4881
 
4817
4882
  # Add a table to the worksheet.
4818
4883
  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
- )
4884
+ 'B3:G8',
4885
+ {
4886
+ :data => data,
4887
+ :total_row => 1,
4888
+ :columns => [
4889
+ { :header => 'Product', :total_string => 'Totals' },
4890
+ {
4891
+ :header => 'Quarter 1',
4892
+ :total_function => 'sum',
4893
+ :format => currency_format,
4894
+ },
4895
+ {
4896
+ :header => 'Quarter 2',
4897
+ :total_function => 'sum',
4898
+ :format => currency_format,
4899
+ },
4900
+ {
4901
+ :header => 'Quarter 3',
4902
+ :total_function => 'sum',
4903
+ :format => currency_format,
4904
+ },
4905
+ {
4906
+ :header => 'Quarter 4',
4907
+ :total_function => 'sum',
4908
+ :format => currency_format,
4909
+ },
4910
+ {
4911
+ :header => 'Year',
4912
+ :formula => '=SUM(Table8[@[Quarter 1]:[Quarter 4]])',
4913
+ :total_function => 'sum',
4914
+ :format => currency_format,
4915
+ }
4916
+ ]
4917
+ }
4918
+ )
4854
4919
 
4855
4920
  workbook.close
4856
4921
  store_to_tempfile
@@ -4864,42 +4929,42 @@ def test_sparklines1
4864
4929
 
4865
4930
  # Some sample data to plot.
4866
4931
  data = [
4867
- [ -2, 2, 3, -1, 0 ],
4868
- [ 30, 20, 33, 20, 15 ],
4869
- [ 1, -1, -1, 1, -1 ]
4870
- ]
4932
+ [ -2, 2, 3, -1, 0 ],
4933
+ [ 30, 20, 33, 20, 15 ],
4934
+ [ 1, -1, -1, 1, -1 ]
4935
+ ]
4871
4936
 
4872
4937
  # Write the sample data to the worksheet.
4873
4938
  worksheet.write_col('A1', data)
4874
4939
 
4875
4940
  # Add a line sparkline (the default) with markers.
4876
4941
  worksheet.add_sparkline(
4877
- {
4878
- :location => 'F1',
4879
- :range => 'Sheet1!A1:E1',
4880
- :markers => 1
4881
- }
4882
- )
4942
+ {
4943
+ :location => 'F1',
4944
+ :range => 'Sheet1!A1:E1',
4945
+ :markers => 1
4946
+ }
4947
+ )
4883
4948
 
4884
4949
  # Add a column sparkline with non-default style.
4885
4950
  worksheet.add_sparkline(
4886
- {
4887
- :location => 'F2',
4888
- :range => 'Sheet1!A2:E2',
4889
- :type => 'column',
4890
- :style => 12
4891
- }
4892
- )
4951
+ {
4952
+ :location => 'F2',
4953
+ :range => 'Sheet1!A2:E2',
4954
+ :type => 'column',
4955
+ :style => 12
4956
+ }
4957
+ )
4893
4958
 
4894
4959
  # Add a win/loss sparkline with negative values highlighted.
4895
4960
  worksheet.add_sparkline(
4896
- {
4897
- :location => 'F3',
4898
- :range => 'Sheet1!A3:E3',
4899
- :type => 'win_loss',
4900
- :negative_points => 1
4901
- }
4902
- )
4961
+ {
4962
+ :location => 'F3',
4963
+ :range => 'Sheet1!A3:E3',
4964
+ :type => 'win_loss',
4965
+ :negative_points => 1
4966
+ }
4967
+ )
4903
4968
 
4904
4969
  workbook.close
4905
4970
  store_to_tempfile
@@ -4928,11 +4993,11 @@ def test_sparklines2
4928
4993
  str = 'A default "line" sparkline.'
4929
4994
 
4930
4995
  worksheet1.add_sparkline(
4931
- {
4932
- :location => 'A2',
4933
- :range => 'Sheet2!A1:J1'
4934
- }
4935
- )
4996
+ {
4997
+ :location => 'A2',
4998
+ :range => 'Sheet2!A1:J1'
4999
+ }
5000
+ )
4936
5001
 
4937
5002
  worksheet1.write(row, 1, str)
4938
5003
  row += 1
@@ -4942,12 +5007,12 @@ def test_sparklines2
4942
5007
  str = 'A default "column" sparkline.'
4943
5008
 
4944
5009
  worksheet1.add_sparkline(
4945
- {
4946
- :location => 'A3',
4947
- :range => 'Sheet2!A2:J2',
4948
- :type => 'column'
4949
- }
4950
- )
5010
+ {
5011
+ :location => 'A3',
5012
+ :range => 'Sheet2!A2:J2',
5013
+ :type => 'column'
5014
+ }
5015
+ )
4951
5016
 
4952
5017
  worksheet1.write(row, 1, str)
4953
5018
  row += 1
@@ -4957,12 +5022,12 @@ def test_sparklines2
4957
5022
  str = 'A default "win/loss" sparkline.'
4958
5023
 
4959
5024
  worksheet1.add_sparkline(
4960
- {
4961
- :location => 'A4',
4962
- :range => 'Sheet2!A3:J3',
4963
- :type => 'win_loss'
4964
- }
4965
- )
5025
+ {
5026
+ :location => 'A4',
5027
+ :range => 'Sheet2!A3:J3',
5028
+ :type => 'win_loss'
5029
+ }
5030
+ )
4966
5031
 
4967
5032
  worksheet1.write(row, 1, str)
4968
5033
  row += 2
@@ -4972,12 +5037,12 @@ def test_sparklines2
4972
5037
  str = 'Line with markers.'
4973
5038
 
4974
5039
  worksheet1.add_sparkline(
4975
- {
4976
- :location => 'A6',
4977
- :range => 'Sheet2!A1:J1',
4978
- :markers => 1
4979
- }
4980
- )
5040
+ {
5041
+ :location => 'A6',
5042
+ :range => 'Sheet2!A1:J1',
5043
+ :markers => 1
5044
+ }
5045
+ )
4981
5046
 
4982
5047
  worksheet1.write(row, 1, str)
4983
5048
  row += 1
@@ -4987,13 +5052,13 @@ def test_sparklines2
4987
5052
  str = 'Line with high and low points.'
4988
5053
 
4989
5054
  worksheet1.add_sparkline(
4990
- {
4991
- :location => 'A7',
4992
- :range => 'Sheet2!A1:J1',
4993
- :high_point => 1,
4994
- :low_point => 1
4995
- }
4996
- )
5055
+ {
5056
+ :location => 'A7',
5057
+ :range => 'Sheet2!A1:J1',
5058
+ :high_point => 1,
5059
+ :low_point => 1
5060
+ }
5061
+ )
4997
5062
 
4998
5063
  worksheet1.write(row, 1, str)
4999
5064
  row += 1
@@ -5003,13 +5068,13 @@ def test_sparklines2
5003
5068
  str = 'Line with first and last point markers.'
5004
5069
 
5005
5070
  worksheet1.add_sparkline(
5006
- {
5007
- :location => 'A8',
5008
- :range => 'Sheet2!A1:J1',
5009
- :first_point => 1,
5010
- :last_point => 1
5011
- }
5012
- )
5071
+ {
5072
+ :location => 'A8',
5073
+ :range => 'Sheet2!A1:J1',
5074
+ :first_point => 1,
5075
+ :last_point => 1
5076
+ }
5077
+ )
5013
5078
 
5014
5079
  worksheet1.write(row, 1, str)
5015
5080
  row += 1
@@ -5019,12 +5084,12 @@ def test_sparklines2
5019
5084
  str = 'Line with negative point markers.'
5020
5085
 
5021
5086
  worksheet1.add_sparkline(
5022
- {
5023
- :location => 'A9',
5024
- :range => 'Sheet2!A1:J1',
5025
- :negative_points => 1
5026
- }
5027
- )
5087
+ {
5088
+ :location => 'A9',
5089
+ :range => 'Sheet2!A1:J1',
5090
+ :negative_points => 1
5091
+ }
5092
+ )
5028
5093
 
5029
5094
  worksheet1.write(row, 1, str)
5030
5095
  row += 1
@@ -5034,12 +5099,12 @@ def test_sparklines2
5034
5099
  str = 'Line with axis.'
5035
5100
 
5036
5101
  worksheet1.add_sparkline(
5037
- {
5038
- :location => 'A10',
5039
- :range => 'Sheet2!A1:J1',
5040
- :axis => 1
5041
- }
5042
- )
5102
+ {
5103
+ :location => 'A10',
5104
+ :range => 'Sheet2!A1:J1',
5105
+ :axis => 1
5106
+ }
5107
+ )
5043
5108
 
5044
5109
  worksheet1.write(row, 1, str)
5045
5110
  row += 2
@@ -5049,12 +5114,12 @@ def test_sparklines2
5049
5114
  str = 'Column with default style (1).'
5050
5115
 
5051
5116
  worksheet1.add_sparkline(
5052
- {
5053
- :location => 'A12',
5054
- :range => 'Sheet2!A2:J2',
5055
- :type => 'column'
5056
- }
5057
- )
5117
+ {
5118
+ :location => 'A12',
5119
+ :range => 'Sheet2!A2:J2',
5120
+ :type => 'column'
5121
+ }
5122
+ )
5058
5123
 
5059
5124
  worksheet1.write(row, 1, str)
5060
5125
  row += 1
@@ -5064,13 +5129,13 @@ def test_sparklines2
5064
5129
  str = 'Column with style 2.'
5065
5130
 
5066
5131
  worksheet1.add_sparkline(
5067
- {
5068
- :location => 'A13',
5069
- :range => 'Sheet2!A2:J2',
5070
- :type => 'column',
5071
- :style => 2
5072
- }
5073
- )
5132
+ {
5133
+ :location => 'A13',
5134
+ :range => 'Sheet2!A2:J2',
5135
+ :type => 'column',
5136
+ :style => 2
5137
+ }
5138
+ )
5074
5139
 
5075
5140
  worksheet1.write(row, 1, str)
5076
5141
  row += 1
@@ -5080,13 +5145,13 @@ def test_sparklines2
5080
5145
  str = 'Column with style 3.'
5081
5146
 
5082
5147
  worksheet1.add_sparkline(
5083
- {
5084
- :location => 'A14',
5085
- :range => 'Sheet2!A2:J2',
5086
- :type => 'column',
5087
- :style => 3
5088
- }
5089
- )
5148
+ {
5149
+ :location => 'A14',
5150
+ :range => 'Sheet2!A2:J2',
5151
+ :type => 'column',
5152
+ :style => 3
5153
+ }
5154
+ )
5090
5155
 
5091
5156
  worksheet1.write(row, 1, str)
5092
5157
  row += 1
@@ -5096,13 +5161,13 @@ def test_sparklines2
5096
5161
  str = 'Column with style 4.'
5097
5162
 
5098
5163
  worksheet1.add_sparkline(
5099
- {
5100
- :location => 'A15',
5101
- :range => 'Sheet2!A2:J2',
5102
- :type => 'column',
5103
- :style => 4
5104
- }
5105
- )
5164
+ {
5165
+ :location => 'A15',
5166
+ :range => 'Sheet2!A2:J2',
5167
+ :type => 'column',
5168
+ :style => 4
5169
+ }
5170
+ )
5106
5171
 
5107
5172
  worksheet1.write(row, 1, str)
5108
5173
  row += 1
@@ -5112,13 +5177,13 @@ def test_sparklines2
5112
5177
  str = 'Column with style 5.'
5113
5178
 
5114
5179
  worksheet1.add_sparkline(
5115
- {
5116
- :location => 'A16',
5117
- :range => 'Sheet2!A2:J2',
5118
- :type => 'column',
5119
- :style => 5
5120
- }
5121
- )
5180
+ {
5181
+ :location => 'A16',
5182
+ :range => 'Sheet2!A2:J2',
5183
+ :type => 'column',
5184
+ :style => 5
5185
+ }
5186
+ )
5122
5187
 
5123
5188
  worksheet1.write(row, 1, str)
5124
5189
  row += 1
@@ -5128,13 +5193,13 @@ def test_sparklines2
5128
5193
  str = 'Column with style 6.'
5129
5194
 
5130
5195
  worksheet1.add_sparkline(
5131
- {
5132
- :location => 'A17',
5133
- :range => 'Sheet2!A2:J2',
5134
- :type => 'column',
5135
- :style => 6
5136
- }
5137
- )
5196
+ {
5197
+ :location => 'A17',
5198
+ :range => 'Sheet2!A2:J2',
5199
+ :type => 'column',
5200
+ :style => 6
5201
+ }
5202
+ )
5138
5203
 
5139
5204
  worksheet1.write(row, 1, str)
5140
5205
  row += 1
@@ -5144,13 +5209,13 @@ def test_sparklines2
5144
5209
  str = 'Column with a user defined colour.'
5145
5210
 
5146
5211
  worksheet1.add_sparkline(
5147
- {
5148
- :location => 'A18',
5149
- :range => 'Sheet2!A2:J2',
5150
- :type => 'column',
5151
- :series_color => '#E965E0'
5152
- }
5153
- )
5212
+ {
5213
+ :location => 'A18',
5214
+ :range => 'Sheet2!A2:J2',
5215
+ :type => 'column',
5216
+ :series_color => '#E965E0'
5217
+ }
5218
+ )
5154
5219
 
5155
5220
  worksheet1.write(row, 1, str)
5156
5221
  row += 2
@@ -5160,12 +5225,12 @@ def test_sparklines2
5160
5225
  str = 'A win/loss sparkline.'
5161
5226
 
5162
5227
  worksheet1.add_sparkline(
5163
- {
5164
- :location => 'A20',
5165
- :range => 'Sheet2!A3:J3',
5166
- :type => 'win_loss'
5167
- }
5168
- )
5228
+ {
5229
+ :location => 'A20',
5230
+ :range => 'Sheet2!A3:J3',
5231
+ :type => 'win_loss'
5232
+ }
5233
+ )
5169
5234
 
5170
5235
  worksheet1.write(row, 1, str)
5171
5236
  row += 1
@@ -5175,13 +5240,13 @@ def test_sparklines2
5175
5240
  str = 'A win/loss sparkline with negative points highlighted.'
5176
5241
 
5177
5242
  worksheet1.add_sparkline(
5178
- {
5179
- :location => 'A21',
5180
- :range => 'Sheet2!A3:J3',
5181
- :type => 'win_loss',
5182
- :negative_points => 1
5183
- }
5184
- )
5243
+ {
5244
+ :location => 'A21',
5245
+ :range => 'Sheet2!A3:J3',
5246
+ :type => 'win_loss',
5247
+ :negative_points => 1
5248
+ }
5249
+ )
5185
5250
 
5186
5251
  worksheet1.write(row, 1, str)
5187
5252
  row += 2
@@ -5191,13 +5256,13 @@ def test_sparklines2
5191
5256
  str = 'A left to right column (the default).'
5192
5257
 
5193
5258
  worksheet1.add_sparkline(
5194
- {
5195
- :location => 'A23',
5196
- :range => 'Sheet2!A4:J4',
5197
- :type => 'column',
5198
- :style => 20
5199
- }
5200
- )
5259
+ {
5260
+ :location => 'A23',
5261
+ :range => 'Sheet2!A4:J4',
5262
+ :type => 'column',
5263
+ :style => 20
5264
+ }
5265
+ )
5201
5266
 
5202
5267
  worksheet1.write(row, 1, str)
5203
5268
  row += 1
@@ -5207,14 +5272,14 @@ def test_sparklines2
5207
5272
  str = 'A right to left column.'
5208
5273
 
5209
5274
  worksheet1.add_sparkline(
5210
- {
5211
- :location => 'A24',
5212
- :range => 'Sheet2!A4:J4',
5213
- :type => 'column',
5214
- :style => 20,
5215
- :reverse => 1
5216
- }
5217
- )
5275
+ {
5276
+ :location => 'A24',
5277
+ :range => 'Sheet2!A4:J4',
5278
+ :type => 'column',
5279
+ :style => 20,
5280
+ :reverse => 1
5281
+ }
5282
+ )
5218
5283
 
5219
5284
  worksheet1.write(row, 1, str)
5220
5285
  row += 1
@@ -5224,13 +5289,13 @@ def test_sparklines2
5224
5289
  str = 'Sparkline and text in one cell.'
5225
5290
 
5226
5291
  worksheet1.add_sparkline(
5227
- {
5228
- :location => 'A25',
5229
- :range => 'Sheet2!A4:J4',
5230
- :type => 'column',
5231
- :style => 20
5232
- }
5233
- )
5292
+ {
5293
+ :location => 'A25',
5294
+ :range => 'Sheet2!A4:J4',
5295
+ :type => 'column',
5296
+ :style => 20
5297
+ }
5298
+ )
5234
5299
 
5235
5300
  worksheet1.write(row, 0, 'Growth')
5236
5301
  worksheet1.write(row, 1, str)
@@ -5241,12 +5306,12 @@ def test_sparklines2
5241
5306
  str = 'A grouped sparkline. Changes are applied to all three.'
5242
5307
 
5243
5308
  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
- )
5309
+ {
5310
+ :location => [ 'A27', 'A28', 'A29' ],
5311
+ :range => [ 'Sheet2!A5:J5', 'Sheet2!A6:J6', 'Sheet2!A7:J7' ],
5312
+ :markers => 1
5313
+ }
5314
+ )
5250
5315
 
5251
5316
  worksheet1.write(row, 1, str)
5252
5317
  row += 1
@@ -5258,23 +5323,23 @@ def test_sparklines2
5258
5323
  worksheet2.set_column('A:J', 11)
5259
5324
 
5260
5325
  data = [
5261
- # Simple line data.
5262
- [ -2, 2, 3, -1, 0, -2, 3, 2, 1, 0 ],
5326
+ # Simple line data.
5327
+ [ -2, 2, 3, -1, 0, -2, 3, 2, 1, 0 ],
5263
5328
 
5264
- # Simple column data.
5265
- [ 30, 20, 33, 20, 15, 5, 5, 15, 10, 15 ],
5329
+ # Simple column data.
5330
+ [ 30, 20, 33, 20, 15, 5, 5, 15, 10, 15 ],
5266
5331
 
5267
- # Simple win/loss data.
5268
- [ 1, 1, -1, -1, 1, -1, 1, 1, 1, -1 ],
5332
+ # Simple win/loss data.
5333
+ [ 1, 1, -1, -1, 1, -1, 1, 1, 1, -1 ],
5269
5334
 
5270
- # Unbalanced histogram.
5271
- [ 5, 6, 7, 10, 15, 20, 30, 50, 70, 100 ],
5335
+ # Unbalanced histogram.
5336
+ [ 5, 6, 7, 10, 15, 20, 30, 50, 70, 100 ],
5272
5337
 
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
- ]
5338
+ # Data for the grouped sparkline example.
5339
+ [ -2, 2, 3, -1, 0, -2, 3, 2, 1, 0 ],
5340
+ [ 3, -1, 0, -2, 3, 2, 1, 0, 2, 1 ],
5341
+ [ 0, -2, 3, 2, 1, 0, 1, 2, 3, 1 ]
5342
+ ]
5278
5343
 
5279
5344
  # Write the sample data to the worksheet.
5280
5345
  worksheet2.write_col('A1', data)
@@ -5339,10 +5404,10 @@ def test_chart_data_table
5339
5404
  # Add the worksheet data that the charts will refer to.
5340
5405
  headings = [ 'Number', 'Batch 1', 'Batch 2' ]
5341
5406
  data = [
5342
- [ 2, 3, 4, 5, 6, 7 ],
5343
- [ 10, 40, 50, 20, 10, 50 ],
5344
- [ 30, 60, 70, 50, 40, 30 ]
5345
- ]
5407
+ [ 2, 3, 4, 5, 6, 7 ],
5408
+ [ 10, 40, 50, 20, 10, 50 ],
5409
+ [ 30, 60, 70, 50, 40, 30 ]
5410
+ ]
5346
5411
 
5347
5412
  worksheet.write('A1', headings, bold)
5348
5413
  worksheet.write('A2', data)
@@ -5352,18 +5417,18 @@ def test_chart_data_table
5352
5417
 
5353
5418
  # Configure the first series.
5354
5419
  chart1.add_series(
5355
- :name => '=Sheet1!$B$1',
5356
- :categories => '=Sheet1!$A$2:$A$7',
5357
- :values => '=Sheet1!$B$2:$B$7'
5358
- )
5420
+ :name => '=Sheet1!$B$1',
5421
+ :categories => '=Sheet1!$A$2:$A$7',
5422
+ :values => '=Sheet1!$B$2:$B$7'
5423
+ )
5359
5424
 
5360
5425
  # Configure second series. Note alternative use of array ref to define
5361
5426
  # ranges: [ sheetname, row_start, row_end, col_start, col_end ].
5362
5427
  chart1.add_series(
5363
- :name => '=Sheet1!$C$1',
5364
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
5365
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
5366
- )
5428
+ :name => '=Sheet1!$C$1',
5429
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
5430
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
5431
+ )
5367
5432
 
5368
5433
  # Add a chart title and some axis labels.
5369
5434
  chart1.set_title(:name => 'Chart with Data Table')
@@ -5383,18 +5448,18 @@ def test_chart_data_table
5383
5448
 
5384
5449
  # Configure the first series.
5385
5450
  chart2.add_series(
5386
- :name => '=Sheet1!$B$1',
5387
- :categories => '=Sheet1!$A$2:$A$7',
5388
- :values => '=Sheet1!$B$2:$B$7'
5389
- )
5451
+ :name => '=Sheet1!$B$1',
5452
+ :categories => '=Sheet1!$A$2:$A$7',
5453
+ :values => '=Sheet1!$B$2:$B$7'
5454
+ )
5390
5455
 
5391
5456
  # Configure second series. Note alternative use of array ref to define
5392
5457
  # ranges: [ sheetname, row_start, row_end, col_start, col_end ].
5393
5458
  chart2.add_series(
5394
- :name => '=Sheet1!$C$1',
5395
- :categories => [ 'Sheet1', 1, 6, 0, 0 ],
5396
- :values => [ 'Sheet1', 1, 6, 2, 2 ]
5397
- )
5459
+ :name => '=Sheet1!$C$1',
5460
+ :categories => [ 'Sheet1', 1, 6, 0, 0 ],
5461
+ :values => [ 'Sheet1', 1, 6, 2, 2 ]
5462
+ )
5398
5463
 
5399
5464
  # Add a chart title and some axis labels.
5400
5465
  chart2.set_title(:name => 'Data Table with legend keys')
@@ -5424,10 +5489,10 @@ def test_chart_data_tools
5424
5489
  # Add the worksheet data that the charts will refer to.
5425
5490
  headings = [ 'Number', 'Data 1', 'Data 2' ]
5426
5491
  data = [
5427
- [ 2, 3, 4, 5, 6, 7 ],
5428
- [ 10, 40, 50, 20, 10, 50 ],
5429
- [ 30, 60, 70, 50, 40, 30 ]
5430
- ]
5492
+ [ 2, 3, 4, 5, 6, 7 ],
5493
+ [ 10, 40, 50, 20, 10, 50 ],
5494
+ [ 30, 60, 70, 50, 40, 30 ]
5495
+ ]
5431
5496
 
5432
5497
  worksheet.write('A1', headings, bold)
5433
5498
  worksheet.write('A2', data)
@@ -5443,20 +5508,20 @@ def test_chart_data_tools
5443
5508
 
5444
5509
  # Configure the first series with a polynomial trendline.
5445
5510
  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
- )
5511
+ :categories => '=Sheet1!$A$2:$A$7',
5512
+ :values => '=Sheet1!$B$2:$B$7',
5513
+ :trendline => {
5514
+ :type => 'polynomial',
5515
+ :order => 3,
5516
+ }
5517
+ )
5453
5518
 
5454
5519
  # Configure the second series with a moving average trendline.
5455
5520
  chart1.add_series(
5456
- :categories => '=Sheet1!$A$2:$A$7',
5457
- :values => '=Sheet1!$C$2:$C$7',
5458
- :trendline => { :type => 'linear' }
5459
- )
5521
+ :categories => '=Sheet1!$A$2:$A$7',
5522
+ :values => '=Sheet1!$C$2:$C$7',
5523
+ :trendline => { :type => 'linear' }
5524
+ )
5460
5525
 
5461
5526
  # Add a chart title. and some axis labels.
5462
5527
  chart1.set_title(:name => 'Chart with Trendlines')
@@ -5474,17 +5539,17 @@ def test_chart_data_tools
5474
5539
 
5475
5540
  # Configure the first series.
5476
5541
  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
- )
5542
+ :categories => '=Sheet1!$A$2:$A$7',
5543
+ :values => '=Sheet1!$B$2:$B$7',
5544
+ :data_labels => { :value => 1 },
5545
+ :marker => { :type => 'automatic' }
5546
+ )
5482
5547
 
5483
5548
  # Configure the second series.
5484
5549
  chart2.add_series(
5485
- :categories => '=Sheet1!$A$2:$A$7',
5486
- :values => '=Sheet1!$C$2:$C$7'
5487
- )
5550
+ :categories => '=Sheet1!$A$2:$A$7',
5551
+ :values => '=Sheet1!$C$2:$C$7'
5552
+ )
5488
5553
 
5489
5554
  # Add a chart title. and some axis labels.
5490
5555
  chart2.set_title(:name => 'Chart with Data Labels and Markers')
@@ -5502,16 +5567,16 @@ def test_chart_data_tools
5502
5567
 
5503
5568
  # Configure the first series.
5504
5569
  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
- )
5570
+ :categories => '=Sheet1!$A$2:$A$7',
5571
+ :values => '=Sheet1!$B$2:$B$7',
5572
+ :y_error_bars => { :type => 'standard_error' }
5573
+ )
5509
5574
 
5510
5575
  # Configure the second series.
5511
5576
  chart3.add_series(
5512
- :categories => '=Sheet1!$A$2:$A$7',
5513
- :values => '=Sheet1!$C$2:$C$7'
5514
- )
5577
+ :categories => '=Sheet1!$A$2:$A$7',
5578
+ :values => '=Sheet1!$C$2:$C$7'
5579
+ )
5515
5580
 
5516
5581
  # Add a chart title. and some axis labels.
5517
5582
  chart3.set_title(:name => 'Chart with Error Bars')
@@ -5532,15 +5597,15 @@ def test_chart_data_tools
5532
5597
 
5533
5598
  # Configure the first series.
5534
5599
  chart4.add_series(
5535
- :categories => '=Sheet1!$A$2:$A$7',
5536
- :values => '=Sheet1!$B$2:$B$7'
5537
- )
5600
+ :categories => '=Sheet1!$A$2:$A$7',
5601
+ :values => '=Sheet1!$B$2:$B$7'
5602
+ )
5538
5603
 
5539
5604
  # Configure the second series.
5540
5605
  chart4.add_series(
5541
- :categories => '=Sheet1!$A$2:$A$7',
5542
- :values => '=Sheet1!$C$2:$C$7'
5543
- )
5606
+ :categories => '=Sheet1!$A$2:$A$7',
5607
+ :values => '=Sheet1!$C$2:$C$7'
5608
+ )
5544
5609
 
5545
5610
  # Add a chart title. and some axis labels.
5546
5611
  chart4.set_title(:name => 'Chart with Up-Down Bars')
@@ -5561,15 +5626,15 @@ def test_chart_data_tools
5561
5626
 
5562
5627
  # Configure the first series.
5563
5628
  chart5.add_series(
5564
- :categories => '=Sheet1!$A$2:$A$7',
5565
- :values => '=Sheet1!$B$2:$B$7'
5566
- )
5629
+ :categories => '=Sheet1!$A$2:$A$7',
5630
+ :values => '=Sheet1!$B$2:$B$7'
5631
+ )
5567
5632
 
5568
5633
  # Configure the second series.
5569
5634
  chart5.add_series(
5570
- :categories => '=Sheet1!$A$2:$A$7',
5571
- :values => '=Sheet1!$C$2:$C$7'
5572
- )
5635
+ :categories => '=Sheet1!$A$2:$A$7',
5636
+ :values => '=Sheet1!$C$2:$C$7'
5637
+ )
5573
5638
 
5574
5639
  # Add a chart title. and some axis labels.
5575
5640
  chart5.set_title(:name => 'Chart with High-Low Lines')
@@ -5590,15 +5655,15 @@ def test_chart_data_tools
5590
5655
 
5591
5656
  # Configure the first series.
5592
5657
  chart6.add_series(
5593
- :categories => '=Sheet1!$A$2:$A$7',
5594
- :values => '=Sheet1!$B$2:$B$7'
5595
- )
5658
+ :categories => '=Sheet1!$A$2:$A$7',
5659
+ :values => '=Sheet1!$B$2:$B$7'
5660
+ )
5596
5661
 
5597
5662
  # Configure the second series.
5598
5663
  chart6.add_series(
5599
- :categories => '=Sheet1!$A$2:$A$7',
5600
- :values => '=Sheet1!$C$2:$C$7'
5601
- )
5664
+ :categories => '=Sheet1!$A$2:$A$7',
5665
+ :values => '=Sheet1!$C$2:$C$7'
5666
+ )
5602
5667
 
5603
5668
  # Add a chart title. and some axis labels.
5604
5669
  chart6.set_title(:name => 'Chart with Drop Lines')