murr1999
asked on
How to copy Datagridview Backcolors to Excel
Is there a good way to transfer the backcolor of a Datagridview to Excel using Vb.net? I have working code but it's very slow.
For intTube = 1 To intTubeCount
GetActiveChild.tspbThicknessData.Value = GetActiveChild.tspbThicknessData.Value + 1
If GetActiveChild.dgvThicknessData.Rows.Item(intRow + 2).Cells(Y + intTube).Value = "" Then
.Cells(X, Y + 1 + intTube).Interior.Color = System.Drawing.ColorTranslator.ToOle(Color.White)
Else
If GetActiveChild.dgvThicknessData.Rows.Item(intRow + 2).Cells(Y + intTube).Style.BackColor <> Color.White Then
If .Cells(X, Y + 1 + intTube).Interior.Color <> System.Drawing.ColorTranslator.ToOle(GetActiveChild.dgvThicknessData.Rows.Item(intRow + 2).Cells(Y + intTube).Style.BackColor) Then
.Cells(X, Y + 1 + intTube).Interior.Color = System.Drawing.ColorTranslator.ToOle(GetActiveChild.dgvThicknessData.Rows.Item(intRow + 2).Cells(Y + intTube).Style.BackColor)
End If
End If
End If
ThicknessReadings(intRow + 2, intTube - 1) = GetActiveChild.dgvThicknessData.Rows.Item(intRow + 2).Cells(Y + intTube).Value
Next
There is the Open XML way, but that depends on the Excel version that you are using...
ASKER
Can you provide some sample code for this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.