forked from exceljs/exceljs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-image-out.js
42 lines (34 loc) · 956 Bytes
/
test-image-out.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
const fs = require('fs');
const path = require('path');
const HrStopwatch = require('./utils/hr-stopwatch');
const {Workbook} = require('../excel');
const filename = process.argv[2];
const wb = new Workbook();
const ws = wb.addWorksheet('blort');
ws.getCell('B2').value = 'Hello, World!';
const imageId = wb.addImage({
filename: path.join(__dirname, 'data/image2.png'),
extension: 'png',
});
const backgroundId = wb.addImage({
buffer: fs.readFileSync(path.join(__dirname, 'data/bubbles.jpg')),
extension: 'jpeg',
});
ws.addImage(imageId, {
tl: {col: 1, row: 1},
br: {col: 3.5, row: 5.5},
});
ws.addImage(imageId, 'B7:E12');
ws.addBackgroundImage(backgroundId);
const stopwatch = new HrStopwatch();
stopwatch.start();
wb.xlsx
.writeFile(filename)
.then(() => {
const micros = stopwatch.microseconds;
console.log('Done.');
console.log('Time taken:', micros);
})
.catch(error => {
console.error(error.stack);
});