Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tallty_import_export
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
tallty_import_export
Commits
557ccd5a
Commit
557ccd5a
authored
May 07, 2022
by
Ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 收尾
parent
25ae125c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
export_form.rb
lib/tallty_import_export/export_form.rb
+14
-8
export_spec.rb
spec/export_spec.rb
+1
-1
No files found.
lib/tallty_import_export/export_form.rb
View file @
557ccd5a
module
TalltyImportExport
module
TalltyImportExport
class
ExportForm
<
TalltyImportExport
::
Export
class
ExportForm
<
TalltyImportExport
::
Export
def
initialize
def
initialize
*
attrs
super
(
{}
)
super
(
*
attrs
)
end
end
class
<<
self
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
end
end
...
@@ -17,19 +20,20 @@ module TalltyImportExport
...
@@ -17,19 +20,20 @@ module TalltyImportExport
title1
=
workbook
.
styles
.
add_style
(
alignment:
alignment
,
border:
border
,
sz:
12
,
b:
true
)
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"
)
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
)
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
header_obj
=
export_headers_result
**
options
workbook
.
add_worksheet
(
name:
_sheet_name
)
do
|
sheet
|
workbook
.
add_worksheet
(
name:
_sheet_name
)
do
|
sheet
|
index
=
0
if
respond_to?
(
:first_header
)
if
respond_to?
(
:first_header
)
row_index
=
Axlsx
.
col_ref
(
header
_obj
.
flatten_value
.
size
-
1
)
row_index
=
Axlsx
.
col_ref
(
header
s
.
size
-
1
)
sheet
.
merge_cells
(
"A1:
#{
row_index
}
1"
)
sheet
.
merge_cells
(
"A1:
#{
row_index
}
1"
)
sheet
.
add_row
[
first_header
],
style:
title1
,
height:
30
sheet
.
add_row
[
first_header
],
style:
title1
,
height:
30
index
+=
1
end
end
index
=
0
header_obj
.
header_lines
.
each
do
|
header_line
|
header_obj
.
header_lines
.
each
do
|
header_line
|
sheet
.
add_row
(
header_line
.
map
(
&
:name
),
style:
title2
,
height:
25
)
sheet
.
add_row
(
header_line
.
map
(
&
:name
),
style:
title2
,
height:
25
)
index
+=
1
index
+=
1
...
@@ -46,6 +50,8 @@ module TalltyImportExport
...
@@ -46,6 +50,8 @@ module TalltyImportExport
end
end
end
end
return
if
options
[
:header_only
]
value_seq_to_axios
=
{}
value_seq_to_axios
=
{}
formats
=
[]
formats
=
[]
...
...
spec/export_spec.rb
View file @
557ccd5a
...
@@ -82,7 +82,7 @@ RSpec.describe TalltyImportExport::Importable do
...
@@ -82,7 +82,7 @@ RSpec.describe TalltyImportExport::Importable do
it
'export'
do
it
'export'
do
# TalltyImportExport::ExportForm.new.export_workbook nil, [@payload], { headers: @header_h[:items] }
# 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
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment