Excel BLOB to C# App File Open Error RRS feed

  • Question

  • Hello,

    I have a good excel file that I load into the MSSQL varbinary(max) as a starting point. A user through a c# app access that record and gets the excel file.

    Now I tried to open the byte[] from the db but I read / was told that VSTO won't allow that so you have to write it to disk then open from disk. So I tried to do that and it writes the file out but then I get an error about the file being of the wrong type.

    Further reading says this is because you can't just use BinaryWriter but that you have to actually use Interop to write your file. I am really not sure what approach to take at this point and have lost alot of time so far with this.

    My SQL for inserting the file:

    UPDATE [dbo].[TableA]
    SET [ProjStartExlDoc] = 
      SELECT * FROM OPENROWSET (BULK N'C:\...\ProjStartXls.xls', SINGLE_BLOB) as tempdoc

    I have the Microsoft.Office.Interop.Excel (v14) added but I'm still looking for where I can save a byte[] to disk with it.

    I would really appreciate any help getting this accomplished



    Monday, March 25, 2013 11:15 PM

All replies