write_xlsx 1.09.0 → 1.09.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -0
- data/Changes +12 -1
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/examples/keep_leading_zeros.rb +17 -0
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/worksheet.rb +15 -1
- data/test/perl_output/keep_leading_zeros.xlsx +0 -0
- data/test/perl_output/multi_line.xlsx +0 -0
- data/test/test_example_match.rb +30 -0
- metadata +11 -7
- data/ignore_errors.xlsx +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dea384f9a4a5af52b21f5a45abd5ae4a88b7448da7f9c9fd64e12a555536b90
|
4
|
+
data.tar.gz: 7204b2a2fd050b4cf6a970e8bb9d9e83bc8d7162d71d59728253290e407baf37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 941d4e9db310aabb6b7ef7a2695945c9d2919a17fa8640664fd55b3d8461d0a63223feaccaced2d9e6f2286a6423a2092adb2c337d01055706d4ff1d4c53fff8
|
7
|
+
data.tar.gz: cf57ea36741b31fd1c25e82526d9a545179ec91266f92381b09d8d136502f72054196446ab4ead6e27a667d1eb6e656a6362c54a8aa116b5b95152354216c6ea
|
data/.travis.yml
CHANGED
@@ -1,9 +1,18 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
+
- 3.0.3
|
4
|
+
- 3.0.2
|
5
|
+
- 3.0.1
|
3
6
|
- 3.0.0
|
7
|
+
- 2.7.5
|
8
|
+
- 2.7.4
|
9
|
+
- 2.7.3
|
4
10
|
- 2.7.2
|
5
11
|
- 2.7.1
|
6
12
|
- 2.7.0
|
13
|
+
- 2.6.9
|
14
|
+
- 2.6.8
|
15
|
+
- 2.6.7
|
7
16
|
- 2.6.6
|
8
17
|
- 2.6.5
|
9
18
|
- 2.6.4
|
@@ -11,6 +20,7 @@ rvm:
|
|
11
20
|
- 2.6.2
|
12
21
|
- 2.6.1
|
13
22
|
- 2.6.0
|
23
|
+
- 2.5.9
|
14
24
|
- 2.5.8
|
15
25
|
- 2.5.7
|
16
26
|
- 2.5.6
|
data/Changes
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
Change history of write_xlsx rubygem.
|
2
2
|
|
3
|
+
2022-07-08 v1.09.3
|
4
|
+
Fixed issue #47. Dealing with NAN
|
5
|
+
|
6
|
+
2022-02-14 v1.09.2
|
7
|
+
Fixed issue #79. Worksheet#write calls the write_number
|
8
|
+
when multi-line string has a line with only numbers.
|
9
|
+
|
10
|
+
2021-11-27 v1.09.1
|
11
|
+
Added Worksheet#keep_leading_zeros method to handle '001' as string in
|
12
|
+
Worksheet#write, write_row, and write_col method.
|
13
|
+
|
3
14
|
2021-11-26 v1.09.0
|
4
15
|
|
5
16
|
Added support for background images in worksheets. See set_background().
|
@@ -247,7 +258,7 @@ Change history of write_xlsx rubygem.
|
|
247
258
|
Fix work well in ms windows.
|
248
259
|
|
249
260
|
2018-04-29 v0.85.5
|
250
|
-
Added option to store hyperlink strings as string (
|
261
|
+
Added option to store hyperlink strings as string (strings_to_urls: false).
|
251
262
|
|
252
263
|
2018-04-29 v0.85.4
|
253
264
|
Added option to store hyperlink strings as string (urls_as_strings).
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -85,7 +85,7 @@ the first worksheet in an Excel XML spreadsheet called ruby.xlsx:
|
|
85
85
|
Original Perl module was written by John McNamara(jmcnamara@cpan.org).
|
86
86
|
|
87
87
|
Converted to ruby by Hideo NAKAMURA(nakamrua.hideo@gmail.com)
|
88
|
-
Copyright (c) 2012-
|
88
|
+
Copyright (c) 2012-2022 Hideo NAKAMURA.
|
89
89
|
|
90
90
|
See LICENSE.txt for further details.
|
91
91
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
require 'write_xlsx'
|
5
|
+
|
6
|
+
workbook = WriteXLSX.new('keep_leading_zeros.xlsx')
|
7
|
+
worksheet = workbook.add_worksheet
|
8
|
+
|
9
|
+
worksheet.keep_leading_zeros(true)
|
10
|
+
worksheet.write('A1', '001')
|
11
|
+
worksheet.write('B1', 'written as string.')
|
12
|
+
worksheet.write('A2', '012')
|
13
|
+
worksheet.write('B2', 'written as string.')
|
14
|
+
worksheet.write('A3', '123')
|
15
|
+
worksheet.write('B3', 'written as number.')
|
16
|
+
|
17
|
+
workbook.close
|
data/lib/write_xlsx/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
WriteXLSX_VERSION = "1.09.
|
1
|
+
WriteXLSX_VERSION = "1.09.3"
|
data/lib/write_xlsx/worksheet.rb
CHANGED
@@ -68,6 +68,7 @@ module Writexlsx
|
|
68
68
|
@zoom = 100
|
69
69
|
@zoom_scale_normal = true
|
70
70
|
@right_to_left = false
|
71
|
+
@leading_zeros = false
|
71
72
|
|
72
73
|
@autofilter_area = nil
|
73
74
|
@filter_on = false
|
@@ -832,6 +833,14 @@ module Writexlsx
|
|
832
833
|
@page_setup.black_white = true
|
833
834
|
end
|
834
835
|
|
836
|
+
#
|
837
|
+
# Causes the write() method to treat integers with a leading zero as a string.
|
838
|
+
# This ensures that any leading zeros such, as in zip codes, are maintained.
|
839
|
+
#
|
840
|
+
def keep_leading_zeros(flag = true)
|
841
|
+
@leading_zeros = !!flag
|
842
|
+
end
|
843
|
+
|
835
844
|
#
|
836
845
|
# Display the worksheet right to left for some eastern versions of Excel.
|
837
846
|
#
|
@@ -890,7 +899,10 @@ module Writexlsx
|
|
890
899
|
write_row(*args)
|
891
900
|
elsif token.respond_to?(:coerce) # Numeric
|
892
901
|
write_number(*args)
|
893
|
-
|
902
|
+
# Match integer with leading zero(s)
|
903
|
+
elsif @leading_zeros && token =~ /^0\d*$/
|
904
|
+
write_string(*args)
|
905
|
+
elsif token =~ /\A([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?\Z/
|
894
906
|
write_number(*args)
|
895
907
|
# Match formula
|
896
908
|
elsif token =~ /^=/
|
@@ -2032,6 +2044,8 @@ module Writexlsx
|
|
2032
2044
|
# Write the cell value <v> element.
|
2033
2045
|
#
|
2034
2046
|
def write_cell_value(value = '') #:nodoc:
|
2047
|
+
return write_cell_formula('=NA()') if !value.nil? && value.is_a?(Float) && value.nan?
|
2048
|
+
|
2035
2049
|
value ||= ''
|
2036
2050
|
value = value.to_i if value == value.to_i
|
2037
2051
|
@writer.data_element('v', value)
|
Binary file
|
Binary file
|
data/test/test_example_match.rb
CHANGED
@@ -11,6 +11,18 @@ class TestExampleMatch < Minitest::Test
|
|
11
11
|
@tempfile.close
|
12
12
|
end
|
13
13
|
|
14
|
+
def test_multi_line
|
15
|
+
@xlsx = 'multi_line.xlsx'
|
16
|
+
workbook = WriteXLSX.new(@io)
|
17
|
+
worksheet = workbook.add_worksheet
|
18
|
+
|
19
|
+
worksheet.write(0, 0, "Hi Excel!\n1234\nHi, again!")
|
20
|
+
|
21
|
+
workbook.close
|
22
|
+
store_to_tempfile
|
23
|
+
compare_xlsx(File.join(@perl_output, @xlsx), @tempfile.path)
|
24
|
+
end
|
25
|
+
|
14
26
|
def test_a_simple
|
15
27
|
@xlsx = 'a_simple.xlsx'
|
16
28
|
# Create a new workbook called simple.xls and add a worksheet
|
@@ -3335,6 +3347,24 @@ EOS
|
|
3335
3347
|
compare_xlsx(File.join(@perl_output, @xlsx), @tempfile.path)
|
3336
3348
|
end
|
3337
3349
|
|
3350
|
+
def test_keep_leading_zoros
|
3351
|
+
@xlsx = 'keep_leading_zeros.xlsx'
|
3352
|
+
workbook = WriteXLSX.new(@io)
|
3353
|
+
worksheet = workbook.add_worksheet
|
3354
|
+
|
3355
|
+
worksheet.keep_leading_zeros(true)
|
3356
|
+
worksheet.write('A1', '001')
|
3357
|
+
worksheet.write('B1', 'written as string.')
|
3358
|
+
worksheet.write('A2', '012')
|
3359
|
+
worksheet.write('B2', 'written as string.')
|
3360
|
+
worksheet.write('A3', '123')
|
3361
|
+
worksheet.write('B3', 'written as number.')
|
3362
|
+
|
3363
|
+
workbook.close
|
3364
|
+
store_to_tempfile
|
3365
|
+
compare_xlsx(File.join(@perl_output, @xlsx), @tempfile.path)
|
3366
|
+
end
|
3367
|
+
|
3338
3368
|
def test_merge1
|
3339
3369
|
@xlsx = 'merge1.xlsx'
|
3340
3370
|
# Create a new workbook and add a worksheet
|
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.09.
|
4
|
+
version: 1.09.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hideo NAKAMURA
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -140,6 +140,7 @@ files:
|
|
140
140
|
- examples/hyperlink1.rb
|
141
141
|
- examples/ignore_errors.rb
|
142
142
|
- examples/indent.rb
|
143
|
+
- examples/keep_leading_zeros.rb
|
143
144
|
- examples/macros.rb
|
144
145
|
- examples/merge1.rb
|
145
146
|
- examples/merge2.rb
|
@@ -174,7 +175,6 @@ files:
|
|
174
175
|
- examples/tables.rb
|
175
176
|
- examples/update_range_format_with_params.rb
|
176
177
|
- examples/vbaProject.bin
|
177
|
-
- ignore_errors.xlsx
|
178
178
|
- lib/write_xlsx.rb
|
179
179
|
- lib/write_xlsx/chart.rb
|
180
180
|
- lib/write_xlsx/chart/area.rb
|
@@ -371,12 +371,14 @@ files:
|
|
371
371
|
- test/perl_output/hyperlink.xlsx
|
372
372
|
- test/perl_output/ignore_errors.xlsx
|
373
373
|
- test/perl_output/indent.xlsx
|
374
|
+
- test/perl_output/keep_leading_zeros.xlsx
|
374
375
|
- test/perl_output/merge1.xlsx
|
375
376
|
- test/perl_output/merge2.xlsx
|
376
377
|
- test/perl_output/merge3.xlsx
|
377
378
|
- test/perl_output/merge4.xlsx
|
378
379
|
- test/perl_output/merge5.xlsx
|
379
380
|
- test/perl_output/merge6.xlsx
|
381
|
+
- test/perl_output/multi_line.xlsx
|
380
382
|
- test/perl_output/outline.xlsx
|
381
383
|
- test/perl_output/outline_collapsed.xlsx
|
382
384
|
- test/perl_output/panes.xlsx
|
@@ -2164,7 +2166,7 @@ homepage: https://github.com/cxn03651/write_xlsx#readme
|
|
2164
2166
|
licenses:
|
2165
2167
|
- MIT
|
2166
2168
|
metadata: {}
|
2167
|
-
post_install_message:
|
2169
|
+
post_install_message:
|
2168
2170
|
rdoc_options: []
|
2169
2171
|
require_paths:
|
2170
2172
|
- lib
|
@@ -2179,8 +2181,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
2179
2181
|
- !ruby/object:Gem::Version
|
2180
2182
|
version: '0'
|
2181
2183
|
requirements: []
|
2182
|
-
rubygems_version: 3.
|
2183
|
-
signing_key:
|
2184
|
+
rubygems_version: 3.3.7
|
2185
|
+
signing_key:
|
2184
2186
|
specification_version: 4
|
2185
2187
|
summary: write_xlsx is a gem to create a new file in the Excel 2007+ XLSX format.
|
2186
2188
|
test_files:
|
@@ -2329,12 +2331,14 @@ test_files:
|
|
2329
2331
|
- test/perl_output/hyperlink.xlsx
|
2330
2332
|
- test/perl_output/ignore_errors.xlsx
|
2331
2333
|
- test/perl_output/indent.xlsx
|
2334
|
+
- test/perl_output/keep_leading_zeros.xlsx
|
2332
2335
|
- test/perl_output/merge1.xlsx
|
2333
2336
|
- test/perl_output/merge2.xlsx
|
2334
2337
|
- test/perl_output/merge3.xlsx
|
2335
2338
|
- test/perl_output/merge4.xlsx
|
2336
2339
|
- test/perl_output/merge5.xlsx
|
2337
2340
|
- test/perl_output/merge6.xlsx
|
2341
|
+
- test/perl_output/multi_line.xlsx
|
2338
2342
|
- test/perl_output/outline.xlsx
|
2339
2343
|
- test/perl_output/outline_collapsed.xlsx
|
2340
2344
|
- test/perl_output/panes.xlsx
|
data/ignore_errors.xlsx
DELETED
Binary file
|