Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
criteria.push({ Filter_Name: 'End_Date', value: this.endDate });
this.exportToxlsx(criteria);
}

exportToxlsx(criteria: any) {
if (criteria.length > 0) {
const criteriaArray = criteria.filter(function (obj: any) {
Expand Down Expand Up @@ -232,22 +233,16 @@
report_worksheet.addRow(rowData);
});

// Write to file
workbook.xlsx.writeBuffer().then((buffer) => {
const blob = new Blob([buffer], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
});
saveAs(blob, wb_name + '.xlsx');
if (navigator.msSaveBlob) {
navigator.msSaveBlob(blob, wb_name);
const filename = wb_name.replace(/ /g, '_') + '.xlsx';

Check warning on line 240 in src/app/app-modules/inventory/reports/expiry-report/expiry-report.component.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `String#replaceAll()` over `String#replace()`.

See more on https://sonarcloud.io/project/issues?id=PSMRI_HWC-Inventory-UI-NEXT&issues=AZsRmnI4Hyc47FBcByic&open=AZsRmnI4Hyc47FBcByic&pullRequest=109

if ((window as any).navigator && (window as any).navigator.msSaveBlob) {

Check warning on line 242 in src/app/app-modules/inventory/reports/expiry-report/expiry-report.component.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `globalThis` over `window`.

See more on https://sonarcloud.io/project/issues?id=PSMRI_HWC-Inventory-UI-NEXT&issues=AZsRmnI4Hyc47FBcByie&open=AZsRmnI4Hyc47FBcByie&pullRequest=109

Check warning on line 242 in src/app/app-modules/inventory/reports/expiry-report/expiry-report.component.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer using an optional chain expression instead, as it's more concise and easier to read.

See more on https://sonarcloud.io/project/issues?id=PSMRI_HWC-Inventory-UI-NEXT&issues=AZsRmnI4Hyc47FBcByid&open=AZsRmnI4Hyc47FBcByid&pullRequest=109

Check warning on line 242 in src/app/app-modules/inventory/reports/expiry-report/expiry-report.component.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `globalThis` over `window`.

See more on https://sonarcloud.io/project/issues?id=PSMRI_HWC-Inventory-UI-NEXT&issues=AZsRmnI4Hyc47FBcByif&open=AZsRmnI4Hyc47FBcByif&pullRequest=109
(window as any).navigator.msSaveBlob(blob, filename);

Check warning on line 243 in src/app/app-modules/inventory/reports/expiry-report/expiry-report.component.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `globalThis` over `window`.

See more on https://sonarcloud.io/project/issues?id=PSMRI_HWC-Inventory-UI-NEXT&issues=AZsRmnI4Hyc47FBcByig&open=AZsRmnI4Hyc47FBcByig&pullRequest=109
} else {
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.setAttribute('visibility', 'hidden');
link.download = wb_name.replace(/ /g, '_') + '.xlsx';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
saveAs(blob, filename);
}
});
}
Expand Down