This repository was archived by the owner on Dec 2, 2023. It is now read-only.
File tree 2 files changed +9
-2
lines changed
2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ Template for next version
26
26
27
27
### Fixed
28
28
29
+ - field sort in excel submission export (https://github.com/ohmyform/ohmyform/issues/163 )
30
+
29
31
### Security
30
32
31
33
## [ 1.0.1] - 2022-03-01
Original file line number Diff line number Diff line change @@ -36,6 +36,9 @@ export const ExportSubmissionAction: React.FC<Props> = (props) => {
36
36
workbook . created = new Date ( )
37
37
workbook . modified = new Date ( )
38
38
39
+ const orderedFields = form . data . form . fields
40
+ . sort ( ( a , b ) => ( a . idx ?? 0 ) - ( b . idx ?? 0 ) )
41
+
39
42
const sheet = workbook . addWorksheet ( 'Submissions' )
40
43
sheet . getRow ( 1 ) . values = [
41
44
'Submission ID' ,
@@ -45,7 +48,7 @@ export const ExportSubmissionAction: React.FC<Props> = (props) => {
45
48
'City' ,
46
49
'User Agent' ,
47
50
'Device' ,
48
- ...form . data . form . fields . map ( ( field ) => `${ field . title } (${ field . type } )` ) ,
51
+ ...orderedFields . map ( ( field ) => `${ field . title } (${ field . type } )` ) ,
49
52
]
50
53
51
54
const firstPage = await getSubmissions ( {
@@ -65,7 +68,9 @@ export const ExportSubmissionAction: React.FC<Props> = (props) => {
65
68
data . device . name ,
66
69
]
67
70
68
- data . fields . forEach ( ( field ) => {
71
+ orderedFields . forEach ( ( formField ) => {
72
+ const field = data . fields . find ( field => field . id === formField . id )
73
+
69
74
try {
70
75
fieldTypes [ field . type ] ?. stringifyValue ( field . value )
71
76
You can’t perform that action at this time.
0 commit comments