I have an image (logo) stored in my database that I would like to insert into a cell in the worksheet that I am creating. How do I go about doing this?
My code results in "ExportImage" in cell H18 and "System.Byte[]" in cell H19.
The code:
SqlDataAdapter adapter = new SqlDataAdapter("Select ExportImage From Organization Where ID = @OrgID", con);
As I said in my original post, my images reside within a database - NOT in a file. Is there a technique available to accomplish inserting such images into a worksheet?
Yes, you can use worksheet.Pictures.Add() overload that takes stream not file path.
Here are the steps you will follow.
1 - Get the image in the form of bytes from your database. 2 - Create a memory stream object from the image bytes. 3 - Pass the memory stream object as a parameter worksheet.Pictures.Add() method.