xlsxtream 1.1.0 → 1.2.0
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/README.md +8 -0
- data/lib/xlsxtream/errors.rb +3 -0
- data/lib/xlsxtream/version.rb +1 -1
- data/lib/xlsxtream/workbook.rb +21 -3
- 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: 1d7ef18ac21a43cee29087458665fd3ff6511c62
|
4
|
+
data.tar.gz: 03bf65a93162886fbfcdebefb89191ea29a09744
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '087c1ab2888d86144ce3872a5a74579b3d82eb07f672dd261b29c5513129a24eb81340b16fb0bb9f3e0843c39d7ae8d17e076bc2aff3b92ff569f617259e2351'
|
7
|
+
data.tar.gz: dbc340a4f04e01e975886d5e94c939e2a6879bc754a632bd334895545bf982944b0c6053014ab0ddd8d383ac36ee677c118046cdeff21dd090df68dbbdb0d547
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -82,6 +82,14 @@ end
|
|
82
82
|
xlsx.close
|
83
83
|
# Close IO object
|
84
84
|
io.close
|
85
|
+
|
86
|
+
# Changing the default font from Calibri, 12pt, Swiss
|
87
|
+
Xlsxtream::Workbook.new(io, :font => {
|
88
|
+
:name => 'Times New Roman',
|
89
|
+
:size => 10, # size in pt
|
90
|
+
:family => 'Roman' # Swiss, Modern, Script, Decorative
|
91
|
+
})
|
92
|
+
|
85
93
|
```
|
86
94
|
|
87
95
|
## Development
|
data/lib/xlsxtream/version.rb
CHANGED
data/lib/xlsxtream/workbook.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "stringio"
|
3
|
+
require "xlsxtream/errors"
|
3
4
|
require "xlsxtream/xml"
|
4
5
|
require "xlsxtream/shared_string_table"
|
5
6
|
require "xlsxtream/workbook"
|
@@ -10,6 +11,15 @@ require "xlsxtream/io/stream"
|
|
10
11
|
module Xlsxtream
|
11
12
|
class Workbook
|
12
13
|
|
14
|
+
FONT_FAMILY_IDS = {
|
15
|
+
'' => 0,
|
16
|
+
'roman' => 1,
|
17
|
+
'swiss' => 2,
|
18
|
+
'modern' => 3,
|
19
|
+
'script' => 4,
|
20
|
+
'decorative' => 5
|
21
|
+
}.freeze
|
22
|
+
|
13
23
|
class << self
|
14
24
|
|
15
25
|
def open(data = nil, options = {})
|
@@ -98,6 +108,14 @@ module Xlsxtream
|
|
98
108
|
end
|
99
109
|
|
100
110
|
def write_styles
|
111
|
+
font_options = @options.fetch(:font, {})
|
112
|
+
font_size = font_options.fetch(:size, 12).to_s
|
113
|
+
font_name = font_options.fetch(:name, 'Calibri').to_s
|
114
|
+
font_family = font_options.fetch(:family, 'Swiss').to_s.downcase
|
115
|
+
font_family_id = FONT_FAMILY_IDS[font_family] or fail Error,
|
116
|
+
"Invalid font family #{font_family}, must be one of "\
|
117
|
+
+ FONT_FAMILY_IDS.keys.map(&:inspect).join(', ')
|
118
|
+
|
101
119
|
@io.add_file "xl/styles.xml"
|
102
120
|
@io << XML.header
|
103
121
|
@io << XML.strip(<<-XML)
|
@@ -108,9 +126,9 @@ module Xlsxtream
|
|
108
126
|
</numFmts>
|
109
127
|
<fonts count="1">
|
110
128
|
<font>
|
111
|
-
<sz val="
|
112
|
-
<name val="
|
113
|
-
<family val="
|
129
|
+
<sz val="#{XML.escape_attr font_size}"/>
|
130
|
+
<name val="#{XML.escape_attr font_name}"/>
|
131
|
+
<family val="#{font_family_id}"/>
|
114
132
|
</font>
|
115
133
|
</fonts>
|
116
134
|
<fills count="2">
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xlsxtream
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix Bünemann
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- bin/console
|
99
99
|
- bin/setup
|
100
100
|
- lib/xlsxtream.rb
|
101
|
+
- lib/xlsxtream/errors.rb
|
101
102
|
- lib/xlsxtream/io/directory.rb
|
102
103
|
- lib/xlsxtream/io/hash.rb
|
103
104
|
- lib/xlsxtream/io/rubyzip.rb
|