forked from exceljs/exceljs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestProcess.js
More file actions
49 lines (38 loc) · 1.11 KB
/
Copy pathtestProcess.js
File metadata and controls
49 lines (38 loc) · 1.11 KB
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
42
43
44
45
46
47
48
49
'use strict';
var fs = require('fs');
var _ = require('underscore');
var HrStopwatch = require('./utils/hr-stopwatch');
var Excel = require('../excel');
var inputFile = process.argv[2];
var outputFile = process.argv[3];
var wb = new Excel.Workbook();
var passed = true;
var assert = function(value, failMessage, passMessage) {
if (!value) {
if (failMessage) console.error(failMessage);
passed = false;
} else {
if (passMessage) console.log(passMessage);
}
};
// assuming file created by testBookOut
wb.xlsx.readFile(inputFile)
.then(function() {
console.log('Loaded', inputFile);
wb.eachSheet(function(sheet) {
console.log(sheet.name);
});
var ws = wb.getWorksheet('Sheet1');
assert(ws, "Expected to find a worksheet called sheet1");
ws.getCell('B1').value = new Date();
ws.getCell('B1').numFmt = 'hh:mm:ss';
ws.addRow([1, 'hello']);
return wb.xlsx.writeFile(outputFile);
})
.then(function() {
assert(passed, "Something went wrong", "All tests passed!");
})
.catch(function(error) {
console.error(error.message);
console.error(error.stack);
});