C#Windows将Excel中的图片导入到数据库中

lnz1314 2017-04-07 02:37:56
将Excel中的图片导入到数据库中???????求给各位大神指点一下
...全文
312 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
燃烧的荷尔蒙 2017-04-10
  • 打赏
  • 举报
回复

//引用Excel命名空间
        using Excel;
        //......
        //下面从test.xls中的2,2格复制图片到剪贴板,然后从剪贴板读取图片并显示到pictureBox1中。
        private void btnGetImageFromExcel_Click(object sender, EventArgs e)
        {
            //初始化excel对象
            Excel.Application excel = new Excel.Application();
            //打开xls文件(注意:后面的参数都用Type.Missing填充,表示使用参数的默认值)
            excel.Workbooks.Open(@"D:\Documents and Settings\xrwang\桌面\test.xls", System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing);
            //选定到第2行第2列所在的单元格
            Range r = (Range)excel.Cells[2, 2];
            r.Select();
            //将单元格复制到剪贴板中
            r.CopyPicture(XlPictureAppearance.xlScreen, XlCopyPictureFormat.xlBitmap);
            //退出excel
            excel.Quit();
            //判断剪贴板中是否存在图片,如果存在,则将图片显示到pictureBox1中
            if (Clipboard.ContainsImage())
            {
                Image image=Clipboard.GetImage();
                pictureBox1.Image = image;
            }
        }
燃烧的荷尔蒙 2017-04-10
  • 打赏
  • 举报
回复
卧槽!好变态的需求!
  • 打赏
  • 举报
回复
这个不好处理,很容易出问题 入库建议只保存路径

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧