write_xlsx 0.85.3 → 0.85.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Changes +3 -0
- data/Rakefile +1 -1
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/workbook.rb +2 -0
- data/lib/write_xlsx/worksheet.rb +13 -9
- data/test/regression/test_urls_as_strings.rb +25 -0
- data/test/regression/xlsx_files/urls_as_strings.xlsx +0 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 653c8e697dbe8468dd60f4cde55e69a2454ce80192b455e7bb0c88b385aadce0
|
4
|
+
data.tar.gz: 75777d4a17597792871a0b78981e3b359b9113dc749ff7e495b80bf3812b232d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fc85d45b48b49b1a75a06b53c06a53bf1eb3b03dee67318e88f2a78248b3d75290d82920f41cc28327e676f6bb1c0a4742b816195fafd60f9817fbe7d830aa7
|
7
|
+
data.tar.gz: 934303155838fc8008fa1e560d64d111fccd954b1006744645139124f8e2c403e9aa9ee31fd29e98b0ec2682069ea6293e46fcbe5146c5ac39d1e8dbdea07c8c
|
data/Changes
CHANGED
data/Rakefile
CHANGED
data/lib/write_xlsx/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
WriteXLSX_VERSION = "0.85.
|
1
|
+
WriteXLSX_VERSION = "0.85.4"
|
data/lib/write_xlsx/workbook.rb
CHANGED
@@ -47,6 +47,7 @@ class Workbook
|
|
47
47
|
attr_reader :shared_strings # :nodoc:
|
48
48
|
attr_reader :vba_project # :nodoc:
|
49
49
|
attr_reader :excel2003_style # :nodoc:
|
50
|
+
attr_reader :strings_to_urls # :nodoc:
|
50
51
|
#
|
51
52
|
# A new Excel workbook is created using the +new+ constructor
|
52
53
|
# which accepts either a filename or an IO object as a parameter.
|
@@ -123,6 +124,7 @@ def initialize(file, *option_params)
|
|
123
124
|
@table_count = 0
|
124
125
|
@image_types = {}
|
125
126
|
@images = []
|
127
|
+
@strings_to_urls = (options[:strings_to_urls].nil? || options[:strings_to_urls]) ? true : false
|
126
128
|
|
127
129
|
# Structures for the shared strings data.
|
128
130
|
@shared_strings = Package::SharedStrings.new
|
data/lib/write_xlsx/worksheet.rb
CHANGED
@@ -1783,15 +1783,6 @@ def write(*args)
|
|
1783
1783
|
write_number(*args)
|
1784
1784
|
elsif token =~ /^\d+$/
|
1785
1785
|
write_number(*args)
|
1786
|
-
# Match http, https or ftp URL
|
1787
|
-
elsif token =~ %r|\A[fh]tt?ps?://|
|
1788
|
-
write_url(*args)
|
1789
|
-
# Match mailto:
|
1790
|
-
elsif token =~ %r|\Amailto:|
|
1791
|
-
write_url(*args)
|
1792
|
-
# Match internal or external sheet link
|
1793
|
-
elsif token =~ %r!\A(?:in|ex)ternal:!
|
1794
|
-
write_url(*args)
|
1795
1786
|
# Match formula
|
1796
1787
|
elsif token =~ /^=/
|
1797
1788
|
write_formula(*args)
|
@@ -1802,6 +1793,19 @@ def write(*args)
|
|
1802
1793
|
elsif token == ''
|
1803
1794
|
row_col_args.delete_at(2) # remove the empty string from the parameter list
|
1804
1795
|
write_blank(*row_col_args)
|
1796
|
+
elsif @workbook.strings_to_urls
|
1797
|
+
# Match http, https or ftp URL
|
1798
|
+
if token =~ %r|\A[fh]tt?ps?://|
|
1799
|
+
write_url(*args)
|
1800
|
+
# Match mailto:
|
1801
|
+
elsif token =~ %r|\Amailto:|
|
1802
|
+
write_url(*args)
|
1803
|
+
# Match internal or external sheet link
|
1804
|
+
elsif token =~ %r!\A(?:in|ex)ternal:!
|
1805
|
+
write_url(*args)
|
1806
|
+
else
|
1807
|
+
write_string(*args)
|
1808
|
+
end
|
1805
1809
|
else
|
1806
1810
|
write_string(*args)
|
1807
1811
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
class TestUrlsAsStrings < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
setup_dir_var
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
File.delete(@xlsx) if File.exist?(@xlsx)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_urls_as_strings
|
14
|
+
@xlsx = 'urls_as_strings.xlsx'
|
15
|
+
workbook = WriteXLSX.new(@xlsx, urls_as_strings: true)
|
16
|
+
worksheet = workbook.add_worksheet
|
17
|
+
worksheet.write('A1', 'http://www.write_xlsx.com')
|
18
|
+
worksheet.write('A2', 'mailto:write_xlsx@example.com')
|
19
|
+
worksheet.write('A3', 'ftp://ftp.ruby.org/' )
|
20
|
+
worksheet.write('A4', 'internal:Sheet1!A1' )
|
21
|
+
worksheet.write('A5', 'external:c:\foo.xlsx')
|
22
|
+
workbook.close
|
23
|
+
compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
|
24
|
+
end
|
25
|
+
end
|
Binary file
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hideo NAKAMURA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -978,6 +978,7 @@ files:
|
|
978
978
|
- test/regression/test_tutorial01.rb
|
979
979
|
- test/regression/test_tutorial02.rb
|
980
980
|
- test/regression/test_tutorial03.rb
|
981
|
+
- test/regression/test_urls_as_strings.rb
|
981
982
|
- test/regression/test_utf8_01.rb
|
982
983
|
- test/regression/test_utf8_03.rb
|
983
984
|
- test/regression/test_utf8_04.rb
|
@@ -1560,6 +1561,7 @@ files:
|
|
1560
1561
|
- test/regression/xlsx_files/tutorial01.xlsx
|
1561
1562
|
- test/regression/xlsx_files/tutorial02.xlsx
|
1562
1563
|
- test/regression/xlsx_files/tutorial03.xlsx
|
1564
|
+
- test/regression/xlsx_files/urls_as_strings.xlsx
|
1563
1565
|
- test/regression/xlsx_files/utf8_01.xlsx
|
1564
1566
|
- test/regression/xlsx_files/utf8_03.xlsx
|
1565
1567
|
- test/regression/xlsx_files/utf8_04.xlsx
|
@@ -1708,7 +1710,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1708
1710
|
version: '0'
|
1709
1711
|
requirements: []
|
1710
1712
|
rubyforge_project:
|
1711
|
-
rubygems_version: 2.
|
1713
|
+
rubygems_version: 2.7.3
|
1712
1714
|
signing_key:
|
1713
1715
|
specification_version: 4
|
1714
1716
|
summary: write_xlsx is a gem to create a new file in the Excel 2007+ XLSX format.
|
@@ -2488,6 +2490,7 @@ test_files:
|
|
2488
2490
|
- test/regression/test_tutorial01.rb
|
2489
2491
|
- test/regression/test_tutorial02.rb
|
2490
2492
|
- test/regression/test_tutorial03.rb
|
2493
|
+
- test/regression/test_urls_as_strings.rb
|
2491
2494
|
- test/regression/test_utf8_01.rb
|
2492
2495
|
- test/regression/test_utf8_03.rb
|
2493
2496
|
- test/regression/test_utf8_04.rb
|
@@ -3070,6 +3073,7 @@ test_files:
|
|
3070
3073
|
- test/regression/xlsx_files/tutorial01.xlsx
|
3071
3074
|
- test/regression/xlsx_files/tutorial02.xlsx
|
3072
3075
|
- test/regression/xlsx_files/tutorial03.xlsx
|
3076
|
+
- test/regression/xlsx_files/urls_as_strings.xlsx
|
3073
3077
|
- test/regression/xlsx_files/utf8_01.xlsx
|
3074
3078
|
- test/regression/xlsx_files/utf8_03.xlsx
|
3075
3079
|
- test/regression/xlsx_files/utf8_04.xlsx
|