在sql server中保存excel文件的数据类型? [英] Datatype to save excel file in sql server?

查看:54
本文介绍了在sql server中保存excel文件的数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格,其中有两列:1. 导入类型,2. Excel 导入模板.

I have a table in which there are two columns : 1. import type, 2. Excel import template.

第二列 - Excel 导入模板"应该存储整个 excel 文件.

The second column - "Excel import template" should store the whole excel file.

如何在数据库中保存 excel 文件...我可以使用二进制数据类型列,将 excel 文件转换为字节并保存吗?

How would I save excel file in databse...can I use binary datatype column, convert excel file to bytes and save the same ?

提前致谢!

推荐答案

是的,您可以使用二进制文件类型.VARBINARY(MAX) 可能最符合目的.

Yes, you can use a binary file type. VARBINARY(MAX) is likely to fit the purpose best.

关于如何将 Excel 文件转换为字节"(从一开始就是字节),我们需要更多地了解您的编程环境才能提供帮助.如果您使用 .NET,您应该能够执行以下操作:

Regarding how to "convert the Excel file to bytes" (it really is bytes from the beginning), we will need to know more about your programming environment in order to help. If you are using .NET, you should be able to do something like this:

var insert = new SqlCommand("INSERT INTO tbl (xls) VALUES (@xls)", conn);
insert.Parameters.AddWithValue("xls", File.ReadAllBytes("template.xls"));
insert.ExecuteNonQuery();

这篇关于在sql server中保存excel文件的数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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