Browse Source

for code frozen

TonyKang 7 years ago
parent
commit
a23912e8bf
1 changed files with 15 additions and 18 deletions
  1. 15 18
      modules/reports/util/rpt_excel_util.js

+ 15 - 18
modules/reports/util/rpt_excel_util.js

@@ -23,10 +23,10 @@ function writeContentTypes(sheets, isSinglePage) {
     rst.push('<Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/>');
     rst.push('<Override PartName="/xl/sharedStrings.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"/>');
     if (isSinglePage) {
-        rst.push('<Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>')
+        rst.push('<Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>');
     } else {
         for (let i = 0; i < sheets.length; i++) {
-            rst.push('<Override PartName="/xl/worksheets/sheet' + (i + 1) + '.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>')
+            rst.push('<Override PartName="/xl/worksheets/sheet' + (i + 1) + '.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>');
         }
     }
     rst.push('<Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>');
@@ -60,11 +60,11 @@ function writeApp(sheets, isSinglePage) {
     rst.push('<TitlesOfParts>');
     if (isSinglePage) {
         rst.push('<vt:vector size="1" baseType="lpstr">');
-        rst.push('<vt:lpstr>' + sheets[0].sheetName + '</vt:lpstr>')
+        rst.push('<vt:lpstr>' + sheets[0].sheetName + '</vt:lpstr>');
     } else {
         rst.push('<vt:vector size="' + sheets.length + '" baseType="lpstr">');
         for (let i = 0; i < sheets.length; i++) {
-            rst.push('<vt:lpstr>' + sheets[i].sheetName + '</vt:lpstr>')
+            rst.push('<vt:lpstr>' + sheets[i].sheetName + '</vt:lpstr>');
         }
     }
     rst.push('</vt:vector>');
@@ -74,7 +74,6 @@ function writeApp(sheets, isSinglePage) {
     rst.push('<SharedDoc>false</SharedDoc>');
     rst.push('<HyperlinksChanged>false</HyperlinksChanged>');
     rst.push('<AppVersion>12.0000</AppVersion>');
-    //rst.push('');
     rst.push('</Properties>');
     return rst;
 }
@@ -116,7 +115,6 @@ function writeXlWorkBook(sheets, isSinglePage){
     }
     rst.push('</sheets>');
     rst.push('<calcPr calcId="124519"/>');
-    //rst.push('');
     rst.push('</workbook>');
     return rst;
 }
@@ -125,11 +123,11 @@ function writeXlRels(sheets, isSinglePage){
     rst.push(dftHeadXml + '\r\n');
     rst.push('<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">');
     if (isSinglePage) {
-        rst.push('<Relationship Id="rId' + idx + '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/>')
+        rst.push('<Relationship Id="rId' + idx + '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/>');
         idx++;
     } else {
         for (let i = 0; i < sheets.length; i++) {
-            rst.push('<Relationship Id="rId' + idx + '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet' + (i + 1) + '.xml"/>')
+            rst.push('<Relationship Id="rId' + idx + '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet' + (i + 1) + '.xml"/>');
             idx++;
         }
     }
@@ -138,7 +136,6 @@ function writeXlRels(sheets, isSinglePage){
     rst.push('<Relationship Id="rId' + idx + '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>');
     idx++;
     rst.push('<Relationship Id="rId' + idx + '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" Target="sharedStrings.xml"/>');
-    //rst.push('');
     rst.push('</Relationships>');
     return rst;
 }
@@ -151,7 +148,7 @@ function writeStyles(stylesObj){
     rst.push(dftHeadXml + '\r\n');
     rst.push('<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">');
     //1. push fonts
-    rst.push('<fonts count="' + stylesObj.fonts.length + '">')
+    rst.push('<fonts count="' + stylesObj.fonts.length + '">');
     for (let i = 0; i < stylesObj.fonts.length; i++) {
         let font = stylesObj.fonts[i];
         rst.push('<font>');
@@ -171,14 +168,14 @@ function writeStyles(stylesObj){
     //2. push default fills
     rst.push('<fills count="2"><fill><patternFill patternType="none" /></fill><fill><patternFill patternType="gray125" /></fill></fills>');
     //3. push borders
-    rst.push('<borders count="' + stylesObj.borders.length + '">')
+    rst.push('<borders count="' + stylesObj.borders.length + '">');
     let private_setBorder = function(border, borderDirection) {
-        if (border[borderDirection][JV.PROP_LINE_WEIGHT] == 0) {
+        if (parseInt(border[borderDirection][JV.PROP_LINE_WEIGHT]) === 0) {
             rst.push('<' + borderDirection.toLowerCase() + '/>');
         } else {
             let bW = 'thin';
-            if (border[borderDirection][JV.PROP_LINE_WEIGHT] == 2) bW = 'medium';
-            if (border[borderDirection][JV.PROP_LINE_WEIGHT] > 2) bW = 'thick';
+            if (parseInt(border[borderDirection][JV.PROP_LINE_WEIGHT]) === 2) bW = 'medium';
+            if (parseInt(border[borderDirection][JV.PROP_LINE_WEIGHT]) > 2) bW = 'thick';
             rst.push('<' + borderDirection.toLowerCase() + ' style="' + bW + '">' + '<color indexed="64"/>' + '</' + borderDirection.toLowerCase() + '>');
         }
     };
@@ -244,7 +241,7 @@ function writeStyles(stylesObj){
             newVertical = tmpV;
         }
         alignStr += ' horizontal="' + newHorizontal + '" vertical="' + newVertical + '"';
-        if (strUtil.convertStrToBoolean(excelStyle[JV.CONTROL_PROPS[1]])) {
+        if (strUtil.convertStrToBoolean(excelStyle[JV.CONTROL_PROPS[0]])) {
             alignStr += ' shrinkToFit="1"';
         }
         if (strUtil.convertStrToBoolean(excelStyle[JV.CONTROL_PROPS[4]])) {
@@ -493,7 +490,7 @@ function writeSheet(pageData, sheetData, paperSize, sharedStrList, stylesObj){
     };
     let private_chkAndGetMergeLine = function(cell, sheetBorder, borderStr, needFurtherChk) {
         let rst = 0,
-            mergeBorder = (sheetData[JV.PROP_PAGE_MERGE_BORDER])?sheetData[JV.PROP_PAGE_MERGE_BORDER]:pageData[JV.BAND_PROP_MERGE_BAND],
+            mergeBorder = (sheetData)?sheetData[JV.PROP_PAGE_MERGE_BORDER]:pageData[JV.BAND_PROP_MERGE_BAND],
             mergeBand = pageData[JV.BAND_PROP_MERGE_BAND]
         ;
         if (sheetBorder[borderStr] && sheetBorder[borderStr][JV.PROP_LINE_WEIGHT] !== undefined) {
@@ -625,7 +622,7 @@ function writeSheet(pageData, sheetData, paperSize, sharedStrList, stylesObj){
         return rst;
     };
     let private_setCols = function(){
-        //remark: 1 excel width = 2.117 mm
+        //remark: 1 excel unit width = 2.117 mm
         rst.push('<cols>');
         let w = 0;
         for (let i = 1; i < xPos.length - 1; i++) {
@@ -1013,7 +1010,7 @@ module.exports = {
             }
             //3. everything is ok, then call me
             me.exportExcel(newPageData, paperSize, fName, 'false', sheetNames, callback);
-            fsUtil.writeObjToFile(newPageData, 'D:/GitHome/ConstructionOperation/tmp/combinedHeader.js');
+            // fsUtil.writeObjToFile(newPageData, 'D:/GitHome/ConstructionOperation/tmp/combinedHeader.js');
         } catch (e) {
             console.log(e);
         }