caxlsx 3.0.2 → 3.0.3
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 +5 -5
- data/CHANGELOG.md +7 -0
- data/examples/{image1.jpeg → assets/image1.jpeg} +0 -0
- data/examples/generate.rb +15 -0
- data/lib/axlsx.rb +1 -0
- data/lib/axlsx/drawing/pie_series.rb +1 -1
- data/lib/axlsx/package.rb +17 -4
- data/lib/axlsx/util/constants.rb +2 -1
- data/lib/axlsx/util/zip_command.rb +73 -0
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/worksheet/cell.rb +4 -2
- data/test/drawing/tc_drawing.rb +2 -2
- data/test/drawing/tc_hyperlink.rb +1 -1
- data/test/drawing/tc_one_cell_anchor.rb +1 -1
- data/test/drawing/tc_pic.rb +4 -4
- data/test/drawing/tc_pie_series.rb +2 -1
- data/test/fixtures/image1.gif +0 -0
- data/test/fixtures/image1.jpeg +0 -0
- data/test/fixtures/image1.jpg +0 -0
- data/test/fixtures/image1.png +0 -0
- data/test/fixtures/image1_fake.jpg +0 -0
- data/test/tc_package.rb +29 -12
- data/test/util/tc_mime_type_utils.rb +1 -1
- data/test/workbook/worksheet/tc_cell.rb +31 -0
- metadata +18 -39
- data/examples/2010_comments.rb +0 -17
- data/examples/anchor_swapping.rb +0 -28
- data/examples/auto_filter.rb +0 -25
- data/examples/basic_charts.rb +0 -58
- data/examples/chart_colors.rb +0 -88
- data/examples/colored_links.rb +0 -45
- data/examples/conditional_formatting/example_conditional_formatting.rb +0 -89
- data/examples/conditional_formatting/getting_barred.rb +0 -37
- data/examples/conditional_formatting/hitting_the_high_notes.rb +0 -37
- data/examples/conditional_formatting/scaled_colors.rb +0 -39
- data/examples/conditional_formatting/stop_and_go.rb +0 -37
- data/examples/data_validation.rb +0 -67
- data/examples/example.rb +0 -900
- data/examples/extractive.rb +0 -45
- data/examples/ios_preview.rb +0 -14
- data/examples/merge_cells.rb +0 -17
- data/examples/no_grid_with_borders.rb +0 -18
- data/examples/page_setup.rb +0 -11
- data/examples/pivot_table.rb +0 -39
- data/examples/pivot_test.rb +0 -63
- data/examples/sheet_protection.rb +0 -10
- data/examples/skydrive/real_example.rb +0 -63
- data/examples/split.rb +0 -16
- data/examples/styles.rb +0 -66
- data/examples/underline.rb +0 -13
- data/examples/wrap_text.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 49062d90fcd29bac6406a90ad46894a3b0624b2a5c391d8fc24a4b35f4c7a0b3
|
4
|
+
data.tar.gz: 18fbd2886127ae59169c94ce4b7025adf78bb15651dba590d1f2955a2e276940
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5be713d4ea7daa76c58bbb648d37a146b094ea2cb9a132e3f02e58a536b20551aabef73513d4f1f619eb29c54294d02ec758f1fd959a50edbd4be565b368ade
|
7
|
+
data.tar.gz: 8a58ee22d90bdd99a3b0a85c59441f926c15f5ce66fdcb6ec2bb969380ba5e2c12458ab16e97cc67291b69d9e4633d102385662733de130aa2cd7bb06e693130
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
---------
|
3
3
|
|
4
|
+
- **Unreleased**
|
5
|
+
|
6
|
+
- **December.7.20**: 3.0.3
|
7
|
+
- [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
|
+
- [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
|
+
- [PR #54](https://github.com/caxlsx/caxlsx/pull/54) - Fix type detection for floats with out-of-rage exponents
|
10
|
+
|
4
11
|
- **July.16.20**: 3.0.2
|
5
12
|
- [I #51](https://github.com/caxlsx/caxlsx/issues/51) - Images do not import on Windows. IO read set explicitly to binary mode.
|
6
13
|
- [PR #53](https://github.com/caxlsx/caxlsx/pull/53) - Limit column width to 255. Maximum column width limit in MS Excel is 255 characters, see https://support.microsoft.com/en-us/office/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
files = if !ARGV.empty?
|
4
|
+
ARGV.select { |file| File.exist?(file) }
|
5
|
+
else
|
6
|
+
Dir['*_example.md']
|
7
|
+
end
|
8
|
+
|
9
|
+
files.each do |file|
|
10
|
+
puts "Executing #{file.split('.')[0].tr('_', ' ')}"
|
11
|
+
code = File.read(file).match(/```ruby(?<code>.+)```/m)[:code]
|
12
|
+
unless code.nil?
|
13
|
+
eval(['$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"', code].join("\n"))
|
14
|
+
end
|
15
|
+
end
|
data/lib/axlsx.rb
CHANGED
@@ -47,7 +47,7 @@ module Axlsx
|
|
47
47
|
# @return [String]
|
48
48
|
def to_xml_string(str = '')
|
49
49
|
super(str) do
|
50
|
-
str << '<c:explosion val="' + @explosion + '"/>' unless @explosion.nil?
|
50
|
+
str << '<c:explosion val="' + @explosion.to_s + '"/>' unless @explosion.nil?
|
51
51
|
colors.each_with_index do |c, index|
|
52
52
|
str << '<c:dPt>'
|
53
53
|
str << ('<c:idx val="' << index.to_s << '"/>')
|
data/lib/axlsx/package.rb
CHANGED
@@ -75,6 +75,9 @@ module Axlsx
|
|
75
75
|
#
|
76
76
|
# @param [String] output The name of the file you want to serialize your package to
|
77
77
|
# @param [Boolean] confirm_valid Validate the package prior to serialization.
|
78
|
+
# @param [String, nil] zip_command When `nil`, `#serialize` with RubyZip to
|
79
|
+
# zip the XLSX file contents. When a String, the provided zip command (e.g.,
|
80
|
+
# "zip") is used to zip the file contents (may be faster for large files)
|
78
81
|
# @return [Boolean] False if confirm_valid and validation errors exist. True if the package was serialized
|
79
82
|
# @note A tremendous amount of effort has gone into ensuring that you cannot create invalid xlsx documents.
|
80
83
|
# confirm_valid should be used in the rare case that you cannot open the serialized file.
|
@@ -88,13 +91,23 @@ module Axlsx
|
|
88
91
|
# # ......add cool stuff to your workbook......
|
89
92
|
# p.serialize("example.xlsx")
|
90
93
|
#
|
94
|
+
# # Serialize to a file, using a system zip binary
|
95
|
+
# p.serialize("example.xlsx", false, zip_command: "zip")
|
96
|
+
# p.serialize("example.xlsx", false, zip_command: "/path/to/zip")
|
97
|
+
# p.serialize("example.xlsx", false, zip_command: "zip -1")
|
98
|
+
#
|
91
99
|
# # Serialize to a stream
|
92
100
|
# s = p.to_stream()
|
93
101
|
# File.open('example_streamed.xlsx', 'w') { |f| f.write(s.read) }
|
94
|
-
def serialize(output, confirm_valid=false)
|
102
|
+
def serialize(output, confirm_valid=false, zip_command: nil)
|
95
103
|
return false unless !confirm_valid || self.validate.empty?
|
104
|
+
zip_provider = if zip_command
|
105
|
+
ZipCommand.new(zip_command)
|
106
|
+
else
|
107
|
+
Zip::OutputStream
|
108
|
+
end
|
96
109
|
Relationship.initialize_ids_cache
|
97
|
-
|
110
|
+
zip_provider.open(output) do |zip|
|
98
111
|
write_parts(zip)
|
99
112
|
end
|
100
113
|
true
|
@@ -153,8 +166,8 @@ module Axlsx
|
|
153
166
|
private
|
154
167
|
|
155
168
|
# Writes the package parts to a zip archive.
|
156
|
-
# @param [Zip::OutputStream] zip
|
157
|
-
# @return [Zip::OutputStream]
|
169
|
+
# @param [Zip::OutputStream, ZipCommand] zip
|
170
|
+
# @return [Zip::OutputStream, ZipCommand]
|
158
171
|
def write_parts(zip)
|
159
172
|
p = parts
|
160
173
|
p.each do |part|
|
data/lib/axlsx/util/constants.rb
CHANGED
@@ -393,7 +393,8 @@ module Axlsx
|
|
393
393
|
ISO_8601_REGEX = /\A(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[0-1]|0[1-9]|[1-2][0-9])T(2[0-3]|[0-1][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?(Z|[+-](?:2[0-3]|[0-1][0-9]):[0-5][0-9])?\Z/.freeze
|
394
394
|
|
395
395
|
# FLOAT recognition
|
396
|
-
|
396
|
+
SAFE_FLOAT_REGEX = /\A[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]{1,2})?\Z/.freeze
|
397
|
+
MAYBE_FLOAT_REGEX = /\A[-+]?[0-9]*\.?[0-9]+[eE](?<exp>[-+]?[0-9]{3})\Z/.freeze
|
397
398
|
|
398
399
|
# Numeric recognition
|
399
400
|
NUMERIC_REGEX = /\A[+-]?\d+?\Z/.freeze
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'open3'
|
3
|
+
require 'shellwords'
|
4
|
+
|
5
|
+
module Axlsx
|
6
|
+
|
7
|
+
# The ZipCommand class supports zipping the Excel file contents using
|
8
|
+
# a binary zip program instead of RubyZip's `Zip::OutputStream`.
|
9
|
+
#
|
10
|
+
# The methods provided here mimic `Zip::OutputStream` so that `ZipCommand` can
|
11
|
+
# be used as a drop-in replacement. Note that method signatures are not
|
12
|
+
# identical to `Zip::OutputStream`, they are only sufficiently close so that
|
13
|
+
# `ZipCommand` and `Zip::OutputStream` can be interchangeably used within
|
14
|
+
# `caxlsx`.
|
15
|
+
class ZipCommand
|
16
|
+
# Raised when the zip command exits with a non-zero status.
|
17
|
+
class ZipError < StandardError; end
|
18
|
+
|
19
|
+
def initialize(zip_command)
|
20
|
+
@current_file = nil
|
21
|
+
@files = []
|
22
|
+
@zip_command = zip_command
|
23
|
+
end
|
24
|
+
|
25
|
+
# Create a temporary directory for writing files to.
|
26
|
+
#
|
27
|
+
# The directory and its contents are removed at the end of the block.
|
28
|
+
def open(output, &block)
|
29
|
+
Dir.mktmpdir do |dir|
|
30
|
+
@dir = dir
|
31
|
+
block.call(self)
|
32
|
+
write_file
|
33
|
+
zip_parts(output)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Closes the current entry and opens a new for writing.
|
38
|
+
def put_next_entry(entry)
|
39
|
+
write_file
|
40
|
+
@current_file = "#{@dir}/#{entry.name}"
|
41
|
+
@files << entry.name
|
42
|
+
FileUtils.mkdir_p(File.dirname(@current_file))
|
43
|
+
end
|
44
|
+
|
45
|
+
# Write to a buffer that will be written to the current entry
|
46
|
+
def write(content)
|
47
|
+
@buffer << content
|
48
|
+
end
|
49
|
+
alias << write
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def write_file
|
54
|
+
if @current_file
|
55
|
+
@buffer.rewind
|
56
|
+
File.open(@current_file, "wb") { |f| f.write @buffer.read }
|
57
|
+
end
|
58
|
+
@current_file = nil
|
59
|
+
@buffer = StringIO.new
|
60
|
+
end
|
61
|
+
|
62
|
+
def zip_parts(output)
|
63
|
+
output = Shellwords.shellescape(File.absolute_path(output))
|
64
|
+
inputs = Shellwords.shelljoin(@files)
|
65
|
+
escaped_dir = Shellwords.shellescape(@dir)
|
66
|
+
command = "cd #{escaped_dir} && #{@zip_command} #{output} #{inputs}"
|
67
|
+
stdout_and_stderr, status = Open3.capture2e(command)
|
68
|
+
if !status.success?
|
69
|
+
raise(ZipError.new(stdout_and_stderr))
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/lib/axlsx/version.rb
CHANGED
@@ -451,9 +451,11 @@ module Axlsx
|
|
451
451
|
:time
|
452
452
|
elsif v.is_a?(TrueClass) || v.is_a?(FalseClass)
|
453
453
|
:boolean
|
454
|
-
elsif v.to_s =~ Axlsx::NUMERIC_REGEX
|
454
|
+
elsif v.to_s =~ Axlsx::NUMERIC_REGEX && v.respond_to?(:to_i)
|
455
455
|
:integer
|
456
|
-
elsif v.to_s =~ Axlsx::
|
456
|
+
elsif v.to_s =~ Axlsx::SAFE_FLOAT_REGEX && v.respond_to?(:to_f)
|
457
|
+
:float
|
458
|
+
elsif (matchdata = v.to_s.match(MAYBE_FLOAT_REGEX)) && (Float::MIN_10_EXP..Float::MAX_10_EXP).cover?(matchdata[:exp].to_i) && v.respond_to?(:to_f)
|
457
459
|
:float
|
458
460
|
elsif v.to_s =~ Axlsx::ISO_8601_REGEX
|
459
461
|
:iso_8601
|
data/test/drawing/tc_drawing.rb
CHANGED
@@ -23,7 +23,7 @@ class TestDrawing < Test::Unit::TestCase
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_add_image
|
26
|
-
src = File.dirname(__FILE__) + "
|
26
|
+
src = File.dirname(__FILE__) + "/../fixtures/image1.jpeg"
|
27
27
|
image = @ws.add_image(:image_src => src, :start_at=>[0,0], :width=>600, :height=>400)
|
28
28
|
assert(@ws.drawing.anchors.last.is_a?(Axlsx::OneCellAnchor))
|
29
29
|
assert(image.is_a?(Axlsx::Pic))
|
@@ -31,7 +31,7 @@ class TestDrawing < Test::Unit::TestCase
|
|
31
31
|
assert_equal(400, image.height)
|
32
32
|
end
|
33
33
|
def test_add_two_cell_anchor_image
|
34
|
-
src = File.dirname(__FILE__) + "
|
34
|
+
src = File.dirname(__FILE__) + "/../fixtures/image1.jpeg"
|
35
35
|
image = @ws.add_image(:image_src => src, :start_at=>[0,0], :end_at => [15,0])
|
36
36
|
assert(@ws.drawing.anchors.last.is_a?(Axlsx::TwoCellAnchor))
|
37
37
|
assert(image.is_a?(Axlsx::Pic))
|
@@ -5,7 +5,7 @@ class TestHyperlink < Test::Unit::TestCase
|
|
5
5
|
def setup
|
6
6
|
@p = Axlsx::Package.new
|
7
7
|
ws = @p.workbook.add_worksheet
|
8
|
-
@test_img = File.dirname(__FILE__) + "
|
8
|
+
@test_img = File.dirname(__FILE__) + "/../fixtures/image1.jpeg"
|
9
9
|
@image = ws.add_image :image_src => @test_img, :hyperlink => "http://axlsx.blogspot.com"
|
10
10
|
@hyperlink = @image.hyperlink
|
11
11
|
end
|
@@ -5,7 +5,7 @@ class TestOneCellAnchor < Test::Unit::TestCase
|
|
5
5
|
def setup
|
6
6
|
@p = Axlsx::Package.new
|
7
7
|
@ws = @p.workbook.add_worksheet
|
8
|
-
@test_img = File.dirname(__FILE__) + "
|
8
|
+
@test_img = File.dirname(__FILE__) + "/../fixtures/image1.jpeg"
|
9
9
|
@image = @ws.add_image :image_src => @test_img
|
10
10
|
@anchor = @image.anchor
|
11
11
|
end
|
data/test/drawing/tc_pic.rb
CHANGED
@@ -5,10 +5,10 @@ class TestPic < Test::Unit::TestCase
|
|
5
5
|
def setup
|
6
6
|
@p = Axlsx::Package.new
|
7
7
|
ws = @p.workbook.add_worksheet
|
8
|
-
@test_img = @test_img_jpg = File.dirname(__FILE__) + "
|
9
|
-
@test_img_png = File.dirname(__FILE__) + "
|
10
|
-
@test_img_gif = File.dirname(__FILE__) + "
|
11
|
-
@test_img_fake = File.dirname(__FILE__) + "
|
8
|
+
@test_img = @test_img_jpg = File.dirname(__FILE__) + "/../fixtures/image1.jpeg"
|
9
|
+
@test_img_png = File.dirname(__FILE__) + "/../fixtures/image1.png"
|
10
|
+
@test_img_gif = File.dirname(__FILE__) + "/../fixtures/image1.gif"
|
11
|
+
@test_img_fake = File.dirname(__FILE__) + "/../fixtures/image1_fake.jpg"
|
12
12
|
@image = ws.add_image :image_src => @test_img, :hyperlink => 'https://github.com/randym', :tooltip => "What's up doc?", :opacity => 5
|
13
13
|
end
|
14
14
|
|
@@ -20,12 +20,13 @@ class TestPieSeries < Test::Unit::TestCase
|
|
20
20
|
assert_raise(ArgumentError, "require valid explosion") { @series.explosion = :lots }
|
21
21
|
assert_nothing_raised("allow valid explosion") { @series.explosion = 20 }
|
22
22
|
assert(@series.explosion == 20)
|
23
|
+
# issue 58 - explosion caused to_xml_string to fail - now tested
|
24
|
+
assert_nothing_raised("allow to_xml_string") { @series.to_xml_string }
|
23
25
|
end
|
24
26
|
|
25
27
|
def test_to_xml_string
|
26
28
|
doc = Nokogiri::XML(@series.to_xml_string)
|
27
29
|
assert(doc.xpath("//srgbClr[@val='#{@series.colors[0]}']"))
|
28
|
-
|
29
30
|
end
|
30
31
|
#TODO test unique serialization parts
|
31
32
|
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
File without changes
|
data/test/tc_package.rb
CHANGED
@@ -65,7 +65,7 @@ class TestPackage < Test::Unit::TestCase
|
|
65
65
|
end
|
66
66
|
|
67
67
|
@fname = 'axlsx_test_serialization.xlsx'
|
68
|
-
img = File.expand_path('
|
68
|
+
img = File.expand_path('../fixtures/image1.jpeg', __FILE__)
|
69
69
|
ws.add_image(:image_src => img, :noSelect => true, :noMove => true, :hyperlink=>"http://axlsx.blogspot.com") do |image|
|
70
70
|
image.width=720
|
71
71
|
image.height=666
|
@@ -73,12 +73,12 @@ class TestPackage < Test::Unit::TestCase
|
|
73
73
|
image.start_at 5, 5
|
74
74
|
image.end_at 10, 10
|
75
75
|
end
|
76
|
-
ws.add_image :image_src => File.expand_path('
|
76
|
+
ws.add_image :image_src => File.expand_path('../fixtures/image1.gif', __FILE__) do |image|
|
77
77
|
image.start_at 0, 20
|
78
78
|
image.width=360
|
79
79
|
image.height=333
|
80
80
|
end
|
81
|
-
ws.add_image :image_src => File.expand_path('
|
81
|
+
ws.add_image :image_src => File.expand_path('../fixtures/image1.png', __FILE__) do |image|
|
82
82
|
image.start_at 9, 20
|
83
83
|
image.width = 180
|
84
84
|
image.height = 167
|
@@ -127,18 +127,35 @@ class TestPackage < Test::Unit::TestCase
|
|
127
127
|
end
|
128
128
|
|
129
129
|
def test_serialization
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
130
|
+
@package.serialize(@fname)
|
131
|
+
assert_zip_file_matches_package(@fname, @package)
|
132
|
+
File.delete(@fname)
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_serialization_with_zip_command
|
136
|
+
@package.serialize(@fname, false, zip_command: "zip")
|
137
|
+
assert_zip_file_matches_package(@fname, @package)
|
138
|
+
File.delete(@fname)
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_serialization_with_zip_command_and_absolute_path
|
142
|
+
fname = "#{Dir.tmpdir}/#{@fname}"
|
143
|
+
@package.serialize(fname, false, zip_command: "zip")
|
144
|
+
assert_zip_file_matches_package(fname, @package)
|
145
|
+
File.delete(fname)
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_serialization_with_invalid_zip_command
|
149
|
+
assert_raises Axlsx::ZipCommand::ZipError do
|
150
|
+
@package.serialize(@fname, false, zip_command: "invalid_zip")
|
139
151
|
end
|
140
152
|
end
|
141
153
|
|
154
|
+
def assert_zip_file_matches_package(fname, package)
|
155
|
+
zf = Zip::File.open(fname)
|
156
|
+
package.send(:parts).each{ |part| zf.get_entry(part[:entry]) }
|
157
|
+
end
|
158
|
+
|
142
159
|
# See comment for Package#zip_entry_for_part
|
143
160
|
def test_serialization_creates_identical_files_at_any_time_if_created_at_is_set
|
144
161
|
@package.core.created = Time.now
|
@@ -100,6 +100,12 @@ class TestCell < Test::Unit::TestCase
|
|
100
100
|
|
101
101
|
def test_cell_type_from_value
|
102
102
|
assert_equal(@c.send(:cell_type_from_value, 1.0), :float)
|
103
|
+
assert_equal(@c.send(:cell_type_from_value, "1e1"), :float)
|
104
|
+
assert_equal(@c.send(:cell_type_from_value, "1e#{Float::MAX_10_EXP}"), :float)
|
105
|
+
assert_equal(@c.send(:cell_type_from_value, "1e#{Float::MAX_10_EXP + 1}"), :string)
|
106
|
+
assert_equal(@c.send(:cell_type_from_value, "1e-1"), :float)
|
107
|
+
assert_equal(@c.send(:cell_type_from_value, "1e#{Float::MIN_10_EXP}"), :float)
|
108
|
+
assert_equal(@c.send(:cell_type_from_value, "1e#{Float::MIN_10_EXP - 1}"), :string)
|
103
109
|
assert_equal(@c.send(:cell_type_from_value, 1), :integer)
|
104
110
|
assert_equal(@c.send(:cell_type_from_value, Date.today), :date)
|
105
111
|
assert_equal(@c.send(:cell_type_from_value, Time.now), :time)
|
@@ -114,6 +120,31 @@ class TestCell < Test::Unit::TestCase
|
|
114
120
|
assert_equal(:iso_8601, @c.send(:cell_type_from_value, '2008-08-30T01:45:36.123+09:00'))
|
115
121
|
end
|
116
122
|
|
123
|
+
def test_cell_type_from_value_looks_like_number_but_is_not
|
124
|
+
mimic_number = Class.new do
|
125
|
+
def initialize(to_s_value)
|
126
|
+
@to_s_value = to_s_value
|
127
|
+
end
|
128
|
+
|
129
|
+
def to_s
|
130
|
+
@to_s_value
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
number_strings = [
|
135
|
+
'1',
|
136
|
+
'1234567890',
|
137
|
+
'1.0',
|
138
|
+
'1e1',
|
139
|
+
'0',
|
140
|
+
"1e#{Float::MIN_10_EXP}"
|
141
|
+
]
|
142
|
+
|
143
|
+
number_strings.each do |number_string|
|
144
|
+
assert_equal(@c.send(:cell_type_from_value, mimic_number.new(number_string)), :string)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
117
148
|
def test_cast_value
|
118
149
|
@c.type = :string
|
119
150
|
assert_equal(@c.send(:cast_value, 1.0), "1.0")
|
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.3
|
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: 2020-07
|
12
|
+
date: 2020-12-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -105,20 +105,14 @@ dependencies:
|
|
105
105
|
requirements:
|
106
106
|
- - "~>"
|
107
107
|
- !ruby/object:Gem::Version
|
108
|
-
version: '
|
109
|
-
- - ">="
|
110
|
-
- !ruby/object:Gem::Version
|
111
|
-
version: 1.16.2
|
108
|
+
version: '2.3'
|
112
109
|
type: :development
|
113
110
|
prerelease: false
|
114
111
|
version_requirements: !ruby/object:Gem::Requirement
|
115
112
|
requirements:
|
116
113
|
- - "~>"
|
117
114
|
- !ruby/object:Gem::Version
|
118
|
-
version: '
|
119
|
-
- - ">="
|
120
|
-
- !ruby/object:Gem::Version
|
121
|
-
version: 1.16.2
|
115
|
+
version: '2.3'
|
122
116
|
- !ruby/object:Gem::Dependency
|
123
117
|
name: timecop
|
124
118
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,33 +145,8 @@ files:
|
|
151
145
|
- LICENSE
|
152
146
|
- README.md
|
153
147
|
- Rakefile
|
154
|
-
- examples/
|
155
|
-
- examples/
|
156
|
-
- examples/auto_filter.rb
|
157
|
-
- examples/basic_charts.rb
|
158
|
-
- examples/chart_colors.rb
|
159
|
-
- examples/colored_links.rb
|
160
|
-
- examples/conditional_formatting/example_conditional_formatting.rb
|
161
|
-
- examples/conditional_formatting/getting_barred.rb
|
162
|
-
- examples/conditional_formatting/hitting_the_high_notes.rb
|
163
|
-
- examples/conditional_formatting/scaled_colors.rb
|
164
|
-
- examples/conditional_formatting/stop_and_go.rb
|
165
|
-
- examples/data_validation.rb
|
166
|
-
- examples/example.rb
|
167
|
-
- examples/extractive.rb
|
168
|
-
- examples/image1.jpeg
|
169
|
-
- examples/ios_preview.rb
|
170
|
-
- examples/merge_cells.rb
|
171
|
-
- examples/no_grid_with_borders.rb
|
172
|
-
- examples/page_setup.rb
|
173
|
-
- examples/pivot_table.rb
|
174
|
-
- examples/pivot_test.rb
|
175
|
-
- examples/sheet_protection.rb
|
176
|
-
- examples/skydrive/real_example.rb
|
177
|
-
- examples/split.rb
|
178
|
-
- examples/styles.rb
|
179
|
-
- examples/underline.rb
|
180
|
-
- examples/wrap_text.rb
|
148
|
+
- examples/assets/image1.jpeg
|
149
|
+
- examples/generate.rb
|
181
150
|
- lib/axlsx.rb
|
182
151
|
- lib/axlsx/content_type/abstract_content_type.rb
|
183
152
|
- lib/axlsx/content_type/content_type.rb
|
@@ -256,6 +225,7 @@ files:
|
|
256
225
|
- lib/axlsx/util/simple_typed_list.rb
|
257
226
|
- lib/axlsx/util/storage.rb
|
258
227
|
- lib/axlsx/util/validators.rb
|
228
|
+
- lib/axlsx/util/zip_command.rb
|
259
229
|
- lib/axlsx/version.rb
|
260
230
|
- lib/axlsx/workbook/defined_name.rb
|
261
231
|
- lib/axlsx/workbook/defined_names.rb
|
@@ -403,6 +373,11 @@ files:
|
|
403
373
|
- test/drawing/tc_view_3D.rb
|
404
374
|
- test/drawing/tc_vml_drawing.rb
|
405
375
|
- test/drawing/tc_vml_shape.rb
|
376
|
+
- test/fixtures/image1.gif
|
377
|
+
- test/fixtures/image1.jpeg
|
378
|
+
- test/fixtures/image1.jpg
|
379
|
+
- test/fixtures/image1.png
|
380
|
+
- test/fixtures/image1_fake.jpg
|
406
381
|
- test/profile.rb
|
407
382
|
- test/rels/tc_relationship.rb
|
408
383
|
- test/rels/tc_relationships.rb
|
@@ -492,8 +467,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
492
467
|
- !ruby/object:Gem::Version
|
493
468
|
version: '0'
|
494
469
|
requirements: []
|
495
|
-
|
496
|
-
rubygems_version: 2.6.12
|
470
|
+
rubygems_version: 3.0.3
|
497
471
|
signing_key:
|
498
472
|
specification_version: 4
|
499
473
|
summary: Excel OOXML (xlsx) with charts, styles, images and autowidth columns.
|
@@ -547,6 +521,11 @@ test_files:
|
|
547
521
|
- test/drawing/tc_view_3D.rb
|
548
522
|
- test/drawing/tc_vml_drawing.rb
|
549
523
|
- test/drawing/tc_vml_shape.rb
|
524
|
+
- test/fixtures/image1.gif
|
525
|
+
- test/fixtures/image1.jpeg
|
526
|
+
- test/fixtures/image1.jpg
|
527
|
+
- test/fixtures/image1.png
|
528
|
+
- test/fixtures/image1_fake.jpg
|
550
529
|
- test/profile.rb
|
551
530
|
- test/rels/tc_relationship.rb
|
552
531
|
- test/rels/tc_relationships.rb
|