-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathdemo.js
74 lines (56 loc) · 1.61 KB
/
demo.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
var xl = require('./lib/libxl');
function fillSheet(sheet) {
var book = sheet.book,
row = 1,
format;
sheet
.writeStr(row, 0, 'Some string')
.writeStr(row, 0, 'Unicode - فارسی - Қазақша');
row++;
format = book.addFormat();
format.setFont(book.addFont().setSize(20));
sheet
.writeStr(row, 0, 'green', format);
sheet.cellFormat(row, 0)
.setFillPattern(xl.FILLPATTERN_SOLID)
.setPatternForegroundColor(xl.COLOR_GREEN);
sheet.setCellFormat(row, 1, format);
format = {};
sheet.readStr(row, 0, format);
sheet.setCellFormat(row, 2, format.format);
row++;
sheet
.writeStr(row, 0, 'Ten')
.writeNum(row, 1, 10);
row++;
sheet.insertRow(row, row+1);
row += 2;
sheet.insertCol(1, 2);
sheet
.writeStr(row, 0, 'True')
.writeBool(row, 1, true);
row++;
sheet
.writeStr(row, 0, 'a blank cell')
.writeStr(row, 1, 'foo')
.writeBlank(row, 1, sheet.cellFormat(row, 0));
row++;
sheet
.writeString(row, 0, 'Comment')
.writeComment(row, 0, 'This a comment', 'from me', 200, 200);
row++;
sheet.writeNum(row, 0, book.datePack(1980, 8, 19),
book.addFormat().setNumFormat(xl.NUMFORMAT_DATE));
row++;
sheet.split(2, 5);
}
function fillBook(book) {
var sheet = book.addSheet('Sheet 1');
fillSheet(sheet);
}
var xlsBook = new xl.Book(xl.BOOK_TYPE_XLS),
xlsxBook = new xl.Book(xl.BOOK_TYPE_XLSX);
fillBook(xlsBook);
fillBook(xlsxBook);
xlsBook.writeSync('demo.xls');
xlsxBook.writeSync('demo.xlsx');