Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI,
Please suggest how to export picture box images to excel.
C#
Bitmap bm = default(Bitmap);

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

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

But i am getting a grey image instead of original image on my excel sheet.
Thanks In advance!
Posted
Updated 24-Jul-15 2:46am
v2

1 solution

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:
C#
System.Windows.Forms.Clipboard.SetDataObject(pictureBox1.Image, false);
xlWorkSheet.Cells[48, 4].PasteSpecial("Bitmap");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900