write_xlsx 1.11.0 → 1.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/Changes +3 -0
- data/lib/write_xlsx/chart/area.rb +1 -0
- data/lib/write_xlsx/chart/axis.rb +1 -0
- data/lib/write_xlsx/chart/bar.rb +1 -0
- data/lib/write_xlsx/chart/caption.rb +1 -0
- data/lib/write_xlsx/chart/column.rb +1 -0
- data/lib/write_xlsx/chart/doughnut.rb +1 -0
- data/lib/write_xlsx/chart/legend.rb +1 -0
- data/lib/write_xlsx/chart/line.rb +1 -0
- data/lib/write_xlsx/chart/pie.rb +1 -0
- data/lib/write_xlsx/chart/radar.rb +1 -0
- data/lib/write_xlsx/chart/scatter.rb +1 -0
- data/lib/write_xlsx/chart/series.rb +8 -4
- data/lib/write_xlsx/chart/stock.rb +1 -0
- data/lib/write_xlsx/chart.rb +44 -13
- data/lib/write_xlsx/colors.rb +20 -19
- data/lib/write_xlsx/format.rb +9 -7
- data/lib/write_xlsx/package/comments.rb +2 -1
- data/lib/write_xlsx/package/conditional_format.rb +4 -4
- data/lib/write_xlsx/package/styles.rb +11 -13
- data/lib/write_xlsx/utility.rb +3 -3
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/workbook.rb +0 -1
- data/lib/write_xlsx/worksheet/cell_data.rb +1 -2
- data/lib/write_xlsx/worksheet.rb +3 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cabafeb058f3742956ec06251cab5ecf67d9b76cd5db3ec659e2e4184d2c1483
|
4
|
+
data.tar.gz: 95a68e0390bff44e03dc8577b31162c1d1c2cb80d77f3943947e1114327afb01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70a98e3ffc2be69574805f72a63678b2023cc3aef9a1c1a97c5f8a13de80de29c641c573d8c8c9bd7d33da088827a15fb6feb3b4c7591b50ffb26cb321591b49
|
7
|
+
data.tar.gz: 1d387aa195a7a35f0b664e4ff155ca71de765ad6ae886df66debc9063d1fea8c4c905ab10a7aef735d69813b79faa1d6e7ded96e70ce23a75df56e5f172b1648
|
data/.rubocop.yml
CHANGED
data/Changes
CHANGED
data/lib/write_xlsx/chart/bar.rb
CHANGED
data/lib/write_xlsx/chart/pie.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Writexlsx
|
4
5
|
class Chart
|
@@ -182,6 +183,7 @@ module Writexlsx
|
|
182
183
|
attr_reader :values, :categories, :name, :name_formula, :name_id
|
183
184
|
attr_reader :cat_data_id, :val_data_id, :fill, :pattern, :gradient
|
184
185
|
attr_reader :trendline, :smooth, :labels, :invert_if_negative
|
186
|
+
attr_reader :inverted_color
|
185
187
|
attr_reader :x2_axis, :y2_axis, :error_bars, :points
|
186
188
|
attr_accessor :line, :marker
|
187
189
|
|
@@ -217,10 +219,12 @@ module Writexlsx
|
|
217
219
|
|
218
220
|
@label_positions = chart.label_positions
|
219
221
|
@label_position_default = chart.label_position_default
|
220
|
-
@labels
|
222
|
+
@labels = labels_properties(params[:data_labels])
|
223
|
+
@inverted_color = params[:invert_if_negative_color]
|
221
224
|
|
222
|
-
%i[
|
223
|
-
|
225
|
+
%i[
|
226
|
+
smooth invert_if_negative x2_axis y2_axis
|
227
|
+
].each { |key| instance_variable_set("@#{key}", params[key]) }
|
224
228
|
end
|
225
229
|
|
226
230
|
def ==(other)
|
@@ -228,7 +232,7 @@ module Writexlsx
|
|
228
232
|
categories values name name_formula name_id
|
229
233
|
cat_data_id val_data_id
|
230
234
|
line fill gradient marker trendline
|
231
|
-
smooth labels
|
235
|
+
smooth labels inverted_color
|
232
236
|
x2_axis y2_axis error_bars points
|
233
237
|
]
|
234
238
|
methods.each do |method|
|
data/lib/write_xlsx/chart.rb
CHANGED
@@ -950,10 +950,36 @@ module Writexlsx
|
|
950
950
|
write_val(series)
|
951
951
|
# Write the c:smooth element.
|
952
952
|
write_c_smooth(series.smooth) if ptrue?(@smooth_allowed)
|
953
|
+
write_ext_lst(series.inverted_color) if series.inverted_color
|
953
954
|
end
|
954
955
|
@series_index += 1
|
955
956
|
end
|
956
957
|
|
958
|
+
def write_ext_lst(color)
|
959
|
+
uri = '{6F2FDCE9-48DA-4B69-8628-5D25D57E5C99}'
|
960
|
+
xmlns_c_14 =
|
961
|
+
'http://schemas.microsoft.com/office/drawing/2007/8/2/chart'
|
962
|
+
|
963
|
+
attributes_1 = [
|
964
|
+
['uri', uri],
|
965
|
+
['xmlns:c14', xmlns_c_14]
|
966
|
+
]
|
967
|
+
|
968
|
+
attributes_2 = [
|
969
|
+
['xmlns:c14', xmlns_c_14]
|
970
|
+
]
|
971
|
+
|
972
|
+
@writer.tag_elements('c:extLst') do
|
973
|
+
@writer.tag_elements('c:ext', attributes_1) do
|
974
|
+
@writer.tag_elements('c14:invertSolidFillFmt') do
|
975
|
+
@writer.tag_elements('c14:spPr', attributes_2) do
|
976
|
+
write_a_solid_fill(color: color)
|
977
|
+
end
|
978
|
+
end
|
979
|
+
end
|
980
|
+
end
|
981
|
+
end
|
982
|
+
|
957
983
|
def write_ser_base(series)
|
958
984
|
# Write the c:idx element.
|
959
985
|
write_idx(@series_index)
|
@@ -2018,20 +2044,25 @@ module Writexlsx
|
|
2018
2044
|
attributes << ['w', width]
|
2019
2045
|
end
|
2020
2046
|
|
2021
|
-
|
2022
|
-
|
2023
|
-
|
2024
|
-
|
2025
|
-
|
2026
|
-
|
2027
|
-
|
2028
|
-
|
2029
|
-
|
2030
|
-
|
2031
|
-
|
2032
|
-
# Write the
|
2033
|
-
|
2047
|
+
if ptrue?(line[:none]) || ptrue?(line[:color]) || line[:dash_type]
|
2048
|
+
@writer.tag_elements('a:ln', attributes) do
|
2049
|
+
# Write the line fill.
|
2050
|
+
if ptrue?(line[:none])
|
2051
|
+
# Write the a:noFill element.
|
2052
|
+
write_a_no_fill
|
2053
|
+
elsif ptrue?(line[:color])
|
2054
|
+
# Write the a:solidFill element.
|
2055
|
+
write_a_solid_fill(line)
|
2056
|
+
end
|
2057
|
+
|
2058
|
+
# Write the line/dash type.
|
2059
|
+
if line[:dash_type]
|
2060
|
+
# Write the a:prstDash element.
|
2061
|
+
write_a_prst_dash(line[:dash_type])
|
2062
|
+
end
|
2034
2063
|
end
|
2064
|
+
else
|
2065
|
+
@writer.empty_tag('a:ln', attributes)
|
2035
2066
|
end
|
2036
2067
|
end
|
2037
2068
|
|
data/lib/write_xlsx/colors.rb
CHANGED
@@ -4,25 +4,26 @@
|
|
4
4
|
module Writexlsx
|
5
5
|
class Colors
|
6
6
|
COLORS = {
|
7
|
-
aqua:
|
8
|
-
cyan:
|
9
|
-
black:
|
10
|
-
blue:
|
11
|
-
brown:
|
12
|
-
magenta:
|
13
|
-
fuchsia:
|
14
|
-
gray:
|
15
|
-
grey:
|
16
|
-
green:
|
17
|
-
lime:
|
18
|
-
navy:
|
19
|
-
orange:
|
20
|
-
pink:
|
21
|
-
purple:
|
22
|
-
red:
|
23
|
-
silver:
|
24
|
-
white:
|
25
|
-
yellow:
|
7
|
+
aqua: 0x0F,
|
8
|
+
cyan: 0x0F,
|
9
|
+
black: 0x08,
|
10
|
+
blue: 0x0C,
|
11
|
+
brown: 0x10,
|
12
|
+
magenta: 0x0E,
|
13
|
+
fuchsia: 0x0E,
|
14
|
+
gray: 0x17,
|
15
|
+
grey: 0x17,
|
16
|
+
green: 0x11,
|
17
|
+
lime: 0x0B,
|
18
|
+
navy: 0x12,
|
19
|
+
orange: 0x35,
|
20
|
+
pink: 0x21,
|
21
|
+
purple: 0x14,
|
22
|
+
red: 0x0A,
|
23
|
+
silver: 0x16,
|
24
|
+
white: 0x09,
|
25
|
+
yellow: 0x0D,
|
26
|
+
automatic: 0x40
|
26
27
|
} # :nodoc:
|
27
28
|
|
28
29
|
###############################################################################
|
data/lib/write_xlsx/format.rb
CHANGED
@@ -584,14 +584,16 @@ module Writexlsx
|
|
584
584
|
if theme == -1
|
585
585
|
# Ignore for excel2003_style
|
586
586
|
elsif ptrue?(theme)
|
587
|
-
write_color(
|
587
|
+
write_color('theme', theme, writer)
|
588
588
|
elsif ptrue?(@color_indexed)
|
589
|
-
write_color(
|
589
|
+
write_color('indexed', @color_indexed, writer)
|
590
590
|
elsif ptrue?(@color)
|
591
591
|
color = worksheet.palette_color(@color)
|
592
|
-
|
592
|
+
if color != 'Automatic'
|
593
|
+
write_color('rgb', color, writer)
|
594
|
+
end
|
593
595
|
elsif !ptrue?(dxf_format)
|
594
|
-
write_color(
|
596
|
+
write_color('theme', 1, writer)
|
595
597
|
end
|
596
598
|
|
597
599
|
unless ptrue?(dxf_format)
|
@@ -607,12 +609,12 @@ module Writexlsx
|
|
607
609
|
writer.empty_tag('sz', [['val', size]])
|
608
610
|
|
609
611
|
if ptrue?(theme)
|
610
|
-
write_color(
|
612
|
+
write_color('theme', theme, writer)
|
611
613
|
elsif ptrue?(@color)
|
612
614
|
color = worksheet.palette_color(@color)
|
613
|
-
write_color(
|
615
|
+
write_color('rgb', color, writer)
|
614
616
|
else
|
615
|
-
write_color(
|
617
|
+
write_color('theme', 1, writer)
|
616
618
|
end
|
617
619
|
|
618
620
|
writer.empty_tag('rFont', [['val', @font]])
|
@@ -57,7 +57,8 @@ module Writexlsx
|
|
57
57
|
# Minor modification to allow comparison testing. Change RGB colors
|
58
58
|
# from long format, ffcc00 to short format fc0 used by VML.
|
59
59
|
def rgb_color(rgb)
|
60
|
-
|
60
|
+
r, g, b = rgb
|
61
|
+
result = sprintf("%02x%02x%02x", r, g, b)
|
61
62
|
result = "#{::Regexp.last_match(1)}#{::Regexp.last_match(2)}#{::Regexp.last_match(3)}" if result =~ /^([0-9a-f])\1([0-9a-f])\2([0-9a-f])\3$/
|
62
63
|
result
|
63
64
|
end
|
@@ -818,9 +818,9 @@ module Writexlsx
|
|
818
818
|
write_cfvo(min_type, min_value)
|
819
819
|
write_cfvo(mid_type, mid_value) if mid_type
|
820
820
|
write_cfvo(max_type, max_value)
|
821
|
-
write_color(
|
822
|
-
write_color(
|
823
|
-
write_color(
|
821
|
+
write_color('rgb', min_color)
|
822
|
+
write_color('rgb', mid_color) if mid_color
|
823
|
+
write_color('rgb', max_color)
|
824
824
|
end
|
825
825
|
end
|
826
826
|
end
|
@@ -844,7 +844,7 @@ module Writexlsx
|
|
844
844
|
write_cfvo(min_type, min_value)
|
845
845
|
write_cfvo(max_type, max_value)
|
846
846
|
|
847
|
-
write_color(
|
847
|
+
write_color('rgb', bar_color)
|
848
848
|
end
|
849
849
|
end
|
850
850
|
|
@@ -59,6 +59,8 @@ module Writexlsx
|
|
59
59
|
def palette_color(index)
|
60
60
|
if index.to_s =~ /^#([0-9A-F]{6})$/i
|
61
61
|
"FF#{::Regexp.last_match(1).upcase}"
|
62
|
+
elsif index == 0x40
|
63
|
+
"Automatic"
|
62
64
|
else
|
63
65
|
"FF#{super(index)}"
|
64
66
|
end
|
@@ -186,15 +188,6 @@ module Writexlsx
|
|
186
188
|
end
|
187
189
|
end
|
188
190
|
|
189
|
-
#
|
190
|
-
# Write the <color> element.
|
191
|
-
#
|
192
|
-
def write_color(name, value)
|
193
|
-
attributes = [[name, value]]
|
194
|
-
|
195
|
-
@writer.empty_tag('color', attributes)
|
196
|
-
end
|
197
|
-
|
198
191
|
#
|
199
192
|
# Write the <fills> element.
|
200
193
|
#
|
@@ -284,10 +277,14 @@ module Writexlsx
|
|
284
277
|
def write_pattern_fill(format, dxf_format)
|
285
278
|
bg_color, fg_color = bg_and_fg_color(format, dxf_format)
|
286
279
|
|
287
|
-
|
280
|
+
if fg_color && fg_color != 0 && fg_color != 0x40 # 'Automatic'
|
281
|
+
@writer.empty_tag('fgColor', [['rgb', palette_color(fg_color)]])
|
282
|
+
end
|
288
283
|
|
289
284
|
if bg_color && bg_color != 0
|
290
|
-
|
285
|
+
if bg_color != 0x40 # 'Automatic'
|
286
|
+
@writer.empty_tag('bgColor', [['rgb', palette_color(bg_color)]])
|
287
|
+
end
|
291
288
|
elsif !dxf_format && format.pattern <= 1
|
292
289
|
@writer.empty_tag('bgColor', [['indexed', 64]])
|
293
290
|
end
|
@@ -390,10 +387,11 @@ module Writexlsx
|
|
390
387
|
attributes = [[:style, BORDER_STYLES[style]]]
|
391
388
|
|
392
389
|
@writer.tag_elements(type, attributes) do
|
393
|
-
if color
|
390
|
+
if [0, 0x40].include?(color) # 'Automatic'
|
394
391
|
@writer.empty_tag('color', [['auto', 1]])
|
395
|
-
|
392
|
+
elsif color != 0 && color != 0x40 # 'Automatic'
|
396
393
|
color = palette_color(color)
|
394
|
+
|
397
395
|
@writer.empty_tag('color', [['rgb', color]])
|
398
396
|
end
|
399
397
|
end
|
data/lib/write_xlsx/utility.rb
CHANGED
@@ -341,7 +341,7 @@ module Writexlsx
|
|
341
341
|
#
|
342
342
|
# Write the <color> element.
|
343
343
|
#
|
344
|
-
def write_color(
|
344
|
+
def write_color(name, value, writer = @writer) # :nodoc:
|
345
345
|
attributes = [[name, value]]
|
346
346
|
|
347
347
|
writer.empty_tag('color', attributes)
|
@@ -751,8 +751,8 @@ module Writexlsx
|
|
751
751
|
# Adjust the colour index.
|
752
752
|
idx = index - 8
|
753
753
|
|
754
|
-
|
755
|
-
sprintf("%02X%02X%02X",
|
754
|
+
r, g, b = @palette[idx]
|
755
|
+
sprintf("%02X%02X%02X", r, g, b)
|
756
756
|
end
|
757
757
|
|
758
758
|
#
|
data/lib/write_xlsx/version.rb
CHANGED
data/lib/write_xlsx/workbook.rb
CHANGED
data/lib/write_xlsx/worksheet.rb
CHANGED
@@ -23,6 +23,7 @@ module Writexlsx
|
|
23
23
|
|
24
24
|
MAX_DIGIT_WIDTH = 7 # For Calabri 11. # :nodoc:
|
25
25
|
PADDING = 5 # :nodoc:
|
26
|
+
COLINFO = Struct.new('ColInfo', :width, :format, :hidden, :level, :collapsed, :autofit)
|
26
27
|
|
27
28
|
attr_reader :index # :nodoc:
|
28
29
|
attr_reader :charts, :images, :tables, :shapes, :drawings # :nodoc:
|
@@ -357,8 +358,7 @@ module Writexlsx
|
|
357
358
|
# Store the column data based on the first column. Padded for sorting.
|
358
359
|
(firstcol..lastcol).each do |col|
|
359
360
|
@col_info[col] =
|
360
|
-
|
361
|
-
.new(width, format, hidden, level, collapsed, autofit)
|
361
|
+
COLINFO.new(width, format, hidden, level, collapsed, autofit)
|
362
362
|
end
|
363
363
|
|
364
364
|
# Store the column change to allow optimisations.
|
@@ -497,8 +497,7 @@ module Writexlsx
|
|
497
497
|
@col_info[col_num].autofit = 1
|
498
498
|
else
|
499
499
|
@col_info[col_num] =
|
500
|
-
|
501
|
-
.new(width, nil, 0, 0, 0, 1)
|
500
|
+
COLINFO.new(width, nil, 0, 0, 0, 1)
|
502
501
|
end
|
503
502
|
end
|
504
503
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: write_xlsx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.11.
|
4
|
+
version: 1.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hideo NAKAMURA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|