export_to 1.0.0 → 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/Gemfile.lock +1 -1
- data/lib/export_to/base.rb +4 -4
- data/lib/export_to/exporter/xlsx.rb +10 -10
- data/lib/export_to/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e6900888a5e2ff9dc099b3f6327a4ce1b07869c80991afc86c48be902baa554
|
4
|
+
data.tar.gz: f5dc1916c65e52376fcce1de96699628262b340cfacb97c32576b0c5d9b5afeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 100069ed5dc91b24173488fb30a2d7c821673184ddd9dfc68290756f7e752e0a5bb35611e1037e236d1e8040746ed20963a0db3840d26303d66f4ea8a6e3477c
|
7
|
+
data.tar.gz: a69f77a907acaec0f701ad692b10072b1060d1502aae48e15b5e9fc0c547947db97ca0a3b83ea2fd3ecccedc6692278aea6259a6c38cedc61b82faf6e6881c62
|
data/Gemfile.lock
CHANGED
data/lib/export_to/base.rb
CHANGED
@@ -3,7 +3,7 @@ module ExportTo
|
|
3
3
|
class_attribute :options
|
4
4
|
class_attribute :head_titles
|
5
5
|
class_attribute :body_keys
|
6
|
-
class_attribute :
|
6
|
+
class_attribute :column_options
|
7
7
|
class_attribute :body_column_proc
|
8
8
|
|
9
9
|
class_attribute :presenter_klass
|
@@ -99,15 +99,15 @@ module ExportTo
|
|
99
99
|
self.options = options
|
100
100
|
end
|
101
101
|
|
102
|
-
def set(title, key,
|
102
|
+
def set(title, key, options={}, &block)
|
103
103
|
self.head_titles ||= []
|
104
104
|
self.body_keys ||= []
|
105
|
-
self.
|
105
|
+
self.column_options ||= []
|
106
106
|
self.body_column_proc ||= []
|
107
107
|
|
108
108
|
self.head_titles.push(title)
|
109
109
|
self.body_keys.push(key)
|
110
|
-
self.
|
110
|
+
self.column_options.push(options)
|
111
111
|
self.body_column_proc.push(block)
|
112
112
|
end
|
113
113
|
|
@@ -4,7 +4,7 @@ module ExportTo
|
|
4
4
|
|
5
5
|
def export
|
6
6
|
rows.each! do |columns, model, x|
|
7
|
-
worksheet.set_row(x, height, nil)
|
7
|
+
worksheet.set_row(x, height, nil) if x > 0
|
8
8
|
worksheet.write_row(x, columns)
|
9
9
|
end
|
10
10
|
|
@@ -20,20 +20,20 @@ module ExportTo
|
|
20
20
|
def worksheet
|
21
21
|
@worksheet ||= begin
|
22
22
|
ws = workbook.add_worksheet(options.fetch(:worksheet) { "Default" })
|
23
|
-
# 設定表頭樣式
|
24
|
-
ws.set_row(0, height, head_format)
|
25
23
|
|
26
24
|
# 表身樣式
|
27
|
-
|
28
|
-
next if
|
29
|
-
|
30
|
-
width = format.delete(:width) { FastExcel::DEF_COL_WIDTH }
|
25
|
+
column_options.each_with_index do |column_options, i|
|
26
|
+
next if column_options.blank?
|
31
27
|
|
32
|
-
|
28
|
+
width = column_options.fetch(:width) { FastExcel::DEF_COL_WIDTH }
|
29
|
+
format = column_options.fetch(:format) { {} }
|
33
30
|
|
34
31
|
ws.set_column(i, i, width, workbook.add_format(format))
|
35
32
|
end
|
36
33
|
|
34
|
+
# 設定表頭樣式
|
35
|
+
ws.set_row(0, height, head_format)
|
36
|
+
|
37
37
|
ws
|
38
38
|
end
|
39
39
|
end
|
@@ -54,8 +54,8 @@ module ExportTo
|
|
54
54
|
options.fetch(:height) { 20 }
|
55
55
|
end
|
56
56
|
|
57
|
-
def
|
58
|
-
@
|
57
|
+
def column_options
|
58
|
+
@column_options ||= rows.class.column_options
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
data/lib/export_to/version.rb
CHANGED