caxlsx 3.0.3 → 3.0.4
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/CHANGELOG.md +7 -0
- data/README.md +2 -0
- data/lib/axlsx/util/validators.rb +1 -1
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/worksheet/cell.rb +5 -1
- data/lib/axlsx/workbook/worksheet/data_validation.rb +4 -4
- data/lib/axlsx/workbook/worksheet/worksheet.rb +3 -1
- data/test/util/tc_validators.rb +1 -1
- data/test/workbook/worksheet/tc_cell.rb +7 -0
- data/test/workbook/worksheet/tc_worksheet.rb +16 -18
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1add2e0fe915a49d02b64fe4df1aac62541f75ed27c97d0b418cdea137077c6
|
4
|
+
data.tar.gz: d334797649d8ea1382ff2809359b7455cbde69365ecf798de4a51f0cfce903ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b164b9fe978fbc8866c3dbeea317c50d93c8b6796eeeb3a6b5214e9c11be439034543e1c1caaf9b4ddbf8a23713398a1bb4c6c207107a77b47353e183f59a226
|
7
|
+
data.tar.gz: c3b2eb3c86f0498ce1979bc3898a22baff4ca2e3eb0b9efe4751062fb2cb69ba6b0cfdce72c7366830627b5c912450303abceeb7ca81179781a4f865bd4d8186
|
data/CHANGELOG.md
CHANGED
@@ -3,10 +3,17 @@ CHANGELOG
|
|
3
3
|
|
4
4
|
- **Unreleased**
|
5
5
|
|
6
|
+
- **January.5.21**: 3.0.4
|
7
|
+
- [PR #72](https://github.com/caxlsx/caxlsx/pull/72) - Relax Ruby dependency to allow for Ruby 3. This required Travis to be upgraded from Ubuntu Trusty to Ubuntu Bionic. rbx-3 was dropped.
|
8
|
+
- [PR #71](https://github.com/caxlsx/caxlsx/pull/71) - Adds date type to validator so sheet.add_data_validation works with date type. Addresses [I #26](https://github.com/caxlsx/caxlsx/issues/26) - Date Data Validation not working
|
9
|
+
- [PR #70](https://github.com/caxlsx/caxlsx/pull/70) - Fix worksheet title length enforcement caused by switching from size to bytesize. Addresses [I #67](https://github.com/caxlsx/caxlsx/issues/67) - character length error in worksheet name when using Japanese, which was introduced by addressing [I #588](https://github.com/randym/axlsx/issues/588) in the old Axlsx repo.
|
10
|
+
|
11
|
+
|
6
12
|
- **December.7.20**: 3.0.3
|
7
13
|
- [PR #62](https://github.com/caxlsx/caxlsx/pull/62) - Fix edge cases in format detection for objects whose string representation made them look like numbers but the object didn’t respond to `#to_i` or `#to_f`.
|
8
14
|
- [PR #56](https://github.com/caxlsx/caxlsx/pull/56) - Add `zip_command` option to `#serialize` for faster serialization of large Excel files by using a zip binary
|
9
15
|
- [PR #54](https://github.com/caxlsx/caxlsx/pull/54) - Fix type detection for floats with out-of-rage exponents
|
16
|
+
- [I #67](https://github.com/caxlsx/caxlsx/issues/67) - Fix regression in worksheet name length enforcement: Some unicode characters were counted incorrectly, so that names that previously worked fine now stopped working. (This was introduced in 3.0.2)
|
10
17
|
|
11
18
|
- **July.16.20**: 3.0.2
|
12
19
|
- [I #51](https://github.com/caxlsx/caxlsx/issues/51) - Images do not import on Windows. IO read set explicitly to binary mode.
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Caxlsx (Community Continued Version)
|
2
2
|
[](https://travis-ci.com/caxlsx/caxlsx)
|
3
|
+
[](http://badge.fury.io/rb/caxlsx)
|
3
5
|
|
4
6
|
## Notice: Community Axlsx Organization
|
5
7
|
|
@@ -269,7 +269,7 @@ module Axlsx
|
|
269
269
|
# valid types must be one of custom, data, decimal, list, none, textLength, time, whole
|
270
270
|
# @param [Any] v The value validated
|
271
271
|
def self.validate_data_validation_type(v)
|
272
|
-
RestrictionValidator.validate :data_validation_type, [:custom, :data, :decimal, :list, :none, :textLength, :time, :whole], v
|
272
|
+
RestrictionValidator.validate :data_validation_type, [:custom, :data, :decimal, :list, :none, :textLength, :date, :time, :whole], v
|
273
273
|
end
|
274
274
|
|
275
275
|
# Requires that the value is a valid sheet view type.
|
data/lib/axlsx/version.rb
CHANGED
@@ -475,7 +475,11 @@ module Axlsx
|
|
475
475
|
case type
|
476
476
|
when :date
|
477
477
|
self.style = STYLE_DATE if self.style == 0
|
478
|
-
v
|
478
|
+
if !v.is_a?(Date) && v.respond_to?(:to_date)
|
479
|
+
v.to_date
|
480
|
+
else
|
481
|
+
v
|
482
|
+
end
|
479
483
|
when :time
|
480
484
|
self.style = STYLE_DATE if self.style == 0
|
481
485
|
if !v.is_a?(Time) && v.respond_to?(:to_time)
|
@@ -171,7 +171,7 @@ module Axlsx
|
|
171
171
|
def formula1=(v); Axlsx::validate_string(v); @formula1 = v end
|
172
172
|
|
173
173
|
# @see formula2
|
174
|
-
def formula2=(v); Axlsx::validate_string(v); @formula2 = v end
|
174
|
+
def formula2=(v); Axlsx::validate_string(v); @formula2 = v end
|
175
175
|
|
176
176
|
# @see allowBlank
|
177
177
|
def allowBlank=(v); Axlsx::validate_boolean(v); @allowBlank = v end
|
@@ -216,8 +216,8 @@ module Axlsx
|
|
216
216
|
valid_attributes = get_valid_attributes
|
217
217
|
|
218
218
|
str << '<dataValidation '
|
219
|
-
str << instance_values.map do |key, value|
|
220
|
-
'' << key << '="' << Axlsx.booleanize(value).to_s << '"' if (valid_attributes.include?(key.to_sym) && !CHILD_ELEMENTS.include?(key.to_sym))
|
219
|
+
str << instance_values.map do |key, value|
|
220
|
+
'' << key << '="' << Axlsx.booleanize(value).to_s << '"' if (valid_attributes.include?(key.to_sym) && !CHILD_ELEMENTS.include?(key.to_sym))
|
221
221
|
end.join(' ')
|
222
222
|
str << '>'
|
223
223
|
str << ('<formula1>' << self.formula1 << '</formula1>') if @formula1 and valid_attributes.include?(:formula1)
|
@@ -229,7 +229,7 @@ module Axlsx
|
|
229
229
|
def get_valid_attributes
|
230
230
|
attributes = [:allowBlank, :error, :errorStyle, :errorTitle, :prompt, :promptTitle, :showErrorMessage, :showInputMessage, :sqref, :type ]
|
231
231
|
|
232
|
-
if [:whole, :decimal, :data, :time, :textLength].include?(@type)
|
232
|
+
if [:whole, :decimal, :data, :time, :date, :textLength].include?(@type)
|
233
233
|
attributes << [:operator, :formula1]
|
234
234
|
attributes << [:formula2] if [:between, :notBetween].include?(@operator)
|
235
235
|
elsif @type == :list
|
@@ -663,7 +663,9 @@ module Axlsx
|
|
663
663
|
|
664
664
|
def validate_sheet_name(name)
|
665
665
|
DataTypeValidator.validate :worksheet_name, String, name
|
666
|
-
|
666
|
+
# ignore first character (BOM) after encoding to utf16 because Excel does so, too.
|
667
|
+
character_length = name.encode("utf-16")[1..-1].encode("utf-16").bytesize / 2
|
668
|
+
raise ArgumentError, (ERR_SHEET_NAME_TOO_LONG % name) if character_length > 31
|
667
669
|
raise ArgumentError, (ERR_SHEET_NAME_CHARACTER_FORBIDDEN % name) if '[]*/\?:'.chars.any? { |char| name.include? char }
|
668
670
|
name = Axlsx::coder.encode(name)
|
669
671
|
sheet_names = @workbook.worksheets.reject { |s| s == self }.map { |s| s.name }
|
data/test/util/tc_validators.rb
CHANGED
@@ -127,7 +127,7 @@ class TestValidators < Test::Unit::TestCase
|
|
127
127
|
assert_raise(ArgumentError) { Axlsx.validate_data_validation_error_style 0 }
|
128
128
|
|
129
129
|
#data_validation_type
|
130
|
-
[:custom, :data, :decimal, :list, :none, :textLength, :time, :whole].each do |sym|
|
130
|
+
[:custom, :data, :decimal, :list, :none, :textLength, :date, :time, :whole].each do |sym|
|
131
131
|
assert_nothing_raised { Axlsx.validate_data_validation_type sym }
|
132
132
|
end
|
133
133
|
assert_raise(ArgumentError) { Axlsx.validate_data_validation_error_style :other_symbol }
|
@@ -71,6 +71,13 @@ class TestCell < Test::Unit::TestCase
|
|
71
71
|
assert_equal(@c.value, now.to_time)
|
72
72
|
end
|
73
73
|
|
74
|
+
def test_date
|
75
|
+
@c.type = :date
|
76
|
+
now = Time.now
|
77
|
+
@c.value = now
|
78
|
+
assert_equal(@c.value, now.to_date)
|
79
|
+
end
|
80
|
+
|
74
81
|
def test_style
|
75
82
|
assert_raise(ArgumentError, "must reject invalid style indexes") { @c.style=@c.row.worksheet.workbook.styles.cellXfs.size }
|
76
83
|
assert_nothing_raised("must allow valid style index changes") {@c.style=1}
|
@@ -29,15 +29,28 @@ class TestWorksheet < Test::Unit::TestCase
|
|
29
29
|
assert_raises(ArgumentError) { @ws.name = 'foo?bar' }
|
30
30
|
end
|
31
31
|
|
32
|
+
def test_name_unique
|
33
|
+
assert_raise(ArgumentError, "worksheet name must be unique") { n = @ws.name; @ws.workbook.add_worksheet(:name=> n) }
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_name_unique_only_checks_other_worksheet_names
|
37
|
+
assert_nothing_raised { @ws.name = @ws.name }
|
38
|
+
assert_nothing_raised { Axlsx::Package.new.workbook.add_worksheet :name => 'Sheet1' }
|
39
|
+
end
|
40
|
+
|
32
41
|
def test_exception_if_name_too_long
|
33
42
|
assert_nothing_raised { @ws.name = 'x' * 31 }
|
34
43
|
assert_raises(ArgumentError) { @ws.name = 'x' * 32 }
|
35
44
|
end
|
36
45
|
|
37
46
|
def test_exception_if_name_too_long_because_of_multibyte_characters
|
38
|
-
|
39
|
-
|
40
|
-
|
47
|
+
four_characters_for_excel = "\u{1F1EB 1F1F7}" # french flag emoji
|
48
|
+
assert_raises(ArgumentError, "name too long!") do
|
49
|
+
@ws.name = four_characters_for_excel + "x" * 28
|
50
|
+
end
|
51
|
+
assert_nothing_raised { @ws.name = "#{four_characters_for_excel}123456789012345678901234567" }
|
52
|
+
assert_nothing_raised { @ws.name = "123456789012345678901234567890…" }
|
53
|
+
assert_nothing_raised { @ws.name = "123456789012345678901234567890✔" }
|
41
54
|
end
|
42
55
|
|
43
56
|
def test_page_margins
|
@@ -460,21 +473,6 @@ class TestWorksheet < Test::Unit::TestCase
|
|
460
473
|
assert_equal(@ws.relationships.size, 4, "adding a pivot table adds 1 relationship")
|
461
474
|
end
|
462
475
|
|
463
|
-
|
464
|
-
def test_name_unique
|
465
|
-
assert_raise(ArgumentError, "worksheet name must be unique") { n = @ws.name; @ws.workbook.add_worksheet(:name=> n) }
|
466
|
-
end
|
467
|
-
|
468
|
-
def test_name_unique_only_checks_other_worksheet_names
|
469
|
-
assert_nothing_raised { @ws.name = @ws.name }
|
470
|
-
assert_nothing_raised { Axlsx::Package.new.workbook.add_worksheet :name => 'Sheet1' }
|
471
|
-
end
|
472
|
-
|
473
|
-
def test_name_size
|
474
|
-
assert_raise(ArgumentError, "name too long!") { @ws.name = Array.new(32, "A").join() }
|
475
|
-
assert_nothing_raised { @ws.name = Array.new(31, "A").join() }
|
476
|
-
end
|
477
|
-
|
478
476
|
def test_set_fixed_width_column
|
479
477
|
@ws.add_row ["mule", "donkey", "horse"], :widths => [20, :ignore, nil]
|
480
478
|
assert(@ws.column_info.size == 3, "a data item for each column")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caxlsx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Randy Morgan
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-01-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -458,7 +458,7 @@ require_paths:
|
|
458
458
|
- lib
|
459
459
|
required_ruby_version: !ruby/object:Gem::Requirement
|
460
460
|
requirements:
|
461
|
-
- - "
|
461
|
+
- - ">="
|
462
462
|
- !ruby/object:Gem::Version
|
463
463
|
version: '2.3'
|
464
464
|
required_rubygems_version: !ruby/object:Gem::Requirement
|