node-excel-export
Advanced tools
Comparing version 1.1.0 to 1.2.0
11
index.js
@@ -52,10 +52,15 @@ | ||
if(specification[col].cellFormat && typeof specification[col].cellFormat == 'function') { | ||
cell_value = specification[col].cellFormat(cell_value); | ||
cell_value = specification[col].cellFormat(record[col], record); | ||
} | ||
if(specification[col].cellStyle) { | ||
if(specification[col].cellStyle && typeof specification[col].cellStyle == 'function') { | ||
cell_value = { | ||
value: cell_value, | ||
style: specification[col].cellStyle(record[col], record) | ||
}; | ||
} else if(specification[col].cellStyle) { | ||
cell_value = { | ||
value: cell_value, | ||
style: specification[col].cellStyle | ||
} | ||
}; | ||
} | ||
@@ -62,0 +67,0 @@ row.push(cell_value); // Push new cell to the row |
@@ -21,3 +21,3 @@ 'use strict'; | ||
if(typeof data[R][C] === 'object' && data[R][C].style && !(data[R][C] instanceof Date)) { | ||
if(data[R][C] && typeof data[R][C] === 'object' && data[R][C].style && !(data[R][C] instanceof Date)) { | ||
var cell = { | ||
@@ -24,0 +24,0 @@ v: data[R][C].value, |
{ | ||
"name": "node-excel-export", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Node-Excel-Export", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -39,2 +39,9 @@ ### Node.JS Excel-Export | ||
} | ||
}, | ||
cellGreen: { | ||
fill: { | ||
fgColor: { | ||
rgb: 'FF00FF00' | ||
} | ||
} | ||
} | ||
@@ -53,3 +60,8 @@ }; | ||
displayName: 'Customer', // <- Here you specify the column header | ||
headerStyle: styles.headerDark // <- Header style, | ||
headerStyle: styles.headerDark, // <- Header style | ||
cellStyle: function(value, row) { // <- style renderer function | ||
// if the status is 1 then color in green else color in red | ||
// Notice how we use another cell value to style the current one | ||
return (row.status_id == 1) ? styles.cellGreen : {fill: {fgColor: {rgb: 'FFFF0000'}}}; // <- Inline cell style is possible | ||
}, | ||
width: 120 // <- width in pixels | ||
@@ -60,3 +72,3 @@ }, | ||
headerStyle: styles.headerDark, | ||
cellFormat: function(value) { // <- Renderer function | ||
cellFormat: function(value, row) { // <- Renderer function, you can access also any row.property | ||
return (value == 1) ? 'Active' : 'Inactive'; | ||
@@ -69,3 +81,3 @@ }, | ||
headerStyle: styles.headerDark, | ||
cellStyle: styles.cellPink, // <- Cell style [todo: allow function] | ||
cellStyle: styles.cellPink, // <- Cell style | ||
width: 220 // <- width in pixels | ||
@@ -72,0 +84,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9011
142
114