Commit 557ccd5a by Ivan Lan

feat: 收尾

parent 25ae125c
module TalltyImportExport
class ExportForm < TalltyImportExport::Export
def initialize
super({})
def initialize *attrs
super(*attrs)
end
class << self
def form_transfer_to_headers form
def export_template_xlsx form
export_xlsx([], {
headers: form_transfer_to_headers(form),
header_only: true
})
end
end
......@@ -17,19 +20,20 @@ module TalltyImportExport
title1 = workbook.styles.add_style(alignment: alignment, border: border, sz: 12, b: true)
title2 = workbook.styles.add_style(alignment: alignment, border: border, bg_color: "2a5caa", sz: 12, fg_color: "fffffb")
title3 = workbook.styles.add_style(alignment: alignment.merge(wrap_text: true), border: border, sz: 10)
_sheet_name = respond_to?(:sheet_name) ? self.sheet_name : nil
_sheet_name = (respond_to?(:sheet_name) ? self.sheet_name : nil) || options[:sheet_name]
header_obj = export_headers_result **options
workbook.add_worksheet(name: _sheet_name) do |sheet|
index = 0
if respond_to?(:first_header)
row_index = Axlsx.col_ref(header_obj.flatten_value.size - 1)
row_index = Axlsx.col_ref(headers.size - 1)
sheet.merge_cells("A1:#{row_index}1")
sheet.add_row [first_header], style: title1, height: 30
index += 1
end
index = 0
header_obj.header_lines.each do |header_line|
sheet.add_row(header_line.map(&:name), style: title2, height: 25)
index += 1
......@@ -46,6 +50,8 @@ module TalltyImportExport
end
end
return if options[:header_only]
value_seq_to_axios = {}
formats = []
......
......@@ -82,7 +82,7 @@ RSpec.describe TalltyImportExport::Importable do
it 'export' do
# TalltyImportExport::ExportForm.new.export_workbook nil, [@payload], { headers: @header_h[:items] }
TalltyImportExport::ExportForm.new.export_xlsx [@payload, @payload], { headers: @header_h[:items] }
TalltyImportExport::ExportForm.new(nil).export_xlsx [@payload, @payload], { headers: @header_h[:items] }
end
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