Skip to content

Commit

Permalink
fix(Microsoft Excel 365 Node): Support for more extensions in workboo…
Browse files Browse the repository at this point in the history
…k rlc (#7020)

Github issue / Community forum post (link here to close automatically):
  • Loading branch information
michael-radency committed Aug 25, 2023
1 parent 0356419 commit d6e1cf2
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packages/nodes-base/nodes/Microsoft/Excel/v2/methods/listSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ export async function searchWorkbooks(
filter?: string,
paginationToken?: string,
): Promise<INodeListSearchResult> {
const q = filter ? encodeURI(`.xlsx AND ${filter}`) : '.xlsx';
const fileExtensions = ['.xlsx', '.xlsm', '.xlst'];
const extensionFilter = fileExtensions.join(' OR ');

const q = filter || extensionFilter;

let response: IDataObject = {};

Expand All @@ -37,10 +40,22 @@ export async function searchWorkbooks(
);
}

if (response.value && filter) {
response.value = (response.value as IDataObject[]).filter((workbook: IDataObject) => {
return fileExtensions.some((extension) => (workbook.name as string).includes(extension));
});
}

return {
results: (response.value as IDataObject[]).map((workbook: IDataObject) => {
for (const extension of fileExtensions) {
if ((workbook.name as string).includes(extension)) {
workbook.name = (workbook.name as string).replace(extension, '');
break;
}
}
return {
name: (workbook.name as string).replace('.xlsx', ''),
name: workbook.name as string,
value: workbook.id as string,
url: workbook.webUrl as string,
};
Expand Down

0 comments on commit d6e1cf2

Please sign in to comment.