我正在使用officegen 使用nodejs 创建MS-word 文件。到目前为止它工作得很好。我需要将自定义图像添加到表格单元格。但我想出了任何办法。现在我只是使用他们的默认表格示例。
代码:
var officegen = require('officegen');
var docx = officegen ( 'docx' );
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",
vAlign: "center",
cellColWidth: 42,
b:true,
sz: '48',
shd: {
fill: "92CDDC",
themeFill: "text1",
"themeFillTint": "80"
}
}
}],
[1,'All grown-ups were once children','I need to add custom image here'],
[2,'there is no harm in putting off a piece of work until another day.',''],
[3,'But when it is a matter of baobabs, that always means a catastrophe.',''],
[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);
上面的代码能够创建一个自定义表格。但我无法在表格单元格内添加自定义图像或段落。
我感谢任何形式的帮助。提前致谢
用于化妆第一行的第一个单元格而不是
[1,'All grown-ups were once children','I need to add custom image here']
使用
[{"val":1,"opts":{place here your desired options - same notation as heading opts}},'All grown-ups were once children','I need to add custom image here']
我是一名优秀的程序员,十分优秀!