Excel BLOB到C#应用程序文件打开错误 [英] Excel BLOB to C# App File Open Error

查看:123
本文介绍了Excel BLOB到C#应用程序文件打开错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我有一个很好的excel文件,我加载到MSSQL varbinary(max)作为起点。用户通过ac#app访问记录并获取excel文件。


现在我尝试从数据库中打开byte [],但是我读到/被告知VSTO将不允许所以你必须把它写到磁盘然后从磁盘打开。所以我试着这样做,它把文件写出去,但后来我得到一个关于文件错误类型的错误。


进一步阅读说这是因为你不能只使用BinaryWriter但你必须实际使用Interop来编写你的文件。到目前为止,我真的不确定采取什么方法并且已经失去了很多时间。


我插入文件的SQL:


< pre class ="prettyprint lang-sql"> UPDATE [dbo]。[TableA]
SET [ProjStartExlDoc] =

SELECT * FROM OPENROWSET(BULK N'C:\ .. .\ProjStartXls.xls',SINGLE_BLOB)as tempdoc


我有Microsoft.Office.Interop .Excel(v14)已添加,但我仍在寻找可以将字节[]保存到磁盘的位置。



我会非常感谢任何帮助实现这一目标


TIA


JB


解决方案

您好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,


这篇关于Excel BLOB到C#应用程序文件打开错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆