write_xlsx 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (261) hide show
  1. data/.document +5 -0
  2. data/.gitattributes +1 -0
  3. data/Gemfile +12 -0
  4. data/LICENSE.txt +20 -0
  5. data/README.rdoc +82 -0
  6. data/Rakefile +78 -0
  7. data/VERSION +1 -0
  8. data/examples/a_simple.rb +45 -0
  9. data/examples/array_formula.rb +33 -0
  10. data/examples/autofilter.rb +235 -0
  11. data/examples/chart_area.rb +59 -0
  12. data/examples/chart_bar.rb +59 -0
  13. data/examples/chart_column.rb +58 -0
  14. data/examples/chart_line.rb +59 -0
  15. data/examples/chart_pie.rb +49 -0
  16. data/examples/chart_scatter.rb +59 -0
  17. data/examples/chart_stock.rb +65 -0
  18. data/examples/colors.rb +130 -0
  19. data/examples/comments1.rb +12 -0
  20. data/examples/comments2.rb +335 -0
  21. data/examples/conditional_format.rb +67 -0
  22. data/examples/data_validate.rb +279 -0
  23. data/examples/defined_name.rb +28 -0
  24. data/examples/demo.rb +104 -0
  25. data/examples/diag_border.rb +26 -0
  26. data/examples/headers.rb +119 -0
  27. data/examples/hide_sheet.rb +30 -0
  28. data/examples/hyperlink1.rb +58 -0
  29. data/examples/indent.rb +28 -0
  30. data/examples/merge1.rb +38 -0
  31. data/examples/merge2.rb +48 -0
  32. data/examples/merge3.rb +43 -0
  33. data/examples/merge4.rb +82 -0
  34. data/examples/merge5.rb +70 -0
  35. data/examples/merge6.rb +48 -0
  36. data/examples/outline.rb +252 -0
  37. data/examples/properties.rb +33 -0
  38. data/examples/protection.rb +34 -0
  39. data/examples/rich_strings.rb +42 -0
  40. data/examples/right_to_left.rb +24 -0
  41. data/examples/tab_colors.rb +26 -0
  42. data/lib/write_xlsx.rb +77 -0
  43. data/lib/write_xlsx/chart.rb +3027 -0
  44. data/lib/write_xlsx/chart/area.rb +52 -0
  45. data/lib/write_xlsx/chart/bar.rb +126 -0
  46. data/lib/write_xlsx/chart/column.rb +132 -0
  47. data/lib/write_xlsx/chart/line.rb +51 -0
  48. data/lib/write_xlsx/chart/pie.rb +210 -0
  49. data/lib/write_xlsx/chart/scatter.rb +252 -0
  50. data/lib/write_xlsx/chart/stock.rb +134 -0
  51. data/lib/write_xlsx/chartsheet.rb +173 -0
  52. data/lib/write_xlsx/colors.rb +65 -0
  53. data/lib/write_xlsx/compatibility.rb +71 -0
  54. data/lib/write_xlsx/drawing.rb +547 -0
  55. data/lib/write_xlsx/format.rb +683 -0
  56. data/lib/write_xlsx/package/app.rb +218 -0
  57. data/lib/write_xlsx/package/comments.rb +221 -0
  58. data/lib/write_xlsx/package/content_types.rb +189 -0
  59. data/lib/write_xlsx/package/core.rb +196 -0
  60. data/lib/write_xlsx/package/packager.rb +510 -0
  61. data/lib/write_xlsx/package/relationships.rb +98 -0
  62. data/lib/write_xlsx/package/shared_strings.rb +96 -0
  63. data/lib/write_xlsx/package/styles.rb +705 -0
  64. data/lib/write_xlsx/package/theme.rb +45 -0
  65. data/lib/write_xlsx/package/vml.rb +386 -0
  66. data/lib/write_xlsx/package/xml_writer_simple.rb +90 -0
  67. data/lib/write_xlsx/utility.rb +113 -0
  68. data/lib/write_xlsx/workbook.rb +1488 -0
  69. data/lib/write_xlsx/worksheet.rb +6578 -0
  70. data/lib/write_xlsx/zip_file_utils.rb +98 -0
  71. data/test/chart/test_add_series.rb +113 -0
  72. data/test/chart/test_process_names.rb +27 -0
  73. data/test/chart/test_write_auto.rb +15 -0
  74. data/test/chart/test_write_ax_id.rb +15 -0
  75. data/test/chart/test_write_ax_pos.rb +15 -0
  76. data/test/chart/test_write_chart_space.rb +15 -0
  77. data/test/chart/test_write_cross_ax.rb +15 -0
  78. data/test/chart/test_write_crosses.rb +15 -0
  79. data/test/chart/test_write_format_code.rb +15 -0
  80. data/test/chart/test_write_idx.rb +15 -0
  81. data/test/chart/test_write_label_align.rb +15 -0
  82. data/test/chart/test_write_label_offset.rb +15 -0
  83. data/test/chart/test_write_lang.rb +15 -0
  84. data/test/chart/test_write_layout.rb +15 -0
  85. data/test/chart/test_write_legend.rb +16 -0
  86. data/test/chart/test_write_legend_pos.rb +15 -0
  87. data/test/chart/test_write_major_gridlines.rb +15 -0
  88. data/test/chart/test_write_marker.rb +17 -0
  89. data/test/chart/test_write_marker_size.rb +15 -0
  90. data/test/chart/test_write_marker_value.rb +16 -0
  91. data/test/chart/test_write_num_cache.rb +16 -0
  92. data/test/chart/test_write_num_fmt.rb +16 -0
  93. data/test/chart/test_write_number_format.rb +15 -0
  94. data/test/chart/test_write_order.rb +15 -0
  95. data/test/chart/test_write_orientation.rb +15 -0
  96. data/test/chart/test_write_page_margins.rb +15 -0
  97. data/test/chart/test_write_page_setup.rb +15 -0
  98. data/test/chart/test_write_plot_vis_only.rb +15 -0
  99. data/test/chart/test_write_pt.rb +16 -0
  100. data/test/chart/test_write_pt_count.rb +16 -0
  101. data/test/chart/test_write_series_formula.rb +16 -0
  102. data/test/chart/test_write_style.rb +41 -0
  103. data/test/chart/test_write_symbol.rb +16 -0
  104. data/test/chart/test_write_tick_lbl_pos.rb +16 -0
  105. data/test/chart/test_write_v.rb +16 -0
  106. data/test/drawing/test_drawing_chart_01.rb +50 -0
  107. data/test/drawing/test_drawing_image_01.rb +59 -0
  108. data/test/helper.rb +90 -0
  109. data/test/package/app/test_app01.rb +44 -0
  110. data/test/package/app/test_app02.rb +46 -0
  111. data/test/package/app/test_app03.rb +53 -0
  112. data/test/package/comments/test_comments01.rb +36 -0
  113. data/test/package/comments/test_write_text_t.rb +44 -0
  114. data/test/package/content_types/test_content_types.rb +35 -0
  115. data/test/package/content_types/test_write_default.rb +13 -0
  116. data/test/package/content_types/test_write_override.rb +13 -0
  117. data/test/package/core/test_core01.rb +28 -0
  118. data/test/package/core/test_core02.rb +42 -0
  119. data/test/package/relationships/test_relationships.rb +28 -0
  120. data/test/package/relationships/test_sheet_rels.rb +22 -0
  121. data/test/package/shared_strings/test_shared_strings01.rb +30 -0
  122. data/test/package/shared_strings/test_shared_strings02.rb +30 -0
  123. data/test/package/shared_strings/test_write_si.rb +13 -0
  124. data/test/package/shared_strings/test_write_sst.rb +15 -0
  125. data/test/package/styles/test_styles_01.rb +69 -0
  126. data/test/package/styles/test_styles_02.rb +104 -0
  127. data/test/package/styles/test_styles_03.rb +90 -0
  128. data/test/package/styles/test_styles_04.rb +216 -0
  129. data/test/package/styles/test_styles_05.rb +150 -0
  130. data/test/package/styles/test_styles_06.rb +104 -0
  131. data/test/package/styles/test_styles_07.rb +104 -0
  132. data/test/package/styles/test_styles_08.rb +109 -0
  133. data/test/package/styles/test_styles_09.rb +95 -0
  134. data/test/package/vml/test_vml_01.rb +42 -0
  135. data/test/package/vml/test_write_anchor.rb +14 -0
  136. data/test/package/vml/test_write_auto_fill.rb +14 -0
  137. data/test/package/vml/test_write_column.rb +14 -0
  138. data/test/package/vml/test_write_div.rb +14 -0
  139. data/test/package/vml/test_write_fill.rb +14 -0
  140. data/test/package/vml/test_write_idmap.rb +14 -0
  141. data/test/package/vml/test_write_move_with_cells.rb +14 -0
  142. data/test/package/vml/test_write_path.rb +22 -0
  143. data/test/package/vml/test_write_row.rb +14 -0
  144. data/test/package/vml/test_write_shadow.rb +14 -0
  145. data/test/package/vml/test_write_shapelayout.rb +14 -0
  146. data/test/package/vml/test_write_shapetype.rb +14 -0
  147. data/test/package/vml/test_write_size_with_cells.rb +14 -0
  148. data/test/package/vml/test_write_stroke.rb +14 -0
  149. data/test/package/vml/test_write_textbox.rb +14 -0
  150. data/test/perl_output/a_simple.xlsx +0 -0
  151. data/test/perl_output/array_formula.xlsx +0 -0
  152. data/test/perl_output/autofilter.xlsx +0 -0
  153. data/test/perl_output/chart_area.xlsx +0 -0
  154. data/test/perl_output/chart_bar.xlsx +0 -0
  155. data/test/perl_output/chart_column.xlsx +0 -0
  156. data/test/perl_output/chart_line.xlsx +0 -0
  157. data/test/perl_output/chart_pie.xlsx +0 -0
  158. data/test/perl_output/chart_scatter.xlsx +0 -0
  159. data/test/perl_output/chart_stock.xlsx +0 -0
  160. data/test/perl_output/comments1.xlsx +0 -0
  161. data/test/perl_output/comments2.xlsx +0 -0
  162. data/test/perl_output/conditional_format.xlsx +0 -0
  163. data/test/perl_output/data_validate.xlsx +0 -0
  164. data/test/perl_output/defined_name.xlsx +0 -0
  165. data/test/perl_output/demo.xlsx +0 -0
  166. data/test/perl_output/diag_border.xlsx +0 -0
  167. data/test/perl_output/fit_to_pages.xlsx +0 -0
  168. data/test/perl_output/headers.xlsx +0 -0
  169. data/test/perl_output/hide_sheet.xlsx +0 -0
  170. data/test/perl_output/hyperlink.xlsx +0 -0
  171. data/test/perl_output/indent.xlsx +0 -0
  172. data/test/perl_output/merge1.xlsx +0 -0
  173. data/test/perl_output/merge2.xlsx +0 -0
  174. data/test/perl_output/merge3.xlsx +0 -0
  175. data/test/perl_output/merge4.xlsx +0 -0
  176. data/test/perl_output/merge5.xlsx +0 -0
  177. data/test/perl_output/merge6.xlsx +0 -0
  178. data/test/perl_output/outline.xlsx +0 -0
  179. data/test/perl_output/print_scale.xlsx +0 -0
  180. data/test/perl_output/properties.xlsx +0 -0
  181. data/test/perl_output/protection.xlsx +0 -0
  182. data/test/perl_output/rich_strings.xlsx +0 -0
  183. data/test/perl_output/right_to_left.xlsx +0 -0
  184. data/test/perl_output/tab_colors.xlsx +0 -0
  185. data/test/test_delete_files.rb +37 -0
  186. data/test/test_example_match.rb +2281 -0
  187. data/test/test_xml_writer_simple.rb +63 -0
  188. data/test/workbook/test_get_chart_range.rb +59 -0
  189. data/test/workbook/test_sort_defined_names.rb +77 -0
  190. data/test/workbook/test_workbook_01.rb +29 -0
  191. data/test/workbook/test_workbook_02.rb +31 -0
  192. data/test/workbook/test_workbook_03.rb +31 -0
  193. data/test/workbook/test_workbook_new.rb +18 -0
  194. data/test/workbook/test_write_defined_name.rb +17 -0
  195. data/test/workbook/test_write_defined_names.rb +41 -0
  196. data/test/worksheet/test_calculate_spans.rb +58 -0
  197. data/test/worksheet/test_convert_date_time_01.rb +439 -0
  198. data/test/worksheet/test_convert_date_time_02.rb +478 -0
  199. data/test/worksheet/test_convert_date_time_03.rb +435 -0
  200. data/test/worksheet/test_extract_filter_tokens.rb +109 -0
  201. data/test/worksheet/test_parse_filter_expression.rb +143 -0
  202. data/test/worksheet/test_position_object.rb +50 -0
  203. data/test/worksheet/test_repeat_formula.rb +55 -0
  204. data/test/worksheet/test_worksheet_01.rb +32 -0
  205. data/test/worksheet/test_worksheet_02.rb +38 -0
  206. data/test/worksheet/test_worksheet_03.rb +44 -0
  207. data/test/worksheet/test_worksheet_04.rb +45 -0
  208. data/test/worksheet/test_write_array_formula_01.rb +99 -0
  209. data/test/worksheet/test_write_autofilter.rb +260 -0
  210. data/test/worksheet/test_write_brk.rb +18 -0
  211. data/test/worksheet/test_write_cell.rb +49 -0
  212. data/test/worksheet/test_write_cell_value.rb +33 -0
  213. data/test/worksheet/test_write_col_breaks.rb +27 -0
  214. data/test/worksheet/test_write_col_info.rb +95 -0
  215. data/test/worksheet/test_write_conditional_formatting.rb +72 -0
  216. data/test/worksheet/test_write_custom_filter.rb +18 -0
  217. data/test/worksheet/test_write_custom_filters.rb +25 -0
  218. data/test/worksheet/test_write_data_validation_01.rb +113 -0
  219. data/test/worksheet/test_write_data_validation_02.rb +528 -0
  220. data/test/worksheet/test_write_dimension.rb +94 -0
  221. data/test/worksheet/test_write_ext.rb +18 -0
  222. data/test/worksheet/test_write_ext_lst.rb +18 -0
  223. data/test/worksheet/test_write_filter.rb +18 -0
  224. data/test/worksheet/test_write_filter_column.rb +18 -0
  225. data/test/worksheet/test_write_filters.rb +32 -0
  226. data/test/worksheet/test_write_header_footer.rb +53 -0
  227. data/test/worksheet/test_write_hyperlink.rb +39 -0
  228. data/test/worksheet/test_write_hyperlinks.rb +27 -0
  229. data/test/worksheet/test_write_legacy_drawing.rb +19 -0
  230. data/test/worksheet/test_write_merge_cell.rb +18 -0
  231. data/test/worksheet/test_write_merge_cells.rb +192 -0
  232. data/test/worksheet/test_write_methods.rb +353 -0
  233. data/test/worksheet/test_write_mx_plv.rb +19 -0
  234. data/test/worksheet/test_write_page_margins.rb +98 -0
  235. data/test/worksheet/test_write_page_set_up_pr.rb +19 -0
  236. data/test/worksheet/test_write_page_setup.rb +54 -0
  237. data/test/worksheet/test_write_pane.rb +123 -0
  238. data/test/worksheet/test_write_phonetic_pr.rb +19 -0
  239. data/test/worksheet/test_write_print_options.rb +77 -0
  240. data/test/worksheet/test_write_row_breaks.rb +27 -0
  241. data/test/worksheet/test_write_row_element.rb +69 -0
  242. data/test/worksheet/test_write_selection.rb +18 -0
  243. data/test/worksheet/test_write_sheet_calc_pr.rb +18 -0
  244. data/test/worksheet/test_write_sheet_data.rb +18 -0
  245. data/test/worksheet/test_write_sheet_format_pr.rb +18 -0
  246. data/test/worksheet/test_write_sheet_pr.rb +36 -0
  247. data/test/worksheet/test_write_sheet_protection.rb +174 -0
  248. data/test/worksheet/test_write_sheet_view.rb +62 -0
  249. data/test/worksheet/test_write_sheet_view1.rb +64 -0
  250. data/test/worksheet/test_write_sheet_view2.rb +56 -0
  251. data/test/worksheet/test_write_sheet_view3.rb +83 -0
  252. data/test/worksheet/test_write_sheet_view4.rb +83 -0
  253. data/test/worksheet/test_write_sheet_view5.rb +74 -0
  254. data/test/worksheet/test_write_sheet_view6.rb +51 -0
  255. data/test/worksheet/test_write_sheet_view7.rb +71 -0
  256. data/test/worksheet/test_write_sheet_view8.rb +51 -0
  257. data/test/worksheet/test_write_sheet_view9.rb +51 -0
  258. data/test/worksheet/test_write_tab_color.rb +23 -0
  259. data/test/worksheet/test_write_worksheet.rb +19 -0
  260. data/write_xlsx.gemspec +308 -0
  261. metadata +363 -0
@@ -0,0 +1,16 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx/chart'
4
+
5
+ class TestWriteLegend < Test::Unit::TestCase
6
+ def setup
7
+ @chart = Writexlsx::Chart.new('Bar')
8
+ end
9
+
10
+ def test_write_legend
11
+ expected = '<c:legend><c:legendPos val="r" /><c:layout /></c:legend>'
12
+ @chart.__send__('write_legend')
13
+ result = @chart.instance_variable_get(:@writer).string
14
+ assert_equal(expected, result)
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx/chart'
4
+
5
+ class TestWriteLegendPos < Test::Unit::TestCase
6
+ def setup
7
+ @chart = Writexlsx::Chart.new('Bar')
8
+ end
9
+
10
+ def test_write_legend_pos
11
+ expected = '<c:legendPos val="r" />'
12
+ result = @chart.__send__('write_legend_pos', 'r')
13
+ assert_equal(expected, result)
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx/chart'
4
+
5
+ class TestWriteMajorGridlines < Test::Unit::TestCase
6
+ def setup
7
+ @chart = Writexlsx::Chart.new('Bar')
8
+ end
9
+
10
+ def test_write_major_gridlines
11
+ expected = '<c:majorGridlines />'
12
+ result = @chart.__send__('write_major_gridlines')
13
+ assert_equal(expected, result)
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx/chart'
4
+
5
+ class TestWriteMarker < Test::Unit::TestCase
6
+ def setup
7
+ @chart = Writexlsx::Chart.new('Bar')
8
+ end
9
+
10
+ def test_write_marker
11
+ expected = '<c:marker><c:symbol val="none" /></c:marker>'
12
+ @chart.instance_variable_set(:@default_marker, { :type => 'none'})
13
+ @chart.__send__('write_marker')
14
+ result = @chart.instance_variable_get(:@writer).string
15
+ assert_equal(expected, result)
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx/chart'
4
+
5
+ class TestWriteMarkerSize < Test::Unit::TestCase
6
+ def setup
7
+ @chart = Writexlsx::Chart.new('Bar')
8
+ end
9
+
10
+ def test_write_marker_size
11
+ expected = '<c:size val="3" />'
12
+ result = @chart.__send__('write_marker_size', 3)
13
+ assert_equal(expected, result)
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx/chart'
4
+
5
+ class TestWriteMarkerValue < Test::Unit::TestCase
6
+ def setup
7
+ @chart = Writexlsx::Chart.new('Bar')
8
+ end
9
+
10
+ def test_write_marker_value
11
+ expected = '<c:marker val="1" />'
12
+ @chart.instance_variable_set(:@default_marker, 'none')
13
+ result = @chart.__send__('write_marker_value')
14
+ assert_equal(expected, result)
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx/chart'
4
+
5
+ class TestWriteNumCache < Test::Unit::TestCase
6
+ def setup
7
+ @chart = Writexlsx::Chart.new('Bar')
8
+ end
9
+
10
+ def test_write_num_cache
11
+ expected = '<c:numCache><c:formatCode>General</c:formatCode><c:ptCount val="5" /><c:pt idx="0"><c:v>1</c:v></c:pt><c:pt idx="1"><c:v>2</c:v></c:pt><c:pt idx="2"><c:v>3</c:v></c:pt><c:pt idx="3"><c:v>4</c:v></c:pt><c:pt idx="4"><c:v>5</c:v></c:pt></c:numCache>'
12
+ @chart.__send__('write_num_cache', [1, 2, 3, 4, 5])
13
+ result = @chart.instance_variable_get(:@writer).string
14
+ assert_equal(expected, result)
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx/chart'
4
+
5
+ class TestWriteNumFmt < Test::Unit::TestCase
6
+ def setup
7
+ @chart = Writexlsx::Chart.new('Bar')
8
+ end
9
+
10
+ def test_write_num_fmt
11
+ expected = '<c:numFmt formatCode="General" sourceLinked="1" />'
12
+ @chart.instance_variable_set(:@has_category, 1)
13
+ result = @chart.__send__('write_num_fmt')
14
+ assert_equal(expected, result)
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx/chart'
4
+
5
+ class TestWriteNumberFormat < Test::Unit::TestCase
6
+ def setup
7
+ @chart = Writexlsx::Chart.new('Bar')
8
+ end
9
+
10
+ def test_write_number_format
11
+ expected = '<c:numFmt formatCode="General" sourceLinked="1" />'
12
+ result = @chart.__send__('write_number_format')
13
+ assert_equal(expected, result)
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx/chart'
4
+
5
+ class TestWriteOrder < Test::Unit::TestCase
6
+ def setup
7
+ @chart = Writexlsx::Chart.new('Bar')
8
+ end
9
+
10
+ def test_write_order
11
+ expected = '<c:order val="0" />'
12
+ result = @chart.__send__('write_order', 0)
13
+ assert_equal(expected, result)
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx/chart'
4
+
5
+ class TestWriteOrientation < Test::Unit::TestCase
6
+ def setup
7
+ @chart = Writexlsx::Chart.new('Bar')
8
+ end
9
+
10
+ def test_write_orientation
11
+ expected = '<c:orientation val="minMax" />'
12
+ result = @chart.__send__('write_orientation')
13
+ assert_equal(expected, result)
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx/chart'
4
+
5
+ class TestChartWritePageMargins < Test::Unit::TestCase
6
+ def setup
7
+ @chart = Writexlsx::Chart.new('Bar')
8
+ end
9
+
10
+ def test_write_page_margins
11
+ expected = '<c:pageMargins b="0.75" l="0.7" r="0.7" t="0.75" header="0.3" footer="0.3" />'
12
+ result = @chart.__send__('write_page_margins')
13
+ assert_equal(expected, result)
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx/chart'
4
+
5
+ class TestChartWritePageSetup < Test::Unit::TestCase
6
+ def setup
7
+ @chart = Writexlsx::Chart.new('Bar')
8
+ end
9
+
10
+ def test_write_page_setup
11
+ expected = '<c:pageSetup />'
12
+ result = @chart.__send__('write_page_setup')
13
+ assert_equal(expected, result)
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx/chart'
4
+
5
+ class TestWritePlotVisOnly < Test::Unit::TestCase
6
+ def setup
7
+ @chart = Writexlsx::Chart.new('Bar')
8
+ end
9
+
10
+ def test_write_plot_vis_only
11
+ expected = '<c:plotVisOnly val="1" />'
12
+ result = @chart.__send__('write_plot_vis_only')
13
+ assert_equal(expected, result)
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx/chart'
4
+
5
+ class TestWritePt < Test::Unit::TestCase
6
+ def setup
7
+ @chart = Writexlsx::Chart.new('Bar')
8
+ end
9
+
10
+ def test_write_pt
11
+ expected = '<c:pt idx="0"><c:v>1</c:v></c:pt>'
12
+ @chart.__send__('write_pt', 0, 1)
13
+ result = @chart.instance_variable_get(:@writer).string
14
+ assert_equal(expected, result)
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx/chart'
4
+
5
+ class TestWritePtCount < Test::Unit::TestCase
6
+ def setup
7
+ @chart = Writexlsx::Chart.new('Bar')
8
+ end
9
+
10
+ def test_write_pt_count
11
+ expected = '<c:ptCount val="5" />'
12
+ @chart.__send__('write_pt_count', 5)
13
+ result = @chart.instance_variable_get(:@writer).string
14
+ assert_equal(expected, result)
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx/chart'
4
+
5
+ class TestWriteSeriesFormula < Test::Unit::TestCase
6
+ def setup
7
+ @chart = Writexlsx::Chart.new('Bar')
8
+ end
9
+
10
+ def test_write_series_formula
11
+ expected = '<c:f>Sheet1!$A$1:$A$5</c:f>'
12
+ @chart.__send__('write_series_formula', 'Sheet1!$A$1:$A$5')
13
+ result = @chart.instance_variable_get(:@writer).string
14
+ assert_equal(expected, result)
15
+ end
16
+ end
@@ -0,0 +1,41 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx/chart'
4
+
5
+ class TestWriteStyle < Test::Unit::TestCase
6
+ def setup
7
+ @chart = Writexlsx::Chart.new('Bar')
8
+ end
9
+
10
+ def test_write_style_1
11
+ expected = '<c:style val="1" />'
12
+ @chart.set_style(1)
13
+ @chart.__send__('write_style')
14
+ result = @chart.instance_variable_get(:@writer).string
15
+ assert_equal(expected, result)
16
+ end
17
+
18
+ def test_write_style_with_default_style_not_written
19
+ expected = ''
20
+ @chart.set_style(2)
21
+ @chart.__send__('write_style')
22
+ result = @chart.instance_variable_get(:@writer).string
23
+ assert_equal(expected, result)
24
+ end
25
+
26
+ def test_write_style_with_outside_range
27
+ expected = ''
28
+ @chart.set_style(-1)
29
+ @chart.__send__('write_style')
30
+ result = @chart.instance_variable_get(:@writer).string
31
+ assert_equal(expected, result)
32
+ end
33
+
34
+ def test_write_style_with_outside_range_43
35
+ expected = ''
36
+ @chart.set_style(43)
37
+ @chart.__send__('write_style')
38
+ result = @chart.instance_variable_get(:@writer).string
39
+ assert_equal(expected, result)
40
+ end
41
+ end
@@ -0,0 +1,16 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx/chart'
4
+
5
+ class TestWriteSymbol < Test::Unit::TestCase
6
+ def setup
7
+ @chart = Writexlsx::Chart.new('Bar')
8
+ end
9
+
10
+ def test_write_symbol
11
+ expected = '<c:symbol val="none" />'
12
+ @chart.__send__('write_symbol', 'none')
13
+ result = @chart.instance_variable_get(:@writer).string
14
+ assert_equal(expected, result)
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx/chart'
4
+
5
+ class TestWriteTickLabelPos < Test::Unit::TestCase
6
+ def setup
7
+ @chart = Writexlsx::Chart.new('Bar')
8
+ end
9
+
10
+ def test_write_tick_label_pos
11
+ expected = '<c:tickLblPos val="nextTo" />'
12
+ @chart.__send__('write_tick_label_pos', 'nextTo')
13
+ result = @chart.instance_variable_get(:@writer).string
14
+ assert_equal(expected, result)
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx/chart'
4
+
5
+ class TestWriteV < Test::Unit::TestCase
6
+ def setup
7
+ @chart = Writexlsx::Chart.new('Bar')
8
+ end
9
+
10
+ def test_write_v
11
+ expected = '<c:v>Apple</c:v>'
12
+ @chart.__send__('write_v', 'Apple')
13
+ result = @chart.instance_variable_get(:@writer).string
14
+ assert_equal(expected, result)
15
+ end
16
+ end
@@ -0,0 +1,50 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx/drawing'
4
+
5
+ class DrawingChart011 < Test::Unit::TestCase
6
+ def test_drawing_chart_01
7
+ @obj = Writexlsx::Drawing.new
8
+ @obj.add_drawing_object(1, 4, 8, 457200, 104775, 12, 22, 152400, 180975)
9
+ @obj.embedded = true
10
+ @obj.assemble_xml_file
11
+ result = got_to_array(@obj.xml_str)
12
+ expected = expected_to_array(<<EOS
13
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
14
+ <xdr:wsDr xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
15
+ <xdr:twoCellAnchor>
16
+ <xdr:from>
17
+ <xdr:col>4</xdr:col>
18
+ <xdr:colOff>457200</xdr:colOff>
19
+ <xdr:row>8</xdr:row>
20
+ <xdr:rowOff>104775</xdr:rowOff>
21
+ </xdr:from>
22
+ <xdr:to>
23
+ <xdr:col>12</xdr:col>
24
+ <xdr:colOff>152400</xdr:colOff>
25
+ <xdr:row>22</xdr:row>
26
+ <xdr:rowOff>180975</xdr:rowOff>
27
+ </xdr:to>
28
+ <xdr:graphicFrame macro="">
29
+ <xdr:nvGraphicFramePr>
30
+ <xdr:cNvPr id="2" name="Chart 1"/>
31
+ <xdr:cNvGraphicFramePr/>
32
+ </xdr:nvGraphicFramePr>
33
+ <xdr:xfrm>
34
+ <a:off x="0" y="0"/>
35
+ <a:ext cx="0" cy="0"/>
36
+ </xdr:xfrm>
37
+ <a:graphic>
38
+ <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/chart">
39
+ <c:chart xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" r:id="rId1"/>
40
+ </a:graphicData>
41
+ </a:graphic>
42
+ </xdr:graphicFrame>
43
+ <xdr:clientData/>
44
+ </xdr:twoCellAnchor>
45
+ </xdr:wsDr>
46
+ EOS
47
+ )
48
+ assert_equal(expected, result)
49
+ end
50
+ end