fast_excel 0.1.6 → 0.1.7
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 +4 -4
- data/Gemfile +5 -1
- data/Gemfile.lock +20 -1
- data/fast_excel.gemspec +1 -1
- data/lib/fast_excel.rb +1 -1
- data/test/date_test.rb +22 -0
- data/test/test_helper.rb +36 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56b8736c80626c089a7b20544519504306eaf41f
|
4
|
+
data.tar.gz: 3acc3eceba37ae987a269a75b846713624d6d3fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d4d65513075a6935d344f6d40193db2a4095c3ea66ecb36e5eff2308660704741257b46b83b6535e83c571d945e1f1ada48c95db9aeea48c2eb0299a89b3fc4
|
7
|
+
data.tar.gz: 67792c48ae5170cffb0b8f51701f6e0f44489ed7f7d6b4a55ca814f32e987b271053755939d9fde4e4230ad7ab554827d5f9d9df962df9eb74a1ae47d194602b
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,18 +1,34 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
+
ansi (1.5.0)
|
4
5
|
axlsx (2.0.1)
|
5
6
|
htmlentities (~> 4.3.1)
|
6
7
|
nokogiri (>= 1.4.1)
|
7
8
|
rubyzip (~> 1.0.0)
|
9
|
+
builder (3.2.3)
|
8
10
|
ffi (1.9.17)
|
9
11
|
ffi_gen (1.2.0)
|
10
12
|
ffi (~> 1.0)
|
11
13
|
htmlentities (4.3.4)
|
12
14
|
mini_portile2 (2.1.0)
|
15
|
+
minitest (5.10.1)
|
16
|
+
minitest-reporters (1.1.14)
|
17
|
+
ansi
|
18
|
+
builder
|
19
|
+
minitest (>= 5.0)
|
20
|
+
ruby-progressbar
|
13
21
|
nokogiri (1.7.0.1)
|
14
22
|
mini_portile2 (~> 2.1.0)
|
23
|
+
roo (1.13.2)
|
24
|
+
nokogiri
|
25
|
+
rubyzip
|
26
|
+
spreadsheet (> 0.6.4)
|
27
|
+
ruby-ole (1.2.12.1)
|
28
|
+
ruby-progressbar (1.8.1)
|
15
29
|
rubyzip (1.0.0)
|
30
|
+
spreadsheet (1.1.4)
|
31
|
+
ruby-ole (>= 1.0)
|
16
32
|
|
17
33
|
PLATFORMS
|
18
34
|
ruby
|
@@ -21,6 +37,9 @@ DEPENDENCIES
|
|
21
37
|
axlsx
|
22
38
|
ffi
|
23
39
|
ffi_gen
|
40
|
+
minitest
|
41
|
+
minitest-reporters
|
42
|
+
roo
|
24
43
|
|
25
44
|
BUNDLED WITH
|
26
|
-
1.14.
|
45
|
+
1.14.5
|
data/fast_excel.gemspec
CHANGED
data/lib/fast_excel.rb
CHANGED
@@ -46,7 +46,7 @@ module FastExcel
|
|
46
46
|
XLSX_DATE_DAY = 86400.0
|
47
47
|
|
48
48
|
# days between 1970-jan-01 and 1900-jan-01
|
49
|
-
XLSX_DATE_EPOCH_DIFF =
|
49
|
+
XLSX_DATE_EPOCH_DIFF = 25569
|
50
50
|
|
51
51
|
# Convert time to number of days, and change beginning point from 1st jan 1970 to 1st jan 1900
|
52
52
|
# Offset argument should be number of seconds, if not specified then it will use Time.zone.utc_offset || 0
|
data/test/date_test.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "FastExcel.date_num" do
|
4
|
+
|
5
|
+
it "should save correct date" do
|
6
|
+
workbook = FastExcel.open("test.xlsx", constant_memory: true)
|
7
|
+
worksheet = workbook.add_worksheet("Payments Report")
|
8
|
+
|
9
|
+
date_format = workbook.number_format("[$-409]m/d/yy h:mm AM/PM;@")
|
10
|
+
worksheet.set_column(0, 0, 20, date_format)
|
11
|
+
|
12
|
+
date = DateTime.parse('2017-03-01 15:15:15 +0000').to_time
|
13
|
+
|
14
|
+
worksheet.write_number(0, 0, FastExcel.date_num(date), nil)
|
15
|
+
workbook.close
|
16
|
+
|
17
|
+
data = parse_xlsx_as_matrix("test.xlsx")
|
18
|
+
|
19
|
+
assert_equal(data[0][0].to_time, date)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
Encoding.default_external = Encoding::UTF_8
|
2
|
+
Encoding.default_internal = Encoding::UTF_8
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'minitest/autorun'
|
6
|
+
require "minitest/reporters"
|
7
|
+
|
8
|
+
require 'date'
|
9
|
+
|
10
|
+
Minitest::Reporters.use!(
|
11
|
+
Minitest::Reporters::DefaultReporter.new(color: true)
|
12
|
+
)
|
13
|
+
|
14
|
+
require_relative '../lib/fast_excel'
|
15
|
+
|
16
|
+
def parse_xlsx(file_path)
|
17
|
+
require 'roo'
|
18
|
+
Roo::Excelx.new(file_path)
|
19
|
+
ensure
|
20
|
+
File.delete(file_path)
|
21
|
+
end
|
22
|
+
|
23
|
+
def parse_xlsx_as_array(file_path)
|
24
|
+
excel = parse_xlsx(file_path)
|
25
|
+
data = excel.to_matrix.to_a
|
26
|
+
headers = data.shift
|
27
|
+
|
28
|
+
data.map do |row|
|
29
|
+
Hash[ [headers, row].transpose ]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def parse_xlsx_as_matrix(file_path)
|
34
|
+
excel = parse_xlsx(file_path)
|
35
|
+
excel.to_matrix.to_a
|
36
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fast_excel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Evstigneev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -137,6 +137,8 @@ files:
|
|
137
137
|
- libxlsxwriter/third_party/tmpfileplus/tmpfileplus.c
|
138
138
|
- libxlsxwriter/third_party/tmpfileplus/tmpfileplus.h
|
139
139
|
- libxlsxwriter/version.txt
|
140
|
+
- test/date_test.rb
|
141
|
+
- test/test_helper.rb
|
140
142
|
homepage: https://github.com/paxa/fast_excel
|
141
143
|
licenses:
|
142
144
|
- MIT
|