您可以在自定义单元格的时候保留原始的绘制逻辑,然后在原始逻辑的基础上新增您的逻辑即可,可以参考以下代码:
function LineCellType() {}
LineCellType.prototype = new GC.Spread.Sheets.CellTypes.Text();
const oldPaint = GC.Spread.Sheets.CellTypes.Text.prototype.paint;
LineCellType.prototype.paint = function (
ctx,
value,
x,
y,
w,
h,
style,
options
) {
if (!ctx) {
return;
}
ctx.save();
ctx.beginPath();
ctx.moveTo(x, y);
ctx.lineTo(x + w, y + h);
ctx.stroke();
ctx.font = style.font;
ctx.restore();
oldPaint.call(this, ctx, value, x, y, w, h, style, options);
};
var lineCell = new LineCellType();
sheet.getCell(0, 0).cellType(lineCell).value("Hello Wordl1, Hello World2");
|