write_xlsx 0.99.0 → 1.07.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +0 -1
- data/Changes +70 -0
- data/README.md +1 -1
- data/examples/a_simple.rb +1 -1
- data/examples/add_vba_project.rb +1 -1
- data/examples/array_formula.rb +1 -1
- data/examples/chart_area.rb +5 -2
- data/examples/chart_bar.rb +5 -2
- data/examples/chart_clustered.rb +1 -1
- data/examples/chart_column.rb +5 -2
- data/examples/chart_combined.rb +1 -1
- data/examples/chart_data_labels.rb +320 -0
- data/examples/chart_data_table.rb +9 -3
- data/examples/chart_data_tools.rb +25 -7
- data/examples/chart_doughnut.rb +17 -5
- data/examples/chart_gauge.rb +73 -0
- data/examples/chart_line.rb +90 -12
- data/examples/chart_pareto.rb +1 -1
- data/examples/chart_pie.rb +9 -3
- data/examples/chart_radar.rb +13 -4
- data/examples/chart_scatter.rb +5 -2
- data/examples/chart_secondary_axis.rb +5 -2
- data/examples/chart_stock.rb +1 -1
- data/examples/chart_styles.rb +1 -1
- data/examples/colors.rb +1 -1
- data/examples/data_validate.rb +1 -1
- data/examples/date_time.rb +1 -1
- data/examples/demo.rb +4 -1
- data/examples/formats.rb +1 -1
- data/examples/headers.rb +1 -1
- data/examples/hide_row_col.rb +1 -1
- data/examples/hide_sheet.rb +1 -1
- data/examples/hyperlink1.rb +1 -1
- data/examples/indent.rb +1 -1
- data/examples/macros.rb +1 -1
- data/examples/merge1.rb +1 -1
- data/examples/merge2.rb +1 -1
- data/examples/merge3.rb +1 -1
- data/examples/merge4.rb +1 -1
- data/examples/merge5.rb +1 -1
- data/examples/merge6.rb +1 -1
- data/examples/outline.rb +1 -1
- data/examples/outline_collapsed.rb +1 -1
- data/examples/panes.rb +1 -1
- data/examples/properties.rb +1 -1
- data/examples/regions.rb +1 -1
- data/examples/rich_strings.rb +1 -1
- data/examples/right_to_left.rb +1 -1
- data/examples/shape1.rb +1 -1
- data/examples/shape2.rb +1 -1
- data/examples/shape3.rb +1 -1
- data/examples/shape4.rb +1 -1
- data/examples/shape5.rb +1 -1
- data/examples/shape6.rb +1 -1
- data/examples/shape7.rb +1 -1
- data/examples/shape8.rb +1 -1
- data/examples/shape_all.rb +1 -1
- data/examples/sparklines1.rb +1 -1
- data/examples/sparklines2.rb +1 -1
- data/examples/stats.rb +1 -1
- data/examples/stats_ext.rb +1 -1
- data/examples/stocks.rb +1 -1
- data/examples/tab_colors.rb +1 -1
- data/examples/tables.rb +78 -43
- data/lib/write_xlsx/chart.rb +163 -34
- data/lib/write_xlsx/chart/area.rb +1 -1
- data/lib/write_xlsx/chart/bar.rb +1 -1
- data/lib/write_xlsx/chart/column.rb +1 -1
- data/lib/write_xlsx/chart/doughnut.rb +1 -1
- data/lib/write_xlsx/chart/line.rb +16 -2
- data/lib/write_xlsx/chart/pie.rb +21 -8
- data/lib/write_xlsx/chart/radar.rb +1 -1
- data/lib/write_xlsx/chart/scatter.rb +1 -1
- data/lib/write_xlsx/chart/series.rb +100 -0
- data/lib/write_xlsx/chart/stock.rb +1 -1
- data/lib/write_xlsx/chartsheet.rb +5 -5
- data/lib/write_xlsx/drawing.rb +86 -30
- data/lib/write_xlsx/format.rb +5 -5
- data/lib/write_xlsx/package/comments.rb +11 -11
- data/lib/write_xlsx/package/relationships.rb +4 -4
- data/lib/write_xlsx/package/styles.rb +26 -8
- data/lib/write_xlsx/package/table.rb +8 -7
- data/lib/write_xlsx/package/vml.rb +20 -19
- data/lib/write_xlsx/shape.rb +4 -3
- data/lib/write_xlsx/sheets.rb +18 -16
- data/lib/write_xlsx/sparkline.rb +1 -1
- data/lib/write_xlsx/utility.rb +40 -7
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/workbook.rb +69 -44
- data/lib/write_xlsx/worksheet.rb +206 -138
- data/lib/write_xlsx/worksheet/hyperlink.rb +16 -37
- data/test/drawing/test_drawing_chart_01.rb +6 -2
- data/test/drawing/test_drawing_image_01.rb +12 -3
- data/test/drawing/test_drawing_shape_01.rb +8 -5
- data/test/drawing/test_drawing_shape_02.rb +12 -5
- data/test/drawing/test_drawing_shape_03.rb +8 -5
- data/test/drawing/test_drawing_shape_04.rb +8 -24
- data/test/drawing/test_drawing_shape_05.rb +8 -5
- data/test/drawing/test_drawing_shape_06.rb +11 -6
- data/test/drawing/test_drawing_shape_07.rb +11 -6
- data/test/drawing/test_write_a_graphic_frame_locks.rb +1 -1
- data/test/drawing/test_write_c_chart.rb +1 -1
- data/test/drawing/test_write_c_nv_graphic_frame_pr.rb +1 -1
- data/test/drawing/test_write_c_nv_pr.rb +1 -1
- data/test/drawing/test_write_col.rb +1 -1
- data/test/drawing/test_write_col_off.rb +1 -1
- data/test/drawing/test_write_ext.rb +1 -1
- data/test/drawing/test_write_pos.rb +1 -1
- data/test/drawing/test_write_row.rb +1 -1
- data/test/drawing/test_write_row_off.rb +1 -1
- data/test/drawing/test_write_xfrm_extension.rb +1 -1
- data/test/drawing/test_write_xfrm_offset.rb +1 -1
- data/test/perl_output/chart_data_labels.xlsx +0 -0
- data/test/perl_output/chart_gauge.xlsx +0 -0
- data/test/perl_output/chart_line.xlsx +0 -0
- data/test/perl_output/comments2.xlsx +0 -0
- data/test/perl_output/tables.xlsx +0 -0
- data/test/regression/images/red2.png +0 -0
- data/test/regression/test_array_formula04.rb +31 -0
- data/test/regression/test_chart_axis26.rb +10 -8
- data/test/regression/test_chart_axis27.rb +1 -1
- data/test/regression/test_chart_axis28.rb +1 -1
- data/test/regression/test_chart_axis29.rb +1 -1
- data/test/regression/test_chart_axis33.rb +1 -1
- data/test/regression/test_chart_axis44.rb +54 -0
- data/test/regression/test_chart_axis45.rb +54 -0
- data/test/regression/test_chart_axis46.rb +54 -0
- data/test/regression/test_chart_combined10.rb +43 -0
- data/test/regression/test_chart_combined11.rb +63 -0
- data/test/regression/test_chart_data_labels25.rb +1 -1
- data/test/regression/test_chart_data_labels26.rb +44 -0
- data/test/regression/test_chart_data_labels27.rb +44 -0
- data/test/regression/test_chart_data_labels28.rb +52 -0
- data/test/regression/test_chart_data_labels29.rb +43 -0
- data/test/regression/test_chart_data_labels30.rb +46 -0
- data/test/regression/test_chart_data_labels31.rb +49 -0
- data/test/regression/test_chart_data_labels32.rb +54 -0
- data/test/regression/test_chart_data_labels33.rb +52 -0
- data/test/regression/test_chart_data_labels34.rb +54 -0
- data/test/regression/test_chart_data_labels35.rb +46 -0
- data/test/regression/test_chart_data_labels36.rb +54 -0
- data/test/regression/test_chart_data_labels37.rb +51 -0
- data/test/regression/test_chart_data_labels38.rb +54 -0
- data/test/regression/test_chart_data_labels39.rb +53 -0
- data/test/regression/test_chart_data_labels40.rb +53 -0
- data/test/regression/test_chart_data_labels41.rb +54 -0
- data/test/regression/test_chart_data_labels42.rb +58 -0
- data/test/regression/test_chart_data_labels43.rb +58 -0
- data/test/regression/test_chart_data_labels44.rb +56 -0
- data/test/regression/test_chart_data_labels45.rb +57 -0
- data/test/regression/test_chart_data_labels46.rb +61 -0
- data/test/regression/test_chart_data_labels47.rb +61 -0
- data/test/regression/test_chart_doughnut07.rb +37 -0
- data/test/regression/test_chart_font09.rb +1 -1
- data/test/regression/test_chart_line05.rb +43 -0
- data/test/regression/test_chart_line06.rb +43 -0
- data/test/regression/test_chart_size03.rb +4 -1
- data/test/regression/test_comment14.rb +29 -0
- data/test/regression/test_comment15.rb +28 -0
- data/test/regression/test_comment16.rb +34 -0
- data/test/regression/test_header_image15.rb +36 -0
- data/test/regression/test_header_image16.rb +42 -0
- data/test/regression/test_header_image17.rb +46 -0
- data/test/regression/test_header_image18.rb +48 -0
- data/test/regression/test_header_image19.rb +36 -0
- data/test/regression/test_hyperlink32.rb +27 -0
- data/test/regression/test_hyperlink33.rb +28 -0
- data/test/regression/test_hyperlink34.rb +33 -0
- data/test/regression/test_hyperlink35.rb +39 -0
- data/test/regression/test_hyperlink36.rb +34 -0
- data/test/regression/test_hyperlink37.rb +33 -0
- data/test/regression/test_hyperlink38.rb +27 -0
- data/test/regression/test_hyperlink39.rb +27 -0
- data/test/regression/test_hyperlink40.rb +27 -0
- data/test/regression/test_hyperlink41.rb +27 -0
- data/test/regression/test_hyperlink42.rb +27 -0
- data/test/regression/test_hyperlink43.rb +27 -0
- data/test/regression/test_hyperlink44.rb +27 -0
- data/test/regression/test_hyperlink45.rb +27 -0
- data/test/regression/test_hyperlink47.rb +27 -0
- data/test/regression/test_hyperlink48.rb +31 -0
- data/test/regression/test_hyperlink49.rb +29 -0
- data/test/regression/test_image06.rb +5 -5
- data/test/regression/test_image08.rb +5 -4
- data/test/regression/test_image15.rb +4 -2
- data/test/regression/test_image28.rb +1 -1
- data/test/regression/test_image44.rb +28 -0
- data/test/regression/test_image45.rb +29 -0
- data/test/regression/test_image46.rb +29 -0
- data/test/regression/test_image47.rb +28 -0
- data/test/regression/test_image48.rb +32 -0
- data/test/regression/test_image49.rb +38 -0
- data/test/regression/test_image50.rb +24 -0
- data/test/regression/test_image51.rb +30 -0
- data/test/regression/test_object_position01.rb +26 -0
- data/test/regression/test_object_position02.rb +26 -0
- data/test/regression/test_object_position03.rb +26 -0
- data/test/regression/test_object_position04.rb +44 -0
- data/test/regression/test_object_position06.rb +28 -0
- data/test/regression/test_object_position07.rb +28 -0
- data/test/regression/test_object_position08.rb +47 -0
- data/test/regression/test_object_position09.rb +50 -0
- data/test/regression/test_object_position10.rb +28 -0
- data/test/regression/test_object_position12.rb +25 -0
- data/test/regression/test_object_position13.rb +25 -0
- data/test/regression/test_object_position14.rb +25 -0
- data/test/regression/test_object_position15.rb +29 -0
- data/test/regression/test_object_position16.rb +29 -0
- data/test/regression/test_object_position17.rb +29 -0
- data/test/regression/test_object_position18.rb +29 -0
- data/test/regression/test_object_position19.rb +29 -0
- data/test/regression/test_object_position20.rb +29 -0
- data/test/regression/test_shape_connect01.rb +4 -2
- data/test/regression/test_table24.rb +27 -0
- data/test/regression/test_table25.rb +27 -0
- data/test/regression/xlsx_files/array_formula04.xlsx +0 -0
- data/test/regression/xlsx_files/chart_axis26.xlsx +0 -0
- data/test/regression/xlsx_files/chart_axis27.xlsx +0 -0
- data/test/regression/xlsx_files/chart_axis28.xlsx +0 -0
- data/test/regression/xlsx_files/chart_axis29.xlsx +0 -0
- data/test/regression/xlsx_files/chart_axis33.xlsx +0 -0
- data/test/regression/xlsx_files/chart_axis44.xlsx +0 -0
- data/test/regression/xlsx_files/chart_axis45.xlsx +0 -0
- data/test/regression/xlsx_files/chart_axis46.xlsx +0 -0
- data/test/regression/xlsx_files/chart_combined10.xlsx +0 -0
- data/test/regression/xlsx_files/chart_combined11.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels25.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels26.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels27.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels28.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels29.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels30.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels31.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels32.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels33.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels34.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels35.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels36.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels37.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels38.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels39.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels40.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels41.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels42.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels43.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels44.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels45.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels46.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels47.xlsx +0 -0
- data/test/regression/xlsx_files/chart_doughnut07.xlsx +0 -0
- data/test/regression/xlsx_files/chart_font09.xlsx +0 -0
- data/test/regression/xlsx_files/chart_line05.xlsx +0 -0
- data/test/regression/xlsx_files/chart_line06.xlsx +0 -0
- data/test/regression/xlsx_files/comment14.xlsx +0 -0
- data/test/regression/xlsx_files/comment15.xlsx +0 -0
- data/test/regression/xlsx_files/comment16.xlsx +0 -0
- data/test/regression/xlsx_files/header_image15.xlsx +0 -0
- data/test/regression/xlsx_files/header_image16.xlsx +0 -0
- data/test/regression/xlsx_files/header_image17.xlsx +0 -0
- data/test/regression/xlsx_files/header_image18.xlsx +0 -0
- data/test/regression/xlsx_files/header_image19.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink32.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink33.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink34.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink35.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink36.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink37.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink38.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink39.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink40.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink41.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink42.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink43.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink44.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink45.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink46.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink47.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink48.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink49.xlsx +0 -0
- data/test/regression/xlsx_files/image06.xlsx +0 -0
- data/test/regression/xlsx_files/image44.xlsx +0 -0
- data/test/regression/xlsx_files/image45.xlsx +0 -0
- data/test/regression/xlsx_files/image46.xlsx +0 -0
- data/test/regression/xlsx_files/image47.xlsx +0 -0
- data/test/regression/xlsx_files/image48.xlsx +0 -0
- data/test/regression/xlsx_files/image49.xlsx +0 -0
- data/test/regression/xlsx_files/image50.xlsx +0 -0
- data/test/regression/xlsx_files/image51.xlsx +0 -0
- data/test/regression/xlsx_files/object_position01.xlsx +0 -0
- data/test/regression/xlsx_files/object_position02.xlsx +0 -0
- data/test/regression/xlsx_files/object_position03.xlsx +0 -0
- data/test/regression/xlsx_files/object_position04.xlsx +0 -0
- data/test/regression/xlsx_files/object_position06.xlsx +0 -0
- data/test/regression/xlsx_files/object_position07.xlsx +0 -0
- data/test/regression/xlsx_files/object_position08.xlsx +0 -0
- data/test/regression/xlsx_files/object_position09.xlsx +0 -0
- data/test/regression/xlsx_files/object_position10.xlsx +0 -0
- data/test/regression/xlsx_files/object_position12.xlsx +0 -0
- data/test/regression/xlsx_files/object_position13.xlsx +0 -0
- data/test/regression/xlsx_files/object_position14.xlsx +0 -0
- data/test/regression/xlsx_files/object_position15.xlsx +0 -0
- data/test/regression/xlsx_files/object_position16.xlsx +0 -0
- data/test/regression/xlsx_files/object_position17.xlsx +0 -0
- data/test/regression/xlsx_files/object_position18.xlsx +0 -0
- data/test/regression/xlsx_files/object_position19.xlsx +0 -0
- data/test/regression/xlsx_files/object_position20.xlsx +0 -0
- data/test/regression/xlsx_files/table24.xlsx +0 -0
- data/test/regression/xlsx_files/table25.xlsx +0 -0
- data/test/test_example_match.rb +1268 -780
- data/test/workbook/test_check_sheetname.rb +51 -0
- data/write_xlsx.gemspec +1 -0
- metadata +367 -5
@@ -7,7 +7,7 @@
|
|
7
7
|
# WriteXLSX.
|
8
8
|
#
|
9
9
|
# reverse ('(c)'), December 2012, John McNamara, jmcnamara@cpan.org
|
10
|
-
# convert to ruby by Hideo NAKAMURA,
|
10
|
+
# convert to ruby by Hideo NAKAMURA, nakamura.hideo@gmail.com
|
11
11
|
#
|
12
12
|
|
13
13
|
require 'write_xlsx'
|
@@ -54,7 +54,10 @@
|
|
54
54
|
chart1.set_table
|
55
55
|
|
56
56
|
# Insert the chart into the worksheet (with an offset).
|
57
|
-
worksheet.insert_chart(
|
57
|
+
worksheet.insert_chart(
|
58
|
+
'D2', chart1,
|
59
|
+
:x_offset => 25, :y_offset => 10
|
60
|
+
)
|
58
61
|
|
59
62
|
#
|
60
63
|
# Create a second charat.
|
@@ -88,6 +91,9 @@
|
|
88
91
|
chart2.set_legend(:position => 'none')
|
89
92
|
|
90
93
|
# Insert the chart into the worksheet (with an offset).
|
91
|
-
worksheet.insert_chart(
|
94
|
+
worksheet.insert_chart(
|
95
|
+
'D18', chart2,
|
96
|
+
:x_offset => 25, :y_offset => 11
|
97
|
+
)
|
92
98
|
|
93
99
|
workbook.close
|
@@ -10,7 +10,7 @@
|
|
10
10
|
# High-Low Lines and Up-Down Bars.
|
11
11
|
#
|
12
12
|
# reverse ('(c)'), December 2012, John McNamara, jmcnamara@cpan.org
|
13
|
-
# convert to ruby by Hideo NAKAMURA,
|
13
|
+
# convert to ruby by Hideo NAKAMURA, nakamura.hideo@gmail.com
|
14
14
|
#
|
15
15
|
|
16
16
|
require 'write_xlsx'
|
@@ -62,7 +62,10 @@
|
|
62
62
|
chart1.set_title(:name => 'Chart with Trendlines')
|
63
63
|
|
64
64
|
# Insert the chart into the worksheet (with an offset).
|
65
|
-
worksheet.insert_chart(
|
65
|
+
worksheet.insert_chart(
|
66
|
+
'D2', chart1,
|
67
|
+
:x_offset => 25, :y_offset => 10
|
68
|
+
)
|
66
69
|
|
67
70
|
|
68
71
|
#######################################################################
|
@@ -91,7 +94,10 @@
|
|
91
94
|
chart2.set_title(:name => 'Chart with Data Labels and Markers')
|
92
95
|
|
93
96
|
# Insert the chart into the worksheet (with an offset).
|
94
|
-
worksheet.insert_chart(
|
97
|
+
worksheet.insert_chart(
|
98
|
+
'D18', chart2,
|
99
|
+
:x_offset => 25, :y_offset => 10
|
100
|
+
)
|
95
101
|
|
96
102
|
|
97
103
|
#######################################################################
|
@@ -119,7 +125,10 @@
|
|
119
125
|
chart3.set_title(:name => 'Chart with Error Bars')
|
120
126
|
|
121
127
|
# Insert the chart into the worksheet (with an offset).
|
122
|
-
worksheet.insert_chart(
|
128
|
+
worksheet.insert_chart(
|
129
|
+
'D34', chart3,
|
130
|
+
:x_offset => 25, :y_offset => 10
|
131
|
+
)
|
123
132
|
|
124
133
|
|
125
134
|
#######################################################################
|
@@ -149,7 +158,10 @@
|
|
149
158
|
chart4.set_title(:name => 'Chart with Up-Down Bars')
|
150
159
|
|
151
160
|
# Insert the chart into the worksheet (with an offset).
|
152
|
-
worksheet.insert_chart(
|
161
|
+
worksheet.insert_chart(
|
162
|
+
'D50', chart4,
|
163
|
+
:x_offset => 25, :y_offset => 10
|
164
|
+
)
|
153
165
|
|
154
166
|
|
155
167
|
#######################################################################
|
@@ -179,7 +191,10 @@
|
|
179
191
|
chart5.set_title(:name => 'Chart with High-Low Lines')
|
180
192
|
|
181
193
|
# Insert the chart into the worksheet (with an offset).
|
182
|
-
worksheet.insert_chart(
|
194
|
+
worksheet.insert_chart(
|
195
|
+
'D66', chart5,
|
196
|
+
:x_offset => 25, :y_offset => 10
|
197
|
+
)
|
183
198
|
|
184
199
|
|
185
200
|
#######################################################################
|
@@ -209,6 +224,9 @@
|
|
209
224
|
chart6.set_title(:name => 'Chart with Drop Lines')
|
210
225
|
|
211
226
|
# Insert the chart into the worksheet (with an offset).
|
212
|
-
worksheet.insert_chart(
|
227
|
+
worksheet.insert_chart(
|
228
|
+
'D82', chart6,
|
229
|
+
:x_offset => 25, :y_offset => 10
|
230
|
+
)
|
213
231
|
|
214
232
|
workbook.close
|
data/examples/chart_doughnut.rb
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
# formatting to each point in the series.
|
13
13
|
#
|
14
14
|
# reverse ('(c)'), March 2011, John McNamara, jmcnamara@cpan.org
|
15
|
-
# convert to ruby by Hideo NAKAMURA,
|
15
|
+
# convert to ruby by Hideo NAKAMURA, nakamura.hideo@gmail.com
|
16
16
|
#
|
17
17
|
|
18
18
|
require 'write_xlsx'
|
@@ -50,7 +50,10 @@
|
|
50
50
|
chart1.set_style(10)
|
51
51
|
|
52
52
|
# Insert the chart into the worksheet (with an offset).
|
53
|
-
worksheet.insert_chart(
|
53
|
+
worksheet.insert_chart(
|
54
|
+
'C2', chart1,
|
55
|
+
:x_offset => 25, :y_offset => 10
|
56
|
+
)
|
54
57
|
|
55
58
|
|
56
59
|
#
|
@@ -77,7 +80,10 @@
|
|
77
80
|
|
78
81
|
|
79
82
|
# Insert the chart into the worksheet (with an offset).
|
80
|
-
worksheet.insert_chart(
|
83
|
+
worksheet.insert_chart(
|
84
|
+
'C18', chart2,
|
85
|
+
:x_offset => 25, :y_offset => 10
|
86
|
+
)
|
81
87
|
|
82
88
|
|
83
89
|
#
|
@@ -101,7 +107,10 @@
|
|
101
107
|
chart3.set_rotation(90)
|
102
108
|
|
103
109
|
# Insert the chart into the worksheet (with an offset).
|
104
|
-
worksheet.insert_chart(
|
110
|
+
worksheet.insert_chart(
|
111
|
+
'C34', chart3,
|
112
|
+
:x_offset => 25, :y_offset => 10
|
113
|
+
)
|
105
114
|
|
106
115
|
|
107
116
|
#
|
@@ -125,6 +134,9 @@
|
|
125
134
|
chart4.set_hole_size(33)
|
126
135
|
|
127
136
|
# Insert the chart into the worksheet (with an offset).
|
128
|
-
worksheet.insert_chart(
|
137
|
+
worksheet.insert_chart(
|
138
|
+
'C50', chart4,
|
139
|
+
:x_offset => 25, :y_offset => 10
|
140
|
+
)
|
129
141
|
|
130
142
|
workbook.close
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# #!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# #######################################################################
|
4
|
+
# #
|
5
|
+
# # A demo of an Gauge Chart in WriteXLSX gem.
|
6
|
+
# #
|
7
|
+
# # A Gauge Chart isn't a native chart type in Excel. It is constructed by
|
8
|
+
# # combining a doughnut chart and a pie chart and by using some non-filled
|
9
|
+
# # elements. This example follows the following online example of how to create
|
10
|
+
# # a Gauge Chart in Excel: https://www.excel-easy.com/examples/gauge-chart.html
|
11
|
+
# #
|
12
|
+
# # reverse ('(c)'), May 2019, John McNamara, jmcnamara@cpan.org
|
13
|
+
# # convert to ruby by Hideo NAKAMURA, nakamura.hideo@gmail.com
|
14
|
+
# #
|
15
|
+
|
16
|
+
require 'write_xlsx'
|
17
|
+
|
18
|
+
workbook = WriteXLSX.new('chart_gauge.xlsx')
|
19
|
+
worksheet = workbook.add_worksheet
|
20
|
+
|
21
|
+
chart_doughnut = workbook.add_chart(:type => 'doughnut', :embedded => 1)
|
22
|
+
chart_pie = workbook.add_chart(:type => 'pie', :embedded => 1)
|
23
|
+
|
24
|
+
# Add some data for the Doughnut and Pie charts. This is set up so the
|
25
|
+
# gauge goes from 0-100. It is initially set at 75%.
|
26
|
+
worksheet.write_col('H2', ['Donut', 25, 50, 25, 100])
|
27
|
+
worksheet.write_col('I2', ['Pie', 75, 1, '=200-I4-I3'])
|
28
|
+
|
29
|
+
# Configure the doughnut chart as the background for the gauge.
|
30
|
+
chart_doughnut.add_series(
|
31
|
+
:name => '=Sheet1!$H$2',
|
32
|
+
:values => '=Sheet1!$H$3:$H$6',
|
33
|
+
:points => [
|
34
|
+
{ :fill => { :color => 'green' } },
|
35
|
+
{ :fill => { :color => 'yellow' } },
|
36
|
+
{ :fill => { :color => 'red' } },
|
37
|
+
{ :fill => { :none => 1 } }
|
38
|
+
]
|
39
|
+
)
|
40
|
+
|
41
|
+
# Rotate chart so the gauge parts are above the horizontal.
|
42
|
+
chart_doughnut.set_rotation(270)
|
43
|
+
|
44
|
+
# Turn off the chart legend.
|
45
|
+
chart_doughnut.set_legend(:none => 1)
|
46
|
+
|
47
|
+
# Turn off the chart fill and border.
|
48
|
+
chart_doughnut.set_chartarea(
|
49
|
+
:border => { :none => 1 },
|
50
|
+
:fill => { :none => 1 }
|
51
|
+
)
|
52
|
+
|
53
|
+
# Configure the pie chart as the needle for the gauge.
|
54
|
+
chart_pie.add_series(
|
55
|
+
:name => '=Sheet1!$I$2',
|
56
|
+
:values => '=Sheet1!$I$3:$I$6',
|
57
|
+
:points => [
|
58
|
+
{ :fill => { :none => 1 } },
|
59
|
+
{ :fill => { :color => 'black' } },
|
60
|
+
{ :fill => { :none => 1 } }
|
61
|
+
]
|
62
|
+
)
|
63
|
+
|
64
|
+
# Rotate the pie chart/needle to align with the doughnut/gauge.
|
65
|
+
chart_pie.set_rotation(270)
|
66
|
+
|
67
|
+
# Combine the pie and doughnut charts.
|
68
|
+
chart_doughnut.combine(chart_pie)
|
69
|
+
|
70
|
+
# Insert the chart into the worksheet.
|
71
|
+
worksheet.insert_chart('A1', chart_doughnut)
|
72
|
+
|
73
|
+
workbook.close
|
data/examples/chart_line.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# A demo of a Line chart in Excel::Writer::XLSX.
|
7
7
|
#
|
8
8
|
# reverse('ゥ'), March 2011, John McNamara, jmcnamara@cpan.org
|
9
|
-
# convert to ruby by Hideo NAKAMURA,
|
9
|
+
# convert to ruby by Hideo NAKAMURA, nakamura.hideo@gmail.com
|
10
10
|
#
|
11
11
|
|
12
12
|
require 'write_xlsx'
|
@@ -18,9 +18,9 @@
|
|
18
18
|
# Add the worksheet data that the charts will refer to.
|
19
19
|
headings = [ 'Number', 'Batch 1', 'Batch 2' ]
|
20
20
|
data = [
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
[ 2, 3, 4, 5, 6, 7 ],
|
22
|
+
[ 10, 40, 50, 20, 10, 50 ],
|
23
|
+
[ 30, 60, 70, 50, 40, 30 ]
|
24
24
|
]
|
25
25
|
|
26
26
|
worksheet.write('A1', headings, bold)
|
@@ -31,21 +31,21 @@
|
|
31
31
|
|
32
32
|
# Configure the first series.
|
33
33
|
chart.add_series(
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
:name => '=Sheet1!$B$1',
|
35
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
36
|
+
:values => '=Sheet1!$B$2:$B$7'
|
37
37
|
)
|
38
38
|
|
39
39
|
# Configure second series. Note alternative use of array ref to define
|
40
40
|
# ranges: [ sheetname, row_start, row_end, col_start, col_end ].
|
41
41
|
chart.add_series(
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
:name => '=Sheet1!$C$1',
|
43
|
+
:categories => [ 'Sheet1', 1, 6, 0, 0 ],
|
44
|
+
:values => [ 'Sheet1', 1, 6, 2, 2 ]
|
45
45
|
)
|
46
46
|
|
47
47
|
# Add a chart title and some axis labels.
|
48
|
-
chart.set_title(:name
|
48
|
+
chart.set_title(:name => 'Results of sample analysis')
|
49
49
|
chart.set_x_axis(:name => 'Test number')
|
50
50
|
chart.set_y_axis(:name => 'Sample length (mm)')
|
51
51
|
|
@@ -53,6 +53,84 @@
|
|
53
53
|
chart.set_style(10)
|
54
54
|
|
55
55
|
# Insert the chart into the worksheet (with an offset).
|
56
|
-
worksheet.insert_chart(
|
56
|
+
worksheet.insert_chart(
|
57
|
+
'D2', chart,
|
58
|
+
:x_offset => 25, :y_offset => 10
|
59
|
+
)
|
60
|
+
|
61
|
+
#
|
62
|
+
# Create a stacked chart sub-type
|
63
|
+
#
|
64
|
+
chart2 = workbook.add_chart(
|
65
|
+
:type => 'line',
|
66
|
+
:embedded => 1,
|
67
|
+
:subtype => 'stacked'
|
68
|
+
)
|
69
|
+
|
70
|
+
# Configure the first series.
|
71
|
+
chart2.add_series(
|
72
|
+
:name => '=Sheet1!$B$1',
|
73
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
74
|
+
:values => '=Sheet1!$B$2:$B$7'
|
75
|
+
)
|
76
|
+
|
77
|
+
# Configure second series.
|
78
|
+
chart2.add_series(
|
79
|
+
:name => '=Sheet1!$C$1',
|
80
|
+
:categories => [ 'Sheet1', 1, 6, 0, 0 ],
|
81
|
+
:values => [ 'Sheet1', 1, 6, 2, 2 ]
|
82
|
+
)
|
83
|
+
|
84
|
+
# Add a chart title and some axis labels.
|
85
|
+
chart2.set_title ( :name => 'Stacked Chart' )
|
86
|
+
chart2.set_x_axis( :name => 'Test number' )
|
87
|
+
chart2.set_y_axis( :name => 'Sample length (mm)' )
|
88
|
+
|
89
|
+
# Set an Excel chart style. Blue colors with white outline and shadow.
|
90
|
+
chart2.set_style( 12 )
|
91
|
+
|
92
|
+
# Insert the chart into the worksheet (with an offset).
|
93
|
+
worksheet.insert_chart(
|
94
|
+
'D18', chart2,
|
95
|
+
{ :x_offset => 25, :y_offset => 10 }
|
96
|
+
)
|
97
|
+
|
98
|
+
|
99
|
+
#
|
100
|
+
# Create a percent stacked chart sub-type
|
101
|
+
#
|
102
|
+
chart3 = workbook.add_chart(
|
103
|
+
:type => 'line',
|
104
|
+
:embedded => 1,
|
105
|
+
:subtype => 'percent_stacked'
|
106
|
+
)
|
107
|
+
|
108
|
+
# Configure the first series.
|
109
|
+
chart3.add_series(
|
110
|
+
:name => '=Sheet1!$B$1',
|
111
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
112
|
+
:values => '=Sheet1!$B$2:$B$7'
|
113
|
+
)
|
114
|
+
|
115
|
+
# Configure second series.
|
116
|
+
chart3.add_series(
|
117
|
+
:name => '=Sheet1!$C$1',
|
118
|
+
:categories => [ 'Sheet1', 1, 6, 0, 0 ],
|
119
|
+
:values => [ 'Sheet1', 1, 6, 2, 2 ]
|
120
|
+
)
|
121
|
+
|
122
|
+
# Add a chart title and some axis labels.
|
123
|
+
chart3.set_title ( :name => 'Percent Stacked Chart' )
|
124
|
+
chart3.set_x_axis( :name => 'Test number' )
|
125
|
+
chart3.set_y_axis( :name => 'Sample length (mm)' )
|
126
|
+
|
127
|
+
# Set an Excel chart style. Blue colors with white outline and shadow.
|
128
|
+
chart3.set_style( 13 )
|
129
|
+
|
130
|
+
# Insert the chart into the worksheet (with an offset).
|
131
|
+
worksheet.insert_chart(
|
132
|
+
'D34', chart3,
|
133
|
+
{ :x_offset => 25, :y_offset => 10 }
|
134
|
+
)
|
57
135
|
|
58
136
|
workbook.close
|
data/examples/chart_pareto.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# A demo of a Pareto chart in Excel::Writer::XLSX.
|
7
7
|
#
|
8
8
|
# reverse ('(c)'), March 2015, John McNamara, jmcnamara@cpan.org
|
9
|
-
# convert to ruby by Hideo NAKAMURA,
|
9
|
+
# convert to ruby by Hideo NAKAMURA, nakamura.hideo@gmail.com
|
10
10
|
#
|
11
11
|
|
12
12
|
require 'write_xlsx'
|
data/examples/chart_pie.rb
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
# assign formatting to each point in the series.
|
13
13
|
#
|
14
14
|
# reverse(c), March 2011, John McNamara, jmcnamara@cpan.org
|
15
|
-
# convert to ruby by Hideo NAKAMURA,
|
15
|
+
# convert to ruby by Hideo NAKAMURA, nakamura.hideo@gmail.com
|
16
16
|
#
|
17
17
|
|
18
18
|
require 'write_xlsx'
|
@@ -50,7 +50,10 @@
|
|
50
50
|
chart1.set_style(10)
|
51
51
|
|
52
52
|
# Insert the chart into the worksheet (with an offset).
|
53
|
-
worksheet.insert_chart(
|
53
|
+
worksheet.insert_chart(
|
54
|
+
'C2', chart1,
|
55
|
+
:x_offset => 25, :y_offset => 10
|
56
|
+
)
|
54
57
|
|
55
58
|
#
|
56
59
|
# Create a Pie chart with user defined segment colors.
|
@@ -74,6 +77,9 @@
|
|
74
77
|
# Add a title.
|
75
78
|
chart2.set_title(:name => 'Pie Chart with user defined colors')
|
76
79
|
|
77
|
-
worksheet.insert_chart(
|
80
|
+
worksheet.insert_chart(
|
81
|
+
'C18', chart2,
|
82
|
+
:x_offset => 25, :y_offset => 10
|
83
|
+
)
|
78
84
|
|
79
85
|
workbook.close
|
data/examples/chart_radar.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# A demo of an Area chart in Excel::Writer::XLSX.
|
7
7
|
#
|
8
8
|
# reverse ('(c)'), October 2012, John McNamara, jmcnamara@cpan.org
|
9
|
-
# convert to ruby by Hideo NAKAMURA,
|
9
|
+
# convert to ruby by Hideo NAKAMURA, nakamura.hideo@gmail.com
|
10
10
|
#
|
11
11
|
|
12
12
|
require 'write_xlsx'
|
@@ -53,7 +53,10 @@
|
|
53
53
|
chart1.set_style(11)
|
54
54
|
|
55
55
|
# Insert the chart into the worksheet (with an offset).
|
56
|
-
worksheet.insert_chart(
|
56
|
+
worksheet.insert_chart(
|
57
|
+
'D2', chart1,
|
58
|
+
:x_offset => 25, :y_offset => 10
|
59
|
+
)
|
57
60
|
|
58
61
|
#
|
59
62
|
# Create a with_markers chart sub-type
|
@@ -87,7 +90,10 @@
|
|
87
90
|
chart2.set_style(12)
|
88
91
|
|
89
92
|
# Insert the chart into the worksheet (with an offset).
|
90
|
-
worksheet.insert_chart(
|
93
|
+
worksheet.insert_chart(
|
94
|
+
'D18', chart2,
|
95
|
+
:x_offset => 25, :y_offset => 10
|
96
|
+
)
|
91
97
|
|
92
98
|
#
|
93
99
|
# Create a filled chart sub-type
|
@@ -121,6 +127,9 @@
|
|
121
127
|
chart3.set_style(13)
|
122
128
|
|
123
129
|
# Insert the chart into the worksheet (with an offset).
|
124
|
-
worksheet.insert_chart(
|
130
|
+
worksheet.insert_chart(
|
131
|
+
'D34', chart3,
|
132
|
+
:x_offset => 25, :y_offset => 10
|
133
|
+
)
|
125
134
|
|
126
135
|
workbook.close
|