-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexcel.js
41 lines (28 loc) · 992 Bytes
/
excel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var xlsx = require('xlsx'),
xlsxBuilder = require('msexcel-builder');
function nodeExcel (config) {
this.path = config.path || './' ;
this.fileName = config.fileName || 'sample.xlsx';
this.sheetName = config.sheetName || 'sheet1';
this.columns = config.columns || 10;
this.rows = config.rows || 12;
this.content = config.content || [];
var that = this;
}
nodeExcel.prototype.createExcel = function() {
var workbook , sheet ;
// Create a new workbook file in current working-path
workbook = excelbuilder.createWorkbook (that.path, that.fileName );
// Create a new worksheet
sheet = workbook.createSheet(that.sheetName, that.columns, that.rows);
// Save it
workbook.save( function (ok) {
if (!ok ) workbook.cancel();
else console.log('congratulations, your workbook created');
return workbook;
});
};
exports.updataExcel = function(config) {
}
exports.readExcel = function (config) {
}