欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

vb.net借助剪贴板将图片导入excel内

程序员文章站 2024-02-28 09:03:46
复制代码 代码如下: dim im as image=image.fromfile ("c:/picture.bmp")   '获得image...

复制代码 代码如下:

 dim im as image=image.fromfile ("c:/picture.bmp")   '获得image

        system.windows.forms.clipboard.setdataobject(im, true)  '复制到剪贴板

        dim xlapp as excel.application = new excel.application()
        dim xlbook as excel.workbook

        dim xlsheet as excel.worksheet


        xlbook = xlapp.workbooks().add
        xlsheet = xlbook.worksheets("sheet1")


       dim range as excel.range = xlsheet.range(xlapp.cells(4, 1), xlapp.cells(4, 1))  '粘贴图片的位置
        xlsheet.paste(range, im)  '将图片插入excel