Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

True DBGrid ExportToDelimitedFile missing Header record

Posted on 2003-04-01
6
Medium Priority
?
1,161 Views
Last Modified: 2007-12-19
True DBGrid 6.0
VB 6.0

I am currently using the ExportToDelimitedFile command as follows.

Grid.ExportToDelimitedFile sConvFileName, , ","

I would like to have the headers or as they call it the captions exported to the file also. Can this be done with True DBgrid? Is there another command that supports the export of the header record.

Thanks
0
Comment
Question by:Darebear
  • 3
  • 3
6 Comments
 
LVL 10

Accepted Solution

by:
aeklund earned 1000 total points
ID: 8247782
I don't know much about this 3rd party control, but here is a solution that will work:

  'Call your export function
  Grid.ExportToDelimitedFile sConvFileName, , ","
 
  'Now use this to add the Headers (to a new file)
  Dim sLine As String
  Open sConvFileName For Input As #1
 
  'Write Headers
  Open sConvFileName & "-headers.txt" For Output As #2
    Dim i As Integer
    For i = 0 To Grid.Columns.Count - 1
      If i = 0 Then
        sLine = Chr(34) & Grid.Columns(i).Caption & Chr(34)
      Else
        sLine = sLine & "," & Chr(34) & Grid.Columns(i).Caption & Chr(34)
      End If
    Next
    Print #2, sLine
   
    'Write contents of original file
    Do Until EOF(1)
      Line Input #1, sLine
      Print #2, sLine
    Loop
  Close
0
 

Author Comment

by:Darebear
ID: 8249944
The above solution works and I will award the points if nobody can provide the true dbgrid with in a day or two.

Thank you
0
 

Author Comment

by:Darebear
ID: 8253594
The above solution works and I will award the points if nobody can provide the true dbgrid with in a day or two.

Thank you
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 10

Expert Comment

by:aeklund
ID: 8254240
Great... I downloaded the help for the true dbgrig 8.0 (apex) and I don't see anywhere in the documentation on how to export the headers as the first row of your exported file.
0
 

Author Comment

by:Darebear
ID: 8275535
The points are all yours.
0
 
LVL 10

Expert Comment

by:aeklund
ID: 8284188
Glad to help.. thx for the points
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month15 days, 1 hour left to enroll

577 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