-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Download request stats as excel (#236)
- Loading branch information
Showing
9 changed files
with
150 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Injectable } from "@angular/core"; | ||
import * as FileSaver from "file-saver"; | ||
import * as XLSX from "xlsx"; | ||
|
||
const EXCEL_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"; | ||
const EXCEL_EXTENSION = ".xlsx"; | ||
|
||
@Injectable() | ||
export class ExcelService { | ||
|
||
|
||
public exportAsExcelFile(json: unknown[], excelFileName: string): void { | ||
|
||
const myworksheet: XLSX.WorkSheet = XLSX.utils.json_to_sheet(json); | ||
const myworkbook: XLSX.WorkBook = { Sheets: { "data": myworksheet }, SheetNames: ["data"] }; | ||
const excelBuffer: BlobPart = XLSX.write(myworkbook, { bookType: "xlsx", type: "array" }); | ||
this.saveAsExcelFile(excelBuffer, excelFileName); | ||
} | ||
|
||
private saveAsExcelFile(buffer: BlobPart, fileName: string): void { | ||
const data: Blob = new Blob([buffer], { | ||
type: EXCEL_TYPE | ||
}); | ||
FileSaver.saveAs(data, fileName + EXCEL_EXTENSION); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,3 @@ thead { | |
white-space: nowrap; | ||
overflow: hidden; | ||
} | ||
|
||
.compare-desc { | ||
font-size: 13px; | ||
font-weight: 400; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters