且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Excel BLOB到C#应用程序文件打开错误

更新时间:2023-02-08 14:05:55

您好zzpluralza,


感谢您在MSDN论坛上发帖。


我会就你的问题咨询我的同事。如果有任何更新,我们会通知您。


感谢您的耐心和理解。


祝你好运,


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

TIA

JB

Hi zzpluralza,

Thank you for posting in the MSDN Forum.

I'll consult my colleague on your issue. You'll be informed if there's any update.

Thank you for your patience and understanding.

Best regards,