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.
Let me know if you need more help.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.