Solved

How to copy Datagridview Backcolors to Excel

Posted on 2009-05-07
4
374 Views
Last Modified: 2012-06-27
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

Open in new window

0
Comment
Question by:murr1999
  • 2
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24337241
There is the Open XML way, but that depends on the Excel version that you are using...
0
 

Author Comment

by:murr1999
ID: 24337700
Can you provide some sample code for this?
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 125 total points
ID: 24337749
Oh, I wish...

There are plenty of references, like this one, for the SpreadsheetML Open XML specification:

ExcelPackage: Office Open XML Format file creation
http://www.codeplex.com/ExcelPackage
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now