fast_excel 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/LICENSE +21 -0
- data/README.md +2 -2
- data/fast_excel.gemspec +1 -1
- data/lib/fast_excel.rb +2 -2
- data/test/date_test.rb +34 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c054001c6ea3e0473ef11cd51b9471186e23fb4
|
4
|
+
data.tar.gz: d23f1f61c7087f3f79601ed57f70a408ad0cb684
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a549bc98f588c5ac6cc2a4e466b0425b0e198e5799f6fc9b3ba5ddd96ba2f2fd7c47ff5ce86f69232200362acb83e95ec2a0c475f7536a755d7dcd24a36fd06
|
7
|
+
data.tar.gz: 5ebbae552b28e607b4549145872f564b26d3e6d01cf1509ebeb79fdde09510423182a2c879129780a0f41d152fedbd264abe0580b9c051c5bb860a683b756a6f
|
data/CHANGELOG.md
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Pavel Evstigneev
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -31,7 +31,7 @@ worksheet.write_row(1001, ["Sum", FastExcel::Formula.new("SUM(B2:B1001)")], bold
|
|
31
31
|
workbook.close
|
32
32
|
```
|
33
33
|
|
34
|
-
This
|
34
|
+
This repository and gem contain sources of [libxlsxwriter](https://github.com/jmcnamara/libxlsxwriter)
|
35
35
|
|
36
36
|
## Benchmarks
|
37
37
|
|
@@ -83,7 +83,7 @@ Full libxlsxwriter documentation: [http://libxlsxwriter.github.io/](http://libxl
|
|
83
83
|
|
84
84
|
Helper Methods:
|
85
85
|
|
86
|
-
* `FastExcel.open(filename = nil, constant_memory: false, default_format: {})` - open new workbook, if `filename` is nil - it will
|
86
|
+
* `FastExcel.open(filename = nil, constant_memory: false, default_format: {})` - open new workbook, if `filename` is nil - it will create tmp file, `default_format` will be called with `workbook.default_format.set(...)`
|
87
87
|
* `FastExcel.date_num(time, offset = nil)` - generate Excel's internal date value, number of days since 1900-Jan-01, works faster then creating `Libxlsxwriter::Datetime` struct. `offset` argument is number hours from UTC, e.g. `3.5`
|
88
88
|
* `FastExcel.print_ffi_obj(object)` - print FFI object fields, just for debugging
|
89
89
|
* `workbook.bold_cell_format` - shortcut for creating bold format
|
data/fast_excel.gemspec
CHANGED
data/lib/fast_excel.rb
CHANGED
@@ -397,8 +397,8 @@ module FastExcel
|
|
397
397
|
|
398
398
|
if value.is_a?(Numeric)
|
399
399
|
write_number(row_number, cell_number, value, format)
|
400
|
-
elsif defined?(
|
401
|
-
write_datetime(row_number, cell_number, FastExcel.lxw_datetime(value), format)
|
400
|
+
elsif defined?(Date) && value.is_a?(Date)
|
401
|
+
write_datetime(row_number, cell_number, FastExcel.lxw_datetime(value.to_datetime), format)
|
402
402
|
elsif value.is_a?(Time)
|
403
403
|
write_datetime(row_number, cell_number, FastExcel.lxw_time(value), format)
|
404
404
|
elsif value.is_a?(Formula)
|
data/test/date_test.rb
CHANGED
@@ -20,3 +20,37 @@ describe "FastExcel.date_num" do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
23
|
+
|
24
|
+
describe "FastExcel.write_value" do
|
25
|
+
|
26
|
+
it "should save correct datetime" do
|
27
|
+
workbook = FastExcel.open(constant_memory: true)
|
28
|
+
worksheet = workbook.add_worksheet
|
29
|
+
|
30
|
+
format = workbook.number_format("yyyy-mm-dd hh:mm:ss")
|
31
|
+
value = DateTime.parse('2017-03-01 15:15:15 +0000')
|
32
|
+
|
33
|
+
worksheet.write_value(0, 0, value, format)
|
34
|
+
workbook.close
|
35
|
+
|
36
|
+
data = parse_xlsx_as_matrix(workbook.filename)
|
37
|
+
|
38
|
+
assert_equal(data[0][0], value)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should save correct date" do
|
42
|
+
workbook = FastExcel.open(constant_memory: true)
|
43
|
+
worksheet = workbook.add_worksheet
|
44
|
+
|
45
|
+
format = workbook.number_format("yyyy-mm-dd")
|
46
|
+
value = Date.parse('2017-03-01')
|
47
|
+
|
48
|
+
worksheet.write_value(0, 0, value, format)
|
49
|
+
workbook.close
|
50
|
+
|
51
|
+
data = parse_xlsx_as_matrix(workbook.filename)
|
52
|
+
|
53
|
+
assert_equal(data[0][0], value)
|
54
|
+
end
|
55
|
+
|
56
|
+
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.2.
|
4
|
+
version: 0.2.3
|
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-
|
11
|
+
date: 2017-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -43,6 +43,7 @@ files:
|
|
43
43
|
- CHANGELOG.md
|
44
44
|
- Gemfile
|
45
45
|
- Gemfile.lock
|
46
|
+
- LICENSE
|
46
47
|
- Makefile
|
47
48
|
- README.md
|
48
49
|
- Rakefile
|