rpt_excel_util.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * Created by Tony on 2017/4/1.
  3. */
  4. var JV = require('../rpt_component/Jpc_ValueDefine');
  5. const dftHeadXml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
  6. function writeContentTypes(sheets) {
  7. var rst = [];
  8. rst.push[dftHeadXml + '\r\n'];
  9. rst.push['<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">'];
  10. //...
  11. rst.push['<Override PartName="/xl/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/>'];
  12. rst.push['<Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>'];
  13. rst.push['<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>'];
  14. rst.push['<Default Extension="xml" ContentType="application/xml"/>'];
  15. rst.push['<Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>'];
  16. rst.push['<Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/>'];
  17. rst.push['<Override PartName="/xl/sharedStrings.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"/>'];
  18. for (var i = 0; i < sheets.length; i++) {
  19. rst.push('<Override PartName="/xl/worksheets/' + sheets[i].sheetName + '.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>')
  20. }
  21. rst.push['<Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>'];
  22. rst.push['</Types>'];
  23. return rst;
  24. }
  25. function writeRootRels(){
  26. var rst = [];
  27. rst.push[dftHeadXml + '\r\n'];
  28. rst.push['<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">'];
  29. rst.push['<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>'];
  30. rst.push['<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>'];
  31. rst.push['<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/>'];
  32. //rst.push['']; ...
  33. rst.push['</Relationships>'];
  34. return rst;
  35. }
  36. function writeApp(sheets) {
  37. var rst = [];
  38. rst.push[dftHeadXml + '\r\n'];
  39. rst.push['<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">'];
  40. rst.push['<Application>Microsoft Excel</Application>'];
  41. rst.push['<DocSecurity>0</DocSecurity>'];
  42. rst.push['<ScaleCrop>false</ScaleCrop>'];
  43. rst.push['<HeadingPairs>'];
  44. rst.push['<vt:vector size="2" baseType="variant">'];
  45. rst.push['<vt:variant><vt:lpstr>¹¤×÷±í</vt:lpstr></vt:variant>'];
  46. rst.push['<vt:variant><vt:i4>' + sheets.length + '</vt:i4></vt:variant>'];
  47. rst.push['</vt:vector>'];
  48. rst.push['</HeadingPairs>'];
  49. rst.push['<TitlesOfParts>'];
  50. rst.push['<vt:vector size="' + sheets.length + '" baseType="lpstr">'];
  51. for (var i = 0; i < sheets.length; i++) {
  52. rst.push('<vt:lpstr>' + sheets[i].sheetName + '</vt:lpstr>')
  53. }
  54. rst.push['</vt:vector>'];
  55. rst.push['</TitlesOfParts>'];
  56. rst.push['<Company>SmartCost</Company>'];
  57. rst.push['<LinksUpToDate>false</LinksUpToDate>'];
  58. rst.push['<SharedDoc>false</SharedDoc>'];
  59. rst.push['<HyperlinksChanged>false</HyperlinksChanged>'];
  60. rst.push['<AppVersion>12.0000</AppVersion>'];
  61. //rst.push[''];
  62. rst.push['</Properties>'];
  63. return rst;
  64. }
  65. function writeCore() {
  66. //
  67. }
  68. module.exports = {
  69. exportExcel: function (pageData, options) {
  70. var rptOptions = (options || {singlePage: false, fileName: 'report'});
  71. }
  72. }