gpt4 book ai didi

node.js - 如何使用 Officegen NodeJS 将自定义图像/样式文本添加到表格单元格

转载 作者:太空宇宙 更新时间:2023-11-03 22:40:03 24 4
gpt4 key购买 nike

我正在使用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']

关于node.js - 如何使用 Officegen NodeJS 将自定义图像/样式文本添加到表格单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39010410/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com