找回密码
 立即注册

QQ登录

只需一步,快速开始

刘君

中级会员

141

主题

335

帖子

942

积分

中级会员

积分
942

活字格认证

刘君
中级会员   /  发表于:2016-12-13 11:58  /   查看:3262  /  回复:7
请问可以在单元格中绘制一些特殊符号吗? 例如:

blob539925536.png

7 个回复

倒序浏览
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-12-13 12:32:24
沙发
您这个是图片还是 Unicode 符号。
要是图片可以设置单元格背景图,
Unicode符号直接粘贴进来就好了
回复 使用道具 举报
刘君
中级会员   /  发表于:2016-12-13 14:42:41
板凳
这是一个自定义字符。我不想用自定义字符,我现通过代码在单元格内画出来。
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-12-13 16:43:24
地板
继承 TextCellType 重写 PaintCell 方法,在方法中绘制
回复 使用道具 举报
刘君
中级会员   /  发表于:2016-12-14 08:34:13
5#
谢谢,能提供一个例子吗?
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-12-14 17:41:21
6#
近期用户较多,制作demo需要时间。
PaintCell 方法的第一个参数就是 Graphics ,这个直接用它绘制就好了
public override void PaintCell(
   Graphics g,
   Rectangle r,
   Appearance appearance,
   object value,
   bool isSelected,
   bool isLocked,
   float zoomFactor
)
回复 使用道具 举报
刘君
中级会员   /  发表于:2017-2-6 17:20:40
7#
请问: 重载的 PaintCell 方法怎样才能够执行?
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2017-2-6 17:31:58
8#
新建一个celltype 重写paint 方法
  1.     public class MyCellType : FarPoint.Win.Spread.CellType.TextCellType
  2.     {
  3.         public override void PaintCell(Graphics g, Rectangle r, FarPoint.Win.Spread.Appearance appearance, object value, bool isSelected, bool isLocked, float zoomFactor)
  4.         {
  5.             base.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor);

  6.             // Create graphics path object and add ellipse.
  7.             System.Drawing.Drawing2D.GraphicsPath graphPath = new System.Drawing.Drawing2D.GraphicsPath();
  8.             graphPath.AddEllipse(r.X + 5, r.Y + 5, r.Width - 10, r.Height - 10);

  9.             // Create pen.
  10.             Pen blackPen = new Pen(Color.Black, 3);

  11.             // Draw graphics path to screen.
  12.             g.DrawPath(blackPen, graphPath);
  13.         }
  14.     }
复制代码


使用心得CellType

  1.             var textCell = new MyCellType();
  2.             fpSpread1.ActiveSheet.Cells[0, 0].CellType = textCell;
复制代码

评分

参与人数 1满意度 +5 收起 理由
刘君 + 5 很给力!

查看全部评分

回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部