docx-officegen
Version:
This module can generate Office Open XML files for Microsoft Office 2007 and later. Also the output is a stream and file, not dependent on any output tool. This module should work on any environment that supports Node.js 10.3.0 or later including Windows.
768 lines • 88.6 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var json2xml = require('json2xml');
var _ = require('lodash');
var table = /** @class */ (function () {
function table() {
/**@
*
* @type {string}
* private globalTable ===> Table Body Object
* private globalData ===> The data sent from the server side
*/
this.globalTable = " ";
this.globalData = " ";
this.checkNote = " ";
}
table.prototype.createTr = function (_body, data) {
this.globalData = data;
var check = _body['w:tbl'].length;
if (check == 1) {
_body;
}
else {
for (var i = 1; i < check; i++) {
_body['w:tbl'].pop();
}
}
_body;
var counterRow = _.uniqBy(data, 'x');
var row = counterRow.length;
for (var i = 0; i < row; i++) {
_body['w:tbl'].push({ 'w:tr': [] });
}
return _body;
}; //createTr
table.prototype.createTc = function (_body, data) {
var counterCol = _.uniqBy(data, 'y');
var counterRow = _.uniqBy(data, 'x');
var row = counterRow.length;
var col = counterCol.length;
for (var i = 1; i <= row; i++) {
for (var j = 0; j < col; j++) {
_body['w:tbl'][i]['w:tr'].push({
'w:tc': [{
'w:tcPr': [{
'w:tcW': '',
attr: { 'w:w': 4657, 'w:type': 'dxa' }
}]
},]
});
} // for column
} //for row
return _body;
}; //createTc
table.prototype.createPtable = function (_body, data) {
var counterCol = _.uniqBy(data, 'y');
var counterRow = _.uniqBy(data, 'x');
var row = counterRow.length;
var col = counterCol.length;
for (var i = 1; i <= row; i++) {
for (var j = 0; j < col; j++) {
var checkValue = _.find(data, { x: i, y: j });
var value = checkValue.value;
var note = checkValue.note;
if (value == '') {
_body['w:tbl'][i]['w:tr'][j]['w:tc'].push({ 'w:p': [] });
}
else {
_body['w:tbl'][i]['w:tr'][j]['w:tc'].push({
'w:p': [
{
'w:r': [
{ 'w:t': value }
]
}
]
});
_body;
}
} // for col
} // for row
return _body;
}; //createP
table.prototype.createNote = function (_body) {
_body;
// let _body = this.globalTable;
var data = this.globalData;
var findX = _.uniqBy(data, 'x');
var findY = _.uniqBy(data, 'y');
var count = data.length;
var counterX = findX.length;
var counterY = findY.length;
counterY;
counterX;
for (var i = 1; i <= counterX; i++) {
for (var j = 0; j < counterY; j++) {
var dataInfo = _.find(data, { x: i, y: j });
dataInfo;
var note = dataInfo.note;
note;
if (note) {
var text = note.text;
var position = note.position;
if (text != "") {
_body['w:tbl'][i]['w:tr'][j]['w:tc'][1]['w:p'].push({ 'w:r': [
{ 'w:rPr': [
{ 'w:vertAlign': '', attr: { 'w:val': 'superscript' } },
{ 'w:rtl': '' }
] },
{ 'w:t': note.text }
] });
_body;
}
} // note
}
}
return _body;
};
table.prototype.createMerge = function (_body, data) {
_body;
var counterCol = _.uniqBy(data, 'y');
var counterRow = _.uniqBy(data, 'x');
var row = counterRow.length;
var col = counterCol.length;
var start = [];
for (var i = 1; i <= row; i++) {
for (var j = 0; j < col; j++) {
var checkMerge = _.find(data, { x: i, y: j });
var rowX = checkMerge.mergeRow;
var colY = checkMerge.mergeCol;
if (colY != '' && rowX != '') {
var myX = checkMerge.x;
var myY = checkMerge.y;
myY;
var counterY = colY; // mergeCol
var counterX = rowX; //mergeRow
/// start merge Row and Col
_body['w:tbl'][myX]['w:tr'][myY]['w:tc'][0]['w:tcPr'].push({ 'w:vMerge': '', attr: { 'w:val': 'restart' } }, { 'w:gridSpan': '', attr: { 'w:val': colY } }); //
var b = _body;
b;
var newWidth = colY * 4657;
newWidth;
_body;
var test_1 = _body['w:tbl'][myX]['w:tr'][myY]['w:tc'][0]['w:tcPr'].splice(0, 1, {
'w:tcW': '', attr: { 'w:w': newWidth, 'w:type': 'dxa' }
});
///// loop for merge Col:
for (var i_1 = 1; i_1 < counterY; i_1++) {
myY = myY + 1;
delete _body['w:tbl'][myX]['w:tr'][myY]; // merge col
} // for
/// end loop for
var c = _body;
c;
///// loop for merge Row:
for (var i_2 = 1; i_2 < counterX; i_2++) {
myY = 0;
myY = checkMerge.y;
myX = myX + 1;
_body['w:tbl'][myX]['w:tr'][myY]['w:tc'][0]['w:tcPr'].push({ 'w:vMerge': [] }, {
'w:gridSpan': '',
attr: { 'w:val': colY }
}); // merge row
} // for
/// end loop for
var z = _body;
z;
///// loop for merge Col:
for (var i_3 = 1; i_3 < counterY; i_3++) {
myY = myY + 1;
myX;
delete _body['w:tbl'][myX]['w:tr'][myY]; // merge col
} // for
/// end loop for
var a = _body;
a;
} // if
//
/*else*/
else if (colY != '' && rowX == '') {
var myX = checkMerge.x;
var myY = checkMerge.y;
var counterY = colY;
counterY;
/// start merge Row and Col
_body['w:tbl'][myX]['w:tr'][myY]['w:tc'][0]['w:tcPr'].push({
'w:gridSpan': '',
attr: { 'w:val': colY }
}); ///<w:gridSpan w:val="2"/>
var newWidth = colY * 4657;
newWidth;
var test_2 = _body['w:tbl'][myX]['w:tr'][myY]['w:tc'][0]['w:tcPr'].splice(0, 1, {
'w:tcW': '', attr: { 'w:w': newWidth, 'w:type': 'dxa' }
});
///// loop for merge Col:
for (var i_4 = 1; i_4 < counterY; i_4++) {
myY = myY + 1;
delete _body['w:tbl'][myX]['w:tr'][myY]; // merge col
} // for
var c = _body;
c;
} // else if
else if (colY == '' && rowX != '') {
var myY = checkMerge.y;
var myX = checkMerge.x;
var counterX = rowX;
/// start merge Row and Row
_body['w:tbl'][myX]['w:tr'][myY]['w:tc'][0]['w:tcPr'].push({
'w:vMerge': '',
attr: { 'w:val': 'restart' }
}); ///<w:vMerge w:val="restart"/>
var b = _body;
b;
///// loop for merge Row:
for (var i_5 = 1; i_5 < counterX; i_5++) {
myX = myX + 1;
_body['w:tbl'][myX]['w:tr'][myY]['w:tc'][0]['w:tcPr'].push({ 'w:vMerge': [] });
} // for
var c = _body;
c;
} // else ifs
} // for col
} // for row
this.globalTable = _body;
return this.globalTable;
}; //createMerge
table.prototype.tableStyle = function () {
this.globalTable; // tbl body object
this.globalData; // The data sent from the server side
var count = this.globalData.length;
var styleObject = {};
var styleData = [];
for (var i = 0; i < count; i++) {
var infoData = _.find(this.globalData, this.globalData[i]);
var x = infoData.x;
var y = infoData.y;
var checkMergeCol = infoData.mergeCol;
var style = infoData.style;
var check = Object.keys(styleObject).length;
if (check == 0) {
styleObject = { x: x, y: y, style: style };
styleData.push(styleObject);
}
else if (check > 0) {
if (style == undefined) {
styleObject = { x: x, y: y };
styleData.push(styleObject);
}
else {
styleObject = { x: x, y: y, style: style };
styleData.push(styleObject);
}
}
} // for
if (styleData != null) {
if (typeof styleData == 'object') {
var counterX = _.uniqBy(styleData, 'x');
var counterY = _.uniqBy(styleData, 'y');
var counterCol = counterY.length;
var counterRow = counterX.length;
for (var i = 1; i <= counterRow; i++) {
for (var j = 0; j < counterCol; j++) {
var find = _.find(styleData, { x: i, y: j });
var newStyle = find.style;
var findNote = _.find(this.globalData, { x: i, y: j });
var checkNote = findNote.note;
if (newStyle != undefined) {
var align = newStyle.align;
var tab = newStyle.tab;
var fontFamily = newStyle.fontFamily;
var fontColor = newStyle.fontColor;
var fontSize = newStyle.fontSize;
var backgroundCell = newStyle.background;
var bold = newStyle.bold;
var findBorder = newStyle.border;
if (findBorder != undefined) {
var topBorder = newStyle.border.top;
var bottomBorder = newStyle.border.bottom;
var rightBorder = newStyle.border.right;
var leftBorder = newStyle.border.left;
/***
@IndexArray:
0 = size
1 = type
2 =color
* */
///////////////////////////////////////////////////CHECK BORDER ///////////////////////////////////////////////
/**************************** TopBorder ********************/ /////////
if (topBorder) {
var topBArr = topBorder.split(' ');
var check = topBArr.length;
check;
if (check == 1) {
if (Number(topBArr[0])) {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:top': '', attr: { 'w:val': 'single', 'w:sz': topBArr[0], 'w:space': '0' } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:top': '', attr: { 'w:val': 'single', 'w:sz': '8', 'w:space': '0' } }
]
}); // push
this.globalTable;
}
} // check sizeBorder top
if (check == 2) { // check type border
if (Number(topBArr[0])) {
if (topBArr[1] == 'single' || topBArr[1] == 'double' || topBArr[1] == 'dashed') {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:top': '', attr: { 'w:val': topBArr[1], 'w:sz': topBArr[0], 'w:space': '0' } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:top': '', attr: { 'w:val': 'single', 'w:sz': topBArr[0], 'w:space': '0' } }
]
}); // push
this.globalTable;
} // check type pf Border
}
else if (topBArr[1] == 'single' || topBArr[1] == 'double' || topBArr[1] == 'dashed') {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:top': '', attr: { 'w:val': topBArr[1], 'w:sz': '8', 'w:space': '0' } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:top': '', attr: { 'w:val': 'single', 'w:sz': '8', 'w:space': '0' } }
]
}); // push
this.globalTable;
}
} // check size And Type in Border
if (check == 3) {
if (Number(topBArr[0])) {
if (topBArr[1] == 'single' || topBArr[1] == 'double' || topBArr[1] == 'dashed') {
if (typeof topBArr[2] == "string") {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:top': '', attr: { 'w:val': topBArr[1], 'w:sz': topBArr[0], 'w:space': '0', 'w:color': topBArr[2] } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:top': '', attr: { 'w:val': topBArr[1], 'w:sz': topBArr[0], 'w:space': '0', 'w:color': 'auto' } }
]
}); // push
this.globalTable;
} // check color
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:top': '', attr: { 'w:val': 'single', 'w:sz': topBArr[0], 'w:space': '0', 'w:color': topBArr[2] } }
]
}); // push
this.globalTable;
} // check type border
}
else if (topBArr[1] == 'single' || topBArr[1] == 'double' || topBArr[1] == 'dashed') {
if (typeof topBArr[2] == "string") {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:top': '', attr: { 'w:val': topBArr[1], 'w:sz': '8', 'w:space': '0', 'w:color': topBArr[2] } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:top': '', attr: { 'w:val': 'single', 'w:sz': '8', 'w:space': '0', 'w:color': topBArr[2] } }
]
}); // push
this.globalTable;
}
}
else if (typeof topBArr[2] == 'string') {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:top': '', attr: { 'w:val': 'single', 'w:sz': '8', 'w:space': '0', 'w:color': topBArr[2] } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:top': '', attr: { 'w:val': 'single', 'w:sz': '8', 'w:space': '0' } }
]
}); // push
this.globalTable;
}
} // check size And Type And Color in Border
} // top Border
/********************************************* End TopBorder ***********/ /////////
/********************************************* bottomBorder ***********/ /////////
if (bottomBorder) {
var bottomBArr = bottomBorder.split(' ');
var check = bottomBArr.length;
bottomBArr;
if (check == 1) {
if (Number(bottomBArr[0])) {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:bottom': '', attr: { 'w:val': 'single', 'w:sz': bottomBArr[0], 'w:space': '0' } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:bottom': '', attr: { 'w:val': 'single', 'w:sz': '8', 'w:space': '0' } }
]
}); // push
this.globalTable;
}
} // check sizeBorder top
if (check == 2) { // check type border
if (Number(bottomBArr[0])) {
if (bottomBArr[1] == 'single' || bottomBArr[1] == 'double' || bottomBArr[1] == 'dashed') {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:bottom': '', attr: { 'w:val': bottomBArr[1], 'w:sz': bottomBArr[0], 'w:space': '0' } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:bottom': '', attr: { 'w:val': 'single', 'w:sz': bottomBArr[0], 'w:space': '0' } }
]
}); // push
this.globalTable;
} // check type pf Border
}
else if (bottomBArr[1] == 'single' || bottomBArr[1] == 'double' || bottomBArr[1] == 'dashed') {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:bottom': '', attr: { 'w:val': bottomBArr[1], 'w:sz': '8', 'w:space': '0' } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:bottom': '', attr: { 'w:val': 'single', 'w:sz': '8', 'w:space': '0' } }
]
}); // push
this.globalTable;
}
} // check size And Type in Border
if (check == 3) {
if (Number(bottomBArr[0])) {
if (bottomBArr[1] == 'single' || bottomBArr[1] == 'double' || bottomBArr[1] == 'dashed') {
if (typeof bottomBArr[2] == "string") {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:bottom': '', attr: { 'w:val': bottomBArr[1], 'w:sz': bottomBArr[0], 'w:space': '0', 'w:color': bottomBArr[2] } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:bottom': '', attr: { 'w:val': bottomBArr[1], 'w:sz': bottomBArr[0], 'w:space': '0', 'w:color': 'auto' } }
]
}); // push
this.globalTable;
} // check color
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:bottom': '', attr: { 'w:val': 'single', 'w:sz': bottomBArr[0], 'w:space': '0', 'w:color': bottomBArr[2] } }
]
}); // push
this.globalTable;
} // check type border
}
else if (bottomBArr[1] == 'single' || bottomBArr[1] == 'double' || bottomBArr[1] == 'dashed') {
if (typeof bottomBArr[2] == "string") {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:bottom': '', attr: { 'w:val': bottomBArr[1], 'w:sz': '8', 'w:space': '0', 'w:color': bottomBArr[2] } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:bottom': '', attr: { 'w:val': 'single', 'w:sz': '8', 'w:space': '0', 'w:color': bottomBArr[2] } }
]
}); // push
this.globalTable;
}
}
else if (typeof bottomBArr[2] == 'string') {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:bottom': '', attr: { 'w:val': 'single', 'w:sz': '8', 'w:space': '0', 'w:color': bottomBArr[2] } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:bottom': '', attr: { 'w:val': 'single', 'w:sz': '8', 'w:space': '0' } }
]
}); // push
this.globalTable;
}
} // check size And Type And Color in Border
} // bottom Border
/****************************** END Bottom Border ***/ ///////////////////
/***************************** Right Border ************************/
if (rightBorder) {
var rightBArr = rightBorder.split(' ');
var check = rightBArr.length;
if (check == 1) {
if (Number(rightBArr[0])) {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:left': '', attr: { 'w:val': 'single', 'w:sz': rightBArr[0], 'w:space': '0' } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:left': '', attr: { 'w:val': 'single', 'w:sz': '8', 'w:space': '0' } }
]
}); // push
this.globalTable;
}
} // check sizeBorder top
if (check == 2) { // check type border
if (Number(rightBArr[0])) {
if (rightBArr[1] == 'single' || rightBArr[1] == 'double' || rightBArr[1] == 'dashed') {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:left': '', attr: { 'w:val': rightBArr[1], 'w:sz': rightBArr[0], 'w:space': '0' } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:left': '', attr: { 'w:val': 'single', 'w:sz': rightBArr[0], 'w:space': '0' } }
]
}); // push
this.globalTable;
} // check type pf Border
}
else if (rightBArr[1] == 'single' || rightBArr[1] == 'double' || rightBArr[1] == 'dashed') {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:left': '', attr: { 'w:val': rightBArr[1], 'w:sz': '8', 'w:space': '0' } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:left': '', attr: { 'w:val': 'single', 'w:sz': '8', 'w:space': '0' } }
]
}); // push
this.globalTable;
}
} // check size And Type in Border
if (check == 3) {
if (Number(rightBArr[0])) {
if (rightBArr[1] == 'single' || rightBArr[1] == 'double' || rightBArr[1] == 'dashed') {
if (typeof rightBArr[2] == "string") {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:left': '', attr: { 'w:val': rightBArr[1], 'w:sz': rightBArr[0], 'w:space': '0', 'w:color': rightBArr[2] } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:left': '', attr: { 'w:val': rightBArr[1], 'w:sz': rightBArr[0], 'w:space': '0', 'w:color': 'auto' } }
]
}); // push
this.globalTable;
} // check color
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:left': '', attr: { 'w:val': 'single', 'w:sz': rightBArr[0], 'w:space': '0', 'w:color': rightBArr[2] } }
]
}); // push
this.globalTable;
} // check type border
}
else if (rightBArr[1] == 'single' || rightBArr[1] == 'double' || rightBArr[1] == 'dashed') {
if (typeof rightBArr[2] == "string") {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:left': '', attr: { 'w:val': rightBArr[1], 'w:sz': '8', 'w:space': '0', 'w:color': rightBArr[2] } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:left': '', attr: { 'w:val': 'single', 'w:sz': '8', 'w:space': '0', 'w:color': rightBArr[2] } }
]
}); // push
this.globalTable;
}
}
else if (typeof rightBArr[2] == 'string') {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:left': '', attr: { 'w:val': 'single', 'w:sz': '8', 'w:space': '0', 'w:color': rightBArr[2] } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:left': '', attr: { 'w:val': 'single', 'w:sz': '8', 'w:space': '0' } }
]
}); // push
this.globalTable;
}
} // check size And Type And Color in Border
} // right border
/***************************** END Right Border ************************/
/***************************** Left Border ************************/
if (leftBorder) {
var leftBArr = leftBorder.split(' ');
var check = leftBArr.length;
if (check == 1) {
if (Number(leftBArr[0])) {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:right': '', attr: { 'w:val': 'single', 'w:sz': leftBArr[0], 'w:space': '0' } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:right': '', attr: { 'w:val': 'single', 'w:sz': '8', 'w:space': '0' } }
]
}); // push
this.globalTable;
}
} // check sizeBorder top
if (check == 2) { // check type border
if (Number(leftBArr[0])) {
if (leftBArr[1] == 'single' || leftBArr[1] == 'double' || leftBArr[1] == 'dashed') {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:right': '', attr: { 'w:val': leftBArr[1], 'w:sz': leftBArr[0], 'w:space': '0' } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:right': '', attr: { 'w:val': 'single', 'w:sz': leftBArr[0], 'w:space': '0' } }
]
}); // push
this.globalTable;
} // check type pf Border
}
else if (leftBArr[1] == 'single' || leftBArr[1] == 'double' || leftBArr[1] == 'dashed') {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:right': '', attr: { 'w:val': leftBArr[1], 'w:sz': '8', 'w:space': '0' } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:right': '', attr: { 'w:val': 'single', 'w:sz': '8', 'w:space': '0' } }
]
}); // push
this.globalTable;
}
} // check size And Type in Border
if (check == 3) {
if (Number(leftBArr[0])) {
if (leftBArr[1] == 'single' || leftBArr[1] == 'double' || leftBArr[1] == 'dashed') {
if (typeof leftBArr[2] == "string") {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:right': '', attr: { 'w:val': leftBArr[1], 'w:sz': leftBArr[0], 'w:space': '0', 'w:color': leftBArr[2] } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:right': '', attr: { 'w:val': leftBArr[1], 'w:sz': leftBArr[0], 'w:space': '0', 'w:color': 'auto' } }
]
}); // push
this.globalTable;
} // check color
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:right': '', attr: { 'w:val': 'single', 'w:sz': leftBArr[0], 'w:space': '0', 'w:color': leftBArr[2] } }
]
}); // push
this.globalTable;
} // check type border
}
else if (leftBArr[1] == 'single' || leftBArr[1] == 'double' || leftBArr[1] == 'dashed') {
if (typeof leftBArr[2] == "string") {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:right': '', attr: { 'w:val': leftBArr[1], 'w:sz': '8', 'w:space': '0', 'w:color': leftBArr[2] } }
]
}); // push
this.globalTable;
}
else {
this.globalTable['w:tbl'][i]['w:tr'][j]['w:tc'][0]['w:tcPr'].push({
'w:tcBorders': [
{ 'w:right': '', attr: { 'w:val': 'single', 'w:sz': '8', 'w:space': '0', 'w:color': leftBArr[2] } }
]
}); // push
this.globalTable;
}
}
else if (typeof leftBArr[2] == 'string') {
this.globalTable['w:tbl'][i]['w:t