json2xls
json2xls copied to clipboard
Update json2xls.js
Added custom config or global config to use style.xml.
Then we can use in config :
var conf = {
style: 'excel-style.xml',
width: 50,
captionStyleIndex: 1,
beforeCellWrite: function (row, cellData, eOpt) {
// filled cell
if (cellData !== undefined && cellData !== '') {
eOpt.styleIndex = 1;
}
// line question
if (row[0].length === 0) {
eOpt.styleIndex = 2;
}
// cell email
if (row[0] === cellData) {
eOpt.styleIndex = 3;
}
// error
if (cellData === 'undefined') {
eOpt.styleIndex = 4;
}
eOpt.cellType = 'string';
return cellData;
}
};
or for each column :
var conf = {
style: 'excel-style.xml',
cols: [
{
width: 100,
captionStyleIndex: 4, // index cellXfs
cellType: 'string',
beforeCellWrite : beforeCellWrite
},
{
width: 30,
captionStyleIndex: 4, // index cellXfs
cellType: 'string',
beforeCellWrite : beforeCellWrite
},
{
width: 30,
captionStyleIndex: 4, // index cellXfs
cellType: 'string',
beforeCellWrite : beforeCellWrite
}
]
};
I like the ideas. Could you:
- make sure the tests pass
- add a description of the new config options to the readme
- add an extra example to work with those options