Skip to content

Commit

Permalink
feat: xls export for projects and units finalize
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeen committed Jan 23, 2022
1 parent e386a13 commit 4b7e223
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/utils/xls.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,14 @@ export const createXlsFromSequelizeResults = (rows, model, hex = false, csv = fa
if (!Object.keys(sheets).includes(associatedModel)) {
sheets[associatedModel] = { name: associatedModel, data: [Object.keys(assocColVal).concat([model.name + 'Id'])], };
}
for (const v of Object.values(assocColVal).map(col => col === null ? 'null': col)) {
const colNames = Object.keys(assocColVal);
for (const [i, v] of Object.values(assocColVal).map(col => col === null ? 'null': col).entries()) {
if (typeof v === 'object') {
if (!Object.keys(sheets).includes(colNames[i] + 's')) {
sheets[colNames[i] + 's'] = { name: colNames[i] + 's', data: [Object.keys(v).concat([colNames[i].split('_') + 'Id'])], };
}
sheets[colNames[i] + 's'].data.push(Object.values(v).concat(assocColVal.id));
}
xlsRow.push(encodeValue(v, hex));
}
if (xlsRow.length > 0) {
Expand Down

0 comments on commit 4b7e223

Please sign in to comment.