Commit 1b5b2aac by liyijie

Add with_scope for records

parent e9126beb
......@@ -27,6 +27,7 @@ module TalltyImportExport
# index: 数组方式,需要嵌套拿到里面的
def export_xlsx records, **options
records = with_scope records
exportable_defaults(options)
options = options.with_indifferent_access
......@@ -77,7 +78,7 @@ module TalltyImportExport
sheet.add_row headers.map{|header| header[:name]}, style: title2, height: 39
each_method = records.is_a?(Array) ? :each : :find_each
each_method = records.is_a?(Array) ? :each : :each
records.send(each_method) do |record|
row = []
headers.each{ |header| row.push(handle_data(record, header)) }
......@@ -96,6 +97,10 @@ module TalltyImportExport
@group_by ||= options.delete(:group_by)
end
def with_scope records
records
end
def headers= val
@headers = val.map { |header| header.with_indifferent_access }
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment