Import image from MS SQL Database into Excel

0

I have a MS SQL Database where images are stored as byte[]. Is it possible to import these byte[] into Excel and convert them back into images?

I already have a connection to the database in my Excel and I get the IDs and the names (which are also stored in the table) but Excel doesn't load the image data.

katho2404

Posted 2015-03-26T13:30:32.053

Reputation: 111

I seriously doubt it I'm afraid – Dave – 2015-03-26T13:57:07.727

Answers

0

You can do this if you cast the image data as an nvarchar and import it then write that data to a text file in VBA with the stored filename as the name of the text file. If the data in the server is truly the raw contents of the image file.

Mr. Mascaro

Posted 2015-03-26T13:30:32.053

Reputation: 383

0

Excel is not able to recognize the fact that you stored an image as an array of bytes into SQL Server (Why not the file path instead?) and it's not able (unless you want to check if VBA is able to do that) to convert back the array to the original image.

I don't think the procedure you're requesting is possible without much effort. The best way for you I think it's to write a program that retrieves this byte array from SQL Server and performs this conversion task. Once you're done with that, insert the images into Excel.

Alberto Solano

Posted 2015-03-26T13:30:32.053

Reputation: 276