write_xlsx 1.10.0 → 1.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +10 -0
- data/Changes +9 -0
- data/README.md +2 -2
- data/examples/autofilter.rb +1 -1
- 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 +2 -2
- 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/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.rb +1 -1
- 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 +30 -30
- data/lib/write_xlsx/colors.rb +19 -19
- data/lib/write_xlsx/package/conditional_format.rb +18 -7
- data/lib/write_xlsx/package/table.rb +33 -24
- data/lib/write_xlsx/shape.rb +5 -5
- data/lib/write_xlsx/sheets.rb +1 -1
- data/lib/write_xlsx/sparkline.rb +286 -286
- data/lib/write_xlsx/utility.rb +32 -31
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/workbook.rb +20 -20
- data/lib/write_xlsx/worksheet/cell_data.rb +1 -1
- data/lib/write_xlsx/worksheet/data_validation.rb +13 -1
- data/lib/write_xlsx/worksheet.rb +486 -246
- metadata +3 -3
data/lib/write_xlsx/utility.rb
CHANGED
@@ -53,7 +53,12 @@ module Writexlsx
|
|
53
53
|
|
54
54
|
def xl_col_to_name(col, col_absolute)
|
55
55
|
col_str = ColName.instance.col_str(col)
|
56
|
-
|
56
|
+
if col_absolute
|
57
|
+
"#{absolute_char(col_absolute)}#{col_str}"
|
58
|
+
else
|
59
|
+
# Do not allocate new string
|
60
|
+
col_str
|
61
|
+
end
|
57
62
|
end
|
58
63
|
|
59
64
|
def xl_range(row_1, row_2, col_1, col_2,
|
@@ -252,12 +257,8 @@ module Writexlsx
|
|
252
257
|
end
|
253
258
|
|
254
259
|
# Check for a cell reference in A1 notation and substitute row and column
|
255
|
-
def row_col_notation(
|
256
|
-
if
|
257
|
-
substitute_cellref(*args)
|
258
|
-
else
|
259
|
-
args
|
260
|
-
end
|
260
|
+
def row_col_notation(row_or_a1) # :nodoc:
|
261
|
+
substitute_cellref(row_or_a1) if row_or_a1.to_s =~ /^\D/
|
261
262
|
end
|
262
263
|
|
263
264
|
#
|
@@ -267,7 +268,7 @@ module Writexlsx
|
|
267
268
|
# Ex: ("A4", "Hello") is converted to (3, 0, "Hello").
|
268
269
|
#
|
269
270
|
def substitute_cellref(cell, *args) # :nodoc:
|
270
|
-
return [*args] if cell.respond_to?(:coerce) # Numeric
|
271
|
+
# return [*args] if cell.respond_to?(:coerce) # Numeric
|
271
272
|
|
272
273
|
normalized_cell = cell.upcase
|
273
274
|
|
@@ -683,7 +684,7 @@ module Writexlsx
|
|
683
684
|
end
|
684
685
|
|
685
686
|
def line_fill_properties(params)
|
686
|
-
return { :
|
687
|
+
return { _defined: 0 } unless params
|
687
688
|
|
688
689
|
ret = params.dup
|
689
690
|
ret[:dash_type] = yield if block_given? && ret[:dash_type]
|
@@ -693,17 +694,17 @@ module Writexlsx
|
|
693
694
|
|
694
695
|
def dash_types
|
695
696
|
{
|
696
|
-
:
|
697
|
-
:
|
698
|
-
:
|
699
|
-
:
|
700
|
-
:
|
701
|
-
:
|
702
|
-
:
|
703
|
-
:
|
704
|
-
:
|
705
|
-
:
|
706
|
-
:
|
697
|
+
solid: 'solid',
|
698
|
+
round_dot: 'sysDot',
|
699
|
+
square_dot: 'sysDash',
|
700
|
+
dash: 'dash',
|
701
|
+
dash_dot: 'dashDot',
|
702
|
+
long_dash: 'lgDash',
|
703
|
+
long_dash_dot: 'lgDashDot',
|
704
|
+
long_dash_dot_dot: 'lgDashDotDot',
|
705
|
+
dot: 'dot',
|
706
|
+
system_dash_dot: 'sysDashDot',
|
707
|
+
system_dash_dot_dot: 'sysDashDotDot'
|
707
708
|
}
|
708
709
|
end
|
709
710
|
|
@@ -766,16 +767,16 @@ module Writexlsx
|
|
766
767
|
|
767
768
|
def params_to_font(params)
|
768
769
|
{
|
769
|
-
:
|
770
|
-
:
|
771
|
-
:
|
772
|
-
:
|
773
|
-
:
|
774
|
-
:
|
775
|
-
:
|
776
|
-
:
|
777
|
-
:
|
778
|
-
:
|
770
|
+
_name: params[:name],
|
771
|
+
_color: params[:color],
|
772
|
+
_size: params[:size],
|
773
|
+
_bold: params[:bold],
|
774
|
+
_italic: params[:italic],
|
775
|
+
_underline: params[:underline],
|
776
|
+
_pitch_family: params[:pitch_family],
|
777
|
+
_charset: params[:charset],
|
778
|
+
_baseline: params[:baseline] || 0,
|
779
|
+
_rotation: params[:rotation]
|
779
780
|
}
|
780
781
|
end
|
781
782
|
|
@@ -862,7 +863,7 @@ module Writexlsx
|
|
862
863
|
|
863
864
|
if !latin_attributes.empty? || has_color
|
864
865
|
@writer.tag_elements(tag, style_attributes) do
|
865
|
-
write_a_solid_fill(:
|
866
|
+
write_a_solid_fill(color: font[:_color]) if has_color
|
866
867
|
write_a_latin(latin_attributes) unless latin_attributes.empty?
|
867
868
|
end
|
868
869
|
else
|
data/lib/write_xlsx/version.rb
CHANGED
data/lib/write_xlsx/workbook.rb
CHANGED
@@ -95,18 +95,18 @@ module Writexlsx
|
|
95
95
|
|
96
96
|
if @excel2003_style
|
97
97
|
add_format(default_formats.merge(
|
98
|
-
:
|
99
|
-
:
|
100
|
-
:
|
101
|
-
:
|
102
|
-
:
|
98
|
+
xf_index: 0,
|
99
|
+
font_family: 0,
|
100
|
+
font: 'Arial',
|
101
|
+
size: 10,
|
102
|
+
theme: -1
|
103
103
|
))
|
104
104
|
else
|
105
|
-
add_format(default_formats.merge(:
|
105
|
+
add_format(default_formats.merge(xf_index: 0))
|
106
106
|
end
|
107
107
|
|
108
108
|
# Add a default URL format.
|
109
|
-
@default_url_format = add_format(:
|
109
|
+
@default_url_format = add_format(hyperlink: 1)
|
110
110
|
|
111
111
|
set_color_palette
|
112
112
|
end
|
@@ -273,7 +273,7 @@ module Writexlsx
|
|
273
273
|
#
|
274
274
|
def add_format(property_hash = {})
|
275
275
|
properties = {}
|
276
|
-
properties.update(:
|
276
|
+
properties.update(font: 'Arial', size: 10, theme: -1) if @excel2003_style
|
277
277
|
properties.update(property_hash)
|
278
278
|
|
279
279
|
format = Format.new(@formats, properties)
|
@@ -376,18 +376,18 @@ module Writexlsx
|
|
376
376
|
|
377
377
|
# List of valid input parameters.
|
378
378
|
valid = {
|
379
|
-
:
|
380
|
-
:
|
381
|
-
:
|
382
|
-
:
|
383
|
-
:
|
384
|
-
:
|
385
|
-
:
|
386
|
-
:
|
387
|
-
:
|
388
|
-
:
|
389
|
-
:
|
390
|
-
:
|
379
|
+
title: 1,
|
380
|
+
subject: 1,
|
381
|
+
author: 1,
|
382
|
+
keywords: 1,
|
383
|
+
comments: 1,
|
384
|
+
last_author: 1,
|
385
|
+
created: 1,
|
386
|
+
category: 1,
|
387
|
+
manager: 1,
|
388
|
+
company: 1,
|
389
|
+
status: 1,
|
390
|
+
hyperlink_base: 1
|
391
391
|
}
|
392
392
|
|
393
393
|
# Check for valid input parameters.
|
@@ -13,7 +13,19 @@ module Writexlsx
|
|
13
13
|
|
14
14
|
def initialize(*args)
|
15
15
|
# Check for a cell reference in A1 notation and substitute row and column.
|
16
|
-
|
16
|
+
if (row_col_array = row_col_notation(args.first))
|
17
|
+
case row_col_array.size
|
18
|
+
when 2
|
19
|
+
row1, col1 = row_col_array
|
20
|
+
row2, col2, options = args[1..-1]
|
21
|
+
when 4
|
22
|
+
row1, col1, row2, col2 = row_col_array
|
23
|
+
options = args[1]
|
24
|
+
end
|
25
|
+
else
|
26
|
+
row1, col1, row2, col2, options = args
|
27
|
+
end
|
28
|
+
|
17
29
|
if row2.respond_to?(:keys)
|
18
30
|
options_to_instance_variable(row2.dup)
|
19
31
|
row2 = row1
|