From e1e79a9f4035463c3d87c92c2e448052252d271b Mon Sep 17 00:00:00 2001 From: Carl Brugger Date: Fri, 26 Apr 2024 15:33:09 -0500 Subject: [PATCH] fix: excel parser error handling (#497) --- .changeset/khaki-needles-join.md | 5 +++++ plugins/xlsx-extractor/src/parser.ts | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .changeset/khaki-needles-join.md diff --git a/.changeset/khaki-needles-join.md b/.changeset/khaki-needles-join.md new file mode 100644 index 000000000..fff480be9 --- /dev/null +++ b/.changeset/khaki-needles-join.md @@ -0,0 +1,5 @@ +--- +'@flatfile/plugin-xlsx-extractor': patch +--- + +This release reattempts to read XLSX files that may have emitted an error that could be handled. diff --git a/plugins/xlsx-extractor/src/parser.ts b/plugins/xlsx-extractor/src/parser.ts index 642aa5cc0..0867a5d1f 100644 --- a/plugins/xlsx-extractor/src/parser.ts +++ b/plugins/xlsx-extractor/src/parser.ts @@ -38,7 +38,14 @@ export async function parseBuffer( 'File is too large to parse. Try converting this file to CSV.' ) } - throw e + + // Try reading the file again without the 'WTF' option. + workbook = XLSX.read(buffer, { + type: 'buffer', + cellDates: true, + dense: true, + dateNF: options?.dateNF || undefined, + }) } const sheetNames = Object.keys(workbook.Sheets)