PictureBox图像到excel文件 [英] PictureBox Image to excel file

查看:264
本文介绍了PictureBox图像到excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,

请建议如何将图片框图像导出为ex​​cel。


Please suggest how to export picture box images to excel.

Bitmap bm = default(Bitmap);

bm = new Bitmap(pictureBox1.Width, pictureBox1.Height);

System.Windows.Forms.Clipboard.SetDataObject(bm, false);
xlWorkSheet.Cells[48, 4].PasteSpecial("Bitmap");



但我在Excel工作表上得到的是灰色图像而不是原始图像。

先谢谢了!


But i am getting a grey image instead of original image on my excel sheet.
Thanks In advance!

推荐答案

您已经创建了一个新的空白位图,并设置了它的宽度和高度,但是你还没有绘制任何东西在它上面。



尝试将图片框的图像属性传递给 SetDataObject 代替:

You've created a new blank Bitmap, and set its width and height, but you haven't drawn anything on it.

Try passing the picture box's Image property to the SetDataObject instead:
System.Windows.Forms.Clipboard.SetDataObject(pictureBox1.Image, false);
xlWorkSheet.Cells[48, 4].PasteSpecial("Bitmap");


这篇关于PictureBox图像到excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆