excel_utils 1.1.0 → 1.1.1

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: 6493c2a06cb2a07929144889ea06b679e97c68b740ef5b18714d702c0f83bc01
4
- data.tar.gz: ff567b623fd4e93095288d9d8d74fc23bd0275944628a861837daca10fb06391
3
+ metadata.gz: b318fb2a815346b8292031cf5236e0744525b919902eb5b81c288c8429399132
4
+ data.tar.gz: 70d6e62cfcd662b4d5f913174e06119f45b3f69bf78d66b3c743277a6dcd81c6
5
5
  SHA512:
6
- metadata.gz: b37f20e6f1addcc3ca8f7bacd02d2a64309b9f8399a36a6b6096d73acd111e9de8c601bec278a27bd24541aa899ebbd56d437b47ed88735aec51fd0fa808bfc5
7
- data.tar.gz: cd7ea90eb909e3119d59eae7a1a6e4d9c32435906a40df39e8bff946b7f5835af19e51b45ae13efdf02ce8b9fe8072fe4fdd28245a9c671255eed717ae3cf59f
6
+ metadata.gz: 29a539fcab3a28fcd97f479c40840d2694286494e262fb66446567a11c28cffb9e6d6258df2470aec2c48959aa3f8170533a461e0f88b7a10b23eaa91a3503c6
7
+ data.tar.gz: 4255935e350cda3a56d62da964e7c9d50c0cf8db194ae0cec39c20ba4ac0be12206d43583702d198cb9b55e4c617abe6b30462a9e407c7622683669e8599acee
@@ -1,3 +1,3 @@
1
1
  module ExcelUtils
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
@@ -38,14 +38,19 @@ module ExcelUtils
38
38
  sheet.write_row 0, 0, header.map(&:to_s)
39
39
 
40
40
  sheet_data.each_with_index do |row, r|
41
- header.each_with_index do |column, c|
41
+ row_index = r + 1
42
+ header.each_with_index do |column, col_index|
42
43
  if row[column]
43
- if row[column].respond_to? :to_time
44
+ if row[column].is_a? String
45
+ sheet.write_string row_index, col_index, row[column]
46
+
47
+ elsif row[column].respond_to? :to_time
44
48
  time = row[column].to_time
45
49
  type = date?(time) ? :date : :date_time
46
- sheet.write_date_time r + 1, c, time.to_time.strftime(TIME_FORMAT), formats[type]
50
+ sheet.write_date_time row_index, col_index, time.to_time.strftime(TIME_FORMAT), formats[type]
51
+
47
52
  else
48
- sheet.write r + 1, c, row[column]
53
+ sheet.write row_index, col_index, row[column]
49
54
  end
50
55
  end
51
56
  end
data/spec/write_spec.rb CHANGED
@@ -17,8 +17,8 @@ describe ExcelUtils do
17
17
 
18
18
  data = {
19
19
  'Sheet 1' => [
20
- {'column_a' => 1.5, 'column_b' => 'text 1', 'column_c' => DateTime.parse('2019-05-25T16:30:00')},
21
- {'column_b' => 'text 2', 'column_c' => Date.parse('2019-07-09'), 'column_a' => 2},
20
+ {'column_a' => 1.5, 'column_b' => 'text 1', 'column_c' => DateTime.parse('2019-05-25T16:30:00'), 'column_d' => '999'},
21
+ {'column_b' => 'text 2', 'column_c' => Date.parse('2019-07-09'), 'column_a' => 2, 'column_d' => '0123'},
22
22
  ],
23
23
  'Sheet 2' => [
24
24
  {'Column A' => long_url, 'Column B' => long_text}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: excel_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Naiman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-12 00:00:00.000000000 Z
11
+ date: 2020-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inflecto