ricardoo27-writeexcel 0.6.12.1

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 (245) hide show
  1. data/.document +5 -0
  2. data/.gitattributes +1 -0
  3. data/README.rdoc +136 -0
  4. data/Rakefile +52 -0
  5. data/VERSION +1 -0
  6. data/charts/chartex.rb +316 -0
  7. data/charts/demo1.rb +46 -0
  8. data/charts/demo101.bin +0 -0
  9. data/charts/demo2.rb +65 -0
  10. data/charts/demo201.bin +0 -0
  11. data/charts/demo3.rb +117 -0
  12. data/charts/demo301.bin +0 -0
  13. data/charts/demo4.rb +119 -0
  14. data/charts/demo401.bin +0 -0
  15. data/charts/demo5.rb +48 -0
  16. data/charts/demo501.bin +0 -0
  17. data/examples/a_simple.rb +43 -0
  18. data/examples/autofilter.rb +265 -0
  19. data/examples/bigfile.rb +30 -0
  20. data/examples/chart_area.rb +121 -0
  21. data/examples/chart_bar.rb +120 -0
  22. data/examples/chart_column.rb +120 -0
  23. data/examples/chart_line.rb +120 -0
  24. data/examples/chart_pie.rb +108 -0
  25. data/examples/chart_scatter.rb +121 -0
  26. data/examples/chart_stock.rb +148 -0
  27. data/examples/chess.rb +142 -0
  28. data/examples/colors.rb +129 -0
  29. data/examples/comments1.rb +27 -0
  30. data/examples/comments2.rb +352 -0
  31. data/examples/copyformat.rb +52 -0
  32. data/examples/data_validate.rb +279 -0
  33. data/examples/date_time.rb +87 -0
  34. data/examples/defined_name.rb +32 -0
  35. data/examples/demo.rb +124 -0
  36. data/examples/diag_border.rb +36 -0
  37. data/examples/formats.rb +490 -0
  38. data/examples/formula_result.rb +30 -0
  39. data/examples/header.rb +137 -0
  40. data/examples/hide_sheet.rb +29 -0
  41. data/examples/hyperlink.rb +43 -0
  42. data/examples/images.rb +63 -0
  43. data/examples/indent.rb +31 -0
  44. data/examples/merge1.rb +40 -0
  45. data/examples/merge2.rb +45 -0
  46. data/examples/merge3.rb +66 -0
  47. data/examples/merge4.rb +83 -0
  48. data/examples/merge5.rb +80 -0
  49. data/examples/merge6.rb +67 -0
  50. data/examples/outline.rb +255 -0
  51. data/examples/outline_collapsed.rb +209 -0
  52. data/examples/panes.rb +113 -0
  53. data/examples/password_protection.rb +33 -0
  54. data/examples/properties.rb +34 -0
  55. data/examples/properties_jp.rb +33 -0
  56. data/examples/protection.rb +47 -0
  57. data/examples/regions.rb +53 -0
  58. data/examples/repeat.rb +43 -0
  59. data/examples/republic.png +0 -0
  60. data/examples/right_to_left.rb +27 -0
  61. data/examples/row_wrap.rb +53 -0
  62. data/examples/set_first_sheet.rb +14 -0
  63. data/examples/stats.rb +74 -0
  64. data/examples/stocks.rb +81 -0
  65. data/examples/store_formula.rb +15 -0
  66. data/examples/tab_colors.rb +31 -0
  67. data/examples/utf8.rb +15 -0
  68. data/examples/write_arrays.rb +83 -0
  69. data/html/en/doc_en.html +5946 -0
  70. data/html/images/a_simple.jpg +0 -0
  71. data/html/images/area1.jpg +0 -0
  72. data/html/images/bar1.jpg +0 -0
  73. data/html/images/chart_area.xls +0 -0
  74. data/html/images/column1.jpg +0 -0
  75. data/html/images/data_validation.jpg +0 -0
  76. data/html/images/line1.jpg +0 -0
  77. data/html/images/pie1.jpg +0 -0
  78. data/html/images/regions.jpg +0 -0
  79. data/html/images/scatter1.jpg +0 -0
  80. data/html/images/stats.jpg +0 -0
  81. data/html/images/stock1.jpg +0 -0
  82. data/html/images/stocks.jpg +0 -0
  83. data/html/index.html +16 -0
  84. data/html/style.css +433 -0
  85. data/lib/writeexcel.rb +1159 -0
  86. data/lib/writeexcel/biffwriter.rb +223 -0
  87. data/lib/writeexcel/caller_info.rb +12 -0
  88. data/lib/writeexcel/cell_range.rb +332 -0
  89. data/lib/writeexcel/chart.rb +1968 -0
  90. data/lib/writeexcel/charts/area.rb +154 -0
  91. data/lib/writeexcel/charts/bar.rb +177 -0
  92. data/lib/writeexcel/charts/column.rb +156 -0
  93. data/lib/writeexcel/charts/external.rb +66 -0
  94. data/lib/writeexcel/charts/line.rb +154 -0
  95. data/lib/writeexcel/charts/pie.rb +169 -0
  96. data/lib/writeexcel/charts/scatter.rb +192 -0
  97. data/lib/writeexcel/charts/stock.rb +213 -0
  98. data/lib/writeexcel/col_info.rb +87 -0
  99. data/lib/writeexcel/colors.rb +68 -0
  100. data/lib/writeexcel/comments.rb +460 -0
  101. data/lib/writeexcel/compatibility.rb +65 -0
  102. data/lib/writeexcel/convert_date_time.rb +117 -0
  103. data/lib/writeexcel/data_validations.rb +370 -0
  104. data/lib/writeexcel/debug_info.rb +41 -0
  105. data/lib/writeexcel/embedded_chart.rb +35 -0
  106. data/lib/writeexcel/excelformula.y +139 -0
  107. data/lib/writeexcel/excelformulaparser.rb +587 -0
  108. data/lib/writeexcel/format.rb +1575 -0
  109. data/lib/writeexcel/formula.rb +987 -0
  110. data/lib/writeexcel/helper.rb +78 -0
  111. data/lib/writeexcel/image.rb +218 -0
  112. data/lib/writeexcel/olewriter.rb +305 -0
  113. data/lib/writeexcel/outline.rb +24 -0
  114. data/lib/writeexcel/properties.rb +242 -0
  115. data/lib/writeexcel/shared_string_table.rb +153 -0
  116. data/lib/writeexcel/storage_lite.rb +984 -0
  117. data/lib/writeexcel/workbook.rb +2478 -0
  118. data/lib/writeexcel/worksheet.rb +6925 -0
  119. data/lib/writeexcel/worksheets.rb +25 -0
  120. data/lib/writeexcel/write_file.rb +63 -0
  121. data/test/excelfile/Chart1.xls +0 -0
  122. data/test/excelfile/Chart2.xls +0 -0
  123. data/test/excelfile/Chart3.xls +0 -0
  124. data/test/excelfile/Chart4.xls +0 -0
  125. data/test/excelfile/Chart5.xls +0 -0
  126. data/test/helper.rb +31 -0
  127. data/test/perl_output/Chart1.xls.data +0 -0
  128. data/test/perl_output/Chart2.xls.data +0 -0
  129. data/test/perl_output/Chart3.xls.data +0 -0
  130. data/test/perl_output/Chart4.xls.data +0 -0
  131. data/test/perl_output/Chart5.xls.data +0 -0
  132. data/test/perl_output/README +31 -0
  133. data/test/perl_output/a_simple.xls +0 -0
  134. data/test/perl_output/autofilter.xls +0 -0
  135. data/test/perl_output/biff_add_continue_testdata +0 -0
  136. data/test/perl_output/chart_area.xls +0 -0
  137. data/test/perl_output/chart_bar.xls +0 -0
  138. data/test/perl_output/chart_column.xls +0 -0
  139. data/test/perl_output/chart_line.xls +0 -0
  140. data/test/perl_output/chess.xls +0 -0
  141. data/test/perl_output/colors.xls +0 -0
  142. data/test/perl_output/comments0.xls +0 -0
  143. data/test/perl_output/comments1.xls +0 -0
  144. data/test/perl_output/comments2.xls +0 -0
  145. data/test/perl_output/data_validate.xls +0 -0
  146. data/test/perl_output/date_time.xls +0 -0
  147. data/test/perl_output/defined_name.xls +0 -0
  148. data/test/perl_output/demo.xls +0 -0
  149. data/test/perl_output/demo101.bin +0 -0
  150. data/test/perl_output/demo201.bin +0 -0
  151. data/test/perl_output/demo301.bin +0 -0
  152. data/test/perl_output/demo401.bin +0 -0
  153. data/test/perl_output/demo501.bin +0 -0
  154. data/test/perl_output/diag_border.xls +0 -0
  155. data/test/perl_output/f_font_biff +0 -0
  156. data/test/perl_output/f_font_key +1 -0
  157. data/test/perl_output/f_xf_biff +0 -0
  158. data/test/perl_output/file_font_biff +0 -0
  159. data/test/perl_output/file_font_key +1 -0
  160. data/test/perl_output/file_xf_biff +0 -0
  161. data/test/perl_output/formula_result.xls +0 -0
  162. data/test/perl_output/headers.xls +0 -0
  163. data/test/perl_output/hidden.xls +0 -0
  164. data/test/perl_output/hide_zero.xls +0 -0
  165. data/test/perl_output/hyperlink.xls +0 -0
  166. data/test/perl_output/images.xls +0 -0
  167. data/test/perl_output/indent.xls +0 -0
  168. data/test/perl_output/merge1.xls +0 -0
  169. data/test/perl_output/merge2.xls +0 -0
  170. data/test/perl_output/merge3.xls +0 -0
  171. data/test/perl_output/merge4.xls +0 -0
  172. data/test/perl_output/merge5.xls +0 -0
  173. data/test/perl_output/merge6.xls +0 -0
  174. data/test/perl_output/ole_write_header +0 -0
  175. data/test/perl_output/outline.xls +0 -0
  176. data/test/perl_output/outline_collapsed.xls +0 -0
  177. data/test/perl_output/panes.xls +0 -0
  178. data/test/perl_output/password_protection.xls +0 -0
  179. data/test/perl_output/protection.xls +0 -0
  180. data/test/perl_output/regions.xls +0 -0
  181. data/test/perl_output/right_to_left.xls +0 -0
  182. data/test/perl_output/set_first_sheet.xls +0 -0
  183. data/test/perl_output/stats.xls +0 -0
  184. data/test/perl_output/stocks.xls +0 -0
  185. data/test/perl_output/store_formula.xls +0 -0
  186. data/test/perl_output/tab_colors.xls +0 -0
  187. data/test/perl_output/unicode_cyrillic.xls +0 -0
  188. data/test/perl_output/utf8.xls +0 -0
  189. data/test/perl_output/workbook1.xls +0 -0
  190. data/test/perl_output/workbook2.xls +0 -0
  191. data/test/perl_output/ws_colinfo +1 -0
  192. data/test/perl_output/ws_store_colinfo +0 -0
  193. data/test/perl_output/ws_store_dimensions +0 -0
  194. data/test/perl_output/ws_store_filtermode +0 -0
  195. data/test/perl_output/ws_store_filtermode_off +0 -0
  196. data/test/perl_output/ws_store_filtermode_on +0 -0
  197. data/test/perl_output/ws_store_selection +0 -0
  198. data/test/perl_output/ws_store_window2 +1 -0
  199. data/test/republic.png +0 -0
  200. data/test/test_00_IEEE_double.rb +13 -0
  201. data/test/test_01_add_worksheet.rb +10 -0
  202. data/test/test_02_merge_formats.rb +49 -0
  203. data/test/test_04_dimensions.rb +388 -0
  204. data/test/test_05_rows.rb +175 -0
  205. data/test/test_06_extsst.rb +74 -0
  206. data/test/test_11_date_time.rb +475 -0
  207. data/test/test_12_date_only.rb +525 -0
  208. data/test/test_13_date_seconds.rb +477 -0
  209. data/test/test_21_escher.rb +624 -0
  210. data/test/test_22_mso_drawing_group.rb +741 -0
  211. data/test/test_23_note.rb +57 -0
  212. data/test/test_24_txo.rb +74 -0
  213. data/test/test_25_position_object.rb +80 -0
  214. data/test/test_26_autofilter.rb +309 -0
  215. data/test/test_27_autofilter.rb +126 -0
  216. data/test/test_28_autofilter.rb +156 -0
  217. data/test/test_29_process_jpg.rb +670 -0
  218. data/test/test_30_validation_dval.rb +74 -0
  219. data/test/test_31_validation_dv_strings.rb +123 -0
  220. data/test/test_32_validation_dv_formula.rb +203 -0
  221. data/test/test_40_property_types.rb +188 -0
  222. data/test/test_41_properties.rb +235 -0
  223. data/test/test_42_set_properties.rb +434 -0
  224. data/test/test_50_name_stored.rb +295 -0
  225. data/test/test_51_name_print_area.rb +353 -0
  226. data/test/test_52_name_print_titles.rb +450 -0
  227. data/test/test_53_autofilter.rb +199 -0
  228. data/test/test_60_chart_generic.rb +574 -0
  229. data/test/test_61_chart_subclasses.rb +84 -0
  230. data/test/test_62_chart_formats.rb +268 -0
  231. data/test/test_63_chart_area_formats.rb +645 -0
  232. data/test/test_biff.rb +71 -0
  233. data/test/test_big_workbook.rb +17 -0
  234. data/test/test_compatibility.rb +12 -0
  235. data/test/test_example_match.rb +3246 -0
  236. data/test/test_format.rb +1189 -0
  237. data/test/test_formula.rb +61 -0
  238. data/test/test_ole.rb +102 -0
  239. data/test/test_storage_lite.rb +116 -0
  240. data/test/test_workbook.rb +146 -0
  241. data/test/test_worksheet.rb +106 -0
  242. data/utils/add_magic_comment.rb +80 -0
  243. data/writeexcel.gemspec +278 -0
  244. data/writeexcel.rdoc +1425 -0
  245. metadata +292 -0
@@ -0,0 +1,154 @@
1
+ # -*- coding: utf-8 -*-
2
+ ###############################################################################
3
+ #
4
+ # Area - A writer class for Excel Area charts.
5
+ #
6
+ # Used in conjunction with Chart.
7
+ #
8
+ # See formatting note in Chart.
9
+ #
10
+ # Copyright 2000-2010, John McNamara, jmcnamara@cpan.org
11
+ #
12
+ # original written in Perl by John McNamara
13
+ # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
14
+ #
15
+
16
+ require 'writeexcel'
17
+
18
+ module Writeexcel
19
+
20
+ class Chart
21
+
22
+ #
23
+ # ==SYNOPSIS
24
+ #
25
+ # To create a simple Excel file with a Area chart using WriteExcel:
26
+ #
27
+ # #!/usr/bin/ruby -w
28
+ #
29
+ # require 'writeexcel'
30
+ #
31
+ # workbook = WriteExcel.new('chart.xls')
32
+ # worksheet = workbook.add_worksheet
33
+ #
34
+ # chart = workbook.add_chart(:type => 'Chart::Area')
35
+ #
36
+ # # Configure the chart.
37
+ # chart.add_series(
38
+ # :categories => '=Sheet1!$A$2:$A$7',
39
+ # :values => '=Sheet1!$B$2:$B$7',
40
+ # )
41
+ #
42
+ # # Add the worksheet data the chart refers to.
43
+ # data = [
44
+ # [ 'Category', 2, 3, 4, 5, 6, 7 ],
45
+ # [ 'Value', 1, 4, 5, 2, 1, 5 ]
46
+ # ]
47
+ #
48
+ # worksheet.write('A1', data)
49
+ #
50
+ # workbook.close
51
+ #
52
+ # ==DESCRIPTION
53
+ #
54
+ # This module implements Area charts for WriteExcel. The chart object is
55
+ # created via the Workbook add_chart method:
56
+ #
57
+ # chart = workbook.add_chart(:type => 'Chart::Area')
58
+ #
59
+ # Once the object is created it can be configured via the following methods
60
+ # that are common to all chart classes:
61
+ #
62
+ # chart.add_series
63
+ # chart.set_x_axis
64
+ # chart.set_y_axis
65
+ # chart.set_title
66
+ #
67
+ # These methods are explained in detail in Chart section of WriteExcel.
68
+ # Class specific methods or settings, if any, are explained below.
69
+ #
70
+ # ==Area Chart Methods
71
+ #
72
+ # There aren't currently any area chart specific methods. See the TODO
73
+ # section of Chart of Writeexcel.
74
+ #
75
+ # ==EXAMPLE
76
+ #
77
+ # Here is a complete example that demonstrates most of the available
78
+ # features when creating a chart.
79
+ #
80
+ # #!/usr/bin/ruby -w
81
+ #
82
+ # require 'writeexcel'
83
+ #
84
+ # workbook = WriteExcel.new('chart_area.xls')
85
+ # worksheet = workbook.add_worksheet
86
+ # bold = workbook.add_format(:bold => 1)
87
+ #
88
+ # # Add the worksheet data that the charts will refer to.
89
+ # headings = [ 'Number', 'Sample 1', 'Sample 2' ]
90
+ # data = [
91
+ # [ 2, 3, 4, 5, 6, 7 ],
92
+ # [ 1, 4, 5, 2, 1, 5 ],
93
+ # [ 3, 6, 7, 5, 4, 3 ]
94
+ # ]
95
+ #
96
+ # worksheet.write('A1', headings, bold)
97
+ # worksheet.write('A2', data)
98
+ #
99
+ # # Create a new chart object. In this case an embedded chart.
100
+ # chart = workbook.add_chart(:type => 'Chart::Area', :embedded => 1)
101
+ #
102
+ # # Configure the first series. (Sample 1)
103
+ # chart.add_series(
104
+ # :name => 'Sample 1',
105
+ # :categories => '=Sheet1!$A$2:$A$7',
106
+ # :values => '=Sheet1!$B$2:$B$7',
107
+ # )
108
+ #
109
+ # # Configure the second series. (Sample 2)
110
+ # chart.add_series(
111
+ # :name => 'Sample 2',
112
+ # :categories => '=Sheet1!$A$2:$A$7',
113
+ # :values => '=Sheet1!$C$2:$C$7',
114
+ # )
115
+ #
116
+ # # Add a chart title and some axis labels.
117
+ # chart.set_title (:name => 'Results of sample analysis')
118
+ # chart.set_x_axis(:name => 'Test number')
119
+ # chart.set_y_axis(:name => 'Sample length (cm)')
120
+ #
121
+ # # Insert the chart into the worksheet (with an offset).
122
+ # worksheet.insert_chart('D2', chart, 25, 10)
123
+ #
124
+ # workbook.close
125
+ #
126
+ class Area < Chart
127
+ ###############################################################################
128
+ #
129
+ # new()
130
+ #
131
+ #
132
+ def initialize(*args) # :nodoc:
133
+ super
134
+ end
135
+
136
+ ###############################################################################
137
+ #
138
+ # _store_chart_type()
139
+ #
140
+ # Implementation of the abstract method from the specific chart class.
141
+ #
142
+ # Write the AREA chart BIFF record. Defines a area chart type.
143
+ #
144
+ def store_chart_type # :nodoc:
145
+ record = 0x101A # Record identifier.
146
+ length = 0x0002 # Number of bytes to follow.
147
+ grbit = 0x0001 # Option flags.
148
+
149
+ store_simple(record, length, grbit)
150
+ end
151
+ end
152
+ end # class Chart
153
+
154
+ end # module Writeexcel
@@ -0,0 +1,177 @@
1
+ # -*- coding: utf-8 -*-
2
+ ###############################################################################
3
+ #
4
+ # Bar - A writer class for Excel Bar charts.
5
+ #
6
+ # Used in conjunction with Chart.
7
+ #
8
+ # See formatting note in Chart.
9
+ #
10
+ # Copyright 2000-2010, John McNamara, jmcnamara@cpan.org
11
+ #
12
+ # original written in Perl by John McNamara
13
+ # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
14
+ #
15
+
16
+ require 'writeexcel/chart'
17
+
18
+ module Writeexcel
19
+
20
+ class Chart
21
+
22
+ #
23
+ # ==SYNOPSIS
24
+ #
25
+ # To create a simple Excel file with a Bar chart using WriteExcel:
26
+ #
27
+ # #!/usr/bin/ruby -w
28
+ #
29
+ # require 'writeexcel'
30
+ #
31
+ # workbook = WriteExcel.new('chart.xls')
32
+ # worksheet = workbook.add_worksheet
33
+ #
34
+ # chart = workbook.add_chart(:type => 'Chart::Bar')
35
+ #
36
+ # # Configure the chart.
37
+ # chart.add_series(
38
+ # :categories => '=Sheet1!$A$2:$A$7',
39
+ # :values => '=Sheet1!$B$2:$B$7',
40
+ # )
41
+ #
42
+ # # Add the worksheet data the chart refers to.
43
+ # data = [
44
+ # [ 'Category', 2, 3, 4, 5, 6, 7 ],
45
+ # [ 'Value', 1, 4, 5, 2, 1, 5 ]
46
+ # ]
47
+ #
48
+ # worksheet.write('A1', data)
49
+ #
50
+ # workbook.close
51
+ #
52
+ # ==DESCRIPTION
53
+ #
54
+ # This module implements Bar charts for WriteExcel. The chart object is
55
+ # created via the Workbook add_chart method:
56
+ #
57
+ # chart = workbook.add_chart(:type => 'Chart::Bar')
58
+ #
59
+ # Once the object is created it can be configured via the following methods
60
+ # that are common to all chart classes:
61
+ #
62
+ # chart.add_series
63
+ # chart.set_x_axis
64
+ # chart.set_y_axis
65
+ # chart.set_title
66
+ #
67
+ # These methods are explained in detail in Chart section of WriteExcel.
68
+ # Class specific methods or settings, if any, are explained below.
69
+ #
70
+ # ==Bar Chart Methods
71
+ #
72
+ # There aren't currently any bar chart specific methods. See the TODO
73
+ # section of Chart of Writeexcel.
74
+ #
75
+ # ==EXAMPLE
76
+ #
77
+ # Here is a complete example that demonstrates most of the available
78
+ # features when creating a chart.
79
+ #
80
+ # #!/usr/bin/ruby -w
81
+ #
82
+ # require 'writeexcel'
83
+ #
84
+ # workbook = WriteExcel.new('chart_bar.xls')
85
+ # worksheet = workbook.add_worksheet
86
+ # bold = workbook.add_format(:bold => 1)
87
+ #
88
+ # # Add the worksheet data that the charts will refer to.
89
+ # headings = [ 'Number', 'Sample 1', 'Sample 2' ]
90
+ # data = [
91
+ # [ 2, 3, 4, 5, 6, 7 ],
92
+ # [ 1, 4, 5, 2, 1, 5 ],
93
+ # [ 3, 6, 7, 5, 4, 3 ]
94
+ # ]
95
+ #
96
+ # worksheet.write('A1', headings, bold)
97
+ # worksheet.write('A2', data)
98
+ #
99
+ # # Create a new chart object. In this case an embedded chart.
100
+ # chart = workbook.add_chart(:type => 'Chart::Bar', :embedded => 1)
101
+ #
102
+ # # Configure the first series. (Sample 1)
103
+ # chart.add_series(
104
+ # :name => 'Sample 1',
105
+ # :categories => '=Sheet1!$A$2:$A$7',
106
+ # :values => '=Sheet1!$B$2:$B$7',
107
+ # )
108
+ #
109
+ # # Configure the second series. (Sample 2)
110
+ # chart.add_series(
111
+ # :name => 'Sample 2',
112
+ # :categories => '=Sheet1!$A$2:$A$7',
113
+ # :values => '=Sheet1!$C$2:$C$7',
114
+ # )
115
+ #
116
+ # # Add a chart title and some axis labels.
117
+ # chart.set_title (:name => 'Results of sample analysis')
118
+ # chart.set_x_axis(:name => 'Test number')
119
+ # chart.set_y_axis(:name => 'Sample length (cm)')
120
+ #
121
+ # # Insert the chart into the worksheet (with an offset).
122
+ # worksheet.insert_chart('D2', chart, 25, 10)
123
+ #
124
+ # workbook.close
125
+ #
126
+ class Bar < Chart
127
+ ###############################################################################
128
+ #
129
+ # new()
130
+ #
131
+ #
132
+ def initialize(*args) # :nodoc:
133
+ super
134
+ @config[:x_axis_text] = [ 0x2D, 0x6D9, 0x5F, 0x1CC, 0x281, 0x0, 90 ]
135
+ @config[:x_axis_text_pos] = [ 2, 2, 0, 0, 0x17, 0x2A ]
136
+ @config[:y_axis_text] = [ 0x078A, 0x0DFC, 0x011D, 0x9C, 0x0081, 0x0000 ]
137
+ @config[:y_axis_text_pos] = [ 2, 2, 0, 0, 0x45, 0x17 ]
138
+ end
139
+
140
+ ###############################################################################
141
+ #
142
+ # _store_chart_type()
143
+ #
144
+ # Implementation of the abstract method from the specific chart class.
145
+ #
146
+ # Write the BAR chart BIFF record. Defines a bar or column chart type.
147
+ #
148
+ def store_chart_type # :nodoc:
149
+ record = 0x1017 # Record identifier.
150
+ length = 0x0006 # Number of bytes to follow.
151
+ pcOverlap = 0x0000 # Space between bars.
152
+ pcGap = 0x0096 # Space between cats.
153
+ grbit = 0x0001 # Option flags.
154
+
155
+ store_simple(record, length, pcOverlap, pcGap, grbit)
156
+ end
157
+
158
+ ###############################################################################
159
+ #
160
+ # _set_embedded_config_data()
161
+ #
162
+ # Override some of the default configuration data for an embedded chart.
163
+ #
164
+ def set_embedded_config_data # :nodoc:
165
+ # Set the parent configuration first.
166
+ super
167
+
168
+ # The axis positions are reversed for a bar chart so we change the config.
169
+ @config[:x_axis_text] = [ 0x57, 0x5BC, 0xB5, 0x214, 0x281, 0x0, 90 ]
170
+ @config[:x_axis_text_pos] = [ 2, 2, 0, 0, 0x17, 0x2A ]
171
+ @config[:y_axis_text] = [ 0x074A, 0x0C8F, 0x021F, 0x123, 0x81, 0x0000 ]
172
+ @config[:y_axis_text_pos] = [ 2, 2, 0, 0, 0x45, 0x17 ]
173
+ end
174
+ end
175
+ end # class Chart
176
+
177
+ end # module Writeexcel
@@ -0,0 +1,156 @@
1
+ # -*- coding: utf-8 -*-
2
+ ###############################################################################
3
+ #
4
+ # Column - A writer class for Excel Column charts.
5
+ #
6
+ # Used in conjunction with Chart.
7
+ #
8
+ # See formatting note in Chart.
9
+ #
10
+ # Copyright 2000-2010, John McNamara, jmcnamara@cpan.org
11
+ #
12
+ # original written in Perl by John McNamara
13
+ # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
14
+ #
15
+
16
+ require 'writeexcel/chart'
17
+
18
+ module Writeexcel
19
+
20
+ class Chart
21
+
22
+ #
23
+ # ==SYNOPSIS
24
+ #
25
+ # To create a simple Excel file with a Column chart using WriteExcel:
26
+ #
27
+ # #!/usr/bin/ruby -w
28
+ #
29
+ # require 'writeexcel'
30
+ #
31
+ # workbook = WriteExcel.new('chart.xls')
32
+ # worksheet = workbook.add_worksheet
33
+ #
34
+ # chart = workbook.add_chart(:type => 'Chart::Column')
35
+ #
36
+ # # Configure the chart.
37
+ # chart.add_series(
38
+ # :categories => '=Sheet1!$A$2:$A$7',
39
+ # :values => '=Sheet1!$B$2:$B$7',
40
+ # )
41
+ #
42
+ # # Add the worksheet data the chart refers to.
43
+ # data = [
44
+ # [ 'Category', 2, 3, 4, 5, 6, 7 ],
45
+ # [ 'Value', 1, 4, 5, 2, 1, 5 ]
46
+ # ]
47
+ #
48
+ # worksheet.write('A1', data)
49
+ #
50
+ # workbook.close
51
+ #
52
+ # ==DESCRIPTION
53
+ #
54
+ # This module implements Column charts for WriteExcel. The chart object is
55
+ # created via the Workbook add_chart method:
56
+ #
57
+ # chart = workbook.add_chart(:type => 'Chart::Column')
58
+ #
59
+ # Once the object is created it can be configured via the following methods
60
+ # that are common to all chart classes:
61
+ #
62
+ # chart.add_series
63
+ # chart.set_x_axis
64
+ # chart.set_y_axis
65
+ # chart.set_title
66
+ #
67
+ # These methods are explained in detail in Chart section of WriteExcel.
68
+ # Class specific methods or settings, if any, are explained below.
69
+ #
70
+ # ==Column Chart Methods
71
+ #
72
+ # There aren't currently any column chart specific methods. See the TODO
73
+ # section of Chart of Writeexcel.
74
+ #
75
+ # ==EXAMPLE
76
+ #
77
+ # Here is a complete example that demonstrates most of the available
78
+ # features when creating a chart.
79
+ #
80
+ # #!/usr/bin/ruby -w
81
+ #
82
+ # require 'writeexcel'
83
+ #
84
+ # workbook = WriteExcel.new('chart_column.xls')
85
+ # worksheet = workbook.add_worksheet
86
+ # bold = workbook.add_format(:bold => 1)
87
+ #
88
+ # # Add the worksheet data that the charts will refer to.
89
+ # headings = [ 'Number', 'Sample 1', 'Sample 2' ]
90
+ # data = [
91
+ # [ 2, 3, 4, 5, 6, 7 ],
92
+ # [ 1, 4, 5, 2, 1, 5 ],
93
+ # [ 3, 6, 7, 5, 4, 3 ]
94
+ # ]
95
+ #
96
+ # worksheet.write('A1', headings, bold)
97
+ # worksheet.write('A2', data)
98
+ #
99
+ # # Create a new chart object. In this case an embedded chart.
100
+ # chart = workbook.add_chart(:type => 'Chart::Column', :embedded => 1)
101
+ #
102
+ # # Configure the first series. (Sample 1)
103
+ # chart.add_series(
104
+ # :name => 'Sample 1',
105
+ # :categories => '=Sheet1!$A$2:$A$7',
106
+ # :values => '=Sheet1!$B$2:$B$7',
107
+ # )
108
+ #
109
+ # # Configure the second series. (Sample 2)
110
+ # chart.add_series(
111
+ # :name => 'Sample 2',
112
+ # :categories => '=Sheet1!$A$2:$A$7',
113
+ # :values => '=Sheet1!$C$2:$C$7',
114
+ # )
115
+ #
116
+ # # Add a chart title and some axis labels.
117
+ # chart.set_title (:name => 'Results of sample analysis')
118
+ # chart.set_x_axis(:name => 'Test number')
119
+ # chart.set_y_axis(:name => 'Sample length (cm)')
120
+ #
121
+ # # Insert the chart into the worksheet (with an offset).
122
+ # worksheet.insert_chart('D2', chart, 25, 10)
123
+ #
124
+ # workbook.close
125
+ #
126
+ class Column < Chart
127
+ ###############################################################################
128
+ #
129
+ # new()
130
+ #
131
+ #
132
+ def initialize(*args) # :nodoc:
133
+ super(*args)
134
+ end
135
+
136
+ ###############################################################################
137
+ #
138
+ # _store_chart_type()
139
+ #
140
+ # Implementation of the abstract method from the specific chart class.
141
+ #
142
+ # Write the BAR chart BIFF record. Defines a bar or column chart type.
143
+ #
144
+ def store_chart_type # :nodoc:
145
+ record = 0x1017 # Record identifier.
146
+ length = 0x0006 # Number of bytes to follow.
147
+ pcOverlap = 0x0000 # Space between bars.
148
+ pcGap = 0x0096 # Space between cats.
149
+ grbit = 0x0000 # Option flags.
150
+
151
+ store_simple(record, length, pcOverlap, pcGap, grbit)
152
+ end
153
+ end
154
+ end # class Chart
155
+
156
+ end # module Writeexcel