write_xlsx 0.88.0 → 0.89.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 994776679641b1907ecab841ff3f708bdf82e7db2347b12a7b3e06c3cf3de218
4
- data.tar.gz: 47fefd5324ac9fc71d40b4fcdcd59c2679098c04ff793d4a96c0e9988e7170cb
3
+ metadata.gz: 980d940d4b7386abe4429d994fdb89621a410b7dee208f931e0571034c40b7df
4
+ data.tar.gz: 376c1bd91e9d4139af09b69a35509125566a3a44a072f91e27cfd38524f579ae
5
5
  SHA512:
6
- metadata.gz: 845c34594fea0e22e12663a4bc2912e48eef99de5685573d53c9ba74a89709d5a2ab25efd6eb76f799e1fd4b9913f1fe766d2010352058725389ef119e823c4e
7
- data.tar.gz: e98541a0595e76f391a4dcd38f36b6f754cec385d6310fc169e088bd2f08b38cd4d0d10eebe1f44fd7bed2458bafc2f56fa7994d5bbe8982dc740f0b2ed7be0d
6
+ metadata.gz: 2be6712f3085f77b124f8ce6a400acf9a9c3edea9e27bcefcdef0926af29b29f2cb31eb3b82f5291bf1a6294afd4c504a1e2f32602f7fbbd1aeacc54d79fb9a2
7
+ data.tar.gz: 15cf003eb84c5312b01f4890e8be4299faf88f92710706f3c01a98c28ad35fb9ec1fbbcab253724804e1b4bfdcfa7c4cf0378d8304685f49c60bfa30651737b0
@@ -1,7 +1,50 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 3.0.0
4
+ - 2.7.2
5
+ - 2.7.1
6
+ - 2.7.0
7
+ - 2.6.6
8
+ - 2.6.5
9
+ - 2.6.4
10
+ - 2.6.3
11
+ - 2.6.2
12
+ - 2.6.1
13
+ - 2.6.0
14
+ - 2.5.8
15
+ - 2.5.7
16
+ - 2.5.6
17
+ - 2.5.5
18
+ - 2.5.4
19
+ - 2.5.3
20
+ - 2.5.2
21
+ - 2.5.1
22
+ - 2.5.0
23
+ - 2.4.10
24
+ - 2.4.9
25
+ - 2.4.8
26
+ - 2.4.7
27
+ - 2.4.6
28
+ - 2.4.5
29
+ - 2.4.4
30
+ - 2.4.3
31
+ - 2.4.2
32
+ - 2.4.1
33
+ - 2.4.0
34
+ - 2.3.8
35
+ - 2.3.7
36
+ - 2.3.6
37
+ - 2.3.5
38
+ - 2.3.4
39
+ - 2.3.3
40
+ - 2.3.2
3
41
  - 2.3.1
4
42
  - 2.3.0
43
+ - 2.2.10
44
+ - 2.2.9
45
+ - 2.2.8
46
+ - 2.2.7
47
+ - 2.2.6
5
48
  - 2.2.5
6
49
  - 2.2.4
7
50
  - 2.2.3
data/Changes CHANGED
@@ -1,5 +1,10 @@
1
1
  Change history of write_xlsx rubygem.
2
2
 
3
+ 2020-12-27 v0.89.0
4
+
5
+ Added write_boolean() worksheet method to write Excel boolean values.
6
+
7
+
3
8
  2020-12-26 v0.88.0
4
9
 
5
10
  Added transparency option to solid fills in chart areas.
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.88](https://github.com/jmcnamara/excel-writer-xlsx) .
8
+ [Excel::Writer::XLSX-0.89](https://github.com/jmcnamara/excel-writer-xlsx) .
9
9
 
10
10
  ## Description
11
11
 
@@ -1 +1 @@
1
- WriteXLSX_VERSION = "0.88.0"
1
+ WriteXLSX_VERSION = "0.89.0"
@@ -2529,6 +2529,26 @@ def write_array_formula(*args)
2529
2529
  end
2530
2530
  end
2531
2531
 
2532
+ #
2533
+ # write_boolean(row, col, val, format)
2534
+ #
2535
+ # Write a boolean value to the specified row and column (zero indexed).
2536
+ #
2537
+ def write_boolean(*args)
2538
+ row, col, val, xf = row_col_notation(args)
2539
+ raise WriteXLSXInsufficientArgumentError if row.nil? || col.nil?
2540
+
2541
+ val = val ? 1 : 0 # Boolean value.
2542
+ # xf : cell format.
2543
+ type = 'l' # The data type
2544
+
2545
+ # Check that row and col are valid and store max and min values
2546
+ check_dimensions(row, col)
2547
+ store_row_col_max_min_values(row, col)
2548
+
2549
+ store_data_to_table(BooleanCellData.new(self, row, col, val, xf))
2550
+ end
2551
+
2532
2552
  #
2533
2553
  # :call-seq:
2534
2554
  # update_format_with_params(row, col, format_params)
@@ -2537,12 +2557,12 @@ def write_array_formula(*args)
2537
2557
  #
2538
2558
  # worksheet.update_format_with_params(0, 0, color: 'red')
2539
2559
  #
2540
- # This method is used to update formatting of the cell keeping cell contents
2560
+ # This method is used to update formatting of the cell keeping cell contents
2541
2561
  # and formatting.
2542
2562
  #
2543
- # If the cell doesn't have CellData object, this method create a CellData
2563
+ # If the cell doesn't have CellData object, this method create a CellData
2544
2564
  # using write_blank method.
2545
- # If the cell has CellData, this method fetch contents and format of cell from
2565
+ # If the cell has CellData, this method fetch contents and format of cell from
2546
2566
  # the CellData object and recreate CellData using write method.
2547
2567
  #
2548
2568
  def update_format_with_params(*args)
@@ -2590,7 +2610,7 @@ def update_format_with_params(*args)
2590
2610
  #
2591
2611
  # worksheet.update_range_format_with_params(0, 0, 3, 3, color: 'red')
2592
2612
  #
2593
- # This method is used to update formatting of multiple cells keeping cells' contents
2613
+ # This method is used to update formatting of multiple cells keeping cells' contents
2594
2614
  # and formatting.
2595
2615
  #
2596
2616
  #
@@ -5813,11 +5833,11 @@ def position_object_pixels(col_start, row_start, x1, y1, width, height) #:nodoc:
5813
5833
  y1 += size_row(row_start - 1)
5814
5834
  row_start -= 1
5815
5835
  end
5816
-
5836
+
5817
5837
  # Ensure that the image isn't shifted off the page at top left.
5818
5838
  x1 = 0 if x1 < 0
5819
5839
  y1 = 0 if y1 < 0
5820
-
5840
+
5821
5841
  # Calculate the absolute x offset of the top-left vertex.
5822
5842
  if @col_size_changed
5823
5843
  x_abs = (0 .. col_start-1).inject(0) {|sum, col| sum += size_col(col)}
@@ -128,6 +128,27 @@ def write_cell
128
128
  end
129
129
  end
130
130
 
131
+ class BooleanCellData < CellData # :nodoc:
132
+ def initialize(worksheet, row, col, val, xf)
133
+ @worksheet = worksheet
134
+ @row, @col, @token, @xf = row, col, val, xf
135
+ end
136
+
137
+ def data
138
+ @token
139
+ end
140
+
141
+ def write_cell
142
+ attributes = cell_attributes
143
+
144
+ attributes << ['t', 'b']
145
+ @worksheet.writer.tag_elements('c', attributes) do
146
+ @worksheet.write_cell_value(token)
147
+ end
148
+ end
149
+ end
150
+
151
+
131
152
  class BlankCellData < CellData # :nodoc:
132
153
  def initialize(worksheet, row, col, xf)
133
154
  @worksheet = worksheet
@@ -27,8 +27,13 @@ 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, @url_str = url.split(/#/)
30
+ url, *anchors = url.split(/#/)
31
31
  url ||= ''
32
+ if anchors.empty?
33
+ @url_str = nil
34
+ else
35
+ @url_str = anchors.join('#')
36
+ end
32
37
 
33
38
  # Escape URL unless it looks already escaped.
34
39
  url = escape_url(url)
@@ -0,0 +1,26 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionFormat14 < 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_format14
14
+ @xlsx = 'format14.xlsx'
15
+ workbook = WriteXLSX.new(@io)
16
+ worksheet = workbook.add_worksheet
17
+ center = workbook.add_format
18
+
19
+ center.set_center_across
20
+
21
+ worksheet.write('A1', 'foo', center)
22
+
23
+ workbook.close
24
+ compare_for_regression
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionHyperlink25 < 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_hyperlink25
14
+ @xlsx = 'hyperlink25.xlsx'
15
+ workbook = WriteXLSX.new(@io)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ worksheet.write_url('A1', 'http://www.google.com/#foo#bar')
19
+
20
+ workbook.close
21
+
22
+ compare_for_regression(
23
+ nil,
24
+ { 'xl/workbook.xml' => ['<workbookView'] }
25
+ )
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionHyperlink26 < 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_hyperlink26
14
+ @xlsx = 'hyperlink26.xlsx'
15
+ workbook = WriteXLSX.new(@io)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ worksheet.write_url('A1', 'http://www.google.com/foo#bar#baz')
19
+
20
+ workbook.close
21
+
22
+ compare_for_regression(
23
+ nil,
24
+ { 'xl/workbook.xml' => ['<workbookView'] }
25
+ )
26
+ end
27
+ end
@@ -0,0 +1,25 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionTypes02 < 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_types02
14
+ @xlsx = 'types02.xlsx'
15
+ workbook = WriteXLSX.new(@io)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ worksheet.write_boolean('A1', 1)
19
+ worksheet.write_boolean('A2', false)
20
+
21
+ workbook.close
22
+
23
+ compare_for_regression
24
+ end
25
+ end
@@ -0,0 +1,31 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionTypes08 < 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_types08
14
+ @xlsx = 'types08.xlsx'
15
+ workbook = WriteXLSX.new(@io)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ bold = workbook.add_format(:bold => 1)
19
+ italic = workbook.add_format(:italic => 1)
20
+
21
+ worksheet.write_boolean('A1', 'True', bold)
22
+ worksheet.write_boolean('A2', nil, italic)
23
+
24
+ workbook.close
25
+
26
+ compare_for_regression(
27
+ ['xl/styles.xml'],
28
+ {}
29
+ )
30
+ end
31
+ end
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.88.0
4
+ version: 0.89.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-26 00:00:00.000000000 Z
11
+ date: 2020-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -805,6 +805,7 @@ files:
805
805
  - test/regression/test_format11.rb
806
806
  - test/regression/test_format12.rb
807
807
  - test/regression/test_format13.rb
808
+ - test/regression/test_format14.rb
808
809
  - test/regression/test_formula_results01.rb
809
810
  - test/regression/test_gridlines01.rb
810
811
  - test/regression/test_header01.rb
@@ -848,6 +849,8 @@ files:
848
849
  - test/regression/test_hyperlink22.rb
849
850
  - test/regression/test_hyperlink23.rb
850
851
  - test/regression/test_hyperlink24.rb
852
+ - test/regression/test_hyperlink25.rb
853
+ - test/regression/test_hyperlink26.rb
851
854
  - test/regression/test_image01.rb
852
855
  - test/regression/test_image02.rb
853
856
  - test/regression/test_image03.rb
@@ -1011,6 +1014,8 @@ files:
1011
1014
  - test/regression/test_tutorial01.rb
1012
1015
  - test/regression/test_tutorial02.rb
1013
1016
  - test/regression/test_tutorial03.rb
1017
+ - test/regression/test_types02.rb
1018
+ - test/regression/test_types08.rb
1014
1019
  - test/regression/test_update_range_format_with_params.rb
1015
1020
  - test/regression/test_urls_as_strings.rb
1016
1021
  - test/regression/test_utf8_01.rb
@@ -1421,6 +1426,7 @@ files:
1421
1426
  - test/regression/xlsx_files/format11.xlsx
1422
1427
  - test/regression/xlsx_files/format12.xlsx
1423
1428
  - test/regression/xlsx_files/format13.xlsx
1429
+ - test/regression/xlsx_files/format14.xlsx
1424
1430
  - test/regression/xlsx_files/formula_results01.xlsx
1425
1431
  - test/regression/xlsx_files/gridlines01.xlsx
1426
1432
  - test/regression/xlsx_files/header01.xlsx
@@ -1464,6 +1470,8 @@ files:
1464
1470
  - test/regression/xlsx_files/hyperlink22.xlsx
1465
1471
  - test/regression/xlsx_files/hyperlink23.xlsx
1466
1472
  - test/regression/xlsx_files/hyperlink24.xlsx
1473
+ - test/regression/xlsx_files/hyperlink25.xlsx
1474
+ - test/regression/xlsx_files/hyperlink26.xlsx
1467
1475
  - test/regression/xlsx_files/image01.xlsx
1468
1476
  - test/regression/xlsx_files/image02.xlsx
1469
1477
  - test/regression/xlsx_files/image03.xlsx
@@ -1628,6 +1636,8 @@ files:
1628
1636
  - test/regression/xlsx_files/tutorial01.xlsx
1629
1637
  - test/regression/xlsx_files/tutorial02.xlsx
1630
1638
  - test/regression/xlsx_files/tutorial03.xlsx
1639
+ - test/regression/xlsx_files/types02.xlsx
1640
+ - test/regression/xlsx_files/types08.xlsx
1631
1641
  - test/regression/xlsx_files/update_range_format_with_params.xlsx
1632
1642
  - test/regression/xlsx_files/urls_as_strings.xlsx
1633
1643
  - test/regression/xlsx_files/utf8_01.xlsx
@@ -1777,7 +1787,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1777
1787
  - !ruby/object:Gem::Version
1778
1788
  version: '0'
1779
1789
  requirements: []
1780
- rubygems_version: 3.0.3
1790
+ rubygems_version: 3.1.4
1781
1791
  signing_key:
1782
1792
  specification_version: 4
1783
1793
  summary: write_xlsx is a gem to create a new file in the Excel 2007+ XLSX format.
@@ -2383,6 +2393,7 @@ test_files:
2383
2393
  - test/regression/test_format11.rb
2384
2394
  - test/regression/test_format12.rb
2385
2395
  - test/regression/test_format13.rb
2396
+ - test/regression/test_format14.rb
2386
2397
  - test/regression/test_formula_results01.rb
2387
2398
  - test/regression/test_gridlines01.rb
2388
2399
  - test/regression/test_header01.rb
@@ -2426,6 +2437,8 @@ test_files:
2426
2437
  - test/regression/test_hyperlink22.rb
2427
2438
  - test/regression/test_hyperlink23.rb
2428
2439
  - test/regression/test_hyperlink24.rb
2440
+ - test/regression/test_hyperlink25.rb
2441
+ - test/regression/test_hyperlink26.rb
2429
2442
  - test/regression/test_image01.rb
2430
2443
  - test/regression/test_image02.rb
2431
2444
  - test/regression/test_image03.rb
@@ -2589,6 +2602,8 @@ test_files:
2589
2602
  - test/regression/test_tutorial01.rb
2590
2603
  - test/regression/test_tutorial02.rb
2591
2604
  - test/regression/test_tutorial03.rb
2605
+ - test/regression/test_types02.rb
2606
+ - test/regression/test_types08.rb
2592
2607
  - test/regression/test_update_range_format_with_params.rb
2593
2608
  - test/regression/test_urls_as_strings.rb
2594
2609
  - test/regression/test_utf8_01.rb
@@ -2999,6 +3014,7 @@ test_files:
2999
3014
  - test/regression/xlsx_files/format11.xlsx
3000
3015
  - test/regression/xlsx_files/format12.xlsx
3001
3016
  - test/regression/xlsx_files/format13.xlsx
3017
+ - test/regression/xlsx_files/format14.xlsx
3002
3018
  - test/regression/xlsx_files/formula_results01.xlsx
3003
3019
  - test/regression/xlsx_files/gridlines01.xlsx
3004
3020
  - test/regression/xlsx_files/header01.xlsx
@@ -3042,6 +3058,8 @@ test_files:
3042
3058
  - test/regression/xlsx_files/hyperlink22.xlsx
3043
3059
  - test/regression/xlsx_files/hyperlink23.xlsx
3044
3060
  - test/regression/xlsx_files/hyperlink24.xlsx
3061
+ - test/regression/xlsx_files/hyperlink25.xlsx
3062
+ - test/regression/xlsx_files/hyperlink26.xlsx
3045
3063
  - test/regression/xlsx_files/image01.xlsx
3046
3064
  - test/regression/xlsx_files/image02.xlsx
3047
3065
  - test/regression/xlsx_files/image03.xlsx
@@ -3206,6 +3224,8 @@ test_files:
3206
3224
  - test/regression/xlsx_files/tutorial01.xlsx
3207
3225
  - test/regression/xlsx_files/tutorial02.xlsx
3208
3226
  - test/regression/xlsx_files/tutorial03.xlsx
3227
+ - test/regression/xlsx_files/types02.xlsx
3228
+ - test/regression/xlsx_files/types08.xlsx
3209
3229
  - test/regression/xlsx_files/update_range_format_with_params.xlsx
3210
3230
  - test/regression/xlsx_files/urls_as_strings.xlsx
3211
3231
  - test/regression/xlsx_files/utf8_01.xlsx