active_scaffold_export 3.6.0 → 3.7.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 134b623b7c2d2a8a213e9a4d96b5a109bc2c4328f65a9a99ea8298877cbdf0b9
|
4
|
+
data.tar.gz: 339001d89e079dd644e5d400cea2ee0d0f98e2d4f31d07c6ed506c7f152058c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6f20cc0ad8963b04605ba640839bd29e3188dbbddff8a1d994a1ec0e7c8f04f7520cbade25dac488ba2de4a82d5f9a3a5b3254a42644f1ef13549a35a66406a
|
7
|
+
data.tar.gz: 10fbed3a3f6dd3686068fd8b611ebeee814b48c18e477b56c66b46c5a39e7d25f5b11aafdfa10570476ee2efa941c70665d57345ddd51d9e6507fcc6f42cfc10
|
data/README.md
CHANGED
@@ -58,13 +58,20 @@ active_scaffold:
|
|
58
58
|
```
|
59
59
|
|
60
60
|
### XLSX support
|
61
|
-
This support depends on
|
61
|
+
This support depends on caxlsx_rails and caxlsx of course.
|
62
62
|
header styling override will be added soon.
|
63
63
|
NOTE: There's NO streaming support for xlsx format. Only CSV. So if your data is huge, set default_file_format to 'csv' instead.
|
64
64
|
Streaming in xlsx will never be supported since the entire file needs to be serialized and zipped to be a valid OOXML file.
|
65
65
|
So, rather than streaming, background jobs will be the most likely future approach.
|
66
66
|
[Read axlsx issue about this](https://github.com/randym/axlsx/issues/169#issuecomment-13252750)
|
67
67
|
|
68
|
-
|
68
|
+
The sheet name is generated from conf.label, replacing forbidden chars with '-' and truncated to 31. The generated name can be changed defining workseet_name method in the controller, and calling super with options for truncate String method, and :replace option to use other character, e.g.
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
def worksheet_name(options = {})
|
72
|
+
super replace: '_', omission: ''
|
73
|
+
end
|
74
|
+
```
|
75
|
+
|
69
76
|
For contact, help, support, comments, please use Active Scaffold official mailing list activescaffold@googlegroups.com
|
70
77
|
|
@@ -75,7 +75,7 @@ module ActiveScaffold::Actions
|
|
75
75
|
response.headers['Content-type'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
76
76
|
pkg = Axlsx::Package.new
|
77
77
|
header = pkg.workbook.styles.add_style sz: 11, b: true,:bg_color => "69B5EF", :fg_color => "FF", alignment: { horizontal: :center }
|
78
|
-
pkg.workbook.add_worksheet(name:
|
78
|
+
pkg.workbook.add_worksheet(name: worksheet_name) do |sheet|
|
79
79
|
sheet.add_row(@export_columns.collect { |column| view_context.format_export_column_header_name(column) }, style: header) unless params[:skip_header]
|
80
80
|
find_items_for_export do |records|
|
81
81
|
records.each do |record|
|
@@ -89,6 +89,12 @@ module ActiveScaffold::Actions
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
+
def worksheet_name(options = {})
|
93
|
+
active_scaffold_config.label.
|
94
|
+
gsub(/[#{Regexp.quote Axlsx::WORKSHEET_NAME_FORBIDDEN_CHARS.join}]/, options[:replace] || '-').
|
95
|
+
truncate(Axlsx::WORKSHEET_MAX_NAME_LENGTH, options)
|
96
|
+
end
|
97
|
+
|
92
98
|
def export_columns
|
93
99
|
return @export_columns if defined? @export_columns
|
94
100
|
@export_columns = active_scaffold_config.export.columns.reject { |col| params[:export_columns][col.to_sym].nil? }
|
@@ -12,6 +12,8 @@ module ActiveScaffold
|
|
12
12
|
def get_export_column_value(record, column, format)
|
13
13
|
if (method = export_column_override(column))
|
14
14
|
send(method, record)
|
15
|
+
elsif column.list_ui && (method = override_export_ui(column.list_ui))
|
16
|
+
send(method, record, column, ui_options: column.list_ui_options || column.options)
|
15
17
|
else
|
16
18
|
raw_value = record.send(column.name)
|
17
19
|
|
@@ -31,6 +33,15 @@ module ActiveScaffold
|
|
31
33
|
override_helper column, 'export_column'
|
32
34
|
end
|
33
35
|
|
36
|
+
# the naming convention for overriding column types with helpers
|
37
|
+
def override_export_ui(list_ui)
|
38
|
+
ActiveScaffold::Registry.cache :export_ui_overrides, list_ui do
|
39
|
+
method = "active_scaffold_export_#{list_ui}"
|
40
|
+
method if respond_to? method
|
41
|
+
end
|
42
|
+
end
|
43
|
+
alias override_export_ui? override_export_ui
|
44
|
+
|
34
45
|
def format_export_column(raw_value, format)
|
35
46
|
method = "format_value_for_#{format}"
|
36
47
|
respond_to?(method) ? send(method, raw_value) : raw_value
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_scaffold_export
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Volker Hochstein
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-
|
13
|
+
date: 2024-07-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: active_scaffold
|