943,737 Members | Top Members by Rank

Ad:
Jul 10th, 2004
0

How to write files to an Excel application

Expand Post »
Can anyone tell me how to write files or output to an excel file with tabs etc.

Thanks,

GB4
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
GB4mytime is offline Offline
2 posts
since Jul 2004
Jul 10th, 2004
0

Re: How to write files to an Excel application

Quote originally posted by GB4mytime ...
Can anyone tell me how to write files or output to an excel file with tabs etc.

Thanks,

GB4
i've been able to write a comma-delimited file for use as an excel spreadsheet
quite easily. Even put a Total at the end of one column (only number column).

It does, however require the user to format the columns as to widths, etc. so
I would also be interested in any info about formatting the columns.
Reputation Points: 11
Solved Threads: 0
Light Poster
Buff is offline Offline
40 posts
since May 2004
Jul 13th, 2004
0

Re: How to write files to an Excel application

Thnnks for your reply. If you had a little more information or details on how to do this it would be much appreciated

Thanks

Quote originally posted by Buff ...
i've been able to write a comma-delimited file for use as an excel spreadsheet
quite easily. Even put a Total at the end of one column (only number column).

It does, however require the user to format the columns as to widths, etc. so
I would also be interested in any info about formatting the columns.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
GB4mytime is offline Offline
2 posts
since Jul 2004
Jul 13th, 2004
0

Re: How to write files to an Excel application

Quote originally posted by Buff ...
i've been able to write a comma-delimited file for use as an excel spreadsheet
quite easily. Even put a Total at the end of one column (only number column).

It does, however require the user to format the columns as to widths, etc. so
I would also be interested in any info about formatting the columns.
Hi There,

Here's a code snippet that writes the contents of an ADO recordset to a Excel file, you'll need to reference an Excel library in your project for it to work. Basically you need to learn about the Excel object model, try looking in your MSDN documentation.

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. '*******************************************************************************
  2. ' excelPrintRecordSet(Sub)
  3. '
  4. ' PARAMETERS:
  5. '
  6. '
  7. ' RETURN VALUE:
  8. '
  9. '
  10. ' DESCRIPTION:
  11. ' Test function that will print out all the records from a recordset in Excel.
  12. '*******************************************************************************
  13. Public Sub excelPrintRecordSet(rstTmp As ADODB.Recordset)
  14. Dim appExcel As Excel.Application
  15. Dim wbkReport As Excel.Workbook
  16. Dim wksReport As Excel.Worksheet
  17. Dim intField As Integer, intRow As Integer
  18.  
  19. Const PROCEDURE_NAME As String = "excelPrintRecordSet"
  20.  
  21. On Error GoTo errorHandler
  22.  
  23. Set appExcel = New Excel.Application
  24. appExcel.Visible = True
  25. Set wbkReport = appExcel.Workbooks.Add
  26. 'wbkReportame = "Kilometer Report"
  27. Set wksReport = wbkReport.Worksheets(1)
  28.  
  29. If rstTmp.EOF <> True Then
  30. rstTmp.MoveFirst
  31. intRow = 1
  32. Do
  33. For intField = 0 To rstTmp.Fields.Count - 1
  34. wksReport.Cells(intRow, intField + 1) = rstTmp.Fields(intField).Name & "=" & rstTmp.Fields(intField).Value
  35. Next intField
  36. rstTmp.MoveNext
  37. intRow = intRow + 1
  38. Loop Until rstTmp.EOF = True
  39. End If
  40. Exit Sub
  41.  
  42. errorHandler:
  43. frmErrorHandler.errorForm MODULE_NAME, PROCEDURE_NAME
  44. Err.Clear
  45. End Sub
Reputation Points: 16
Solved Threads: 1
Posting Whiz in Training
mnemtsas is offline Offline
200 posts
since Jul 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Taking cmmd prompt data into Vb
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Users Saving Games?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC