fcs
2025-04-10 0163870d662dc5b7d69ceff977490ede594f7d82
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
var officegen = require('../')
 
var fs = require('fs')
var path = require('path')
 
var outDir = path.join(__dirname, '../tmp/')
 
var docx = officegen('docx')
 
docx.on('finalize', function(written) {
  console.log(
    'Finish to create Word file.\nTotal bytes created: ' + written + '\n'
  )
})
 
docx.on('error', function(err) {
  console.log(err)
})
 
var table = [
  [
    {
      val: 'No.',
      opts: {
        cellColWidth: 4261,
        b: true,
        sz: '48',
        shd: {
          fill: '7F7F7F',
          themeFill: 'text1',
          themeFillTint: '80'
        },
        fontFamily: 'Avenir Book'
      }
    },
    {
      val: 'Title1',
      opts: {
        b: true,
        color: 'A00000',
        align: 'right',
        shd: {
          fill: '92CDDC',
          themeFill: 'text1',
          themeFillTint: '80'
        }
      }
    },
    {
      val: 'Title2',
      opts: {
        align: 'center',
        cellColWidth: 42,
        b: true,
        sz: '48',
        shd: {
          fill: '92CDDC',
          themeFill: 'text1',
          themeFillTint: '80'
        }
      }
    }
  ],
  [1, { val: 'I have two spans.', opts: { gridSpan: 2 } }],
  [{ val: 'I have three spans.', opts: { gridSpan: 3 } }],
  [{ val: 'I have two spans.', opts: { gridSpan: 2 } }, '3'],
  [4, 'watch out for the baobabs!', 'END']
]
 
var tableStyle = {
  tableColWidth: 4261,
  tableSize: 24,
  tableColor: 'ada',
  tableAlign: 'left',
  tableFontFamily: 'Comic Sans MS',
  borders: true
}
 
docx.createTable(table, tableStyle)
 
var out = fs.createWriteStream(
  path.join(outDir, 'example_table_cell_span.docx')
)
 
out.on('error', function(err) {
  console.log(err)
})
 
docx.generate(out)