回复 1楼iceman的帖子
jinzaiya 你好,
Spread 拥有单元格类型 ImageCellType ,可以用户导出图片到 Excel。
请参考以下代码:
- private void Form1_Load(object sender, EventArgs e)
- {
- FarPoint.Win.Spread.CellType.ImageCellType icelltype = new FarPoint.Win.Spread.CellType.ImageCellType();
- icelltype.Style = FarPoint.Win.RenderStyle.Stretch;
- icelltype.TransparencyColor = Color.Black;
- icelltype.TransparencyTolerance = 100;
- fpSpread1.Sheets[0].Rows[0].CellType = icelltype;
- System.Drawing.Image image = System.Drawing.Image.FromFile("Chrysanthemum.jpg");
- System.IO.MemoryStream stream = new System.IO.MemoryStream();
- byte[] bytes;
- string str;
- image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
- stream.Seek(0, System.IO.SeekOrigin.Begin);
- bytes = stream.GetBuffer();
- str = System.Convert.ToBase64String(bytes);
- fpSpread1.Sheets[0].Cells[0, 0].Value = image;
- fpSpread1.Sheets[0].Cells[0, 0].Text = "fdfdasfdas";
- fpSpread1.Sheets[0].Protect = false;
- this.fpSpread1.SaveExcel("test.xls");
- }
复制代码 |