Skip to content

Commit 1ab14fa

Browse files
authored
chore: order excel single row output (#1133)
## Problem The output of Excel “Find single row” is not ordered in the same sequence as the columns in the Excel workbook. ## Solution Add the columns to `dataOut` and use them to specify the order in `getDataOutMetadata` ## Before & After Screenshots **Excel table** <img width="431" height="141" alt="Screenshot 2025-07-31 at 2 42 16 PM" src="https://github.com/user-attachments/assets/e8eebac5-c854-419f-819d-26f90dacaa1e" /> **BEFORE**: https://github.com/user-attachments/assets/34757e51-be0f-4106-b802-a856a2ce22d6 **AFTER**: https://github.com/user-attachments/assets/a2daf869-2447-4e71-ab82-b5b7861798b8 ## Tests - [ ] Existing Excel steps that do not have `columns` in their `dataOut` do not throw error, and output is still rendered correctly - [ ] Find table row still fetches the correct rows - [ ] Columns are now in the same order as the Excel workbook when executing 'Check step' from this PR.
1 parent 63c7781 commit 1ab14fa

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

packages/backend/src/apps/m365-excel/actions/get-table-row/get-data-out-metadata.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,21 @@ async function getDataOutMetadata(
2121
return metadata
2222
}
2323

24+
// hide column array from the output, its only used to order the row data
25+
metadata.columns =
26+
dataOut?.columns?.map((column) => ({
27+
type: 'text',
28+
label: column,
29+
isHidden: true,
30+
})) || []
31+
2432
metadata.rowData = Object.create(null)
2533
for (const [key, datum] of Object.entries(dataOut.rowData)) {
2634
metadata.rowData[key] = {
2735
value: {
2836
type: 'text',
2937
label: datum.columnName,
38+
order: (dataOut?.columns?.indexOf(datum.columnName) ?? 0) + 1,
3039
},
3140
columnName: {
3241
isHidden: true,
@@ -57,5 +66,6 @@ export default getDataOutMetadata
5766
// value: '5',
5867
// },
5968
// },
60-
// sheetRowNumber: 3
69+
// sheetRowNumber: 3,
70+
// columns: ['Item', 'Unit Price'],
6171
// }

packages/backend/src/apps/m365-excel/actions/get-table-row/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ const action: IRawAction = {
174174
columns,
175175
}),
176176
sheetRowNumber,
177+
columns,
177178
} satisfies DataOut,
178179
})
179180
},

packages/backend/src/apps/m365-excel/actions/get-table-row/schemas.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,7 @@ export const dataOutSchema = z.discriminatedUnion('foundRow', [
2626
foundRow: z.literal(true),
2727
rowData: hexEncodedRowRecordSchema,
2828
sheetRowNumber: z.number(),
29+
// optional for backward compatibility
30+
columns: z.array(z.string()).optional(),
2931
}),
3032
])

0 commit comments

Comments
 (0)