write_xlsx 1.09.5 → 1.10.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -1
- data/Changes +8 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/examples/autofilter.rb +39 -10
- data/examples/chart_area.rb +12 -12
- data/examples/chart_bar.rb +12 -12
- data/examples/chart_clustered.rb +12 -12
- data/examples/chart_column.rb +12 -12
- data/examples/chart_combined.rb +25 -25
- data/examples/chart_data_labels.rb +99 -99
- data/examples/chart_data_table.rb +25 -25
- data/examples/chart_data_tools.rb +50 -50
- data/examples/chart_doughnut.rb +29 -29
- data/examples/chart_gauge.rb +18 -18
- data/examples/chart_line.rb +32 -32
- data/examples/chart_pareto.rb +16 -16
- data/examples/chart_pie.rb +17 -17
- data/examples/chart_radar.rb +38 -38
- data/examples/chart_scatter.rb +12 -12
- data/examples/chart_secondary_axis.rb +13 -13
- data/examples/chart_stock.rb +12 -12
- data/examples/chart_styles.rb +5 -5
- data/examples/colors.rb +11 -11
- data/examples/comments2.rb +15 -15
- data/examples/conditional_format.rb +74 -74
- data/examples/data_validate.rb +64 -64
- data/examples/date_time.rb +3 -3
- data/examples/demo.rb +14 -14
- data/examples/diag_border.rb +6 -6
- data/examples/dynamic_arrays.rb +247 -0
- data/examples/formats.rb +10 -10
- data/examples/hyperlink1.rb +4 -4
- data/examples/ignore_errors.rb +2 -2
- data/examples/indent.rb +2 -2
- data/examples/lambda.rb +43 -0
- data/examples/macros.rb +4 -4
- data/examples/merge1.rb +1 -1
- data/examples/merge2.rb +9 -9
- data/examples/merge3.rb +5 -5
- data/examples/merge4.rb +20 -20
- data/examples/merge5.rb +18 -18
- data/examples/merge6.rb +7 -7
- data/examples/outline.rb +1 -1
- data/examples/outline_collapsed.rb +1 -1
- data/examples/panes.rb +4 -4
- data/examples/properties.rb +9 -9
- data/examples/protection.rb +2 -2
- data/examples/rich_strings.rb +6 -6
- data/examples/shape1.rb +7 -7
- data/examples/shape2.rb +16 -16
- data/examples/shape3.rb +5 -5
- data/examples/shape4.rb +7 -7
- data/examples/shape5.rb +7 -7
- data/examples/shape6.rb +7 -7
- data/examples/shape7.rb +10 -10
- data/examples/shape8.rb +10 -10
- data/examples/shape_all.rb +4 -4
- data/examples/sparklines1.rb +11 -11
- data/examples/sparklines2.rb +76 -76
- data/examples/tables.rb +87 -87
- data/examples/watermark.png +0 -0
- data/examples/watermark.rb +26 -0
- data/lib/write_xlsx/chart/bar.rb +4 -4
- data/lib/write_xlsx/chart/line.rb +1 -1
- data/lib/write_xlsx/chart/radar.rb +2 -2
- data/lib/write_xlsx/chart/scatter.rb +4 -4
- data/lib/write_xlsx/chart/series.rb +27 -27
- data/lib/write_xlsx/chart/stock.rb +5 -5
- data/lib/write_xlsx/chart.rb +31 -30
- data/lib/write_xlsx/chartsheet.rb +1 -0
- data/lib/write_xlsx/col_name.rb +1 -0
- data/lib/write_xlsx/colors.rb +20 -19
- data/lib/write_xlsx/compatibility.rb +1 -0
- data/lib/write_xlsx/drawing.rb +20 -10
- data/lib/write_xlsx/format.rb +5 -0
- data/lib/write_xlsx/formats.rb +1 -0
- data/lib/write_xlsx/gradient.rb +2 -0
- data/lib/write_xlsx/package/app.rb +1 -0
- data/lib/write_xlsx/package/button.rb +6 -2
- data/lib/write_xlsx/package/comments.rb +3 -1
- data/lib/write_xlsx/package/conditional_format.rb +4 -3
- data/lib/write_xlsx/package/content_types.rb +1 -0
- data/lib/write_xlsx/package/core.rb +1 -0
- data/lib/write_xlsx/package/custom.rb +1 -0
- data/lib/write_xlsx/package/metadata.rb +1 -0
- data/lib/write_xlsx/package/packager.rb +1 -0
- data/lib/write_xlsx/package/relationships.rb +1 -0
- data/lib/write_xlsx/package/shared_strings.rb +1 -1
- data/lib/write_xlsx/package/styles.rb +1 -0
- data/lib/write_xlsx/package/table.rb +9 -8
- data/lib/write_xlsx/package/theme.rb +1 -0
- data/lib/write_xlsx/package/vml.rb +1 -0
- data/lib/write_xlsx/package/xml_writer_simple.rb +21 -2
- data/lib/write_xlsx/shape.rb +6 -5
- data/lib/write_xlsx/sheets.rb +2 -1
- data/lib/write_xlsx/sparkline.rb +287 -286
- data/lib/write_xlsx/utility.rb +25 -26
- data/lib/write_xlsx/version.rb +3 -1
- data/lib/write_xlsx/workbook.rb +20 -20
- data/lib/write_xlsx/worksheet/cell_data.rb +53 -63
- data/lib/write_xlsx/worksheet/data_validation.rb +1 -0
- data/lib/write_xlsx/worksheet/hyperlink.rb +3 -2
- data/lib/write_xlsx/worksheet/page_setup.rb +1 -0
- data/lib/write_xlsx/worksheet.rb +287 -74
- data/lib/write_xlsx/zip_file_utils.rb +1 -0
- data/lib/write_xlsx.rb +1 -0
- data/write_xlsx.gemspec +1 -0
- metadata +8 -4
data/examples/tables.rb
CHANGED
@@ -30,7 +30,7 @@ worksheet11 = workbook.add_worksheet
|
|
30
30
|
worksheet12 = workbook.add_worksheet
|
31
31
|
worksheet13 = workbook.add_worksheet
|
32
32
|
|
33
|
-
currency_format = workbook.add_format(:
|
33
|
+
currency_format = workbook.add_format(num_format: '$#,##0')
|
34
34
|
|
35
35
|
# Some sample data for the table.
|
36
36
|
data = [
|
@@ -68,7 +68,7 @@ worksheet2.set_column('B:G', 12)
|
|
68
68
|
worksheet2.write('B1', caption)
|
69
69
|
|
70
70
|
# Add a table to the worksheet.
|
71
|
-
worksheet2.add_table('B3:F7', { :
|
71
|
+
worksheet2.add_table('B3:F7', { data: data })
|
72
72
|
|
73
73
|
###############################################################################
|
74
74
|
#
|
@@ -83,7 +83,7 @@ worksheet3.set_column('B:G', 12)
|
|
83
83
|
worksheet3.write('B1', caption)
|
84
84
|
|
85
85
|
# Add a table to the worksheet.
|
86
|
-
worksheet3.add_table('B3:F7', { :
|
86
|
+
worksheet3.add_table('B3:F7', { autofilter: 0 })
|
87
87
|
|
88
88
|
# Table data can also be written separately, as an array or individual cells.
|
89
89
|
worksheet3.write_col('B4', data)
|
@@ -101,7 +101,7 @@ worksheet4.set_column('B:G', 12)
|
|
101
101
|
worksheet4.write('B1', caption)
|
102
102
|
|
103
103
|
# Add a table to the worksheet.
|
104
|
-
worksheet4.add_table('B4:F7', { :
|
104
|
+
worksheet4.add_table('B4:F7', { header_row: 0 })
|
105
105
|
|
106
106
|
# Table data can also be written separately, as an array or individual cells.
|
107
107
|
worksheet4.write_col('B4', data)
|
@@ -119,7 +119,7 @@ worksheet5.set_column('B:G', 12)
|
|
119
119
|
worksheet5.write('B1', caption)
|
120
120
|
|
121
121
|
# Add a table to the worksheet.
|
122
|
-
worksheet5.add_table('B3:F7', { :
|
122
|
+
worksheet5.add_table('B3:F7', { first_column: 1, last_column: 1 })
|
123
123
|
|
124
124
|
# Table data can also be written separately, as an array or individual cells.
|
125
125
|
worksheet5.write_col('B4', data)
|
@@ -137,7 +137,7 @@ worksheet6.set_column('B:G', 12)
|
|
137
137
|
worksheet6.write('B1', caption)
|
138
138
|
|
139
139
|
# Add a table to the worksheet.
|
140
|
-
worksheet6.add_table('B3:F7', { :
|
140
|
+
worksheet6.add_table('B3:F7', { banded_rows: 0, banded_columns: 1 })
|
141
141
|
|
142
142
|
# Table data can also be written separately, as an array or individual cells.
|
143
143
|
worksheet6.write_col('B4', data)
|
@@ -158,13 +158,13 @@ worksheet7.write('B1', caption)
|
|
158
158
|
worksheet7.add_table(
|
159
159
|
'B3:F7',
|
160
160
|
{
|
161
|
-
:
|
162
|
-
:
|
163
|
-
{ :
|
164
|
-
{ :
|
165
|
-
{ :
|
166
|
-
{ :
|
167
|
-
{ :
|
161
|
+
data: data,
|
162
|
+
columns: [
|
163
|
+
{ header: 'Product' },
|
164
|
+
{ header: 'Quarter 1' },
|
165
|
+
{ header: 'Quarter 2' },
|
166
|
+
{ header: 'Quarter 3' },
|
167
|
+
{ header: 'Quarter 4' }
|
168
168
|
]
|
169
169
|
}
|
170
170
|
)
|
@@ -185,16 +185,16 @@ worksheet8.write('B1', caption)
|
|
185
185
|
worksheet8.add_table(
|
186
186
|
'B3:G7',
|
187
187
|
{
|
188
|
-
:
|
189
|
-
:
|
190
|
-
{ :
|
191
|
-
{ :
|
192
|
-
{ :
|
193
|
-
{ :
|
194
|
-
{ :
|
188
|
+
data: data,
|
189
|
+
columns: [
|
190
|
+
{ header: 'Product' },
|
191
|
+
{ header: 'Quarter 1' },
|
192
|
+
{ header: 'Quarter 2' },
|
193
|
+
{ header: 'Quarter 3' },
|
194
|
+
{ header: 'Quarter 4' },
|
195
195
|
{
|
196
|
-
:
|
197
|
-
:
|
196
|
+
header: 'Year',
|
197
|
+
formula: '=SUM(Table8[@[Quarter 1]:[Quarter 4]])'
|
198
198
|
}
|
199
199
|
]
|
200
200
|
}
|
@@ -216,17 +216,17 @@ worksheet9.write('B1', caption)
|
|
216
216
|
worksheet9.add_table(
|
217
217
|
'B3:G8',
|
218
218
|
{
|
219
|
-
:
|
220
|
-
:
|
221
|
-
:
|
222
|
-
{ :
|
223
|
-
{ :
|
224
|
-
{ :
|
225
|
-
{ :
|
226
|
-
{ :
|
219
|
+
data: data,
|
220
|
+
total_row: 1,
|
221
|
+
columns: [
|
222
|
+
{ header: 'Product' },
|
223
|
+
{ header: 'Quarter 1' },
|
224
|
+
{ header: 'Quarter 2' },
|
225
|
+
{ header: 'Quarter 3' },
|
226
|
+
{ header: 'Quarter 4' },
|
227
227
|
{
|
228
|
-
:
|
229
|
-
:
|
228
|
+
header: 'Year',
|
229
|
+
formula: '=SUM(Table8[@[Quarter 1]:[Quarter 4]])'
|
230
230
|
}
|
231
231
|
]
|
232
232
|
}
|
@@ -248,18 +248,18 @@ worksheet10.write('B1', caption)
|
|
248
248
|
worksheet10.add_table(
|
249
249
|
'B3:G8',
|
250
250
|
{
|
251
|
-
:
|
252
|
-
:
|
253
|
-
:
|
254
|
-
{ :
|
255
|
-
{ :
|
256
|
-
{ :
|
257
|
-
{ :
|
258
|
-
{ :
|
251
|
+
data: data,
|
252
|
+
total_row: 1,
|
253
|
+
columns: [
|
254
|
+
{ header: 'Product', total_string: 'Totals' },
|
255
|
+
{ header: 'Quarter 1', total_function: 'sum' },
|
256
|
+
{ header: 'Quarter 2', total_function: 'sum' },
|
257
|
+
{ header: 'Quarter 3', total_function: 'sum' },
|
258
|
+
{ header: 'Quarter 4', total_function: 'sum' },
|
259
259
|
{
|
260
|
-
:
|
261
|
-
:
|
262
|
-
:
|
260
|
+
header: 'Year',
|
261
|
+
formula: '=SUM(Table8[@[Quarter 1]:[Quarter 4]])',
|
262
|
+
total_function: 'sum'
|
263
263
|
}
|
264
264
|
]
|
265
265
|
}
|
@@ -281,19 +281,19 @@ worksheet11.write('B1', caption)
|
|
281
281
|
worksheet11.add_table(
|
282
282
|
'B3:G8',
|
283
283
|
{
|
284
|
-
:
|
285
|
-
:
|
286
|
-
:
|
287
|
-
:
|
288
|
-
{ :
|
289
|
-
{ :
|
290
|
-
{ :
|
291
|
-
{ :
|
292
|
-
{ :
|
284
|
+
data: data,
|
285
|
+
style: 'Table Style Light 11',
|
286
|
+
total_row: 1,
|
287
|
+
columns: [
|
288
|
+
{ header: 'Product', total_string: 'Totals' },
|
289
|
+
{ header: 'Quarter 1', total_function: 'sum' },
|
290
|
+
{ header: 'Quarter 2', total_function: 'sum' },
|
291
|
+
{ header: 'Quarter 3', total_function: 'sum' },
|
292
|
+
{ header: 'Quarter 4', total_function: 'sum' },
|
293
293
|
{
|
294
|
-
:
|
295
|
-
:
|
296
|
-
:
|
294
|
+
header: 'Year',
|
295
|
+
formula: '=SUM(Table8[@[Quarter 1]:[Quarter 4]])',
|
296
|
+
total_function: 'sum'
|
297
297
|
}
|
298
298
|
]
|
299
299
|
}
|
@@ -315,19 +315,19 @@ worksheet12.write('B1', caption)
|
|
315
315
|
worksheet12.add_table(
|
316
316
|
'B3:G8',
|
317
317
|
{
|
318
|
-
:
|
319
|
-
:
|
320
|
-
:
|
321
|
-
:
|
322
|
-
{ :
|
323
|
-
{ :
|
324
|
-
{ :
|
325
|
-
{ :
|
326
|
-
{ :
|
318
|
+
data: data,
|
319
|
+
style: 'None',
|
320
|
+
total_row: 1,
|
321
|
+
columns: [
|
322
|
+
{ header: 'Product', total_string: 'Totals' },
|
323
|
+
{ header: 'Quarter 1', total_function: 'sum' },
|
324
|
+
{ header: 'Quarter 2', total_function: 'sum' },
|
325
|
+
{ header: 'Quarter 3', total_function: 'sum' },
|
326
|
+
{ header: 'Quarter 4', total_function: 'sum' },
|
327
327
|
{
|
328
|
-
:
|
329
|
-
:
|
330
|
-
:
|
328
|
+
header: 'Year',
|
329
|
+
formula: '=SUM(Table12[@[Quarter 1]:[Quarter 4]])',
|
330
|
+
total_function: 'sum'
|
331
331
|
}
|
332
332
|
]
|
333
333
|
}
|
@@ -349,35 +349,35 @@ worksheet13.write('B1', caption)
|
|
349
349
|
worksheet13.add_table(
|
350
350
|
'B3:G8',
|
351
351
|
{
|
352
|
-
:
|
353
|
-
:
|
354
|
-
:
|
355
|
-
{ :
|
352
|
+
data: data,
|
353
|
+
total_row: 1,
|
354
|
+
columns: [
|
355
|
+
{ header: 'Product', total_string: 'Totals' },
|
356
356
|
{
|
357
|
-
:
|
358
|
-
:
|
359
|
-
:
|
357
|
+
header: 'Quarter 1',
|
358
|
+
total_function: 'sum',
|
359
|
+
format: currency_format
|
360
360
|
},
|
361
361
|
{
|
362
|
-
:
|
363
|
-
:
|
364
|
-
:
|
362
|
+
header: 'Quarter 2',
|
363
|
+
total_function: 'sum',
|
364
|
+
format: currency_format
|
365
365
|
},
|
366
366
|
{
|
367
|
-
:
|
368
|
-
:
|
369
|
-
:
|
367
|
+
header: 'Quarter 3',
|
368
|
+
total_function: 'sum',
|
369
|
+
format: currency_format
|
370
370
|
},
|
371
371
|
{
|
372
|
-
:
|
373
|
-
:
|
374
|
-
:
|
372
|
+
header: 'Quarter 4',
|
373
|
+
total_function: 'sum',
|
374
|
+
format: currency_format
|
375
375
|
},
|
376
376
|
{
|
377
|
-
:
|
378
|
-
:
|
379
|
-
:
|
380
|
-
:
|
377
|
+
header: 'Year',
|
378
|
+
formula: '=SUM(Table8[@[Quarter 1]:[Quarter 4]])',
|
379
|
+
total_function: 'sum',
|
380
|
+
format: currency_format
|
381
381
|
}
|
382
382
|
]
|
383
383
|
}
|
Binary file
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#######################################################################
|
4
|
+
#
|
5
|
+
# An example of adding a worksheet watermark image using the WriteXLSX
|
6
|
+
# rubygem. This is based on the method of putting an image in the worksheet
|
7
|
+
# header as suggested in the Microsoft documentation:
|
8
|
+
# https://support.microsoft.com/en-us/office/add-a-watermark-in-excel-a372182a-d733-484e-825c-18ddf3edf009
|
9
|
+
#
|
10
|
+
# Copyright 2000-2023, John McNamara, jmcnamara@cpan.org
|
11
|
+
# convert to ruby by Hideo NAKAMURA, nakamura.hideo@gmail.com
|
12
|
+
#
|
13
|
+
|
14
|
+
require 'write_xlsx'
|
15
|
+
|
16
|
+
workbook = WriteXLSX.new('watermark.xlsx')
|
17
|
+
worksheet = workbook.add_worksheet
|
18
|
+
|
19
|
+
# Set a worksheet header with the watermark image.
|
20
|
+
dirname = File.dirname(File.expand_path(__FILE__))
|
21
|
+
worksheet.set_header(
|
22
|
+
'&C&C&[Picture]', nil,
|
23
|
+
{ image_center: File.join(dirname, 'watermark.png') }
|
24
|
+
)
|
25
|
+
|
26
|
+
workbook.close
|
data/lib/write_xlsx/chart/bar.rb
CHANGED
@@ -86,14 +86,14 @@ module Writexlsx
|
|
86
86
|
|
87
87
|
def axis_defaults_set
|
88
88
|
if @x_axis.defaults
|
89
|
-
@x_axis.defaults[:major_gridlines] = { :
|
89
|
+
@x_axis.defaults[:major_gridlines] = { visible: 1 }
|
90
90
|
else
|
91
|
-
@x_axis.defaults = { :
|
91
|
+
@x_axis.defaults = { major_gridlines: { visible: 1 } }
|
92
92
|
end
|
93
93
|
if @y_axis.defaults
|
94
|
-
@y_axis.defaults[:major_gridlines] = { :
|
94
|
+
@y_axis.defaults[:major_gridlines] = { visible: 0 }
|
95
95
|
else
|
96
|
-
@y_axis.defaults = { :
|
96
|
+
@y_axis.defaults = { major_gridlines: { visible: 0 } }
|
97
97
|
end
|
98
98
|
@x_axis.defaults[:num_format] = '0%' if @subtype == 'percent_stacked'
|
99
99
|
end
|
@@ -32,10 +32,10 @@ module Writexlsx
|
|
32
32
|
def initialize(subtype)
|
33
33
|
super(subtype)
|
34
34
|
@subtype = subtype || 'marker'
|
35
|
-
@default_marker = Marker.new(:
|
35
|
+
@default_marker = Marker.new(type: 'none') if @subtype == 'marker'
|
36
36
|
|
37
37
|
# Override and reset the default axis values.
|
38
|
-
@x_axis.defaults[:major_gridlines] = { :
|
38
|
+
@x_axis.defaults[:major_gridlines] = { visible: 1 }
|
39
39
|
set_x_axis
|
40
40
|
|
41
41
|
# Hardcode major_tick_mark for now untill there is an accessor.
|
@@ -123,8 +123,8 @@ module Writexlsx
|
|
123
123
|
write_layout(@plotarea.layout, 'plot')
|
124
124
|
|
125
125
|
# Write the subclass chart type elements for primary and secondary axes.
|
126
|
-
write_chart_type(:
|
127
|
-
write_chart_type(:
|
126
|
+
write_chart_type(primary_axes: 1)
|
127
|
+
write_chart_type(primary_axes: 0)
|
128
128
|
|
129
129
|
# Write c:catAx and c:valAx elements for series using primary axes.
|
130
130
|
write_cat_val_axis(@x_axis, @y_axis, @axis_ids, 'b')
|
@@ -201,7 +201,7 @@ module Writexlsx
|
|
201
201
|
# Go through each series and define default values.
|
202
202
|
@series.each do |series|
|
203
203
|
# Set a line type unless there is already a user defined type.
|
204
|
-
series.line = line_properties(:
|
204
|
+
series.line = line_properties(width: 2.25, none: 1, _defined: 1) unless series.line_defined?
|
205
205
|
end
|
206
206
|
end
|
207
207
|
|
@@ -210,7 +210,7 @@ module Writexlsx
|
|
210
210
|
# Go through each series and define default values.
|
211
211
|
@series.each do |series|
|
212
212
|
# Set a marker type unless there is already a user defined type.
|
213
|
-
series.marker = Marker.new(:
|
213
|
+
series.marker = Marker.new(type: 'none', _defined: 1) unless ptrue?(series.marker)
|
214
214
|
end
|
215
215
|
end
|
216
216
|
end
|
@@ -77,12 +77,12 @@ module Writexlsx
|
|
77
77
|
|
78
78
|
def types
|
79
79
|
{
|
80
|
-
:
|
81
|
-
:
|
82
|
-
:
|
83
|
-
:
|
84
|
-
:
|
85
|
-
:
|
80
|
+
exponential: 'exp',
|
81
|
+
linear: 'linear',
|
82
|
+
log: 'log',
|
83
|
+
moving_average: 'movingAvg',
|
84
|
+
polynomial: 'poly',
|
85
|
+
power: 'power'
|
86
86
|
}
|
87
87
|
end
|
88
88
|
end
|
@@ -108,20 +108,20 @@ module Writexlsx
|
|
108
108
|
|
109
109
|
def types
|
110
110
|
{
|
111
|
-
:
|
112
|
-
:
|
113
|
-
:
|
114
|
-
:
|
115
|
-
:
|
116
|
-
:
|
117
|
-
:
|
118
|
-
:
|
119
|
-
:
|
120
|
-
:
|
121
|
-
:
|
122
|
-
:
|
123
|
-
:
|
124
|
-
:
|
111
|
+
automatic: 'automatic',
|
112
|
+
none: 'none',
|
113
|
+
square: 'square',
|
114
|
+
diamond: 'diamond',
|
115
|
+
triangle: 'triangle',
|
116
|
+
x: 'x',
|
117
|
+
star: 'star',
|
118
|
+
dot: 'dot',
|
119
|
+
short_dash: 'dot',
|
120
|
+
dash: 'dash',
|
121
|
+
long_dash: 'dash',
|
122
|
+
circle: 'circle',
|
123
|
+
plus: 'plus',
|
124
|
+
picture: 'picture'
|
125
125
|
}
|
126
126
|
end
|
127
127
|
end
|
@@ -155,11 +155,11 @@ module Writexlsx
|
|
155
155
|
|
156
156
|
def types
|
157
157
|
{
|
158
|
-
:
|
159
|
-
:
|
160
|
-
:
|
161
|
-
:
|
162
|
-
:
|
158
|
+
fixed: 'fixedVal',
|
159
|
+
percentage: 'percentage',
|
160
|
+
standard_deviation: 'stdDev',
|
161
|
+
standard_error: 'stdErr',
|
162
|
+
custom: 'cust'
|
163
163
|
}
|
164
164
|
end
|
165
165
|
|
@@ -261,8 +261,8 @@ module Writexlsx
|
|
261
261
|
|
262
262
|
def errorbars(x, y)
|
263
263
|
{
|
264
|
-
:
|
265
|
-
:
|
264
|
+
_x_error_bars: x ? Errorbars.new(x) : nil,
|
265
|
+
_y_error_bars: y ? Errorbars.new(y) : nil
|
266
266
|
}
|
267
267
|
end
|
268
268
|
|
@@ -104,17 +104,17 @@ module Writexlsx
|
|
104
104
|
if index % 4 != 3
|
105
105
|
unless series.line_defined?
|
106
106
|
series.line = {
|
107
|
-
:
|
108
|
-
:
|
109
|
-
:
|
107
|
+
width: 2.25,
|
108
|
+
none: 1,
|
109
|
+
_defined: 1
|
110
110
|
}
|
111
111
|
end
|
112
112
|
|
113
113
|
unless ptrue?(series.marker)
|
114
114
|
series.marker = if index % 4 == 2
|
115
|
-
Marker.new(:
|
115
|
+
Marker.new(type: 'dot', size: 3)
|
116
116
|
else
|
117
|
-
Marker.new(:
|
117
|
+
Marker.new(type: 'none')
|
118
118
|
end
|
119
119
|
end
|
120
120
|
end
|
data/lib/write_xlsx/chart.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'write_xlsx/package/xml_writer_simple'
|
4
5
|
require 'write_xlsx/gradient'
|
@@ -69,7 +70,7 @@ module Writexlsx
|
|
69
70
|
@gradient = gradient_properties(params[:gradient])
|
70
71
|
|
71
72
|
# Map deprecated Spreadsheet::WriteExcel fill colour.
|
72
|
-
fill = params[:color] ? { :
|
73
|
+
fill = params[:color] ? { color: params[:color] } : params[:fill]
|
73
74
|
@fill = fill_properties(fill)
|
74
75
|
|
75
76
|
# Pattern fill overrides solid fill.
|
@@ -89,13 +90,13 @@ module Writexlsx
|
|
89
90
|
|
90
91
|
# Map deprecated Spreadsheet::WriteExcel line_weight.
|
91
92
|
border = params[:border]
|
92
|
-
border = { :
|
93
|
+
border = { width: swe_line_weight(line_weight) } if line_weight
|
93
94
|
|
94
95
|
# Map deprecated Spreadsheet::WriteExcel line_pattern.
|
95
96
|
if params[:line_pattern]
|
96
97
|
pattern = swe_line_pattern(params[:line_pattern])
|
97
98
|
if pattern == 'none'
|
98
|
-
border = { :
|
99
|
+
border = { none: 1 }
|
99
100
|
else
|
100
101
|
border[:dash_type] = pattern
|
101
102
|
end
|
@@ -431,8 +432,8 @@ module Writexlsx
|
|
431
432
|
|
432
433
|
# Set the up and down bar properties.
|
433
434
|
@up_down_bars = {
|
434
|
-
:
|
435
|
-
:
|
435
|
+
_up: Chartline.new(params[:up]),
|
436
|
+
_down: Chartline.new(params[:down])
|
436
437
|
}
|
437
438
|
end
|
438
439
|
|
@@ -694,33 +695,33 @@ module Writexlsx
|
|
694
695
|
|
695
696
|
def x_axis_defaults
|
696
697
|
{
|
697
|
-
:
|
698
|
-
:
|
698
|
+
num_format: 'General',
|
699
|
+
major_gridlines: { visible: 0 }
|
699
700
|
}
|
700
701
|
end
|
701
702
|
|
702
703
|
def y_axis_defaults
|
703
704
|
{
|
704
|
-
:
|
705
|
-
:
|
705
|
+
num_format: 'General',
|
706
|
+
major_gridlines: { visible: 1 }
|
706
707
|
}
|
707
708
|
end
|
708
709
|
|
709
710
|
def x2_axis_defaults
|
710
711
|
{
|
711
|
-
:
|
712
|
-
:
|
713
|
-
:
|
714
|
-
:
|
712
|
+
num_format: 'General',
|
713
|
+
label_position: 'none',
|
714
|
+
crossing: 'max',
|
715
|
+
visible: 0
|
715
716
|
}
|
716
717
|
end
|
717
718
|
|
718
719
|
def y2_axis_defaults
|
719
720
|
{
|
720
|
-
:
|
721
|
-
:
|
722
|
-
:
|
723
|
-
:
|
721
|
+
num_format: 'General',
|
722
|
+
major_gridlines: { visible: 0 },
|
723
|
+
position: 'right',
|
724
|
+
visible: 1
|
724
725
|
}
|
725
726
|
end
|
726
727
|
|
@@ -802,8 +803,8 @@ module Writexlsx
|
|
802
803
|
# Write the c:layout element.
|
803
804
|
write_layout(@plotarea.layout, 'plot')
|
804
805
|
# Write the subclass chart type elements for primary and secondary axes.
|
805
|
-
write_chart_type(:
|
806
|
-
write_chart_type(:
|
806
|
+
write_chart_type(primary_axes: 1)
|
807
|
+
write_chart_type(primary_axes: 0)
|
807
808
|
|
808
809
|
# Configure a combined chart if present.
|
809
810
|
if second_chart
|
@@ -822,15 +823,15 @@ module Writexlsx
|
|
822
823
|
second_chart.series_index = @series_index
|
823
824
|
|
824
825
|
# Write the subclass chart type elements for combined chart.
|
825
|
-
second_chart.write_chart_type(:
|
826
|
-
second_chart.write_chart_type(:
|
826
|
+
second_chart.write_chart_type(primary_axes: 1)
|
827
|
+
second_chart.write_chart_type(primary_axes: 0)
|
827
828
|
end
|
828
829
|
|
829
830
|
# Write the category and value elements for the primary axes.
|
830
831
|
params = {
|
831
|
-
:
|
832
|
-
:
|
833
|
-
:
|
832
|
+
x_axis: @x_axis,
|
833
|
+
y_axis: @y_axis,
|
834
|
+
axis_ids: @axis_ids
|
834
835
|
}
|
835
836
|
|
836
837
|
if @date_category
|
@@ -843,9 +844,9 @@ module Writexlsx
|
|
843
844
|
|
844
845
|
# Write the category and value elements for the secondary axes.
|
845
846
|
params = {
|
846
|
-
:
|
847
|
-
:
|
848
|
-
:
|
847
|
+
x_axis: @x2_axis,
|
848
|
+
y_axis: @y2_axis,
|
849
|
+
axis_ids: @axis2_ids
|
849
850
|
}
|
850
851
|
|
851
852
|
write_val_axis(@x2_axis, @y2_axis, @axis2_ids)
|
@@ -854,9 +855,9 @@ module Writexlsx
|
|
854
855
|
if second_chart && second_chart.is_secondary?
|
855
856
|
|
856
857
|
params = {
|
857
|
-
:
|
858
|
-
:
|
859
|
-
:
|
858
|
+
x_axis: second_chart.x2_axis,
|
859
|
+
y_axis: second_chart.y2_axis,
|
860
|
+
axis_ids: second_chart.axis2_ids
|
860
861
|
}
|
861
862
|
|
862
863
|
second_chart.write_val_axis(
|