Skip to content

Commit

Permalink
Merge pull request #96 from DDMAL/fix-parse-xlsx
Browse files Browse the repository at this point in the history
fix: match image header when parsing excel file
  • Loading branch information
kunfang98927 authored Jul 3, 2024
2 parents 3997320 + 9651db3 commit 3c1228f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Dashboard/Storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ async function parseXLSX(file: File): Promise<any[]> {
rows.push(rowData);
}
});
let imageHeader = headerNames.find((header) => header.includes('image'));
for (const image of worksheet.getImages()) {
// fetch the media item with the data
const img = workbook.model.media.find((m) => m.index === image.imageId);
const base64 = img.buffer.toString('base64');
const dataUrl = `data:${img.type};base64,${base64}`;
rows[image.range.tl.nativeRow - 1]['imagePath'] = dataUrl;
rows[image.range.tl.nativeRow - 1][imageHeader] = dataUrl;
}
resolve([headerNames, rows]);
});
Expand Down

0 comments on commit 3c1228f

Please sign in to comment.