How to write files to an Excel application

Reply

Join Date: Jul 2004
Posts: 2
Reputation: GB4mytime is an unknown quantity at this point 
Solved Threads: 0
GB4mytime GB4mytime is offline Offline
Newbie Poster

How to write files to an Excel application

 
0
  #1
Jul 10th, 2004
Can anyone tell me how to write files or output to an excel file with tabs etc.

Thanks,

GB4
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 40
Reputation: Buff is an unknown quantity at this point 
Solved Threads: 0
Buff Buff is offline Offline
Light Poster

Re: How to write files to an Excel application

 
0
  #2
Jul 10th, 2004
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 2
Reputation: GB4mytime is an unknown quantity at this point 
Solved Threads: 0
GB4mytime GB4mytime is offline Offline
Newbie Poster

Re: How to write files to an Excel application

 
0
  #3
Jul 13th, 2004
Thnnks for your reply. If you had a little more information or details on how to do this it would be much appreciated

Thanks

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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 200
Reputation: mnemtsas is an unknown quantity at this point 
Solved Threads: 1
mnemtsas's Avatar
mnemtsas mnemtsas is offline Offline
Junior Poster

Re: How to write files to an Excel application

 
0
  #4
Jul 13th, 2004
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC