write_xlsx 0.85.8 → 0.85.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changes +3 -0
- data/lib/write_xlsx/chart.rb +1 -1
- data/lib/write_xlsx/package/conditional_format.rb +2 -2
- data/lib/write_xlsx/package/shared_strings.rb +12 -10
- data/lib/write_xlsx/package/styles.rb +1 -1
- data/lib/write_xlsx/package/xml_writer_simple.rb +2 -2
- data/lib/write_xlsx/utility.rb +1 -1
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/workbook.rb +1 -1
- data/lib/write_xlsx/worksheet.rb +6 -6
- data/lib/write_xlsx/worksheet/data_validation.rb +1 -1
- data/test/run_test.rb +9 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee225c252867f895e976e92e0cf2d1fa0617c8d1ab08277dced0f8c53037f0ae
|
4
|
+
data.tar.gz: 846527548749de579fc47f7cdd0df9826032fcb1b15cd500c441e6ffd339c3fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89fe866dcb96df87a917ddf9ef666d5583c5ece4c20424020fffbf55a648e1cbc8fa9cd6c6acd25e979528108c653414879fd020533e20740f7024c1a4678e69
|
7
|
+
data.tar.gz: e065e79287b82fe2b423cf119c008d92dc4c7f982acf1d98a4feb3da1d1ead8d8f8a8cc3c40e62162cf6315408875806366eeb6b058cd65f64197492cf0fe0bb
|
data/Changes
CHANGED
data/lib/write_xlsx/chart.rb
CHANGED
@@ -2631,7 +2631,7 @@ def write_custom_error_base(tag, values, data)
|
|
2631
2631
|
end
|
2632
2632
|
|
2633
2633
|
def write_num_ref_or_lit(values, data)
|
2634
|
-
if values =~ /^=/ # '=Sheet1!$A$1:$A$5'
|
2634
|
+
if values.to_s =~ /^=/ # '=Sheet1!$A$1:$A$5'
|
2635
2635
|
write_num_ref(values, data, 'num')
|
2636
2636
|
else # [1, 2, 3]
|
2637
2637
|
write_num_lit(values)
|
@@ -306,7 +306,7 @@ def range_start_cell_for_conditional_formatting(*args) # :nodoc:
|
|
306
306
|
|
307
307
|
def row_col_param_for_conditional_formatting(*args)
|
308
308
|
# Check for a cell reference in A1 notation and substitute row and column
|
309
|
-
if args[0] =~ /^\D/
|
309
|
+
if args[0].to_s =~ /^\D/
|
310
310
|
# Check for a user defined multiple range like B3:K6,B8:K11.
|
311
311
|
user_range = args[0].sub(/^=/, '').gsub(/\s*,\s*/, ' ').gsub(/\$/, '') if args[0] =~ /,/
|
312
312
|
end
|
@@ -383,7 +383,7 @@ def check_conditional_formatting_parameters(param) # :nodoc:
|
|
383
383
|
end
|
384
384
|
|
385
385
|
def convert_date_time_if_required(val)
|
386
|
-
if val =~ /T/
|
386
|
+
if val.to_s =~ /T/
|
387
387
|
date_time = convert_date_time(val)
|
388
388
|
raise "Invalid date/time value '#{val}' in conditional_formatting()" unless date_time
|
389
389
|
date_time
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
require 'write_xlsx/package/xml_writer_simple'
|
3
4
|
require 'write_xlsx/utility'
|
4
5
|
|
@@ -8,11 +9,13 @@ class SharedStrings
|
|
8
9
|
|
9
10
|
include Writexlsx::Utility
|
10
11
|
|
12
|
+
PRESERVE_SPACE_ATTRIBUTES = ['xml:space', 'preserve'].freeze
|
13
|
+
|
11
14
|
def initialize
|
12
15
|
@writer = Package::XMLWriterSimple.new
|
13
16
|
@strings = [] # string table
|
14
17
|
@strings_index = {} # string table index
|
15
|
-
@count =
|
18
|
+
@count = 0 # count
|
16
19
|
end
|
17
20
|
|
18
21
|
def index(string, params = {})
|
@@ -21,18 +24,18 @@ def index(string, params = {})
|
|
21
24
|
end
|
22
25
|
|
23
26
|
def add(string)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
27
|
+
unless @strings_index[string]
|
28
|
+
# Only first time the string will be append to list
|
29
|
+
# next time we only check and not #dup it
|
30
|
+
str = string.dup.freeze
|
28
31
|
@strings << str
|
29
32
|
@strings_index[str] = @strings.size - 1
|
30
|
-
@count[str] = 1
|
31
33
|
end
|
34
|
+
@count += 1
|
32
35
|
end
|
33
36
|
|
34
37
|
def string(index)
|
35
|
-
@strings[index]
|
38
|
+
@strings[index]
|
36
39
|
end
|
37
40
|
|
38
41
|
def empty?
|
@@ -79,7 +82,6 @@ def write_sst_strings
|
|
79
82
|
# Write the <si> element.
|
80
83
|
#
|
81
84
|
def write_si(string)
|
82
|
-
string = string.dup
|
83
85
|
attributes = []
|
84
86
|
|
85
87
|
# Excel escapes control characters with _xHHHH_ and also escapes any
|
@@ -102,7 +104,7 @@ def write_si(string)
|
|
102
104
|
end
|
103
105
|
|
104
106
|
# Add attribute to preserve leading or trailing whitespace.
|
105
|
-
attributes <<
|
107
|
+
attributes << PRESERVE_SPACE_ATTRIBUTES if string =~ /\A\s|\s\Z/
|
106
108
|
|
107
109
|
# Write any rich strings without further tags.
|
108
110
|
if string =~ %r{^<r>} && string =~ %r{</r>$}
|
@@ -122,7 +124,7 @@ def add_c2_c3(string)
|
|
122
124
|
end
|
123
125
|
|
124
126
|
def total_count
|
125
|
-
@count
|
127
|
+
@count
|
126
128
|
end
|
127
129
|
|
128
130
|
def unique_count
|
@@ -49,7 +49,7 @@ def set_style_properties(xf_formats, palette, font_count, num_format_count, bord
|
|
49
49
|
# based on the default or user defined values in the Workbook palette.
|
50
50
|
#
|
51
51
|
def palette_color(index)
|
52
|
-
if index =~ /^#([0-9A-F]{6})$/i
|
52
|
+
if index.to_s =~ /^#([0-9A-F]{6})$/i
|
53
53
|
"FF#{$1.upcase}"
|
54
54
|
else
|
55
55
|
"FF#{super(index)}"
|
@@ -118,7 +118,7 @@ def key_vals(attribute)
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def escape_attributes(str = '')
|
121
|
-
return str if !(str =~ /["&<>]/)
|
121
|
+
return str if !(str.to_s =~ /["&<>]/)
|
122
122
|
|
123
123
|
str.
|
124
124
|
gsub(/&/, "&").
|
@@ -128,7 +128,7 @@ def escape_attributes(str = '')
|
|
128
128
|
end
|
129
129
|
|
130
130
|
def escape_data(str = '')
|
131
|
-
if str =~ /[&<>]/
|
131
|
+
if str.to_s =~ /[&<>]/
|
132
132
|
str.gsub(/&/, '&').
|
133
133
|
gsub(/</, '<').
|
134
134
|
gsub(/>/, '>')
|
data/lib/write_xlsx/utility.rb
CHANGED
@@ -244,7 +244,7 @@ def put_deprecate_message(method)
|
|
244
244
|
|
245
245
|
# Check for a cell reference in A1 notation and substitute row and column
|
246
246
|
def row_col_notation(args) # :nodoc:
|
247
|
-
if args[0] =~ /^\D/
|
247
|
+
if args[0].to_s =~ /^\D/
|
248
248
|
substitute_cellref(*args)
|
249
249
|
else
|
250
250
|
args
|
data/lib/write_xlsx/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
WriteXLSX_VERSION = "0.85.
|
1
|
+
WriteXLSX_VERSION = "0.85.9"
|
data/lib/write_xlsx/workbook.rb
CHANGED
@@ -927,7 +927,7 @@ def set_calc_mode(mode, calc_id = nil)
|
|
927
927
|
#
|
928
928
|
def set_custom_color(index, red = 0, green = 0, blue = 0)
|
929
929
|
# Match a HTML #xxyyzz style parameter
|
930
|
-
if red =~ /^#(\w\w)(\w\w)(\w\w)/
|
930
|
+
if red.to_s =~ /^#(\w\w)(\w\w)(\w\w)/
|
931
931
|
red = $1.hex
|
932
932
|
green = $2.hex
|
933
933
|
blue = $3.hex
|
data/lib/write_xlsx/worksheet.rb
CHANGED
@@ -721,7 +721,7 @@ def protect_default_settings # :nodoc:
|
|
721
721
|
#
|
722
722
|
def set_column(*args)
|
723
723
|
# Check for a cell reference in A1 notation and substitute row and column
|
724
|
-
if args[0] =~ /^\D/
|
724
|
+
if args[0].to_s =~ /^\D/
|
725
725
|
row1, firstcol, row2, lastcol, *data = substitute_cellref(*args)
|
726
726
|
else
|
727
727
|
firstcol, lastcol, *data = args
|
@@ -5811,7 +5811,7 @@ def excel2003_style? # :nodoc:
|
|
5811
5811
|
# based on the default or user defined values in the Workbook palette.
|
5812
5812
|
#
|
5813
5813
|
def palette_color(index) #:nodoc:
|
5814
|
-
if index =~ /^#([0-9A-F]{6})$/i
|
5814
|
+
if index.to_s =~ /^#([0-9A-F]{6})$/i
|
5815
5815
|
"FF#{$1.upcase}"
|
5816
5816
|
else
|
5817
5817
|
"FF#{super(index)}"
|
@@ -6100,7 +6100,7 @@ def parse_filter_tokens(expression, tokens) #:nodoc:
|
|
6100
6100
|
# Special handling of "Top" filter expressions.
|
6101
6101
|
if tokens[0] =~ /^top|bottom$/i
|
6102
6102
|
value = tokens[1]
|
6103
|
-
if (value =~ /\D/ or value.to_i < 1 or value.to_i > 500)
|
6103
|
+
if (value.to_s =~ /\D/ or value.to_i < 1 or value.to_i > 500)
|
6104
6104
|
raise "The value '#{value}' in expression '#{expression}' " +
|
6105
6105
|
"must be in the range 1 to 500"
|
6106
6106
|
end
|
@@ -6129,7 +6129,7 @@ def parse_filter_tokens(expression, tokens) #:nodoc:
|
|
6129
6129
|
end
|
6130
6130
|
|
6131
6131
|
# Special handling for Blanks/NonBlanks.
|
6132
|
-
if (token =~ /^blanks|nonblanks$/i)
|
6132
|
+
if (token.to_s =~ /^blanks|nonblanks$/i)
|
6133
6133
|
# Only allow Equals or NotEqual in this context.
|
6134
6134
|
if (operator != 2 and operator != 5)
|
6135
6135
|
raise "The operator '#{tokens[1]}' in expression '#{expression}' " +
|
@@ -6157,7 +6157,7 @@ def parse_filter_tokens(expression, tokens) #:nodoc:
|
|
6157
6157
|
|
6158
6158
|
# if the string token contains an Excel match character then change the
|
6159
6159
|
# operator type to indicate a non "simple" equality.
|
6160
|
-
if (operator == 2 and token =~ /[*?]/)
|
6160
|
+
if (operator == 2 and token.to_s =~ /[*?]/)
|
6161
6161
|
operator = 22
|
6162
6162
|
end
|
6163
6163
|
|
@@ -7635,7 +7635,7 @@ def set_active_pane_and_cell_selections(row, col, top_row, left_col, active_cell
|
|
7635
7635
|
|
7636
7636
|
def prepare_filter_column(col) # :nodoc:
|
7637
7637
|
# Check for a column reference in A1 notation and substitute.
|
7638
|
-
if col =~ /^\D/
|
7638
|
+
if col.to_s =~ /^\D/
|
7639
7639
|
col_letter = col
|
7640
7640
|
|
7641
7641
|
# Convert col ref to a cell ref and then to a col number.
|
@@ -282,7 +282,7 @@ def valid_criteria_type # :nodoc:
|
|
282
282
|
|
283
283
|
def convert_date_time_value(key) # :nodoc:
|
284
284
|
value = instance_variable_get("@#{key}")
|
285
|
-
if value && value =~ /T/
|
285
|
+
if value && value.to_s =~ /T/
|
286
286
|
date_time = convert_date_time(value)
|
287
287
|
instance_variable_set("@#{key}", date_time) if date_time
|
288
288
|
date_time
|
data/test/run_test.rb
ADDED
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: 0.85.
|
4
|
+
version: 0.85.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hideo NAKAMURA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -1578,6 +1578,7 @@ files:
|
|
1578
1578
|
- test/regression/xlsx_files/vml03.xlsx
|
1579
1579
|
- test/regression/xlsx_files/vml04.xlsx
|
1580
1580
|
- test/republic.png
|
1581
|
+
- test/run_test.rb
|
1581
1582
|
- test/test_col_name.rb
|
1582
1583
|
- test/test_delete_files.rb
|
1583
1584
|
- test/test_example_match.rb
|
@@ -3089,6 +3090,7 @@ test_files:
|
|
3089
3090
|
- test/regression/xlsx_files/vml03.xlsx
|
3090
3091
|
- test/regression/xlsx_files/vml04.xlsx
|
3091
3092
|
- test/republic.png
|
3093
|
+
- test/run_test.rb
|
3092
3094
|
- test/test_col_name.rb
|
3093
3095
|
- test/test_delete_files.rb
|
3094
3096
|
- test/test_example_match.rb
|