MCPcopy
hub / github.com/exceljs/exceljs / createSimpleWorkbook

Function createSimpleWorkbook

spec/unit/doc/workbook.spec.js:9–55  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7// Helpers
8
9function createSimpleWorkbook() {
10 const wb = new Excel.Workbook();
11 const ws = wb.addWorksheet('blort');
12
13 // plain number
14 ws.getCell('A1').value = 7;
15 ws.getCell('A1').name = 'Seven';
16
17 // simple string
18 ws.getCell('B1').value = 'Hello, World!';
19 ws.getCell('B1').name = 'Hello';
20
21 // floating point
22 ws.getCell('C1').value = 3.14;
23
24 // date-time
25 ws.getCell('D1').value = new Date();
26 ws.getCell('D1').dataValidation = {
27 type: 'date',
28 operator: 'greaterThan',
29 showErrorMessage: true,
30 allowBlank: true,
31 formulae: [new Date(2016, 0, 1)],
32 };
33 // hyperlink
34 ws.getCell('E1').value = {
35 text: 'www.google.com',
36 hyperlink: 'http://www.google.com',
37 };
38
39 // number formula
40 ws.getCell('A2').value = {formula: 'A1', result: 7};
41 ws.getCell('A2').name = 'TheFormula';
42
43 // string formula
44 ws.getCell('B2').value = {
45 formula: 'CONCATENATE("Hello", ", ", "World!")',
46 result: 'Hello, World!',
47 };
48 ws.getCell('B2').name = 'TheFormula';
49
50 // date formula
51 ws.getCell('C2').value = {formula: 'D1', result: new Date()};
52 ws.getCell('C3').value = {formula: 'D1'};
53
54 return wb;
55}
56
57// =============================================================================
58// Tests

Callers 1

workbook.spec.jsFile · 0.85

Calls 2

addWorksheetMethod · 0.95
getCellMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…