write_xlsx 0.89.0 → 0.90.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 980d940d4b7386abe4429d994fdb89621a410b7dee208f931e0571034c40b7df
4
- data.tar.gz: 376c1bd91e9d4139af09b69a35509125566a3a44a072f91e27cfd38524f579ae
3
+ metadata.gz: 94c163c93be013a57cc4a4edba4cea1ac35f91ecbed56443d535fa1d6e1a464f
4
+ data.tar.gz: 29fecf270f9b3382e0adae5f9f8ffd3b15ca97a84fc9da8bc24d0402de9a7ce7
5
5
  SHA512:
6
- metadata.gz: 2be6712f3085f77b124f8ce6a400acf9a9c3edea9e27bcefcdef0926af29b29f2cb31eb3b82f5291bf1a6294afd4c504a1e2f32602f7fbbd1aeacc54d79fb9a2
7
- data.tar.gz: 15cf003eb84c5312b01f4890e8be4299faf88f92710706f3c01a98c28ad35fb9ec1fbbcab253724804e1b4bfdcfa7c4cf0378d8304685f49c60bfa30651737b0
6
+ metadata.gz: da03548ba5d54019f9a69b2aa6ca70042b4d27824d784996ebdd7109f8c54626609f007d099acffb8a0d09448d5fdd2ea49e491e729b2b075d2e142fd0b36dc7
7
+ data.tar.gz: ba23f9b7be254784821b0bae59134bfa53a1cb2afa22e21576a054c718532f34753701d001d46f52871d770db0af4a6027705c22d28c18f658eb082b49172eeb
data/Changes CHANGED
@@ -1,5 +1,18 @@
1
1
  Change history of write_xlsx rubygem.
2
2
 
3
+ 2020-12-28 v0.90.0
4
+
5
+ Added worksheet_by_name() workbook method to retrieve a worksheet
6
+ in a workbook by name.
7
+
8
+ Fixed issue where internal file creation and modification dates where
9
+ in the local timezone instead of UTC.
10
+
11
+ Fixed issue with "external:" urls with space in sheetname.
12
+
13
+ Fixed issue where Unicode full-width number strings were treated as
14
+ numbers in write().
15
+
3
16
  2020-12-27 v0.89.0
4
17
 
5
18
  Added write_boolean() worksheet method to write Excel boolean values.
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  gem to create a new file in the Excel 2007+ XLSX format, and you can use the
7
7
  same interface as writeexcel gem. write_xlsx is converted from Perl's module
8
- [Excel::Writer::XLSX-0.89](https://github.com/jmcnamara/excel-writer-xlsx) .
8
+ [Excel::Writer::XLSX-0.90](https://github.com/jmcnamara/excel-writer-xlsx) .
9
9
 
10
10
  ## Description
11
11
 
@@ -14,7 +14,7 @@ class Core
14
14
  def initialize
15
15
  @writer = Package::XMLWriterSimple.new
16
16
  @properties = {}
17
- @localtime = [Time.now]
17
+ @createtime = [Time.now.gmtime]
18
18
  end
19
19
 
20
20
  def set_xml_writer(filename)
@@ -47,12 +47,14 @@ def write_cp_core_properties_base
47
47
  end
48
48
 
49
49
  #
50
- # Convert a localtime() date to a ISO 8601 style "2010-01-01T00:00:00Z" date.
50
+ # Convert a gmtime/localtime() date to a ISO 8601 style
51
+ # "2010-01-01T00:00:00Z" date. Excel always treats this as
52
+ # a utc date/time.
51
53
  #
52
- def localtime_to_iso8601_date(local_time = nil)
53
- local_time ||= Time.now
54
+ def datetime_to_iso8601_date(gm_time = nil)
55
+ gm_time ||= Time.now.gmtime
54
56
 
55
- local_time.strftime('%Y-%m-%dT%H:%M:%SZ')
57
+ gm_time.strftime('%Y-%m-%dT%H:%M:%SZ')
56
58
  end
57
59
 
58
60
  #
@@ -109,7 +111,7 @@ def write_dcterms(tag)
109
111
  end
110
112
 
111
113
  def dcterms_date
112
- localtime_to_iso8601_date(@properties[:created])
114
+ datetime_to_iso8601_date(@properties[:created])
113
115
  end
114
116
 
115
117
  #
@@ -1 +1 @@
1
- WriteXLSX_VERSION = "0.89.0"
1
+ WriteXLSX_VERSION = "0.90.0"
@@ -203,6 +203,14 @@ def sheets(*args)
203
203
  end
204
204
  end
205
205
 
206
+ #
207
+ # Return a worksheet object in the workbook using the sheetname.
208
+ #
209
+ def worksheet_by_name(sheetname = nil)
210
+ sheets.select { |s| s.name == sheetname }.first
211
+ end
212
+ alias get_worksheet_by_name worksheet_by_name
213
+
206
214
  #
207
215
  # Set the date system: false = 1900 (the default), true = 1904
208
216
  #
@@ -806,7 +814,7 @@ def set_properties(params)
806
814
  end
807
815
 
808
816
  # Set the creation time unless specified by the user.
809
- params[:created] = @local_time unless params.has_key?(:created)
817
+ params[:created] = @createtime unless params.has_key?(:created)
810
818
 
811
819
  @doc_properties = params.dup
812
820
  end
@@ -27,13 +27,7 @@ def initialize(url, str, tip)
27
27
  normalized_str = str.sub(/^mailto:/, '')
28
28
 
29
29
  # Split url into the link and optional anchor/location.
30
- url, *anchors = url.split(/#/)
31
- url ||= ''
32
- if anchors.empty?
33
- @url_str = nil
34
- else
35
- @url_str = anchors.join('#')
36
- end
30
+ url, @url_str = url.split(/#/, 2)
37
31
 
38
32
  # Escape URL unless it looks already escaped.
39
33
  url = escape_url(url)
@@ -135,15 +129,12 @@ def initialize(url, str, tip)
135
129
  # Strip the mailto header.
136
130
  str.sub!(/^mailto:/, '')
137
131
 
132
+ # Split url into the link and optional anchor/location.
133
+ url, url_str = url.split(/#/, 2)
134
+
138
135
  # Escape URL unless it looks already escaped.
139
136
  url = escape_url(url)
140
137
 
141
- # External Workbook links need to be modified into the right format.
142
- # The URL will look something like 'c:\temp\file.xlsx#Sheet!A1'.
143
- # We need the part to the left of the # as the URL and the part to
144
- # the right as the "location" string (if it exists).
145
- url, url_str = url.split(/#/)
146
-
147
138
  # Add the file:/// URI to the url if non-local.
148
139
  if url =~ %r![:]! || # Windows style "C:/" link.
149
140
  url =~ %r!^\\\\! # Network share.
@@ -0,0 +1,24 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionHyperlink27 < Minitest::Test
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ @tempfile.close(true) if @tempfile
11
+ end
12
+
13
+ def test_hyperlink27
14
+ @xlsx = 'hyperlink27.xlsx'
15
+ workbook = WriteXLSX.new(@io)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ worksheet.write_url('A1', %q(external:\\\\Vboxsvr\share\foo bar.xlsx#'Some Sheet'!A1))
19
+
20
+ workbook.close
21
+
22
+ compare_for_regression
23
+ end
24
+ end
@@ -0,0 +1,23 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionUtf8_11 < Minitest::Test
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ @tempfile.close(true)
11
+ end
12
+
13
+ def test_utf8_11
14
+ @xlsx = 'utf8_11.xlsx'
15
+ workbook = WriteXLSX.new(@io)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ worksheet.write( 'A1', '12345' )
19
+
20
+ workbook.close
21
+ compare_for_regression
22
+ end
23
+ end
@@ -0,0 +1,35 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestWorksheeByName < Minitest::Test
5
+ def test_worksheet_by_name
6
+ io = StringIO.new
7
+ workbook = WriteXLSX.new(io)
8
+
9
+ # Test a valid explicit name.
10
+ expected = workbook.add_worksheet
11
+ result = workbook.worksheet_by_name('Sheet1')
12
+ assert_equal(expected, result)
13
+ result = workbook.get_worksheet_by_name('Sheet1')
14
+ assert_equal(expected, result)
15
+
16
+ # Test a valid explicit name.
17
+ expected = workbook.add_worksheet('Sheet 2')
18
+ result = workbook.worksheet_by_name('Sheet 2')
19
+ assert_equal(expected, result)
20
+ result = workbook.get_worksheet_by_name('Sheet 2')
21
+ assert_equal(expected, result)
22
+
23
+ # Test an invalid name.
24
+ result = workbook.worksheet_by_name('Sheet3')
25
+ assert_nil(result)
26
+ result = workbook.get_worksheet_by_name('Sheet3')
27
+ assert_nil(result)
28
+
29
+ # Test an invalid name.
30
+ result = workbook.worksheet_by_name()
31
+ assert_nil(result)
32
+ result = workbook.get_worksheet_by_name()
33
+ assert_nil(result)
34
+ end
35
+ end
@@ -9,13 +9,6 @@ def setup
9
9
  @worksheet = @workbook.add_worksheet('')
10
10
  end
11
11
 
12
- def test_attributes
13
- hyperlink = Writexlsx::Worksheet::Hyperlink.factory('')
14
- result = hyperlink.attributes(0, 0, 1)
15
- expected = [ ['ref', 'A1'], ['r:id', 'rId1']]
16
- assert_equal(expected, result)
17
- end
18
-
19
12
  def test_write_hyperlink_internal_sheet2
20
13
  hyperlink = Writexlsx::Worksheet::Hyperlink.factory('internal:Sheet2!A1', 'Sheet2!A1')
21
14
  result = hyperlink.attributes(0, 0)
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.89.0
4
+ version: 0.90.0
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-12-27 00:00:00.000000000 Z
11
+ date: 2020-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -851,6 +851,7 @@ files:
851
851
  - test/regression/test_hyperlink24.rb
852
852
  - test/regression/test_hyperlink25.rb
853
853
  - test/regression/test_hyperlink26.rb
854
+ - test/regression/test_hyperlink27.rb
854
855
  - test/regression/test_image01.rb
855
856
  - test/regression/test_image02.rb
856
857
  - test/regression/test_image03.rb
@@ -1027,6 +1028,7 @@ files:
1027
1028
  - test/regression/test_utf8_08.rb
1028
1029
  - test/regression/test_utf8_09.rb
1029
1030
  - test/regression/test_utf8_10.rb
1031
+ - test/regression/test_utf8_11.rb
1030
1032
  - test/regression/test_vml01.rb
1031
1033
  - test/regression/test_vml02.rb
1032
1034
  - test/regression/test_vml03.rb
@@ -1472,6 +1474,7 @@ files:
1472
1474
  - test/regression/xlsx_files/hyperlink24.xlsx
1473
1475
  - test/regression/xlsx_files/hyperlink25.xlsx
1474
1476
  - test/regression/xlsx_files/hyperlink26.xlsx
1477
+ - test/regression/xlsx_files/hyperlink27.xlsx
1475
1478
  - test/regression/xlsx_files/image01.xlsx
1476
1479
  - test/regression/xlsx_files/image02.xlsx
1477
1480
  - test/regression/xlsx_files/image03.xlsx
@@ -1649,6 +1652,7 @@ files:
1649
1652
  - test/regression/xlsx_files/utf8_08.xlsx
1650
1653
  - test/regression/xlsx_files/utf8_09.xlsx
1651
1654
  - test/regression/xlsx_files/utf8_10.xlsx
1655
+ - test/regression/xlsx_files/utf8_11.xlsx
1652
1656
  - test/regression/xlsx_files/vbaProject01.bin
1653
1657
  - test/regression/xlsx_files/vbaProject02.bin
1654
1658
  - test/regression/xlsx_files/vml01.xlsx
@@ -1668,6 +1672,7 @@ files:
1668
1672
  - test/workbook/test_workbook_01.rb
1669
1673
  - test/workbook/test_workbook_02.rb
1670
1674
  - test/workbook/test_workbook_03.rb
1675
+ - test/workbook/test_worksheet_by_name.rb
1671
1676
  - test/workbook/test_write_calc_pr.rb
1672
1677
  - test/workbook/test_write_defined_name.rb
1673
1678
  - test/workbook/test_write_defined_names.rb
@@ -2439,6 +2444,7 @@ test_files:
2439
2444
  - test/regression/test_hyperlink24.rb
2440
2445
  - test/regression/test_hyperlink25.rb
2441
2446
  - test/regression/test_hyperlink26.rb
2447
+ - test/regression/test_hyperlink27.rb
2442
2448
  - test/regression/test_image01.rb
2443
2449
  - test/regression/test_image02.rb
2444
2450
  - test/regression/test_image03.rb
@@ -2615,6 +2621,7 @@ test_files:
2615
2621
  - test/regression/test_utf8_08.rb
2616
2622
  - test/regression/test_utf8_09.rb
2617
2623
  - test/regression/test_utf8_10.rb
2624
+ - test/regression/test_utf8_11.rb
2618
2625
  - test/regression/test_vml01.rb
2619
2626
  - test/regression/test_vml02.rb
2620
2627
  - test/regression/test_vml03.rb
@@ -3060,6 +3067,7 @@ test_files:
3060
3067
  - test/regression/xlsx_files/hyperlink24.xlsx
3061
3068
  - test/regression/xlsx_files/hyperlink25.xlsx
3062
3069
  - test/regression/xlsx_files/hyperlink26.xlsx
3070
+ - test/regression/xlsx_files/hyperlink27.xlsx
3063
3071
  - test/regression/xlsx_files/image01.xlsx
3064
3072
  - test/regression/xlsx_files/image02.xlsx
3065
3073
  - test/regression/xlsx_files/image03.xlsx
@@ -3237,6 +3245,7 @@ test_files:
3237
3245
  - test/regression/xlsx_files/utf8_08.xlsx
3238
3246
  - test/regression/xlsx_files/utf8_09.xlsx
3239
3247
  - test/regression/xlsx_files/utf8_10.xlsx
3248
+ - test/regression/xlsx_files/utf8_11.xlsx
3240
3249
  - test/regression/xlsx_files/vbaProject01.bin
3241
3250
  - test/regression/xlsx_files/vbaProject02.bin
3242
3251
  - test/regression/xlsx_files/vml01.xlsx
@@ -3256,6 +3265,7 @@ test_files:
3256
3265
  - test/workbook/test_workbook_01.rb
3257
3266
  - test/workbook/test_workbook_02.rb
3258
3267
  - test/workbook/test_workbook_03.rb
3268
+ - test/workbook/test_worksheet_by_name.rb
3259
3269
  - test/workbook/test_write_calc_pr.rb
3260
3270
  - test/workbook/test_write_defined_name.rb
3261
3271
  - test/workbook/test_write_defined_names.rb