main.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. export const fileTypes = {
  2. "image/gif": "image",
  3. "image/jpeg": "image",
  4. "image/jpg": "image",
  5. "image/png": "image",
  6. "video/mp4": "video",
  7. "video/avi": "video",
  8. "application/vnd.ms-excel": "excel.xls",
  9. "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "excel.xlsx",
  10. "application/pdf": "pdf",
  11. "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
  12. "text/plain": "txt"
  13. }
  14. export const officeOptions = {
  15. excel: {
  16. xls: false, // 预览xlsx文件设为false;预览xls文件设为true
  17. minColLength: 0, // excel最少渲染多少列,如果想实现xlsx文件内容有几列,就渲染几列,可以将此值设置为0.
  18. minRowLength: 0, // excel最少渲染多少行,如果想实现根据xlsx实际函数渲染,可以将此值设置为0.
  19. widthOffset: 10, // 如果渲染出来的结果感觉单元格宽度不够,可以在默认渲染的列表宽度上再加 Npx宽
  20. heightOffset: 10, // 在默认渲染的列表高度上再加 Npx高
  21. beforeTransformData: workbookData => workbookData, // 底层通过exceljs获取excel文件内容,通过该钩子函数,可以对获取的excel文件内容进行修改,比如某个单元格的数据显示不正确,可以在此自行修改每个单元格的value值。
  22. transformData: workbookData => workbookData // 将获取到的excel数据进行处理之后且渲染到页面之前,可通过transformData对即将渲染的数据及样式进行修改,此时每个单元格的text值就是即将渲染到页面上的内容
  23. },
  24. pdf: {
  25. // width: 500, //number,可不传,用来控制pdf预览的宽度,默认根据文档实际宽度计算
  26. httpHeaders: {}, //object, Basic authentication headers
  27. password: "" //string, 加密pdf的密码
  28. },
  29. docx: {
  30. className: "docx", //class name/prefix for default and document style classes
  31. inWrapper: true, //enables rendering of wrapper around document content
  32. ignoreWidth: false, //disables rendering width of page
  33. ignoreHeight: false, //disables rendering height of page
  34. ignoreFonts: false, //disables fonts rendering
  35. breakPages: true, //enables page breaking on page breaks
  36. ignoreLastRenderedPageBreak: false, //disables page breaking on lastRenderedPageBreak elements
  37. experimental: false, //enables experimental features (tab stops calculation)
  38. trimXmlDeclaration: true, //if true, xml declaration will be removed from xml documents before parsing
  39. useBase64URL: false, //if true, images, fonts, etc. will be converted to base 64 URL, otherwise URL.createObjectURL is used
  40. useMathMLPolyfill: false, //includes MathML polyfills for chrome, edge, etc.
  41. showChanges: false, //enables experimental rendering of document changes (inserions/deletions)
  42. debug: false //enables additional logging
  43. }
  44. }