fast_excel 0.2.2 → 0.2.3

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
  SHA1:
3
- metadata.gz: f0bf8afa4f1566ae7cc27fe6b7a59e1d9c0dc0d0
4
- data.tar.gz: eeac6d37268bfc90e54a338e098224acd382309d
3
+ metadata.gz: 9c054001c6ea3e0473ef11cd51b9471186e23fb4
4
+ data.tar.gz: d23f1f61c7087f3f79601ed57f70a408ad0cb684
5
5
  SHA512:
6
- metadata.gz: 75345de42e34f5e4db76737ba2c1ad8d8c2fa74fb44653d1d0c5a86137d635aab3c2abb5297ad32fe6a67e4813e6c57dbd50c543ea5a75404a44ada017e45c2b
7
- data.tar.gz: c37550f5d67c501b16e9199f0a8aab489ea760257d2405f3b0ffbabcb41e20625ee80dfbb89bc7dec1ddb0bf93cc65c5e59b89de55f1727dbb5d85ead3a1e049
6
+ metadata.gz: 6a549bc98f588c5ac6cc2a4e466b0425b0e198e5799f6fc9b3ba5ddd96ba2f2fd7c47ff5ce86f69232200362acb83e95ec2a0c475f7536a755d7dcd24a36fd06
7
+ data.tar.gz: 5ebbae552b28e607b4549145872f564b26d3e6d01cf1509ebeb79fdde09510423182a2c879129780a0f41d152fedbd264abe0580b9c051c5bb860a683b756a6f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ #### Version 0.2.3 - 27 oct 2017
2
+
3
+ * Allow Date along with DateTime in write_value (thanks to @noxern)
4
+
1
5
  #### Version 0.2.2 - 20 sep 2017
2
6
 
3
7
  * Nice setters and getters for format.align
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 repositiry and gem contain sources of [libxlsxwriter](https://github.com/jmcnamara/libxlsxwriter)
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 craete tmp file, `default_format` will be called with `workbook.default_format.set(...)`
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "fast_excel"
3
- s.version = "0.2.2"
3
+ s.version = "0.2.3"
4
4
  s.author = ["Pavel Evstigneev"]
5
5
  s.email = ["pavel.evst@gmail.com"]
6
6
  s.homepage = "https://github.com/paxa/fast_excel"
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?(DateTime) && value.is_a?(DateTime)
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.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-09-19 00:00:00.000000000 Z
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