Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys,

Just a quick question.

I've compiled some code together that is retrieving all the item info with pictures into a datagridview, that's now coming through successfully, but i've hit a brick wall. when you click a button all the info without the pictures get extracted to an excel worksheet, if anyone could shed some light on this i would be very happy as i would like the images to be extracted as well.

VB
For i = 1 To frmPastelItems.DGItems.RowCount - 1
            For j = 0 To frmPastelItems.DGItems.ColumnCount - 1
                If frmPastelItems.DGItems(j, i).Value.ToString() = "System.Drawing.Bitmap" Then
'this is where i'm stuck though, i'm trying to get the image out of the datagridview column and into the cell in the worksheet
                    Dim imgarray As Byte() = frmPastelItems.DGItems(j, i).Value
                    Dim memorystream As IO.MemoryStream = New IO.MemoryStream(imgarray, False)
                    imgPath = Image.FromStream(memorystream)

                    xlWorkSheet.Cells(i + 1, j + 1) = imgPath
                Else
'this section is working fine and filling the worksheet nicely
                    xlWorkSheet.Cells(i + 1, j + 1) = frmPastelItems.DGItems(j, i).Value.ToString()
                End If
            Next

        Next
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900