writeexcel 0.3.5 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/.gitattributes +1 -0
  2. data/README.rdoc +12 -6
  3. data/VERSION +1 -1
  4. data/charts/chartex.rb +316 -315
  5. data/charts/demo1.rb +1 -0
  6. data/charts/demo2.rb +1 -0
  7. data/charts/demo3.rb +117 -116
  8. data/charts/demo4.rb +119 -118
  9. data/charts/demo5.rb +48 -47
  10. data/examples/a_simple.rb +1 -0
  11. data/examples/autofilter.rb +1 -0
  12. data/examples/bigfile.rb +30 -29
  13. data/examples/chart_area.rb +121 -120
  14. data/examples/chart_bar.rb +120 -119
  15. data/examples/chart_column.rb +120 -119
  16. data/examples/chart_line.rb +120 -119
  17. data/examples/chart_pie.rb +108 -107
  18. data/examples/chart_scatter.rb +121 -120
  19. data/examples/chart_stock.rb +148 -147
  20. data/examples/chess.rb +1 -0
  21. data/examples/colors.rb +1 -0
  22. data/examples/comments1.rb +1 -0
  23. data/examples/comments2.rb +3 -2
  24. data/examples/copyformat.rb +1 -0
  25. data/examples/data_validate.rb +1 -0
  26. data/examples/date_time.rb +1 -0
  27. data/examples/defined_name.rb +1 -0
  28. data/examples/demo.rb +1 -0
  29. data/examples/diag_border.rb +1 -0
  30. data/examples/formats.rb +1 -0
  31. data/examples/formula_result.rb +1 -0
  32. data/examples/header.rb +1 -0
  33. data/examples/hide_sheet.rb +1 -0
  34. data/examples/hyperlink.rb +1 -0
  35. data/examples/images.rb +1 -0
  36. data/examples/indent.rb +1 -0
  37. data/examples/merge1.rb +1 -0
  38. data/examples/merge2.rb +1 -0
  39. data/examples/merge3.rb +1 -0
  40. data/examples/merge4.rb +1 -0
  41. data/examples/merge5.rb +1 -0
  42. data/examples/merge6.rb +67 -66
  43. data/examples/outline.rb +1 -0
  44. data/examples/outline_collapsed.rb +1 -0
  45. data/examples/panes.rb +1 -0
  46. data/examples/properties.rb +1 -0
  47. data/examples/properties_jp.rb +1 -0
  48. data/examples/protection.rb +1 -0
  49. data/examples/regions.rb +1 -0
  50. data/examples/repeat.rb +1 -0
  51. data/examples/right_to_left.rb +1 -0
  52. data/examples/row_wrap.rb +1 -0
  53. data/examples/stats.rb +1 -0
  54. data/examples/stocks.rb +1 -0
  55. data/examples/tab_colors.rb +1 -0
  56. data/examples/write_arrays.rb +1 -0
  57. data/lib/writeexcel.rb +6 -1
  58. data/lib/writeexcel/biffwriter.rb +21 -20
  59. data/lib/writeexcel/chart.rb +25 -12
  60. data/lib/writeexcel/charts/area.rb +153 -152
  61. data/lib/writeexcel/charts/bar.rb +178 -177
  62. data/lib/writeexcel/charts/column.rb +157 -156
  63. data/lib/writeexcel/charts/external.rb +62 -61
  64. data/lib/writeexcel/charts/line.rb +153 -152
  65. data/lib/writeexcel/charts/pie.rb +170 -169
  66. data/lib/writeexcel/charts/scatter.rb +4 -3
  67. data/lib/writeexcel/charts/stock.rb +212 -211
  68. data/lib/writeexcel/compatibility.rb +320 -0
  69. data/lib/writeexcel/excelformulaparser.rb +587 -586
  70. data/lib/writeexcel/format.rb +12 -13
  71. data/lib/writeexcel/formula.rb +30 -28
  72. data/lib/writeexcel/helper.rb +23 -0
  73. data/lib/writeexcel/olewriter.rb +5 -16
  74. data/lib/writeexcel/properties.rb +43 -54
  75. data/lib/writeexcel/storage_lite.rb +981 -968
  76. data/lib/writeexcel/workbook.rb +94 -73
  77. data/lib/writeexcel/worksheet.rb +230 -210
  78. data/test/helper.rb +19 -0
  79. data/test/test_00_IEEE_double.rb +1 -0
  80. data/test/test_01_add_worksheet.rb +1 -0
  81. data/test/test_02_merge_formats.rb +3 -5
  82. data/test/test_04_dimensions.rb +3 -5
  83. data/test/test_05_rows.rb +6 -6
  84. data/test/test_06_extsst.rb +8 -8
  85. data/test/test_11_date_time.rb +3 -5
  86. data/test/test_12_date_only.rb +3 -5
  87. data/test/test_13_date_seconds.rb +4 -6
  88. data/test/test_21_escher.rb +3 -5
  89. data/test/test_22_mso_drawing_group.rb +20 -22
  90. data/test/test_23_note.rb +5 -7
  91. data/test/test_24_txo.rb +3 -5
  92. data/test/test_25_position_object.rb +84 -79
  93. data/test/test_26_autofilter.rb +3 -13
  94. data/test/test_27_autofilter.rb +3 -13
  95. data/test/test_28_autofilter.rb +3 -13
  96. data/test/test_29_process_jpg.rb +5 -0
  97. data/test/test_30_validation_dval.rb +3 -5
  98. data/test/test_31_validation_dv_strings.rb +3 -5
  99. data/test/test_32_validation_dv_formula.rb +3 -5
  100. data/test/test_40_property_types.rb +10 -9
  101. data/test/test_41_properties.rb +1 -0
  102. data/test/test_42_set_properties.rb +14 -15
  103. data/test/test_50_name_stored.rb +299 -302
  104. data/test/test_51_name_print_area.rb +357 -360
  105. data/test/test_52_name_print_titles.rb +454 -457
  106. data/test/test_53_autofilter.rb +203 -206
  107. data/test/test_60_chart_generic.rb +5 -0
  108. data/test/test_61_chart_subclasses.rb +95 -94
  109. data/test/test_62_chart_formats.rb +272 -267
  110. data/test/test_63_chart_area_formats.rb +649 -644
  111. data/test/test_biff.rb +12 -38
  112. data/test/test_compatibility.rb +627 -0
  113. data/test/test_example_match.rb +3 -18
  114. data/test/test_format.rb +46 -105
  115. data/test/test_formula.rb +1 -0
  116. data/test/test_ole.rb +3 -4
  117. data/test/test_storage_lite.rb +125 -146
  118. data/test/test_workbook.rb +2 -23
  119. data/test/test_worksheet.rb +4 -5
  120. data/utils/add_magic_comment.rb +80 -0
  121. data/writeexcel.gemspec +8 -2
  122. metadata +10 -4
@@ -1,107 +1,108 @@
1
- #!/usr/bin/ruby -w
2
- #
3
- ###############################################################################
4
- #
5
- # A simple demo of Pie chart in Spreadsheet::WriteExcel.
6
- #
7
- # reverse('ゥ'), December 2009, John McNamara, jmcnamara@cpan.org
8
- #
9
- # original written in Perl by John McNamara
10
- # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
11
- #
12
- require 'writeexcel'
13
-
14
- # Create a new workbook called simple.xls and add a worksheet
15
- workbook = WriteExcel.new('chart_pie.xls')
16
- worksheet = workbook.add_worksheet
17
- bold = workbook.add_format(:bold => 1)
18
-
19
- # Add the worksheet data that the charts will refer to.
20
- headings = ['Category', 'Values']
21
- data = [
22
- [ 'Apple', 'Cherry', 'Pecan' ],
23
- [ 60, 30, 10 ]
24
- ]
25
-
26
- worksheet.write('A1', headings, bold)
27
- worksheet.write('A2', data)
28
-
29
-
30
- ###############################################################################
31
- #
32
- # Example 1. A minimal chart.
33
- #
34
- chart1 = workbook.add_chart(:type => Chart::Pie)
35
-
36
- # Add values only. Use the default categories.
37
- chart1.add_series(:values => '=Sheet1!$B$2:$B$4')
38
-
39
- ###############################################################################
40
- #
41
- # Example 2. A minimal chart with user specified categories and a series name.
42
- #
43
- chart2 = workbook.add_chart(:type => Chart::Pie)
44
-
45
- # Configure the series.
46
- chart2.add_series(
47
- :categories => '=Sheet1!$A$2:$A$4',
48
- :values => '=Sheet1!$B$2:$B$4',
49
- :name => 'Pie sales data'
50
- )
51
-
52
- ###############################################################################
53
- #
54
- # Example 3. Same as previous chart but with an added title.
55
- #
56
- chart3 = workbook.add_chart(:type => Chart::Pie)
57
-
58
- # Configure the series.
59
- chart3.add_series(
60
- :categories => '=Sheet1!$A$2:$A$4',
61
- :values => '=Sheet1!$B$2:$B$4',
62
- :name => 'Pie sales data'
63
- )
64
-
65
- # Add a title.
66
- chart3.set_title(:name => 'Popular Pie Types')
67
-
68
- ###############################################################################
69
- #
70
- # Example 4. Same as previous chart with a user specified chart sheet name.
71
- #
72
- chart4 = workbook.add_chart(:name => 'Results Chart', :type => Chart::Pie)
73
-
74
- # Configure the series.
75
- chart4.add_series(
76
- :categories => '=Sheet1!$A$2:$A$4',
77
- :values => '=Sheet1!$B$2:$B$4',
78
- :name => 'Pie sales data'
79
- )
80
-
81
- # The other chart_*.rb examples add a second series in example 4 but additional
82
- # series aren't plotted in a pie chart.
83
-
84
- # Add a title.
85
- chart4.set_title(:name => 'Popular Pie Types')
86
-
87
- ###############################################################################
88
- #
89
- # Example 5. Same as Example 3 but as an embedded chart.
90
- #
91
- chart5 = workbook.add_chart(:type => Chart::Pie, :embedded => 1)
92
-
93
- # Configure the series.
94
- chart5.add_series(
95
- :categories => '=Sheet1!$A$2:$A$4',
96
- :values => '=Sheet1!$B$2:$B$4',
97
- :name => 'Pie sales data'
98
- )
99
-
100
- # Add a title.
101
- chart5.set_title(:name => 'Popular Pie Types')
102
-
103
- # Insert the chart into the main worksheet.
104
- worksheet.insert_chart('D2', chart5)
105
-
106
- # File save
107
- workbook.close
1
+ #!/usr/bin/ruby -w
2
+ # -*- coding: utf-8 -*-
3
+ #
4
+ ###############################################################################
5
+ #
6
+ # A simple demo of Pie chart in Spreadsheet::WriteExcel.
7
+ #
8
+ # reverse('ゥ'), December 2009, John McNamara, jmcnamara@cpan.org
9
+ #
10
+ # original written in Perl by John McNamara
11
+ # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
12
+ #
13
+ require 'writeexcel'
14
+
15
+ # Create a new workbook called simple.xls and add a worksheet
16
+ workbook = WriteExcel.new('chart_pie.xls')
17
+ worksheet = workbook.add_worksheet
18
+ bold = workbook.add_format(:bold => 1)
19
+
20
+ # Add the worksheet data that the charts will refer to.
21
+ headings = ['Category', 'Values']
22
+ data = [
23
+ [ 'Apple', 'Cherry', 'Pecan' ],
24
+ [ 60, 30, 10 ]
25
+ ]
26
+
27
+ worksheet.write('A1', headings, bold)
28
+ worksheet.write('A2', data)
29
+
30
+
31
+ ###############################################################################
32
+ #
33
+ # Example 1. A minimal chart.
34
+ #
35
+ chart1 = workbook.add_chart(:type => Chart::Pie)
36
+
37
+ # Add values only. Use the default categories.
38
+ chart1.add_series(:values => '=Sheet1!$B$2:$B$4')
39
+
40
+ ###############################################################################
41
+ #
42
+ # Example 2. A minimal chart with user specified categories and a series name.
43
+ #
44
+ chart2 = workbook.add_chart(:type => Chart::Pie)
45
+
46
+ # Configure the series.
47
+ chart2.add_series(
48
+ :categories => '=Sheet1!$A$2:$A$4',
49
+ :values => '=Sheet1!$B$2:$B$4',
50
+ :name => 'Pie sales data'
51
+ )
52
+
53
+ ###############################################################################
54
+ #
55
+ # Example 3. Same as previous chart but with an added title.
56
+ #
57
+ chart3 = workbook.add_chart(:type => Chart::Pie)
58
+
59
+ # Configure the series.
60
+ chart3.add_series(
61
+ :categories => '=Sheet1!$A$2:$A$4',
62
+ :values => '=Sheet1!$B$2:$B$4',
63
+ :name => 'Pie sales data'
64
+ )
65
+
66
+ # Add a title.
67
+ chart3.set_title(:name => 'Popular Pie Types')
68
+
69
+ ###############################################################################
70
+ #
71
+ # Example 4. Same as previous chart with a user specified chart sheet name.
72
+ #
73
+ chart4 = workbook.add_chart(:name => 'Results Chart', :type => Chart::Pie)
74
+
75
+ # Configure the series.
76
+ chart4.add_series(
77
+ :categories => '=Sheet1!$A$2:$A$4',
78
+ :values => '=Sheet1!$B$2:$B$4',
79
+ :name => 'Pie sales data'
80
+ )
81
+
82
+ # The other chart_*.rb examples add a second series in example 4 but additional
83
+ # series aren't plotted in a pie chart.
84
+
85
+ # Add a title.
86
+ chart4.set_title(:name => 'Popular Pie Types')
87
+
88
+ ###############################################################################
89
+ #
90
+ # Example 5. Same as Example 3 but as an embedded chart.
91
+ #
92
+ chart5 = workbook.add_chart(:type => Chart::Pie, :embedded => 1)
93
+
94
+ # Configure the series.
95
+ chart5.add_series(
96
+ :categories => '=Sheet1!$A$2:$A$4',
97
+ :values => '=Sheet1!$B$2:$B$4',
98
+ :name => 'Pie sales data'
99
+ )
100
+
101
+ # Add a title.
102
+ chart5.set_title(:name => 'Popular Pie Types')
103
+
104
+ # Insert the chart into the main worksheet.
105
+ worksheet.insert_chart('D2', chart5)
106
+
107
+ # File save
108
+ workbook.close
@@ -1,120 +1,121 @@
1
- #!/usr/bin/ruby -w
2
- #
3
- ###############################################################################
4
- #
5
- # A simple demo of Scatter charts in Spreadsheet::WriteExcel.
6
- #
7
- # reverse('ゥ'), December 2009, John McNamara, jmcnamara@cpan.org
8
- #
9
- # original written in Perl by John McNamara
10
- # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
11
- #
12
- require 'writeexcel'
13
-
14
- # Create a new workbook called simple.xls and add a worksheet
15
- workbook = WriteExcel.new('chart_scatter.xls')
16
- worksheet = workbook.add_worksheet
17
- bold = workbook.add_format(:bold => 1)
18
-
19
- # Add the worksheet data that the charts will refer to.
20
- headings = ['Category', 'Values 1', 'Values 2']
21
- data = [
22
- [ 2, 3, 4, 5, 6, 7 ],
23
- [ 1, 4, 5, 2, 1, 5 ],
24
- [ 3, 6, 7, 5, 4, 3 ]
25
- ]
26
-
27
- worksheet.write('A1', headings, bold)
28
- worksheet.write('A2', data)
29
-
30
-
31
- ###############################################################################
32
- #
33
- # Example 1. A minimal chart.
34
- #
35
- chart1 = workbook.add_chart(:type => Chart::Scatter)
36
-
37
- # Add values only. Use the default categories.
38
- chart1.add_series(:values => '=Sheet1!$B$2:$B$7')
39
-
40
- ###############################################################################
41
- #
42
- # Example 2. A minimal chart with user specified categories (X axis)
43
- # and a series name.
44
- #
45
- chart2 = workbook.add_chart(:type => Chart::Scatter)
46
-
47
- # Configure the series.
48
- chart2.add_series(
49
- :categories => '=Sheet1!$A$2:$A$7',
50
- :values => '=Sheet1!$B$2:$B$7',
51
- :name => 'Test data series 1'
52
- )
53
-
54
- ###############################################################################
55
- #
56
- # Example 3. Same as previous chart but with added title and axes labels.
57
- #
58
- chart3 = workbook.add_chart(:type => Chart::Scatter)
59
-
60
- # Configure the series.
61
- chart3.add_series(
62
- :categories => '=Sheet1!$A$2:$A$7',
63
- :values => '=Sheet1!$B$2:$B$7',
64
- :name => 'Test data series 1'
65
- )
66
-
67
- # Add some labels.
68
- chart3.set_title(:name => 'Results of sample analysis')
69
- chart3.set_x_axis(:name => 'Sample number')
70
- chart3.set_y_axis(:name => 'Sample length (cm)')
71
-
72
- ###############################################################################
73
- #
74
- # Example 4. Same as previous chart but with an added series and with a
75
- # user specified chart sheet name.
76
- #
77
- chart4 = workbook.add_chart(:name => 'Results Chart', :type => Chart::Scatter)
78
-
79
- # Configure the series.
80
- chart4.add_series(
81
- :categories => '=Sheet1!$A$2:$A$7',
82
- :values => '=Sheet1!$B$2:$B$7',
83
- :name => 'Test data series 1'
84
- )
85
-
86
- # Add another series.
87
- chart4.add_series(
88
- :categories => '=Sheet1!$A$2:$A$7',
89
- :values => '=Sheet1!$C$2:$C$7',
90
- :name => 'Test data series 2'
91
- )
92
-
93
- # Add some labels.
94
- chart4.set_title(:name => 'Results of sample analysis')
95
- chart4.set_x_axis(:name => 'Sample number')
96
- chart4.set_y_axis(:name => 'Sample length (cm)')
97
-
98
- ###############################################################################
99
- #
100
- # Example 5. Same as Example 3 but as an embedded chart.
101
- #
102
- chart5 = workbook.add_chart(:type => Chart::Scatter, :embedded => 1)
103
-
104
- # Configure the series.
105
- chart5.add_series(
106
- :categories => '=Sheet1!$A$2:$A$7',
107
- :values => '=Sheet1!$B$2:$B$7',
108
- :name => 'Test data series 1'
109
- )
110
-
111
- # Add some labels.
112
- chart5.set_title(:name => 'Results of sample analysis')
113
- chart5.set_x_axis(:name => 'Sample number')
114
- chart5.set_y_axis(:name => 'Sample length (cm)')
115
-
116
- # Insert the chart into the main worksheet.
117
- worksheet.insert_chart('E2', chart5)
118
-
119
- # File save
120
- workbook.close
1
+ #!/usr/bin/ruby -w
2
+ # -*- coding: utf-8 -*-
3
+ #
4
+ ###############################################################################
5
+ #
6
+ # A simple demo of Scatter charts in Spreadsheet::WriteExcel.
7
+ #
8
+ # reverse('ゥ'), December 2009, John McNamara, jmcnamara@cpan.org
9
+ #
10
+ # original written in Perl by John McNamara
11
+ # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
12
+ #
13
+ require 'writeexcel'
14
+
15
+ # Create a new workbook called simple.xls and add a worksheet
16
+ workbook = WriteExcel.new('chart_scatter.xls')
17
+ worksheet = workbook.add_worksheet
18
+ bold = workbook.add_format(:bold => 1)
19
+
20
+ # Add the worksheet data that the charts will refer to.
21
+ headings = ['Category', 'Values 1', 'Values 2']
22
+ data = [
23
+ [ 2, 3, 4, 5, 6, 7 ],
24
+ [ 1, 4, 5, 2, 1, 5 ],
25
+ [ 3, 6, 7, 5, 4, 3 ]
26
+ ]
27
+
28
+ worksheet.write('A1', headings, bold)
29
+ worksheet.write('A2', data)
30
+
31
+
32
+ ###############################################################################
33
+ #
34
+ # Example 1. A minimal chart.
35
+ #
36
+ chart1 = workbook.add_chart(:type => Chart::Scatter)
37
+
38
+ # Add values only. Use the default categories.
39
+ chart1.add_series(:values => '=Sheet1!$B$2:$B$7')
40
+
41
+ ###############################################################################
42
+ #
43
+ # Example 2. A minimal chart with user specified categories (X axis)
44
+ # and a series name.
45
+ #
46
+ chart2 = workbook.add_chart(:type => Chart::Scatter)
47
+
48
+ # Configure the series.
49
+ chart2.add_series(
50
+ :categories => '=Sheet1!$A$2:$A$7',
51
+ :values => '=Sheet1!$B$2:$B$7',
52
+ :name => 'Test data series 1'
53
+ )
54
+
55
+ ###############################################################################
56
+ #
57
+ # Example 3. Same as previous chart but with added title and axes labels.
58
+ #
59
+ chart3 = workbook.add_chart(:type => Chart::Scatter)
60
+
61
+ # Configure the series.
62
+ chart3.add_series(
63
+ :categories => '=Sheet1!$A$2:$A$7',
64
+ :values => '=Sheet1!$B$2:$B$7',
65
+ :name => 'Test data series 1'
66
+ )
67
+
68
+ # Add some labels.
69
+ chart3.set_title(:name => 'Results of sample analysis')
70
+ chart3.set_x_axis(:name => 'Sample number')
71
+ chart3.set_y_axis(:name => 'Sample length (cm)')
72
+
73
+ ###############################################################################
74
+ #
75
+ # Example 4. Same as previous chart but with an added series and with a
76
+ # user specified chart sheet name.
77
+ #
78
+ chart4 = workbook.add_chart(:name => 'Results Chart', :type => Chart::Scatter)
79
+
80
+ # Configure the series.
81
+ chart4.add_series(
82
+ :categories => '=Sheet1!$A$2:$A$7',
83
+ :values => '=Sheet1!$B$2:$B$7',
84
+ :name => 'Test data series 1'
85
+ )
86
+
87
+ # Add another series.
88
+ chart4.add_series(
89
+ :categories => '=Sheet1!$A$2:$A$7',
90
+ :values => '=Sheet1!$C$2:$C$7',
91
+ :name => 'Test data series 2'
92
+ )
93
+
94
+ # Add some labels.
95
+ chart4.set_title(:name => 'Results of sample analysis')
96
+ chart4.set_x_axis(:name => 'Sample number')
97
+ chart4.set_y_axis(:name => 'Sample length (cm)')
98
+
99
+ ###############################################################################
100
+ #
101
+ # Example 5. Same as Example 3 but as an embedded chart.
102
+ #
103
+ chart5 = workbook.add_chart(:type => Chart::Scatter, :embedded => 1)
104
+
105
+ # Configure the series.
106
+ chart5.add_series(
107
+ :categories => '=Sheet1!$A$2:$A$7',
108
+ :values => '=Sheet1!$B$2:$B$7',
109
+ :name => 'Test data series 1'
110
+ )
111
+
112
+ # Add some labels.
113
+ chart5.set_title(:name => 'Results of sample analysis')
114
+ chart5.set_x_axis(:name => 'Sample number')
115
+ chart5.set_y_axis(:name => 'Sample length (cm)')
116
+
117
+ # Insert the chart into the main worksheet.
118
+ worksheet.insert_chart('E2', chart5)
119
+
120
+ # File save
121
+ workbook.close