Solved

How to copy Datagridview Backcolors to Excel

Posted on 2009-05-07
4
377 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 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