BP 438: changed to filesaver; removed xls option
diff --git a/src/app/reporting/components/standby-reporting/standby-reporting.component.html b/src/app/reporting/components/standby-reporting/standby-reporting.component.html
index feffc1c..1b237ce 100644
--- a/src/app/reporting/components/standby-reporting/standby-reporting.component.html
+++ b/src/app/reporting/components/standby-reporting/standby-reporting.component.html
@@ -142,7 +142,6 @@
<option value=""></option>
<option>PDF</option>
<option>XLSX</option>
- <option>XLS</option>
</select>
<ok-error [control]="form.controls['printFormat']"></ok-error>
</div>
diff --git a/src/app/reporting/components/standby-reporting/standby-reporting.component.ts b/src/app/reporting/components/standby-reporting/standby-reporting.component.ts
index 499c97e..4a625eb 100644
--- a/src/app/reporting/components/standby-reporting/standby-reporting.component.ts
+++ b/src/app/reporting/components/standby-reporting/standby-reporting.component.ts
@@ -8,12 +8,14 @@
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
import { Component, OnInit, Injector, OnDestroy } from '@angular/core';
-import { StandbylistObject } from '@shared/model/StandbylistObject';
import { Validators } from '@angular/forms';
+import { Subscription } from 'rxjs';
+
+import { saveAs } from 'file-saver';
+
+import { StandbylistObject } from '@shared/model/StandbylistObject';
import { AbstractFormComponent } from '@shared/abstract/abstract-form/abstract-form.component';
import { MasterdataService } from '@masterdata/services/masterdata.service';
-import { Subscription } from 'rxjs';
-import { UserObject } from '@shared/model/UserObject';
import { ReportingService } from '@reporting/services/reporting.service';
import { ReportObject } from '@shared/model/ReportObject';
import { FormUtil } from '@shared/utils/form.util';
@@ -79,15 +81,13 @@
mimeType = 'application/pdf';
} else if (formValue['printFormat'] === 'xlsx') {
mimeType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
- } else if (formValue['printFormat'] === 'xls') {
- mimeType = 'application/xls';
}
this.downLoadFile
(response,
- mimeType,
- formValue['reportName'],
- formValue['printFormat']);
+ mimeType,
+ formValue['reportName'],
+ formValue['printFormat']);
}
);
}
@@ -165,20 +165,11 @@
this.setReportDefaultDays(false);
}
- downLoadFile(data: any, type: string, reportName: String, printFormat: String) {
+ downLoadFile(data: any, type: string, reportName: string, printFormat: string) {
const blob: Blob = new Blob([data], { type: type });
const fileName: string = reportName + '.' + printFormat.toLocaleLowerCase();
- const objectUrl: string = URL.createObjectURL(blob);
- // Workaround to set filename in TypeScript
- // This also means that the file is not directly opened in the browser
- const a: HTMLAnchorElement = document.createElement('a') as HTMLAnchorElement;
- a.href = objectUrl;
- a.download = fileName;
- document.body.appendChild(a);
- a.click();
- document.body.removeChild(a);
- URL.revokeObjectURL(objectUrl);
+ saveAs(blob, fileName);
}
}