找回密码
 立即注册

QQ登录

只需一步,快速开始

silenceyy2010

高级会员

3

主题

10

帖子

1585

积分

高级会员

积分
1585

活字格认证

最新发帖
silenceyy2010
高级会员   /  发表于:2013-5-24 16:38  /   查看:4816  /  回复:1
如题:Spread.Net6 For Win 单元格显示图片问题!XP系统正常但Win7不显示
同样的程序在XP系统里可正常显示,在WIN7下就不行,是不是有什么设置上的区别呢?
代码如下:
...
if (dgv.Sheets[0].Columns[iCol].Tag.ToString().IndexOf("Image") != -1) // 判断是否为IMAGE类型的列 (前面已定义)
                    {
                        if (File.Exists(dt.Rows[iRow][iCol].ToString()))     // dt.Rows[iRow][iCol].ToString() 是图片的物理路径
                        {
                            System.Drawing.Image image = System.Drawing.Image.FromFile(dt.Rows[iRow][iCol].ToString());
                            Bitmap bmp = new Bitmap(image);
                            MemoryStream ms = new MemoryStream();
                            bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                            Image NewImage = Image.FromStream(ms);

                            dgv.Sheets[0].Cells[iRow, iCol].Value = NewImage;
                            dgv.Sheets[0].Rows[iRow].Height = 50;
                            image.Dispose();
                            bmp.Dispose();
                        }
                    }
...

1 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2013-5-27 11:53:00
沙发
回复 1楼silenceyy2010的帖子

silenceyy2010 你好,

请使用 ImageCellType 来设置图片类型:

  1. FarPoint.Win.Spread.CellType.ImageCellType icelltype =new FarPoint.Win.Spread.CellType.ImageCellType();
  2. icelltype.Style = FarPoint.Win.RenderStyle.Stretch;
  3. icelltype.TransparencyColor = Color.Black;
  4. icelltype.TransparencyTolerance = 100;
  5. fpSpread1.Sheets[0].Rows[0].CellType =icelltype;
  6. System.Drawing.Image image = System.Drawing.Image.FromFile("D:\\alphaomega3.jpg");
  7. System.IO.MemoryStream stream = new System.IO.MemoryStream();
  8. byte[] bytes;
  9. string str;
  10. image.Save(stream,System.Drawing.Imaging.ImageFormat.Jpeg);
  11. stream.Seek(0, System.IO.SeekOrigin.Begin);
  12. bytes = stream.GetBuffer();
  13. str = System.Convert.ToBase64String(bytes);
  14. fpSpread1.Sheets[0].Cells[0,0].Value = image;
  15. fpSpread1.Sheets[0].Cells[0,1].Value = bytes;
  16. fpSpread1.Sheets[0].Cells[0,2].Value = str;
复制代码
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部