将Excel工作表导入到SQL表 [英] Importing Excel Sheet to sql table

查看:84
本文介绍了将Excel工作表导入到SQL表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我正在将数据从Excel文件导入sql表.它工作正常,但问题是我的excelsheet包含图像.现在,我必须将图像存储在项目中的Upload文件夹中,并将其存储在表中的路径中.
我正在使用以下代码从excel文件获取数据表

Hi All
I am importing data from an excel file to sql table. It is working fine, but problem is that my excelsheet contains images. Now i have to store the images in Upload folder in my project and path in table.
I am using below code to get datatable from excel file

public DataTable readdata(String sheetname, String filename)
        {
            OleDbConnection MyConnection = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source=''" + filename + "''; Extended Properties=Excel 8.0;");
            OleDbDataAdapter MyCommand = new OleDbDataAdapter("select * from [" + sheetname + "]", MyConnection);
            DataTable dt = new DataTable();
            MyCommand.Fill(dt);
            MyConnection.Close();
            MyConnection.Dispose();
            return dt;
        }



但是它显示图像列为空白.

任何人都可以建议我如何从excel文件中获取图像.

在此先感谢



But it is showing the image column blank.

Can anyone please suggest me how to get image from excel file.

Thanks in advance

推荐答案

Excel不允许您将图片插入到单元格中.
图片已插入工作表中,并且将始终浮动.
图片的属性之一可以设置为随单元移动并调整大小".但这仅在插入,删除或调整基础行和列的大小时移动或拉伸图片.它不会将图片限制为单元格.

而且由于它们不是单元格的一部分,因此您无法将它们导出到表中.
Excel does not allow you to insert a picture into a cell.
Pictures are inserted into the worksheet and will always float.
One of the properties of a picture can be set to "move and size with cells" but that only moves or stretches the picture when the underlying rows and columns are inserted, deleted or sized. It does not confine a picture to a cell.

And since they''re not part of a cell you can''t export them to a table.


这篇关于将Excel工作表导入到SQL表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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