xlsx_writer 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -34,14 +34,16 @@ Features not present in simple_xlsx_writer:
34
34
  "Name",
35
35
  "Occupation",
36
36
  "Salary",
37
- "Citations"
37
+ "Citations",
38
+ "Average citations per paper"
38
39
  ])
39
40
  sheet1.add_row([
40
41
  Date.parse("July 31, 1912"),
41
42
  "Milton Friedman",
42
43
  "Economist / Statistician",
43
44
  {:type => :Currency, :value => 10_000},
44
- 500_000
45
+ 500_000,
46
+ 0.31
45
47
  ])
46
48
  sheet1.add_autofilter 'A1:E1'
47
49
 
@@ -8,12 +8,12 @@ module XlsxWriter
8
8
  case calculated_type
9
9
  when :String
10
10
  :inlineStr
11
- when :Number, :Date, :Currency
11
+ when :Number, :Integer, :Decimal, :Date, :Currency
12
12
  :n
13
13
  when :Boolean
14
14
  :b
15
15
  else
16
- raise ::ArgumentError, "Unknown cell type #{k}"
16
+ raise ::ArgumentError, "Unknown cell type #{calculated_type}"
17
17
  end
18
18
  end
19
19
 
@@ -22,14 +22,16 @@ module XlsxWriter
22
22
  case calculated_type
23
23
  when :String
24
24
  0
25
- when :Number
26
- 3
25
+ when :Boolean
26
+ 0 # todo
27
27
  when :Currency
28
28
  1
29
29
  when :Date
30
30
  2
31
- when :Boolean
32
- 0 # todo
31
+ when :Number, :Integer
32
+ 3
33
+ when :Decimal
34
+ 4
33
35
  else
34
36
  raise ::ArgumentError, "Unknown cell type #{k}"
35
37
  end
@@ -58,6 +60,8 @@ module XlsxWriter
58
60
  end
59
61
 
60
62
  alias :excel_currency :excel_number
63
+ alias :excel_integer :excel_number
64
+ alias :excel_decimal :excel_number
61
65
 
62
66
  # doesn't necessarily work for times yet
63
67
  JAN_1_1900 = ::Time.parse('1900-01-01')
@@ -101,9 +105,10 @@ module XlsxWriter
101
105
  @character_width ||= case calculated_type
102
106
  when :String
103
107
  value.to_s.length
104
- when :Number
108
+ when :Number, :Integer, :Decimal
105
109
  # -1000000.5
106
110
  len = value.round(2).to_s.length
111
+ len += 2 if calculated_type == :Decimal
107
112
  len += 1 if value < 0
108
113
  len
109
114
  when :Currency
@@ -155,6 +160,10 @@ module XlsxWriter
155
160
  data[:type]
156
161
  elsif value.is_a?(::Date)
157
162
  :Date
163
+ elsif value.is_a?(::Integer)
164
+ :Integer
165
+ elsif value.is_a?(::Float) or (defined?(::BigDecimal) and value.is_a?(::BigDecimal)) or (defined?(::Decimal) and value.is_a?(::Decimal))
166
+ :Decimal
158
167
  elsif value.is_a?(::Numeric)
159
168
  :Number
160
169
  else
@@ -1,28 +1,32 @@
1
1
  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
2
  <styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
3
+ <numFmts count="1">
4
+ <numFmt numFmtId="164" formatCode="0.00" />
5
+ </numFmts>
6
+
3
7
  <fonts count="1">
4
8
  <font>
5
9
  <sz val="10"/>
6
10
  <name val="Arial"/>
7
11
  </font>
8
12
  </fonts>
9
-
13
+
10
14
  <fills count="1">
11
15
  <fill />
12
16
  </fills>
13
-
17
+
14
18
  <borders count="1">
15
19
  <border />
16
20
  </borders>
17
-
21
+
18
22
  <cellStyleXfs count="2">
19
23
  <!-- general -->
20
24
  <xf />
21
25
  <!-- currency -->
22
26
  <xf builtinId="4" />
23
27
  </cellStyleXfs>
24
-
25
- <cellXfs count="4">
28
+
29
+ <cellXfs count="5">
26
30
  <!-- general -->
27
31
  <xf numFmtId="0" fontId="0">
28
32
  <alignment vertical="top" horizontal="left" />
@@ -35,9 +39,13 @@
35
39
  <xf numFmtId="14" fontId="0">
36
40
  <alignment vertical="top" horizontal="left" />
37
41
  </xf>
38
- <!-- number -->
42
+ <!-- integer -->
39
43
  <xf numFmtId="0" fontId="0">
40
44
  <alignment vertical="top" horizontal="right" />
41
45
  </xf>
46
+ <!-- float/decimal/etc. -->
47
+ <xf numFmtId="164" fontId="0">
48
+ <alignment vertical="top" horizontal="right" />
49
+ </xf>
42
50
  </cellXfs>
43
51
  </styleSheet>
@@ -1,3 +1,3 @@
1
1
  module XlsxWriter
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xlsx_writer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2011-12-09 00:00:00.000000000Z
14
+ date: 2011-12-15 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
18
- requirement: &2160880880 !ruby/object:Gem::Requirement
18
+ requirement: &2182482680 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: '0'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *2160880880
26
+ version_requirements: *2182482680
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: fast_xs
29
- requirement: &2160880320 !ruby/object:Gem::Requirement
29
+ requirement: &2182482200 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: '0'
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *2160880320
37
+ version_requirements: *2182482200
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: posix-spawn
40
- requirement: &2160879900 !ruby/object:Gem::Requirement
40
+ requirement: &2182481720 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ! '>='
@@ -45,7 +45,7 @@ dependencies:
45
45
  version: '0'
46
46
  type: :runtime
47
47
  prerelease: false
48
- version_requirements: *2160879900
48
+ version_requirements: *2182481720
49
49
  description: Writes XLSX files. Minimal XML and style. Supports autofilters and headers/footers
50
50
  with images and page numbers.
51
51
  email: