| | |
| | | minRowLength: 0, // excel最少渲染多少行,如果想实现根据xlsx实际函数渲染,可以将此值设置为0. |
| | | widthOffset: 10, //如果渲染出来的结果感觉单元格宽度不够,可以在默认渲染的列表宽度上再加 Npx宽 |
| | | heightOffset: 10, //在默认渲染的列表高度上再加 Npx高 |
| | | beforeTransformData: (workbookData) => { return workbookData }, //底层通过exceljs获取excel文件内容,通过该钩子函数,可以对获取的excel文件内容进行修改,比如某个单元格的数据显示不正确,可以在此自行修改每个单元格的value值。 |
| | | beforeTransformData: (workbookData) => { return workbookData }, //底层通过exceljs获取excel文件内容,通过该钩子函数,可以对获取的excel文件内容进行修改,比如某个单元格的数据显示不正确,可以自行修改每个单元格的value值。 |
| | | transformData: (workbookData) => { return workbookData }, //将获取到的excel数据进行处理之后且渲染到页面之前,可通过transformData对即将渲染的数据及样式进行修改,此时每个单元格的text值就是即将渲染到页面上的内容 |
| | | }, |
| | | csvList: [],//csv文件数据 |
| | |
| | | }, |
| | | computed: { |
| | | isImage() { |
| | | let state = /\.(jpg|jpeg|png|gif)$/i.test(this.fileUrl) |
| | | // let state = /\.(jpg|jpeg|png|gif)$/i.test(this.fileUrl) |
| | | // this.imgUrl = this.fileUrl |
| | | // if (state) { |
| | | // this.imgUrl = this.fileUrl.replaceAll('word', 'img') |
| | | // } |
| | | // 从 URL 或文件名中提取实际的文件名 |
| | | const fileName = this.currentFile.fileName || this.fileUrl.split('/').pop().split('?')[0] |
| | | let state = /\.(jpg|jpeg|png|gif)$/i.test(fileName) |
| | | this.imgUrl = this.fileUrl |
| | | if (state) { |
| | | this.imgUrl = this.fileUrl.replaceAll('word', 'img') |
| | | } |
| | | console.log("文件名:", fileName, "是否图片:", state) |
| | | return state; |
| | | }, |
| | | isPdf() { |
| | | return /\.pdf$/i.test(this.fileUrl); |
| | | // return /\.pdf$/i.test(this.fileUrl); |
| | | const fileName = this.currentFile.fileName || this.fileUrl.split('/').pop().split('?')[0] |
| | | return /\.pdf$/i.test(fileName); |
| | | }, |
| | | isDoc() { |
| | | return /\.(doc|docx)$/i.test(this.fileUrl); |
| | | // return /\.(doc|docx)$/i.test(this.fileUrl); |
| | | const fileName = this.currentFile.fileName || this.fileUrl.split('/').pop().split('?')[0] |
| | | return /\.(doc|docx)$/i.test(fileName); |
| | | }, |
| | | isXls() { |
| | | let state = /\.(xls|xlsx)$/i.test(this.fileUrl) |
| | | // let state = /\.(xls|xlsx)$/i.test(this.fileUrl) |
| | | // if (state) { |
| | | // if (/\.(xlsx)$/i.test(this.fileUrl)) { |
| | | // this.options.xls = false |
| | | // } else { |
| | | // this.options.xls = true |
| | | // } |
| | | // } |
| | | const fileName = this.currentFile.fileName || this.fileUrl.split('/').pop().split('?')[0] |
| | | let state = /\.(xls|xlsx)$/i.test(fileName) |
| | | if (state) { |
| | | if (/\.(xlsx)$/i.test(this.fileUrl)) { |
| | | if (/\.(xlsx)$/i.test(fileName)) { |
| | | this.options.xls = false |
| | | } else { |
| | | this.options.xls = true |