Support TS, swagger,Template(xls,docx),PDF convert
This commit is contained in:
parent
b221deb1cf
commit
8d7654423a
84 changed files with 3604 additions and 1 deletions
67
libs/report-template.ts
Normal file
67
libs/report-template.ts
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
export interface templateData {
|
||||
template: string;
|
||||
reportName: string;
|
||||
data: object
|
||||
}
|
||||
export interface IDictionary<TValue> {
|
||||
[key: string]: TValue;
|
||||
}
|
||||
export function mimeToExtension(mime: string): string {
|
||||
const mimeList: IDictionary<string> = {
|
||||
"application/pdf": "pdf",
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
|
||||
"application/msword": "doc",
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
|
||||
"application/vnd.ms-excel": "xls",
|
||||
"application/vnd.ms-powerpoint": "ppt",
|
||||
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
|
||||
"application/vnd.oasis.opendocument.text": "odt",
|
||||
"application/vnd.oasis.opendocument.spreadsheet":"ods",
|
||||
"application/vnd.oasis.opendocument.presentation":"odp",
|
||||
"text/html": "html",
|
||||
"application/json": "json",
|
||||
"text/csv": "csv",
|
||||
"text/markdown": "md",
|
||||
"text/plain": "txt",
|
||||
"application/rtf": "rtf"
|
||||
}
|
||||
if (mimeList[mime]) {
|
||||
return mimeList[mime]
|
||||
} else if (mime.match(/^application\/x\./)) {
|
||||
return mime.substr(mime.indexOf('.') + 1);
|
||||
} else {
|
||||
return mime
|
||||
}
|
||||
|
||||
}
|
||||
/** javascript-obfuscator:disable
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: report-template
|
||||
* description: API สำหรับสร้างเอกสารจาก Template docx หรือ xlsx การทำงานคล้ายการทำ Mail Merge ทำให้ยูสเซอร์ทั่วไปแก้ Template ได้ง่าย สามารถแปลงไฟล์นามสกุลอื่นๆที่ soffice รองรับ
|
||||
*/
|
||||
|
||||
|
||||
/** javascript-obfuscator:disable
|
||||
* @swagger
|
||||
* components:
|
||||
* schemas:
|
||||
* templateData:
|
||||
* type: object
|
||||
* required:
|
||||
* - template
|
||||
* - reportName
|
||||
* - data
|
||||
* - finished
|
||||
* properties:
|
||||
* template:
|
||||
* type: string
|
||||
* description: name of template
|
||||
* reportName:
|
||||
* type: string
|
||||
* description: name of report for download
|
||||
* data:
|
||||
* type: object
|
||||
* description: value for template
|
||||
*/
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue