Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix formatting issues in code example #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 47 additions & 48 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,57 +8,56 @@ Setup configs object before passing it into the execute method. If generating mu


var express = require('express');
var nodeExcel = require('excel-export');
var app = express();
var nodeExcel = require('excel-export');
var app = express();

app.get('/Excel', function(req, res){
var conf ={};
conf.stylesXmlFile = "styles.xml";
app.get('/Excel', function(req, res) {
var conf = {};
conf.stylesXmlFile = "styles.xml";
conf.name = "mysheet";
conf.cols = [{
caption:'string',
type:'string',
beforeCellWrite:function(row, cellData){
return cellData.toUpperCase();
},
width:28.7109375
},{
caption:'date',
type:'date',
beforeCellWrite:function(){
var originDate = new Date(Date.UTC(1899,11,30));
return function(row, cellData, eOpt){
if (eOpt.rowNum%2){
eOpt.styleIndex = 1;
}
else{
eOpt.styleIndex = 2;
}
if (cellData === null){
eOpt.cellType = 'string';
return 'N/A';
conf.cols = [{
caption: 'string',
type: 'string',
beforeCellWrite: function(row, cellData) {
return cellData.toUpperCase();
},
width: 28.7109375
},{
caption: 'date',
type: 'date',
beforeCellWrite: function() {
var originDate = new Date(Date.UTC(1899, 11, 30));
return function(row, cellData, eOpt) {
if (eOpt.rowNum % 2) {
eOpt.styleIndex = 1;
} else {
eOpt.styleIndex = 2;
}
if (cellData === null) {
eOpt.cellType = 'string';
return 'N/A';
} else
return (cellData - originDate) / (24 * 60 * 60 * 1000);
}
}()
},{
caption:'bool',
type:'bool'
},{
caption:'number',
type:'number'
}];
conf.rows = [
['pi', new Date(Date.UTC(2013, 4, 1)), true, 3.14],
["e", new Date(2012, 4, 1), false, 2.7182],
return (cellData - originDate) / (24 * 60 * 60 * 1000);
}
}()
},{
caption: 'bool',
type: 'bool'
},{
caption: 'number',
type: 'number'
}];
conf.rows = [
['pi', new Date(Date.UTC(2013, 4, 1)), true, 3.14],
["e", new Date(2012, 4, 1), false, 2.7182],
["M&M<>'", new Date(Date.UTC(2013, 6, 9)), false, 1.61803],
["null date", null, true, 1.414]
];
var result = nodeExcel.execute(conf);
res.setHeader('Content-Type', 'application/vnd.openxmlformats');
res.setHeader("Content-Disposition", "attachment; filename=" + "Report.xlsx");
res.end(result, 'binary');
});
];
var result = nodeExcel.execute(conf);
res.setHeader('Content-Type', 'application/vnd.openxmlformats');
res.setHeader("Content-Disposition", "attachment; filename=" + "Report.xlsx");
res.end(result, 'binary');
});

app.listen(3000);
console.log('Listening on port 3000');
app.listen(3000);
console.log('Listening on port 3000');