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 +4 -4
- data/lib/excel_utils/version.rb +1 -1
- data/lib/excel_utils/writer.rb +9 -4
- data/spec/write_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b318fb2a815346b8292031cf5236e0744525b919902eb5b81c288c8429399132
|
4
|
+
data.tar.gz: 70d6e62cfcd662b4d5f913174e06119f45b3f69bf78d66b3c743277a6dcd81c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29a539fcab3a28fcd97f479c40840d2694286494e262fb66446567a11c28cffb9e6d6258df2470aec2c48959aa3f8170533a461e0f88b7a10b23eaa91a3503c6
|
7
|
+
data.tar.gz: 4255935e350cda3a56d62da964e7c9d50c0cf8db194ae0cec39c20ba4ac0be12206d43583702d198cb9b55e4c617abe6b30462a9e407c7622683669e8599acee
|
data/lib/excel_utils/version.rb
CHANGED
data/lib/excel_utils/writer.rb
CHANGED
@@ -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
|
-
|
41
|
+
row_index = r + 1
|
42
|
+
header.each_with_index do |column, col_index|
|
42
43
|
if row[column]
|
43
|
-
if row[column].
|
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
|
50
|
+
sheet.write_date_time row_index, col_index, time.to_time.strftime(TIME_FORMAT), formats[type]
|
51
|
+
|
47
52
|
else
|
48
|
-
sheet.write
|
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.
|
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-
|
11
|
+
date: 2020-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inflecto
|