图像从Excel到vb.net Picturebox

时间:2016-02-08 19:46:11

标签: vb.net excel image picturebox

我发现很多问题对于相反的vb.net要擅长但没有用于将excel nav { background-color: #7B7B7B; width: 950px; margin: 0 auto; height: ; /* for ex. 75px */ } 中的图片放到图片框中。我的应用程序是一个模板,可以从excel文件中获取文本字符串。哪个工作正常,但现在我也试图传输图片。我尝试了cell(row,column)但没有做任何事情。虽然没有错误!

将复制和粘贴工作吗?

代码:

picSpindle.Image = shXL.Cells(19, 2).Value

2 个答案:

答案 0 :(得分:1)

shXL.Cells(19, 2).Value
由于图片不会存储在cells中,而是通过它们,因此

等工作无法完成 这些values的含义cells将为nothing

尝试这些链接

1

2

3

答案 1 :(得分:0)

图像不在单元格内。但左上角的坐标指向一个单元格,使用上面的代码,您可以创建自己的搜索图像的功能。

你可以这样做:

    shXL = wbXl.Worksheets("Sheet1")

    ' # Loop for all Shapes 
    ' But I don't know what other controls over 
    '    the images are considered "shapes",
    '    Perhaps the best way is to verify that 
    '    in the "clipboard" there is truly a picture
    For i = 0 To shXL.Shapes.Count - 1

        'THIS IS THE MAIN POINT

        ' # get the pictures and copy to clipboard
        'shXL.Shapes.Item(i).Copy()

        ' # paste the picture in the pictureBox from clipboard
        'PictureBox1.Image = Clipboard.GetImage

        'AND OTHER PROPERTIS

        MsgBox(shXL.Shapes.Item(i).Name) ' the name in excel
        MsgBox(shXL.Shapes.Item(i).AlternativeText) 'the name of the file
        MsgBox(shXL.Shapes.Item(i).TopLeftCell.Column) 'the column position (of the top left corner)
        MsgBox(shXL.Shapes.Item(i).TopLeftCell.Row) 'the row position (of the top left corner)
        MsgBox(shXL.Shapes.Item(i).Width) 'the with in px
        MsgBox(shXL.Shapes.Item(i).Height) 'the height in px
        MsgBox(shXL.Shapes.Item(i).Top) 'the top in px
        MsgBox(shXL.Shapes.Item(i).Left) 'the left in px
    Next