write_xlsx 0.85.2 → 0.85.3

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
  SHA1:
3
- metadata.gz: b06209799005c4363ca55e009fe371d533fa7e7f
4
- data.tar.gz: ec976a656ba2c3ad849a1f078cf00012e8f7aabf
3
+ metadata.gz: 451a49314f7a14e2c9d5bfc5c4df3ca7f54e2718
4
+ data.tar.gz: 040af462094068f22464c341ea38fa971b5e4403
5
5
  SHA512:
6
- metadata.gz: 163fac6a14621889306c47aac360019470862a7eb25781702b33b80f00737c63bc7af9177f612c0db3b8b784663711570d21497d318b3e4ef65643e9e8bec602
7
- data.tar.gz: b19f5e20a77aa834b5850f7d5a550cf777565c3d2fa444cb69ba7a5baa1bf32ef4b6aa4bf47a97f5c8a5d5948cc8c744e73f08d82ef1ce4c16e17c94b3a8bc94
6
+ metadata.gz: 47524ba5498e8529ccc789da00036e0cf7a901d116f6661c75d8ee7b74485181aeb5ee7f657844cdbf756a1dfaa6337faf25c307586960fb32465fcca4764249
7
+ data.tar.gz: b582ea2f76e0bf02a37484581d732c9a329161d606fae13a381cd6541824b0a4ee061f8196385277a4e8b92f0965db79b5d426bf77cc7107201f55f18b1e0b76
data/Changes CHANGED
@@ -1,5 +1,8 @@
1
1
  Change history of write_xlsx rubygem.
2
2
 
3
+ 2018-01-07 v0.85.3
4
+ Fix hide first sheet problem #37
5
+
3
6
  2017-11-05 v0.85.2
4
7
  Fix frozen string litterals problems #30
5
8
 
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(cxn03651@msj.biglobe.ne.jp)
88
- Copyright (c) 2012-2017 Hideo NAKAMURA.
88
+ Copyright (c) 2012-2018 Hideo NAKAMURA.
89
89
 
90
90
  See LICENSE.txt for further details.
91
91
 
@@ -205,6 +205,10 @@ def chartsheets
205
205
  self.select { |worksheet| worksheet.is_chartsheet? }
206
206
  end
207
207
 
208
+ def visible_first
209
+ self.reject { |worksheet| worksheet.hidden? }.first
210
+ end
211
+
208
212
  private
209
213
 
210
214
  def sheet_chart_count(type)
@@ -1 +1 @@
1
- WriteXLSX_VERSION = "0.85.2"
1
+ WriteXLSX_VERSION = "0.85.3"
@@ -1019,6 +1019,14 @@ def non_chartsheets
1019
1019
  @worksheets.worksheets
1020
1020
  end
1021
1021
 
1022
+ def firstsheet #:nodoc:
1023
+ @firstsheet ||= 0
1024
+ end
1025
+
1026
+ def activesheet #:nodoc:
1027
+ @activesheet ||= 0
1028
+ end
1029
+
1022
1030
  private
1023
1031
 
1024
1032
  def filename
@@ -1270,14 +1278,6 @@ def write_io(str) #:nodoc:
1270
1278
  str
1271
1279
  end
1272
1280
 
1273
- def firstsheet #:nodoc:
1274
- @firstsheet ||= 0
1275
- end
1276
-
1277
- def activesheet #:nodoc:
1278
- @activesheet ||= 0
1279
- end
1280
-
1281
1281
  # for test
1282
1282
  def defined_names #:nodoc:
1283
1283
  @defined_names ||= []
@@ -1291,9 +1291,10 @@ def store_workbook #:nodoc:
1291
1291
  add_worksheet if @worksheets.empty?
1292
1292
 
1293
1293
  # Ensure that at least one worksheet has been selected.
1294
- @worksheets.first.select if @activesheet == 0
1294
+ @worksheets.visible_first.select if @activesheet == 0
1295
1295
 
1296
1296
  # Set the active sheet.
1297
+ @activesheet = @worksheets.visible_first.index if @activesheet == 0
1297
1298
  @worksheets[@activesheet].activate
1298
1299
 
1299
1300
  # Prepare the worksheet VML elements such as comments and buttons.
@@ -1917,7 +1918,7 @@ def process_png(data)
1917
1918
  type = 'png'
1918
1919
  width = 0
1919
1920
  height = 0
1920
- x_dip = 96
1921
+ x_dpi = 96
1921
1922
  y_dpi = 96
1922
1923
 
1923
1924
  offset = 8
@@ -509,8 +509,8 @@ def activate
509
509
  def hide
510
510
  @hidden = true
511
511
  @selected = false
512
- @workbook.activesheet = 0
513
- @workbook.firstsheet = 0
512
+ @workbook.activesheet = 0 if @workbook.activesheet == @index
513
+ @workbook.firstsheet = 0 if @workbook.firstsheet == @index
514
514
  end
515
515
 
516
516
  def hidden? # :nodoc:
@@ -2225,6 +2225,7 @@ def write_number(*args)
2225
2225
  def write_string(*args)
2226
2226
  # Check for a cell reference in A1 notation and substitute row and column
2227
2227
  row, col, str, xf = row_col_notation(args)
2228
+ str &&= str.to_s
2228
2229
  raise WriteXLSXInsufficientArgumentError if [row, col, str].include?(nil)
2229
2230
 
2230
2231
  # Check that row and col are valid and store max and min values
@@ -2711,6 +2711,19 @@ def test_headers
2711
2711
  compare_xlsx(File.join(@perl_output, @xlsx), @xlsx)
2712
2712
  end
2713
2713
 
2714
+ def test_hide_first_sheet
2715
+ @xlsx = 'hide_first_sheet.xlsx'
2716
+ workbook = WriteXLSX.new(@xlsx)
2717
+ worksheet1 = workbook.add_worksheet
2718
+ worksheet2 = workbook.add_worksheet
2719
+
2720
+ worksheet2.activate
2721
+ worksheet1.hide
2722
+
2723
+ workbook.close
2724
+ compare_xlsx(File.join(@perl_output, @xlsx), @xlsx)
2725
+ end
2726
+
2714
2727
  def test_hide_sheet
2715
2728
  @xlsx = 'hide_sheet.xlsx'
2716
2729
  workbook = WriteXLSX.new(@xlsx)
@@ -59,6 +59,12 @@ def test_write_number_with_valid_arg_not_raise
59
59
  end
60
60
  end
61
61
 
62
+ def test_write_string_with_non_string_value
63
+ assert_nothing_raised do
64
+ @worksheet.write_string(0, 0, 1)
65
+ end
66
+ end
67
+
62
68
  def test_write_string_with_insufficient_args_raise_InsufficientArgumentError
63
69
  assert_raise(WriteXLSXInsufficientArgumentError) do
64
70
  @worksheet.write_string()
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.2
4
+ version: 0.85.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hideo NAKAMURA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-04 00:00:00.000000000 Z
11
+ date: 2018-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -337,6 +337,7 @@ files:
337
337
  - test/perl_output/fit_to_pages.xlsx
338
338
  - test/perl_output/formats.xlsx
339
339
  - test/perl_output/headers.xlsx
340
+ - test/perl_output/hide_first_sheet.xlsx
340
341
  - test/perl_output/hide_row_col.xlsx
341
342
  - test/perl_output/hide_sheet.xlsx
342
343
  - test/perl_output/hyperlink.xlsx
@@ -1707,7 +1708,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1707
1708
  version: '0'
1708
1709
  requirements: []
1709
1710
  rubyforge_project:
1710
- rubygems_version: 2.5.2
1711
+ rubygems_version: 2.5.2.1
1711
1712
  signing_key:
1712
1713
  specification_version: 4
1713
1714
  summary: write_xlsx is a gem to create a new file in the Excel 2007+ XLSX format.
@@ -1846,6 +1847,7 @@ test_files:
1846
1847
  - test/perl_output/fit_to_pages.xlsx
1847
1848
  - test/perl_output/formats.xlsx
1848
1849
  - test/perl_output/headers.xlsx
1850
+ - test/perl_output/hide_first_sheet.xlsx
1849
1851
  - test/perl_output/hide_row_col.xlsx
1850
1852
  - test/perl_output/hide_sheet.xlsx
1851
1853
  - test/perl_output/hyperlink.xlsx