xlsxtream 1.0.1 → 1.1.0

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
  SHA1:
3
- metadata.gz: 95edaa900980bd320d2c9263ef1ecf9ba89cda93
4
- data.tar.gz: b86eb2573b8344ec2d8aa1d34c1dc831a46ff812
3
+ metadata.gz: 6c2e61534349014a46be7c2e6d6910c8b40b1e01
4
+ data.tar.gz: 4d43327ab3fe0f3006021ed28caf375cb5767ddb
5
5
  SHA512:
6
- metadata.gz: 697ac5618f2577a9aca8653d24e59786fa85316e5fd13306c139540198e3f7968f89010c42461351d1954170e7794b96a506a7afb5868902adeef33d4f2ae1ab
7
- data.tar.gz: aa397f03e684bdd242f86195abb13b56f0590f1a83c4f9ffd9623b57e35d6f2307d59efab981d5d6d5e26946b26e3528a779011366a0a0f5e5b5b40d520e1214
6
+ metadata.gz: 6533bdf0887f634e5b3e3f85684bf67ddffd042afe2096a2f8a458df21089a202a080f393a7fe61131b62b7189e0c7fb6df1d4e6cd329cb5a397fa295b1541ac
7
+ data.tar.gz: c7697cd9435b60986ab4f9be408e5fd8af20bf35257f3fb8ba317ddb9d4b62adede90fa090160c44ed7716c5896abac576286beebc4b95836c17d1cf434757c7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.0 (2017-10-23)
4
+
5
+ - Add support for boolean values (#13)
6
+
3
7
  ## 1.0.1 (2017-10-22)
4
8
 
5
9
  - Fix writing unnamed worksheets with options
data/README.md CHANGED
@@ -36,8 +36,8 @@ Or install it yourself as:
36
36
  # Creates a new workbook and closes it at the end of the block
37
37
  Xlsxtream::Workbook.open('my_data.xlsx') do |xlsx|
38
38
  xlsx.write_worksheet 'Sheet1' do |sheet|
39
- # Date, Time, DateTime and Numeric are properly mapped
40
- sheet << [Date.today, 'hello', 'world', 42, 3.14159265359, 42**13]
39
+ # Boolean, Date, Time, DateTime and Numeric are properly mapped
40
+ sheet << [true, Date.today, 'hello', 'world', 42, 3.14159265359, 42**13]
41
41
  end
42
42
  end
43
43
 
@@ -71,10 +71,11 @@ end
71
71
  # appropriately. This is a convenient way to avoid an Excel-warning about
72
72
  # "Number stored as text". Dates and times must be in the ISO-8601 format and
73
73
  # numeric values must contain only numbers and an optional decimal separator.
74
+ # The strings true and false are detected as boolean values.
74
75
  xlsx.write_worksheet('SheetWithAutoFormat', :auto_format => true) do |sheet|
75
76
  # these two rows will be identical in the xlsx-output
76
- sheet << [11.85, DateTime.parse('2050-01-01T12:00'), Date.parse('1984-01-01')]
77
- sheet << ['11.85', '2050-01-01T12:00', '1984-01-01']
77
+ sheet << [true, 11.85, DateTime.parse('2050-01-01T12:00'), Date.parse('1984-01-01')]
78
+ sheet << ['true', '11.85', '2050-01-01T12:00', '1984-01-01']
78
79
  end
79
80
 
80
81
  # Writes metadata and ZIP archive central directory
data/lib/xlsxtream/row.rb CHANGED
@@ -13,6 +13,9 @@ module Xlsxtream
13
13
  # ISO 8601 yyyy-mm-ddThh:mm:ss(.s)(Z|+hh:mm|-hh:mm)
14
14
  TIME_PATTERN = /\A[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}(?::[0-9]{2}(?:\.[0-9]{1,9})?)?(?:Z|[+-][0-9]{2}:[0-9]{2})?\z/.freeze
15
15
 
16
+ TRUE_STRING = 'true'.freeze
17
+ FALSE_STRING = 'false'.freeze
18
+
16
19
  DATE_STYLE = 1
17
20
  TIME_STYLE = 2
18
21
 
@@ -38,6 +41,8 @@ module Xlsxtream
38
41
  case value
39
42
  when Numeric
40
43
  xml << %Q{<c r="#{cid}" t="n"><v>#{value}</v></c>}
44
+ when TrueClass, FalseClass
45
+ xml << %Q{<c r="#{cid}" t="b"><v>#{value ? 1 : 0}</v></c>}
41
46
  when Time, DateTime
42
47
  xml << %Q{<c r="#{cid}" s="#{TIME_STYLE}"><v>#{time_to_oa_date(value)}</v></c>}
43
48
  when Date
@@ -65,6 +70,10 @@ module Xlsxtream
65
70
  # Detects and casts numbers, date, time in text
66
71
  def auto_format(value)
67
72
  case value
73
+ when TRUE_STRING
74
+ true
75
+ when FALSE_STRING
76
+ false
68
77
  when NUMBER_PATTERN
69
78
  value.include?('.') ? value.to_f : value.to_i
70
79
  when DATE_PATTERN
@@ -1,3 +1,3 @@
1
1
  module Xlsxtream
2
- VERSION = '1.0.1'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xlsxtream
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Bünemann