- const { CellTypes } = GC.Spread.Sheets;
- export class CornerMarkCell extends CellTypes.Text {
- typeName = 'CornerMarkCell';
- showEffect = false;
- constructor(props) {
- super();
- const { showEffect = false } = props;
- this.showEffect = showEffect;
- }
- paint(context, value, x1, y1, a1, b1, style, ctx) {
- if (!context) {
- return;
- }
- if(this.showEffect){
- context.save();
- let base = a1 > b1 ? b1 / 2 : a1 / 2;
- context.beginPath();
- context.moveTo(x1 + a1, y1);
- context.lineTo(x1 + a1, y1 + base);
- context.lineTo(x1 + a1 - base, y1);
- context.fillStyle ='red';
- context.fill();
- context.closePath();
- context.restore();
- }
- CellTypes.Text.prototype.paint.apply(this, [context, value, x1, y1, a1, b1, style, ctx]);
- }
- const sheet = workbook.getActiveSheet();
- sheet.setCellType(0, 1, new CornerMarkCell({ showEffect: true }));
- }
复制代码
你好,我这么写为啥不生效 |