writeexcel 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +7 -0
- data/VERSION +1 -1
- data/examples/chart_area.rb +5 -5
- data/examples/chart_bar.rb +5 -5
- data/examples/chart_column.rb +5 -5
- data/examples/chart_line.rb +5 -5
- data/examples/chart_pie.rb +5 -5
- data/examples/chart_scatter.rb +5 -5
- data/examples/chart_stock.rb +2 -2
- data/lib/writeexcel/biffwriter.rb +1 -1
- data/lib/writeexcel/chart.rb +73 -141
- data/lib/writeexcel/charts/area.rb +9 -8
- data/lib/writeexcel/charts/bar.rb +9 -10
- data/lib/writeexcel/charts/column.rb +9 -10
- data/lib/writeexcel/charts/external.rb +5 -1
- data/lib/writeexcel/charts/line.rb +9 -8
- data/lib/writeexcel/charts/pie.rb +9 -10
- data/lib/writeexcel/charts/scatter.rb +9 -10
- data/lib/writeexcel/charts/stock.rb +9 -8
- data/lib/writeexcel/colors.rb +6 -1
- data/lib/writeexcel/compatibility.rb +1 -9
- data/lib/writeexcel/format.rb +6 -1
- data/lib/writeexcel/formula.rb +6 -12
- data/lib/writeexcel/helper.rb +22 -0
- data/lib/writeexcel/storage_lite.rb +15 -18
- data/lib/writeexcel/workbook.rb +21 -21
- data/lib/writeexcel/worksheet.rb +16 -36
- data/lib/writeexcel.rb +9 -11
- data/test/test_60_chart_generic.rb +1 -1
- data/test/test_61_chart_subclasses.rb +7 -7
- data/test/test_62_chart_formats.rb +2 -2
- data/test/test_63_chart_area_formats.rb +2 -2
- data/test/test_example_match.rb +21 -21
- data/test/test_format.rb +51 -51
- data/test/test_formula.rb +1 -1
- data/test/test_worksheet.rb +1 -1
- data/writeexcel.gemspec +2 -2
- data/writeexcel.rdoc +599 -2
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -4,6 +4,13 @@ Write to a cross-platform Excel binary file.
|
|
4
4
|
|
5
5
|
== Recent Changes
|
6
6
|
|
7
|
+
v0.4.2
|
8
|
+
* use namespace 'Writeexcel::' to Chart(::*), Colors, Format, Formula, Worksheet.
|
9
|
+
* add_chart() parameter of :type changed . ex) Chart::Bar => 'Chart::Bar'
|
10
|
+
* almost complete japanese document : writeexcel.doc
|
11
|
+
* Bug fix. typo in Worksheet#set_zoom()
|
12
|
+
* some refactoring.
|
13
|
+
|
7
14
|
v0.4.1
|
8
15
|
* Bug fix. Workbook#add_format() doesn't work when received two or more parameters.
|
9
16
|
* Bug fix. Worksheet#write_formula() doesn't work when formula contains utf8 string.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.2
|
data/examples/chart_area.rb
CHANGED
@@ -34,7 +34,7 @@ worksheet.write('A2', data)
|
|
34
34
|
#
|
35
35
|
# Example 1. A minimal chart.
|
36
36
|
#
|
37
|
-
chart1 = workbook.add_chart(:type => Chart::Area)
|
37
|
+
chart1 = workbook.add_chart(:type => 'Chart::Area')
|
38
38
|
|
39
39
|
# Add values only. Use the default categories.
|
40
40
|
chart1.add_series( :values => '=Sheet1!$B$2:$B$7' )
|
@@ -44,7 +44,7 @@ chart1.add_series( :values => '=Sheet1!$B$2:$B$7' )
|
|
44
44
|
# Example 2. A minimal chart with user specified categories (X axis)
|
45
45
|
# and a series name.
|
46
46
|
#
|
47
|
-
chart2 = workbook.add_chart(:type => Chart::Area)
|
47
|
+
chart2 = workbook.add_chart(:type => 'Chart::Area')
|
48
48
|
|
49
49
|
# Configure the series.
|
50
50
|
chart2.add_series(
|
@@ -57,7 +57,7 @@ chart2.add_series(
|
|
57
57
|
#
|
58
58
|
# Example 3. Same as previous chart but with added title and axes labels.
|
59
59
|
#
|
60
|
-
chart3 = workbook.add_chart(:type => Chart::Area)
|
60
|
+
chart3 = workbook.add_chart(:type => 'Chart::Area')
|
61
61
|
|
62
62
|
# Configure the series.
|
63
63
|
chart3.add_series(
|
@@ -75,7 +75,7 @@ chart3.set_y_axis( :name => 'Sample length (cm)' )
|
|
75
75
|
#
|
76
76
|
# Example 4. Same as previous chart but with an added series
|
77
77
|
#
|
78
|
-
chart4 = workbook.add_chart(:name => 'Results Chart', :type => Chart::Area)
|
78
|
+
chart4 = workbook.add_chart(:name => 'Results Chart', :type => 'Chart::Area')
|
79
79
|
|
80
80
|
# Configure the series.
|
81
81
|
chart4.add_series(
|
@@ -100,7 +100,7 @@ chart4.set_y_axis( :name => 'Sample length (cm)' )
|
|
100
100
|
#
|
101
101
|
# Example 5. Same as Example 3 but as an embedded chart.
|
102
102
|
#
|
103
|
-
chart5 = workbook.add_chart(:type => Chart::Area, :embedded => 1)
|
103
|
+
chart5 = workbook.add_chart(:type => 'Chart::Area', :embedded => 1)
|
104
104
|
|
105
105
|
# Configure the series.
|
106
106
|
chart5.add_series(
|
data/examples/chart_bar.rb
CHANGED
@@ -33,7 +33,7 @@ worksheet.write('A2', data)
|
|
33
33
|
#
|
34
34
|
# Example 1. A minimal chart.
|
35
35
|
#
|
36
|
-
chart1 = workbook.add_chart(:type => Chart::Bar)
|
36
|
+
chart1 = workbook.add_chart(:type => 'Chart::Bar')
|
37
37
|
|
38
38
|
# Add values only. Use the default categories.
|
39
39
|
chart1.add_series( :values => '=Sheet1!$B$2:$B$7' )
|
@@ -43,7 +43,7 @@ chart1.add_series( :values => '=Sheet1!$B$2:$B$7' )
|
|
43
43
|
# Example 2. A minimal chart with user specified categories (X axis)
|
44
44
|
# and a series name.
|
45
45
|
#
|
46
|
-
chart2 = workbook.add_chart(:type => Chart::Bar)
|
46
|
+
chart2 = workbook.add_chart(:type => 'Chart::Bar')
|
47
47
|
|
48
48
|
# Configure the series.
|
49
49
|
chart2.add_series(
|
@@ -56,7 +56,7 @@ chart2.add_series(
|
|
56
56
|
#
|
57
57
|
# Example 3. Same as previous chart but with added title and axes labels.
|
58
58
|
#
|
59
|
-
chart3 = workbook.add_chart(:type => Chart::Bar)
|
59
|
+
chart3 = workbook.add_chart(:type => 'Chart::Bar')
|
60
60
|
|
61
61
|
# Configure the series.
|
62
62
|
chart3.add_series(
|
@@ -74,7 +74,7 @@ chart3.set_y_axis( :name => 'Sample length (cm)' )
|
|
74
74
|
#
|
75
75
|
# Example 4. Same as previous chart but with an added series
|
76
76
|
#
|
77
|
-
chart4 = workbook.add_chart(:name => 'Results Chart', :type => Chart::Bar)
|
77
|
+
chart4 = workbook.add_chart(:name => 'Results Chart', :type => 'Chart::Bar')
|
78
78
|
|
79
79
|
# Configure the series.
|
80
80
|
chart4.add_series(
|
@@ -99,7 +99,7 @@ chart4.set_y_axis( :name => 'Sample length (cm)' )
|
|
99
99
|
#
|
100
100
|
# Example 5. Same as Example 3 but as an embedded chart.
|
101
101
|
#
|
102
|
-
chart5 = workbook.add_chart(:type => Chart::Bar, :embedded => 1)
|
102
|
+
chart5 = workbook.add_chart(:type => 'Chart::Bar', :embedded => 1)
|
103
103
|
|
104
104
|
# Configure the series.
|
105
105
|
chart5.add_series(
|
data/examples/chart_column.rb
CHANGED
@@ -33,7 +33,7 @@ worksheet.write('A2', data)
|
|
33
33
|
#
|
34
34
|
# Example 1. A minimal chart.
|
35
35
|
#
|
36
|
-
chart1 = workbook.add_chart(:type => Chart::Column)
|
36
|
+
chart1 = workbook.add_chart(:type => 'Chart::Column')
|
37
37
|
|
38
38
|
# Add values only. Use the default categories.
|
39
39
|
chart1.add_series( :values => '=Sheet1!$B$2:$B$7' )
|
@@ -43,7 +43,7 @@ chart1.add_series( :values => '=Sheet1!$B$2:$B$7' )
|
|
43
43
|
# Example 2. A minimal chart with user specified categories (X axis)
|
44
44
|
# and a series name.
|
45
45
|
#
|
46
|
-
chart2 = workbook.add_chart(:type => Chart::Column)
|
46
|
+
chart2 = workbook.add_chart(:type => 'Chart::Column')
|
47
47
|
|
48
48
|
# Configure the series.
|
49
49
|
chart2.add_series(
|
@@ -56,7 +56,7 @@ chart2.add_series(
|
|
56
56
|
#
|
57
57
|
# Example 3. Same as previous chart but with added title and axes labels.
|
58
58
|
#
|
59
|
-
chart3 = workbook.add_chart(:type => Chart::Column)
|
59
|
+
chart3 = workbook.add_chart(:type => 'Chart::Column')
|
60
60
|
|
61
61
|
# Configure the series.
|
62
62
|
chart3.add_series(
|
@@ -74,7 +74,7 @@ chart3.set_y_axis( :name => 'Sample length (cm)' )
|
|
74
74
|
#
|
75
75
|
# Example 4. Same as previous chart but with an added series
|
76
76
|
#
|
77
|
-
chart4 = workbook.add_chart(:name => 'Results Chart', :type => Chart::Column)
|
77
|
+
chart4 = workbook.add_chart(:name => 'Results Chart', :type => 'Chart::Column')
|
78
78
|
|
79
79
|
# Configure the series.
|
80
80
|
chart4.add_series(
|
@@ -99,7 +99,7 @@ chart4.set_y_axis( :name => 'Sample length (cm)' )
|
|
99
99
|
#
|
100
100
|
# Example 5. Same as Example 3 but as an embedded chart.
|
101
101
|
#
|
102
|
-
chart5 = workbook.add_chart(:type => Chart::Column, :embedded => 1)
|
102
|
+
chart5 = workbook.add_chart(:type => 'Chart::Column', :embedded => 1)
|
103
103
|
|
104
104
|
# Configure the series.
|
105
105
|
chart5.add_series(
|
data/examples/chart_line.rb
CHANGED
@@ -33,7 +33,7 @@ worksheet.write('A2', data)
|
|
33
33
|
#
|
34
34
|
# Example 1. A minimal chart.
|
35
35
|
#
|
36
|
-
chart1 = workbook.add_chart(:type => Chart::Line)
|
36
|
+
chart1 = workbook.add_chart(:type => 'Chart::Line')
|
37
37
|
|
38
38
|
# Add values only. Use the default categories.
|
39
39
|
chart1.add_series( :values => '=Sheet1!$B$2:$B$7' )
|
@@ -43,7 +43,7 @@ chart1.add_series( :values => '=Sheet1!$B$2:$B$7' )
|
|
43
43
|
# Example 2. A minimal chart with user specified categories (X axis)
|
44
44
|
# and a series name.
|
45
45
|
#
|
46
|
-
chart2 = workbook.add_chart(:type => Chart::Line)
|
46
|
+
chart2 = workbook.add_chart(:type => 'Chart::Line')
|
47
47
|
|
48
48
|
# Configure the series.
|
49
49
|
chart2.add_series(
|
@@ -56,7 +56,7 @@ chart2.add_series(
|
|
56
56
|
#
|
57
57
|
# Example 3. Same as previous chart but with added title and axes labels.
|
58
58
|
#
|
59
|
-
chart3 = workbook.add_chart(:type => Chart::Line)
|
59
|
+
chart3 = workbook.add_chart(:type => 'Chart::Line')
|
60
60
|
|
61
61
|
# Configure the series.
|
62
62
|
chart3.add_series(
|
@@ -74,7 +74,7 @@ chart3.set_y_axis( :name => 'Sample length (cm)' )
|
|
74
74
|
#
|
75
75
|
# Example 4. Same as previous chart but with an added series
|
76
76
|
#
|
77
|
-
chart4 = workbook.add_chart(:name => 'Results Chart', :type => Chart::Line)
|
77
|
+
chart4 = workbook.add_chart(:name => 'Results Chart', :type => 'Chart::Line')
|
78
78
|
|
79
79
|
# Configure the series.
|
80
80
|
chart4.add_series(
|
@@ -99,7 +99,7 @@ chart4.set_y_axis( :name => 'Sample length (cm)' )
|
|
99
99
|
#
|
100
100
|
# Example 5. Same as Example 3 but as an embedded chart.
|
101
101
|
#
|
102
|
-
chart5 = workbook.add_chart(:type => Chart::Line, :embedded => 1)
|
102
|
+
chart5 = workbook.add_chart(:type => 'Chart::Line', :embedded => 1)
|
103
103
|
|
104
104
|
# Configure the series.
|
105
105
|
chart5.add_series(
|
data/examples/chart_pie.rb
CHANGED
@@ -32,7 +32,7 @@ worksheet.write('A2', data)
|
|
32
32
|
#
|
33
33
|
# Example 1. A minimal chart.
|
34
34
|
#
|
35
|
-
chart1 = workbook.add_chart(:type => Chart::Pie)
|
35
|
+
chart1 = workbook.add_chart(:type => 'Chart::Pie')
|
36
36
|
|
37
37
|
# Add values only. Use the default categories.
|
38
38
|
chart1.add_series(:values => '=Sheet1!$B$2:$B$4')
|
@@ -41,7 +41,7 @@ chart1.add_series(:values => '=Sheet1!$B$2:$B$4')
|
|
41
41
|
#
|
42
42
|
# Example 2. A minimal chart with user specified categories and a series name.
|
43
43
|
#
|
44
|
-
chart2 = workbook.add_chart(:type => Chart::Pie)
|
44
|
+
chart2 = workbook.add_chart(:type => 'Chart::Pie')
|
45
45
|
|
46
46
|
# Configure the series.
|
47
47
|
chart2.add_series(
|
@@ -54,7 +54,7 @@ chart2.add_series(
|
|
54
54
|
#
|
55
55
|
# Example 3. Same as previous chart but with an added title.
|
56
56
|
#
|
57
|
-
chart3 = workbook.add_chart(:type => Chart::Pie)
|
57
|
+
chart3 = workbook.add_chart(:type => 'Chart::Pie')
|
58
58
|
|
59
59
|
# Configure the series.
|
60
60
|
chart3.add_series(
|
@@ -70,7 +70,7 @@ chart3.set_title(:name => 'Popular Pie Types')
|
|
70
70
|
#
|
71
71
|
# Example 4. Same as previous chart with a user specified chart sheet name.
|
72
72
|
#
|
73
|
-
chart4 = workbook.add_chart(:name => 'Results Chart', :type => Chart::Pie)
|
73
|
+
chart4 = workbook.add_chart(:name => 'Results Chart', :type => 'Chart::Pie')
|
74
74
|
|
75
75
|
# Configure the series.
|
76
76
|
chart4.add_series(
|
@@ -89,7 +89,7 @@ chart4.set_title(:name => 'Popular Pie Types')
|
|
89
89
|
#
|
90
90
|
# Example 5. Same as Example 3 but as an embedded chart.
|
91
91
|
#
|
92
|
-
chart5 = workbook.add_chart(:type => Chart::Pie, :embedded => 1)
|
92
|
+
chart5 = workbook.add_chart(:type => 'Chart::Pie', :embedded => 1)
|
93
93
|
|
94
94
|
# Configure the series.
|
95
95
|
chart5.add_series(
|
data/examples/chart_scatter.rb
CHANGED
@@ -33,7 +33,7 @@ worksheet.write('A2', data)
|
|
33
33
|
#
|
34
34
|
# Example 1. A minimal chart.
|
35
35
|
#
|
36
|
-
chart1 = workbook.add_chart(:type => Chart::Scatter)
|
36
|
+
chart1 = workbook.add_chart(:type => 'Chart::Scatter')
|
37
37
|
|
38
38
|
# Add values only. Use the default categories.
|
39
39
|
chart1.add_series(:values => '=Sheet1!$B$2:$B$7')
|
@@ -43,7 +43,7 @@ chart1.add_series(:values => '=Sheet1!$B$2:$B$7')
|
|
43
43
|
# Example 2. A minimal chart with user specified categories (X axis)
|
44
44
|
# and a series name.
|
45
45
|
#
|
46
|
-
chart2 = workbook.add_chart(:type => Chart::Scatter)
|
46
|
+
chart2 = workbook.add_chart(:type => 'Chart::Scatter')
|
47
47
|
|
48
48
|
# Configure the series.
|
49
49
|
chart2.add_series(
|
@@ -56,7 +56,7 @@ chart2.add_series(
|
|
56
56
|
#
|
57
57
|
# Example 3. Same as previous chart but with added title and axes labels.
|
58
58
|
#
|
59
|
-
chart3 = workbook.add_chart(:type => Chart::Scatter)
|
59
|
+
chart3 = workbook.add_chart(:type => 'Chart::Scatter')
|
60
60
|
|
61
61
|
# Configure the series.
|
62
62
|
chart3.add_series(
|
@@ -75,7 +75,7 @@ chart3.set_y_axis(:name => 'Sample length (cm)')
|
|
75
75
|
# Example 4. Same as previous chart but with an added series and with a
|
76
76
|
# user specified chart sheet name.
|
77
77
|
#
|
78
|
-
chart4 = workbook.add_chart(:name => 'Results Chart', :type => Chart::Scatter)
|
78
|
+
chart4 = workbook.add_chart(:name => 'Results Chart', :type => 'Chart::Scatter')
|
79
79
|
|
80
80
|
# Configure the series.
|
81
81
|
chart4.add_series(
|
@@ -100,7 +100,7 @@ chart4.set_y_axis(:name => 'Sample length (cm)')
|
|
100
100
|
#
|
101
101
|
# Example 5. Same as Example 3 but as an embedded chart.
|
102
102
|
#
|
103
|
-
chart5 = workbook.add_chart(:type => Chart::Scatter, :embedded => 1)
|
103
|
+
chart5 = workbook.add_chart(:type => 'Chart::Scatter', :embedded => 1)
|
104
104
|
|
105
105
|
# Configure the series.
|
106
106
|
chart5.add_series(
|
data/examples/chart_stock.rb
CHANGED
@@ -68,7 +68,7 @@ end
|
|
68
68
|
# and a title.
|
69
69
|
#
|
70
70
|
|
71
|
-
chart1 = workbook.add_chart(:type => Chart::Stock)
|
71
|
+
chart1 = workbook.add_chart(:type => 'Chart::Stock')
|
72
72
|
|
73
73
|
# Add a series for each of the Open-High-Low-Close columns. The categories are
|
74
74
|
# the dates in the first column.
|
@@ -107,7 +107,7 @@ chart1.set_y_axis(:name => 'Share price')
|
|
107
107
|
# Example 2. Same as the previous as an embedded chart.
|
108
108
|
#
|
109
109
|
|
110
|
-
chart2 = workbook.add_chart(:type => Chart::Stock, :embedded => 1)
|
110
|
+
chart2 = workbook.add_chart(:type => 'Chart::Stock', :embedded => 1)
|
111
111
|
|
112
112
|
# Add a series for each of the Open-High-Low-Close columns. The categories are
|
113
113
|
# the dates in the first column.
|
@@ -208,7 +208,7 @@ class BIFFWriter < WriteFile #:nodoc:
|
|
208
208
|
# Returns the packed record.
|
209
209
|
#
|
210
210
|
def add_mso_generic(type, version, instance, data, length = nil)
|
211
|
-
length
|
211
|
+
length ||= data.bytesize
|
212
212
|
|
213
213
|
# The header contains version and instance info packed into 2 bytes.
|
214
214
|
header = version | (instance << 4)
|