我正在使用excel4node在nodeJS中创建nodeJS文件。网站给出了以下使用填充属性的指导原则。
fill: { // §18.8.20 fill (Fill)
type: string, // Currently only 'pattern' is implimented. Non- implimented option is 'gradient'
patternType: string, //§18.18.55 ST_PatternType (Pattern Type)
bgColor: string // HTML style hex value. optional. defaults to black
fgColor: string // HTML style hex value. required.
},我没法解决这个问题。有人能帮我吗?
发布于 2017-05-02 15:04:36
基本上,您可以对当前状态的包执行以下操作:
fill: {
type: 'pattern', // the only one implemented so far.
patternType: 'solid', // most common.
fgColor: '2172d7', // you can add two extra characters to serve as alpha, i.e. '2172d7aa'.
// bgColor: 'ffffff' // bgColor only applies on patternTypes other than solid.
}请注意,单元格的背景色将是填充属性的前景色(fgColor)。这听起来令人困惑,但当您理解fill属性的模式使用多个颜色,因此属性具有前景色和背景色时,这是有意义的。
'solid‘patternType可能是您要寻找的东西,但是还有其他的东西,如’暗降‘、’暗视野‘、'lightGrid’等等,如下所示:Exsel4nodepattern.js
发布于 2019-12-04 19:32:03
在excel中定义函数,生成如下所示的函数:var wb =新的xl.Workbook();var ws =wb.addWorksheet(“每日活动报告”);
function colorCell(color, pattern) {
return wb.createStyle({
fill: {
type: 'pattern',
fgColor: color,
patternType: pattern || 'solid',
}
});
}然后应用它就像
ws.cell(1,1).string("Cell Content").style(colorCell('#CDDC39'))还可以选择在函数参数中发送模式类型。
https://stackoverflow.com/questions/43118853
复制相似问题