Solved

How to copy Datagridview Backcolors to Excel

Posted on 2009-05-07
4
366 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

705 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

19 Experts available now in Live!

Get 1:1 Help Now