xlsxtream 1.0.1 → 1.1.0
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/CHANGELOG.md +4 -0
- data/README.md +5 -4
- data/lib/xlsxtream/row.rb +9 -0
- data/lib/xlsxtream/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c2e61534349014a46be7c2e6d6910c8b40b1e01
|
4
|
+
data.tar.gz: 4d43327ab3fe0f3006021ed28caf375cb5767ddb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6533bdf0887f634e5b3e3f85684bf67ddffd042afe2096a2f8a458df21089a202a080f393a7fe61131b62b7189e0c7fb6df1d4e6cd329cb5a397fa295b1541ac
|
7
|
+
data.tar.gz: c7697cd9435b60986ab4f9be408e5fd8af20bf35257f3fb8ba317ddb9d4b62adede90fa090160c44ed7716c5896abac576286beebc4b95836c17d1cf434757c7
|
data/CHANGELOG.md
CHANGED
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
|
data/lib/xlsxtream/version.rb
CHANGED