writeexcel 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -33,22 +33,24 @@ require 'writeexcel/colors'
33
33
  # sub-classes.
34
34
  #
35
35
  #
36
- # Spreadsheet::WriteExcel::BIFFwriter
36
+ # BIFFwriter
37
37
  # ^
38
38
  # |
39
- # Spreadsheet::WriteExcel::Worksheet
39
+ # Writeexcel::Worksheet
40
40
  # ^
41
41
  # |
42
- # Spreadsheet::WriteExcel::Chart
42
+ # Writeexcel::Chart
43
43
  # ^
44
44
  # |
45
- # Spreadsheet::WriteExcel::Chart::* (sub-types)
45
+ # Writeexcel::Chart::* (sub-types)
46
46
  #
47
47
 
48
48
  #
49
49
  # = Chart
50
50
  # Chart - A writer class for Excel Charts.
51
51
  #
52
+ module Writeexcel
53
+
52
54
  class Chart < Worksheet
53
55
  require 'writeexcel/helper'
54
56
  private :convert_to_ascii_if_ascii
@@ -59,7 +61,25 @@ class Chart < Worksheet
59
61
  #
60
62
  # Factory method for returning chart objects based on their class type.
61
63
  #
62
- def self.factory(klass, *args) #:nodoc:
64
+ def self.factory(type, *args) #:nodoc:
65
+ klass =
66
+ case type
67
+ when 'Chart::Column'
68
+ Chart::Column
69
+ when 'Chart::Bar'
70
+ Chart::Bar
71
+ when 'Chart::Line'
72
+ Chart::Line
73
+ when 'Chart::Area'
74
+ Chart::Area
75
+ when 'Chart::Pie'
76
+ Chart::Pie
77
+ when 'Chart::Scatter'
78
+ Chart::Scatter
79
+ when 'Chart::Stock'
80
+ Chart::Stock
81
+ end
82
+
63
83
  klass.new(*args)
64
84
  end
65
85
 
@@ -1072,24 +1092,7 @@ class Chart < Worksheet
1072
1092
  # Write the FRAME chart substream.
1073
1093
  #
1074
1094
  def store_plotarea_frame_stream # :nodoc:
1075
- area = @plotarea
1076
-
1077
- store_frame(0x00, 0x03)
1078
- store_begin
1079
-
1080
- store_lineformat(
1081
- area[:line_color_rgb], area[:line_pattern],
1082
- area[:line_weight], area[:line_options],
1083
- area[:line_color_index]
1084
- )
1085
-
1086
- store_areaformat(
1087
- area[:fg_color_rgb], area[:bg_color_rgb],
1088
- area[:area_pattern], area[:area_options],
1089
- area[:fg_color_index], area[:bg_color_index]
1090
- )
1091
-
1092
- store_end
1095
+ store_area_frame_stream_common(:plot)
1093
1096
  end
1094
1097
 
1095
1098
  ###############################################################################
@@ -1099,9 +1102,19 @@ class Chart < Worksheet
1099
1102
  # Write the FRAME chart substream for and embedded chart.
1100
1103
  #
1101
1104
  def store_chartarea_frame_stream # :nodoc:
1102
- area = @chartarea
1105
+ store_area_frame_stream_common(:chart)
1106
+ end
1107
+
1108
+ def store_area_frame_stream_common(type)
1109
+ if type == :plot
1110
+ area = @plotarea
1111
+ grbit = 0x03
1112
+ else
1113
+ area = @chartarea
1114
+ grbit = 0x02
1115
+ end
1103
1116
 
1104
- store_frame(0x00, 0x02)
1117
+ store_frame(0x00, grbit)
1105
1118
  store_begin
1106
1119
 
1107
1120
  store_lineformat(
@@ -1118,6 +1131,7 @@ class Chart < Worksheet
1118
1131
 
1119
1132
  store_end
1120
1133
  end
1134
+ private :store_area_frame_stream_common
1121
1135
 
1122
1136
  ###############################################################################
1123
1137
  #
@@ -1290,18 +1304,8 @@ class Chart < Worksheet
1290
1304
  catCrossDate = 0x0000 # Crossing point.
1291
1305
  grbit = 0x00EF # Option flags.
1292
1306
 
1293
- header = [record, length].pack('vv')
1294
- data = [catMin].pack('v')
1295
- data += [catMax].pack('v')
1296
- data += [catMajor].pack('v')
1297
- data += [unitMajor].pack('v')
1298
- data += [catMinor].pack('v')
1299
- data += [unitMinor].pack('v')
1300
- data += [unitBase].pack('v')
1301
- data += [catCrossDate].pack('v')
1302
- data += [grbit].pack('v')
1303
-
1304
- append(header, data)
1307
+ store_simple(record, length, catMin, catMax, catMajor, unitMajor,
1308
+ catMinor, unitMinor, unitBase, catCrossDate, grbit)
1305
1309
  end
1306
1310
 
1307
1311
  ###############################################################################
@@ -1315,10 +1319,7 @@ class Chart < Worksheet
1315
1319
  length = 0x0002 # Number of bytes to follow.
1316
1320
  # num_axes # Number of axes used.
1317
1321
 
1318
- header = [record, length].pack('vv')
1319
- data = [num_axes].pack('v')
1320
-
1321
- append(header, data)
1322
+ store_simple(record, length, num_axes)
1322
1323
  end
1323
1324
 
1324
1325
  ###############################################################################
@@ -1357,10 +1358,7 @@ class Chart < Worksheet
1357
1358
  length = 0x0002 # Number of bytes to follow.
1358
1359
  line_format = 0x0001 # Axis line format.
1359
1360
 
1360
- header = [record, length].pack('vv')
1361
- data = [line_format].pack('v')
1362
-
1363
- append(header, data)
1361
+ store_simple(record, length, line_format)
1364
1362
  end
1365
1363
 
1366
1364
  ###############################################################################
@@ -1398,9 +1396,7 @@ class Chart < Worksheet
1398
1396
  record = 0x1033 # Record identifier.
1399
1397
  length = 0x0000 # Number of bytes to follow.
1400
1398
 
1401
- header = [record, length].pack('vv')
1402
-
1403
- append(header)
1399
+ store_simple(record, length)
1404
1400
  end
1405
1401
 
1406
1402
  ###############################################################################
@@ -1417,13 +1413,7 @@ class Chart < Worksheet
1417
1413
  catMark = 0x0001 # Frequency of ticks.
1418
1414
  grbit = 0x0001 # Option flags.
1419
1415
 
1420
- header = [record, length].pack('vv')
1421
- data = [catCross].pack('v')
1422
- data += [catLabel].pack('v')
1423
- data += [catMark].pack('v')
1424
- data += [grbit].pack('v')
1425
-
1426
- append(header, data)
1416
+ store_simple(record, length, catCross, catLabel, catMark, grbit)
1427
1417
  end
1428
1418
 
1429
1419
  ###############################################################################
@@ -1490,10 +1480,7 @@ class Chart < Worksheet
1490
1480
  length = 0x0002 # Number of bytes to follow.
1491
1481
  type = 0x0001 # Drop/hi-lo line type.
1492
1482
 
1493
- header = [record, length].pack('vv')
1494
- data = [type].pack('v')
1495
-
1496
- append(header, data)
1483
+ store_simple(record, length, type)
1497
1484
  end
1498
1485
 
1499
1486
  ###############################################################################
@@ -1550,13 +1537,7 @@ class Chart < Worksheet
1550
1537
  # point_number # Point number.
1551
1538
  grbit = 0x0000 # Format flags.
1552
1539
 
1553
- header = [record, length].pack('vv')
1554
- data = [point_number].pack('v')
1555
- data += [series_index].pack('v')
1556
- data += [series_number].pack('v')
1557
- data += [grbit].pack('v')
1558
-
1559
- append(header, data)
1540
+ store_simple(record, length, point_number, series_index, series_number, grbit)
1560
1541
  end
1561
1542
 
1562
1543
  ###############################################################################
@@ -1571,10 +1552,7 @@ class Chart < Worksheet
1571
1552
  length = 0x0002 # Number of bytes to follow.
1572
1553
  type = 0x0002 # Type.
1573
1554
 
1574
- header = [record, length].pack('vv')
1575
- data = [type].pack('v')
1576
-
1577
- append(header, data)
1555
+ store_simple(record, length, type)
1578
1556
  end
1579
1557
 
1580
1558
  ###############################################################################
@@ -1588,10 +1566,7 @@ class Chart < Worksheet
1588
1566
  length = 0x0002 # Number of bytes to follow.
1589
1567
  percent_gap = 0x0096 # Drop bar width gap (%).
1590
1568
 
1591
- header = [record, length].pack('vv')
1592
- data = [percent_gap].pack('v')
1593
-
1594
- append(header, data)
1569
+ store_simple(record, length, percent_gap)
1595
1570
  end
1596
1571
 
1597
1572
  ###############################################################################
@@ -1604,9 +1579,7 @@ class Chart < Worksheet
1604
1579
  record = 0x1034 # Record identifier.
1605
1580
  length = 0x0000 # Number of bytes to follow.
1606
1581
 
1607
- header = [record, length].pack('vv')
1608
-
1609
- append(header)
1582
+ store_simple(record, length)
1610
1583
  end
1611
1584
 
1612
1585
  ###############################################################################
@@ -1624,14 +1597,7 @@ class Chart < Worksheet
1624
1597
  # height_basis # Height basis, in twips.
1625
1598
  # scale_basis # Scale by chart area or plot area.
1626
1599
 
1627
- header = [record, length].pack('vv')
1628
- data = [width_basis].pack('v')
1629
- data += [height_basis].pack('v')
1630
- data += [height].pack('v')
1631
- data += [scale_basis].pack('v')
1632
- data += [index].pack('v')
1633
-
1634
- append(header, data)
1600
+ store_simple(record, length, width_basis, height_basis, height, scale_basis, index)
1635
1601
  end
1636
1602
 
1637
1603
  ###############################################################################
@@ -1646,10 +1612,7 @@ class Chart < Worksheet
1646
1612
  length = 0x0002 # Number of bytes to follow.
1647
1613
  # index # Font index.
1648
1614
 
1649
- header = [record, length].pack('vv')
1650
- data = [index].pack('v')
1651
-
1652
- append(header, data)
1615
+ store_simple(record, length, index)
1653
1616
  end
1654
1617
 
1655
1618
  ###############################################################################
@@ -1664,11 +1627,7 @@ class Chart < Worksheet
1664
1627
  # frame_type # Frame type.
1665
1628
  # grbit # Option flags.
1666
1629
 
1667
- header = [record, length].pack('vv')
1668
- data = [frame_type].pack('v')
1669
- data += [grbit].pack('v')
1670
-
1671
- append(header, data)
1630
+ store_simple(record, length, frame_type, grbit)
1672
1631
  end
1673
1632
 
1674
1633
  ###############################################################################
@@ -1767,12 +1726,7 @@ class Chart < Worksheet
1767
1726
  link_index1 = 0x0000 # Link index 1.
1768
1727
  link_index2 = 0x0000 # Link index 2.
1769
1728
 
1770
- header = [record, length].pack('vv')
1771
- data = [link_type].pack('v')
1772
- data += [link_index1].pack('v')
1773
- data += [link_index2].pack('v')
1774
-
1775
- append(header, data)
1729
+ store_simple(record, length, link_type, link_index1, link_index2)
1776
1730
  end
1777
1731
 
1778
1732
  ###############################################################################
@@ -1786,10 +1740,7 @@ class Chart < Worksheet
1786
1740
  length = 0x0002 # Number of bytes to follow.
1787
1741
  percent = 0x0000 # Distance % from center.
1788
1742
 
1789
- header = [record, length].pack('vv')
1790
- data = [percent].pack('v')
1791
-
1792
- append(header, data)
1743
+ store_simple(record, length, percent)
1793
1744
  end
1794
1745
 
1795
1746
  ###############################################################################
@@ -1803,9 +1754,7 @@ class Chart < Worksheet
1803
1754
  record = 0x1035 # Record identifier.
1804
1755
  length = 0x0000 # Number of bytes to follow.
1805
1756
 
1806
- header = [record, length].pack('vv')
1807
-
1808
- append(header)
1757
+ store_simple(record, length)
1809
1758
  end
1810
1759
 
1811
1760
  ###############################################################################
@@ -1906,15 +1855,8 @@ class Chart < Worksheet
1906
1855
  bubble_type = 0x0001 # Type: bubble.
1907
1856
  bubble_count = 0x0000 # Num of bubble values.
1908
1857
 
1909
- header = [record, length].pack('vv')
1910
- data = [category_type].pack('v')
1911
- data += [value_type].pack('v')
1912
- data += [category_count].pack('v')
1913
- data += [value_count].pack('v')
1914
- data += [bubble_type].pack('v')
1915
- data += [bubble_count].pack('v')
1916
-
1917
- append(header, data)
1858
+ store_simple(record, length, category_type, value_type,
1859
+ category_count, value_count, bubble_type, bubble_count)
1918
1860
  end
1919
1861
 
1920
1862
  ###############################################################################
@@ -1962,10 +1904,7 @@ class Chart < Worksheet
1962
1904
  length = 0x0002 # Number of bytes to follow.
1963
1905
  # series # Series parent.
1964
1906
 
1965
- header = [record, length].pack('vv')
1966
- data = [series].pack('v')
1967
-
1968
- append(header, data)
1907
+ store_simple(record, length, series)
1969
1908
  end
1970
1909
 
1971
1910
  ###############################################################################
@@ -1979,10 +1918,7 @@ class Chart < Worksheet
1979
1918
  length = 0x0002 # Number of bytes to follow.
1980
1919
  chartgroup = 0x0000 # Chart group index.
1981
1920
 
1982
- header = [record, length].pack('vv')
1983
- data = [chartgroup].pack('v')
1984
-
1985
- append(header, data)
1921
+ store_simple(record, length, chartgroup)
1986
1922
  end
1987
1923
 
1988
1924
  ###############################################################################
@@ -1999,11 +1935,7 @@ class Chart < Worksheet
1999
1935
 
2000
1936
  grbit = 0x000A if @embedded
2001
1937
 
2002
- header = [record, length].pack('vv')
2003
- data = [grbit].pack('v')
2004
- data += [empty_cells].pack('v')
2005
-
2006
- append(header, data)
1938
+ store_simple(record, length, grbit, empty_cells)
2007
1939
  end
2008
1940
 
2009
1941
  ###############################################################################
@@ -2171,8 +2103,11 @@ class Chart < Worksheet
2171
2103
  # Setup the default configuration data for a chart.
2172
2104
  #
2173
2105
  def set_default_config_data # :nodoc:
2174
- #<<< Perltidy ignore this.
2175
- @config = {
2106
+ @config = default_config_data
2107
+ end
2108
+
2109
+ def default_config_data # :nodoc:
2110
+ {
2176
2111
  :axisparent => [ 0, 0x00F8, 0x01F5, 0x0E7F, 0x0B36 ],
2177
2112
  :axisparent_pos => [ 2, 2, 0x008C, 0x01AA, 0x0EEA, 0x0C52 ],
2178
2113
  :chart => [ 0x0000, 0x0000, 0x02DD51E0, 0x01C2B838 ],
@@ -2192,8 +2127,9 @@ class Chart < Worksheet
2192
2127
  :x_axis_text_pos => [ 2, 2, 0, 0, 0x2B, 0x17 ],
2193
2128
  :y_axis_text => [ 0x002D, 0x06AA, 0x5F, 0x1CC, 0x0281, 0x00, 90 ],
2194
2129
  :y_axis_text_pos => [ 2, 2, 0, 0, 0x17, 0x44 ],
2195
- } #>>>
2130
+ }
2196
2131
  end
2132
+ private :default_config_data
2197
2133
 
2198
2134
  ###############################################################################
2199
2135
  #
@@ -2219,8 +2155,7 @@ class Chart < Worksheet
2219
2155
  :line_options => 0x0009,
2220
2156
  }
2221
2157
 
2222
- #<<< Perltidy ignore this.
2223
- @config = {
2158
+ @config = default_config_data.merge({
2224
2159
  :axisparent => [ 0, 0x01D8, 0x031D, 0x0D79, 0x07E9 ],
2225
2160
  :axisparent_pos => [ 2, 2, 0x010C, 0x0292, 0x0E46, 0x09FD ],
2226
2161
  :chart => [ 0x0000, 0x0000, 0x01847FE8, 0x00F47FE8 ],
@@ -2231,15 +2166,12 @@ class Chart < Worksheet
2231
2166
  :legend => [ 0x044E, 0x0E4A, 0x088D, 0x0123, 0x0, 0x1, 0xF ],
2232
2167
  :legend_pos => [ 5, 2, 0x044E, 0x0E4A, 0, 0 ],
2233
2168
  :legend_text => [ 0xFFFFFFD9, 0xFFFFFFC1, 0, 0, 0x00B1, 0x0000 ],
2234
- :legend_text_pos => [ 2, 2, 0, 0, 0, 0 ],
2235
2169
  :series_text => [ 0xFFFFFFD9, 0xFFFFFFC1, 0, 0, 0x00B1, 0x1020 ],
2236
- :series_text_pos => [ 2, 2, 0, 0, 0, 0 ],
2237
2170
  :title_text => [ 0x060F, 0x004C, 0x038A, 0x016F, 0x0081, 0x1030 ],
2238
- :title_text_pos => [ 2, 2, 0, 0, 0x73, 0x1D ],
2239
2171
  :x_axis_text => [ 0x07EF, 0x0C8F, 0x153, 0x123, 0x81, 0x00 ],
2240
- :x_axis_text_pos => [ 2, 2, 0, 0, 0x2B, 0x17 ],
2241
2172
  :y_axis_text => [ 0x0057, 0x0564, 0xB5, 0x035D, 0x0281, 0x00, 90 ],
2242
- :y_axis_text_pos => [ 2, 2, 0, 0, 0x17, 0x44 ],
2243
- } #>>>
2173
+ })
2244
2174
  end
2245
- end
2175
+ end # class Chart
2176
+
2177
+ end # module Writeexcel
@@ -15,6 +15,8 @@
15
15
 
16
16
  require 'writeexcel'
17
17
 
18
+ module Writeexcel
19
+
18
20
  class Chart
19
21
 
20
22
  #
@@ -29,7 +31,7 @@ class Chart
29
31
  # workbook = WriteExcel.new('chart.xls')
30
32
  # worksheet = workbook.add_worksheet
31
33
  #
32
- # chart = workbook.add_chart(:type => Chart::Area)
34
+ # chart = workbook.add_chart(:type => 'Chart::Area')
33
35
  #
34
36
  # # Configure the chart.
35
37
  # chart.add_series(
@@ -52,7 +54,7 @@ class Chart
52
54
  # This module implements Area charts for WriteExcel. The chart object is
53
55
  # created via the Workbook add_chart method:
54
56
  #
55
- # chart = workbook.add_chart(:type => Chart::Area)
57
+ # chart = workbook.add_chart(:type => 'Chart::Area')
56
58
  #
57
59
  # Once the object is created it can be configured via the following methods
58
60
  # that are common to all chart classes:
@@ -95,7 +97,7 @@ class Chart
95
97
  # worksheet.write('A2', data)
96
98
  #
97
99
  # # Create a new chart object. In this case an embedded chart.
98
- # chart = workbook.add_chart(:type => Chart::Area, :embedded => 1)
100
+ # chart = workbook.add_chart(:type => 'Chart::Area', :embedded => 1)
99
101
  #
100
102
  # # Configure the first series. (Sample 1)
101
103
  # chart.add_series(
@@ -144,10 +146,9 @@ class Chart
144
146
  length = 0x0002 # Number of bytes to follow.
145
147
  grbit = 0x0001 # Option flags.
146
148
 
147
- header = [record, length].pack('vv')
148
- data = [grbit].pack('v')
149
-
150
- append(header, data)
149
+ store_simple(record, length, grbit)
151
150
  end
152
151
  end
153
- end
152
+ end # class Chart
153
+
154
+ end # module Writeexcel
@@ -15,6 +15,8 @@
15
15
 
16
16
  require 'writeexcel/chart'
17
17
 
18
+ module Writeexcel
19
+
18
20
  class Chart
19
21
 
20
22
  #
@@ -29,7 +31,7 @@ class Chart
29
31
  # workbook = WriteExcel.new('chart.xls')
30
32
  # worksheet = workbook.add_worksheet
31
33
  #
32
- # chart = workbook.add_chart(:type => Chart::Bar)
34
+ # chart = workbook.add_chart(:type => 'Chart::Bar')
33
35
  #
34
36
  # # Configure the chart.
35
37
  # chart.add_series(
@@ -52,7 +54,7 @@ class Chart
52
54
  # This module implements Bar charts for WriteExcel. The chart object is
53
55
  # created via the Workbook add_chart method:
54
56
  #
55
- # chart = workbook.add_chart(:type => Chart::Bar)
57
+ # chart = workbook.add_chart(:type => 'Chart::Bar')
56
58
  #
57
59
  # Once the object is created it can be configured via the following methods
58
60
  # that are common to all chart classes:
@@ -95,7 +97,7 @@ class Chart
95
97
  # worksheet.write('A2', data)
96
98
  #
97
99
  # # Create a new chart object. In this case an embedded chart.
98
- # chart = workbook.add_chart(:type => Chart::Bar, :embedded => 1)
100
+ # chart = workbook.add_chart(:type => 'Chart::Bar', :embedded => 1)
99
101
  #
100
102
  # # Configure the first series. (Sample 1)
101
103
  # chart.add_series(
@@ -150,12 +152,7 @@ class Chart
150
152
  pcGap = 0x0096 # Space between cats.
151
153
  grbit = 0x0001 # Option flags.
152
154
 
153
- header = [record, length].pack('vv')
154
- data = [pcOverlap].pack('v')
155
- data += [pcGap].pack('v')
156
- data += [grbit].pack('v')
157
-
158
- append(header, data)
155
+ store_simple(record, length, pcOverlap, pcGap, grbit)
159
156
  end
160
157
 
161
158
  ###############################################################################
@@ -175,4 +172,6 @@ class Chart
175
172
  @config[:y_axis_text_pos] = [ 2, 2, 0, 0, 0x45, 0x17 ]
176
173
  end
177
174
  end
178
- end
175
+ end # class Chart
176
+
177
+ end # module Writeexcel
@@ -15,6 +15,8 @@
15
15
 
16
16
  require 'writeexcel/chart'
17
17
 
18
+ module Writeexcel
19
+
18
20
  class Chart
19
21
 
20
22
  #
@@ -29,7 +31,7 @@ class Chart
29
31
  # workbook = WriteExcel.new('chart.xls')
30
32
  # worksheet = workbook.add_worksheet
31
33
  #
32
- # chart = workbook.add_chart(:type => Chart::Column)
34
+ # chart = workbook.add_chart(:type => 'Chart::Column')
33
35
  #
34
36
  # # Configure the chart.
35
37
  # chart.add_series(
@@ -52,7 +54,7 @@ class Chart
52
54
  # This module implements Column charts for WriteExcel. The chart object is
53
55
  # created via the Workbook add_chart method:
54
56
  #
55
- # chart = workbook.add_chart(:type => Chart::Column)
57
+ # chart = workbook.add_chart(:type => 'Chart::Column')
56
58
  #
57
59
  # Once the object is created it can be configured via the following methods
58
60
  # that are common to all chart classes:
@@ -95,7 +97,7 @@ class Chart
95
97
  # worksheet.write('A2', data)
96
98
  #
97
99
  # # Create a new chart object. In this case an embedded chart.
98
- # chart = workbook.add_chart(:type => Chart::Column, :embedded => 1)
100
+ # chart = workbook.add_chart(:type => 'Chart::Column', :embedded => 1)
99
101
  #
100
102
  # # Configure the first series. (Sample 1)
101
103
  # chart.add_series(
@@ -146,12 +148,9 @@ class Chart
146
148
  pcGap = 0x0096 # Space between cats.
147
149
  grbit = 0x0000 # Option flags.
148
150
 
149
- header = [record, length].pack('vv')
150
- data = [pcOverlap].pack('v')
151
- data += [pcGap].pack('v')
152
- data += [grbit].pack('v')
153
-
154
- append(header, data)
151
+ store_simple(record, length, pcOverlap, pcGap, grbit)
155
152
  end
156
153
  end
157
- end
154
+ end # class Chart
155
+
156
+ end # module Writeexcel
@@ -15,6 +15,8 @@
15
15
 
16
16
  require 'writeexcel/chart'
17
17
 
18
+ module Writeexcel
19
+
18
20
  class External < Chart # :nodoc:
19
21
  ###############################################################################
20
22
  #
@@ -59,4 +61,6 @@ class External < Chart # :nodoc:
59
61
  def close
60
62
  nil
61
63
  end
62
- end
64
+ end # class Chart
65
+
66
+ end # module Writeexcel
@@ -15,6 +15,8 @@
15
15
 
16
16
  require 'writeexcel/chart'
17
17
 
18
+ module Writeexcel
19
+
18
20
  class Chart
19
21
 
20
22
  #
@@ -29,7 +31,7 @@ class Chart
29
31
  # workbook = WriteExcel.new('chart.xls')
30
32
  # worksheet = workbook.add_worksheet
31
33
  #
32
- # chart = workbook.add_chart(:type => Chart::Line)
34
+ # chart = workbook.add_chart(:type => 'Chart::Line')
33
35
  #
34
36
  # # Configure the chart.
35
37
  # chart.add_series(
@@ -52,7 +54,7 @@ class Chart
52
54
  # This module implements Line charts for WriteExcel. The chart object is
53
55
  # created via the Workbook add_chart method:
54
56
  #
55
- # chart = workbook.add_chart(:type => Chart::Line)
57
+ # chart = workbook.add_chart(:type => 'Chart::Line')
56
58
  #
57
59
  # Once the object is created it can be configured via the following methods
58
60
  # that are common to all chart classes:
@@ -95,7 +97,7 @@ class Chart
95
97
  # worksheet.write('A2', data)
96
98
  #
97
99
  # # Create a new chart object. In this case an embedded chart.
98
- # chart = workbook.add_chart(:type => Chart::Line, :embedded => 1)
100
+ # chart = workbook.add_chart(:type => 'Chart::Line', :embedded => 1)
99
101
  #
100
102
  # # Configure the first series. (Sample 1)
101
103
  # chart.add_series(
@@ -144,10 +146,9 @@ class Chart
144
146
  length = 0x0002 # Number of bytes to follow.
145
147
  grbit = 0x0000 # Option flags.
146
148
 
147
- header = [record, length].pack('vv')
148
- data = [grbit].pack('v')
149
-
150
- append(header, data)
149
+ store_simple(record, length, grbit)
151
150
  end
152
151
  end
153
- end
152
+ end # class Chart
153
+
154
+ end # module Writeexcel