|
@@ -3,6 +3,7 @@
|
|
*/
|
|
*/
|
|
var JV = require('../rpt_component/Jpc_ValueDefine');
|
|
var JV = require('../rpt_component/Jpc_ValueDefine');
|
|
var fs = require('fs');
|
|
var fs = require('fs');
|
|
|
|
+var strUtil = require('../../../public/stringUtil');
|
|
var jpcCmnHelper = require('../rpt_component/helper/Jpc_Helper_Common');
|
|
var jpcCmnHelper = require('../rpt_component/helper/Jpc_Helper_Common');
|
|
var DPI = jpcCmnHelper.getScreenDPI()[0];
|
|
var DPI = jpcCmnHelper.getScreenDPI()[0];
|
|
const dftHeadXml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
|
|
const dftHeadXml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
|
|
@@ -124,10 +125,10 @@ function writeTheme(){
|
|
var rst = fs.readFileSync('./excel_base_files/theme1.xml', 'utf8', 'r');
|
|
var rst = fs.readFileSync('./excel_base_files/theme1.xml', 'utf8', 'r');
|
|
return rst;
|
|
return rst;
|
|
}
|
|
}
|
|
-function writeStyles(pageData){
|
|
|
|
|
|
+function writeStyles(styleList){
|
|
//
|
|
//
|
|
}
|
|
}
|
|
-function writeSharedString(pageData){
|
|
|
|
|
|
+function writeSharedString(sharedStrList){
|
|
//
|
|
//
|
|
}
|
|
}
|
|
function writeSheets(pageData){
|
|
function writeSheets(pageData){
|
|
@@ -224,7 +225,9 @@ function writeSheet(sheetData, sharedStrList, styleList){
|
|
};
|
|
};
|
|
private_setSheetData = function(){
|
|
private_setSheetData = function(){
|
|
rst.push('<sheetData>');
|
|
rst.push('<sheetData>');
|
|
- var spanX = xPos.length - 1, cellIdx = 0, h = 0, hasMoreCols = true;
|
|
|
|
|
|
+ var spanX = xPos.length - 1, cellIdx = 0, h = 0,
|
|
|
|
+ hasMoreCols = true, nextColIdx = -1,
|
|
|
|
+ nextRowIdx = yPos.indexOf(sheetData.cells[cellIdx][JV.PROP_AREA][JV.PROP_TOP]);
|
|
for (var i = 0; i < yPos.length - 1; i++) {
|
|
for (var i = 0; i < yPos.length - 1; i++) {
|
|
if (i === 0) {
|
|
if (i === 0) {
|
|
h = 1.0 * (yPos[i]) / DPI;
|
|
h = 1.0 * (yPos[i]) / DPI;
|
|
@@ -235,10 +238,47 @@ function writeSheet(sheetData, sharedStrList, styleList){
|
|
rst.push('<row r="' + (i+1) + '" spans="1:' + spanX + '" ht="' + h + '" customHeight="1">');
|
|
rst.push('<row r="' + (i+1) + '" spans="1:' + spanX + '" ht="' + h + '" customHeight="1">');
|
|
//then put the cells of this row
|
|
//then put the cells of this row
|
|
var colIdxStr = '';
|
|
var colIdxStr = '';
|
|
|
|
+ hasMoreCols = true;
|
|
|
|
+ while (nextRowIdx < i) {
|
|
|
|
+ if (cellIdx >= sheetData.cells.length || nextRowIdx > i) {
|
|
|
|
+ break;
|
|
|
|
+ } else {
|
|
|
|
+ cellIdx++;
|
|
|
|
+ nextRowIdx = yPos.indexOf(sheetData.cells[cellIdx][JV.PROP_AREA][JV.PROP_TOP]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (nextRowIdx > i) {
|
|
|
|
+ hasMoreCols = false;
|
|
|
|
+ }
|
|
|
|
+ nextColIdx = xPos.indexOf(sheetData.cells[cellIdx][JV.PROP_AREA][JV.PROP_LEFT]);
|
|
for (var j = 0; j < xPos.length; j++) {
|
|
for (var j = 0; j < xPos.length; j++) {
|
|
colIdxStr = private_getCellIdxStr(j);
|
|
colIdxStr = private_getCellIdxStr(j);
|
|
if (hasMoreCols) {
|
|
if (hasMoreCols) {
|
|
- var ridx = yPos.indexOf(sheetData.cells[cellIdx][JV.PROP_AREA][JV.PROP_TOP]);
|
|
|
|
|
|
+ if (nextColIdx == j) {
|
|
|
|
+ var styleIdx = private_getStyleIdx(sheetData.cells[cellIdx]);
|
|
|
|
+ if (strUtil.isEmptyString(sheetData.cells[cellIdx][JV.PROP_VALUE])) {
|
|
|
|
+ rst.push('<c r="' + colIdxStr + (i+1) + '" s="' + styleIdx + '"/>');
|
|
|
|
+ //should setup the right style instead!
|
|
|
|
+ } else {
|
|
|
|
+ var valIdx = private_getSharedStrIdx(sheetData.cells[cellIdx][JV.PROP_VALUE]);
|
|
|
|
+ rst.push('<c r="' + colIdxStr + (i+1) + '" s="' + styleIdx + '">');
|
|
|
|
+ rst.push('<v>' + valIdx + '</v>');
|
|
|
|
+ rst.push('</c>');
|
|
|
|
+ }
|
|
|
|
+ cellIdx++;
|
|
|
|
+ nextRowIdx = yPos.indexOf(sheetData.cells[cellIdx][JV.PROP_AREA][JV.PROP_TOP]);
|
|
|
|
+ if (nextRowIdx > i) {
|
|
|
|
+ hasMoreCols = false;
|
|
|
|
+ } else {
|
|
|
|
+ nextColIdx = xPos.indexOf(sheetData.cells[cellIdx][JV.PROP_AREA][JV.PROP_LEFT]);
|
|
|
|
+ }
|
|
|
|
+ } else if (nextColIdx < 0) {
|
|
|
|
+ //impossible!
|
|
|
|
+ console.log('has abnormal case!');
|
|
|
|
+ hasMoreCols = false;
|
|
|
|
+ } else {
|
|
|
|
+ rst.push('<c r="' + colIdxStr + (i+1) + '" s="1"/>');
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
rst.push('<c r="' + colIdxStr + (i+1) + '" s="1"/>');
|
|
rst.push('<c r="' + colIdxStr + (i+1) + '" s="1"/>');
|
|
}
|
|
}
|
|
@@ -257,7 +297,7 @@ function writeSheet(sheetData, sharedStrList, styleList){
|
|
rst.push('<selection sqref="A1:' + colStr + '1"/>');
|
|
rst.push('<selection sqref="A1:' + colStr + '1"/>');
|
|
rst.push('</sheetView></sheetViews>');
|
|
rst.push('</sheetView></sheetViews>');
|
|
rst.push('<sheetFormatPr defaultRowHeight="13.5"/>');
|
|
rst.push('<sheetFormatPr defaultRowHeight="13.5"/>');
|
|
- private_setCols
|
|
|
|
|
|
+ private_setCols();
|
|
private_setSheetData();
|
|
private_setSheetData();
|
|
private_setMergedCells();
|
|
private_setMergedCells();
|
|
rst.push('<phoneticPr fontId="1" type="noConversion"/>');
|
|
rst.push('<phoneticPr fontId="1" type="noConversion"/>');
|