Results 1 to 40 of 46

Thread: Best way to print reports ??

Hybrid View

  1. #1

    Thread Starter
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457

    Re: Best way to print reports ??

    Quote Originally Posted by RobCrombie
    David P.
    Is paging required ?
    Is there NO grid on the Form ?
    Is it just a case of print what is on a Form (single page of paper) ?

    If the answer to all of those was yes (no paging, no grid, single sheet of paper), I have a suggestion
    LOL - I wish. I need ....

    Yes to Paging
    Yes to Grid
    and the report is a composite and varies depending on user selections.

    But thanks for the thought
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

  2. #2
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: Best way to print reports ??

    Have you considered automating Excel ?

    I have a very comprehensive form which displays a 'Job Register'
    It is wider than Texas, and may be longer than 'War and Peace'

    Printing that was going to be a nightmare.
    Instead I automated Excel and mimicked the grid (SGrid-2) into Excel.
    User loves it, and can use Excel's printing features (which he likes).
    Rob C

  3. #3

    Thread Starter
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457

    Re: Best way to print reports ??

    Instead I automated Excel and mimicked the grid (SGrid-2) into Excel.
    User loves it, and can use Excel's printing features (which he likes).
    I love that Idea Rob. I may not use it as the only way of doing it but I would certainly like to place it in my code as an option.

    The application is for teachers you see, and not all teachers like excell ( hence the reason for my app). Those teachers that did preffer excell would benefit from the functionality that automating it would give them.

    Given that I am also a major lover and user of SGrid and THAT is what I am trying to print out I would value any input you could give me.
    Last edited by David.Poundall; May 8th, 2005 at 03:33 AM. Reason: typo
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

  4. #4
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: Best way to print reports ??

    Even the Teachers who don't like Excel, could be advised that they don't have to 'use Excel' in the true sense.
    Just introduce them to Excel's print facilities, and tell them it will be opened up for them, displaying the data, and all they have to do is go to the Print option. They can then print and get out.
    (Who knows it may even be possible to add a few more commands to the automation, and do that for them as well ?)

    I could send you my bas file, that is in the 'Job Register' project. However it is a bit specialised.
    Normally I develop a stand alone pgm to prove a concept, then incorporate it into my real project.
    If I did that, then I should send you that.
    a) Not sure if I did that
    b) I'm searching my drive now

    Worst case scenario, I will attach the one from my project.
    Last edited by RobCrombie; May 8th, 2005 at 04:18 AM.
    Rob C

  5. #5

    Thread Starter
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457

    Re: Best way to print reports ??

    That would be great - thanks Rob.
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

  6. #6
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: Best way to print reports ??

    This in a BAS file

    VB Code:
    1. Option Explicit
    2.  
    3. Private Const ROW_START As Long = 1
    4.  
    5. Public Sub ExportGrid(Grid As vbAcceleratorSGrid6.vbalGrid, ByVal bPrint As Boolean, Color_TOTAL_CELL_LIGHT As Long, Optional bUseCellValue As Boolean = False)
    6.    Dim lRow As Long
    7.    Dim lCol As Long
    8.    
    9.    Dim xlApp As Excel.Application
    10.    Dim xlSht As Excel.Worksheet
    11.    
    12.    Set xlApp = New Excel.Application
    13.    xlApp.Workbooks.Add
    14.    Set xlSht = xlApp.ActiveSheet
    15.    
    16.    ' Grid header-
    17.    For lCol = 1 To Grid.Columns
    18.       xlSht.Cells(ROW_START, lCol).Value = Grid.ColumnHeader(lCol)
    19.    Next
    20.    'Cell values
    21.    For lRow = 1 To Grid.Rows
    22.       For lCol = 1 To Grid.Columns
    23.         If bUseCellValue Then
    24.           xlSht.Cells(ROW_START + lRow, lCol).Value = Grid.CellItemData(lRow, lCol)
    25.         Else
    26.           xlSht.Cells(ROW_START + lRow, lCol).Value = Grid.CellText(lRow, lCol)
    27.         End If
    28.       Next
    29.    Next
    30.    ' Draw gridlines
    31.    xlApp.Range(xlApp.Cells(ROW_START, 1), xlApp.Cells(ROW_START + Grid.Rows, Grid.Columns)).Select
    32.    With xlApp.Selection
    33.       With .Borders(xlEdgeLeft)
    34.          .LineStyle = xlContinuous
    35.          .Weight = xlMedium
    36.          .ColorIndex = xlAutomatic
    37.       End With
    38.       With .Borders(xlEdgeTop)
    39.          .LineStyle = xlContinuous
    40.          .Weight = xlMedium
    41.          .ColorIndex = xlAutomatic
    42.       End With
    43.       With .Borders(xlEdgeBottom)
    44.          .LineStyle = xlContinuous
    45.          .Weight = xlMedium
    46.          .ColorIndex = xlAutomatic
    47.       End With
    48.       With .Borders(xlEdgeRight)
    49.          .LineStyle = xlContinuous
    50.          .Weight = xlMedium
    51.          .ColorIndex = xlAutomatic
    52.       End With
    53.       If Grid.Columns > 1 Then
    54.          With .Borders(xlInsideVertical)
    55.             .LineStyle = xlContinuous
    56.             .Weight = xlThin
    57.             .ColorIndex = xlAutomatic
    58.          End With
    59.       End If
    60.       With .Borders(xlInsideHorizontal)
    61.          .LineStyle = xlContinuous
    62.          .Weight = xlThin
    63.          .ColorIndex = xlAutomatic
    64.       End With
    65.    End With
    66.    
    67.    ' Highlight the header using the gray color
    68.    xlApp.Range(xlApp.Cells(ROW_START, 1), xlApp.Cells(ROW_START, Grid.Columns)).Select
    69.    xlApp.Selection.Font.Bold = True
    70.    With xlApp.Selection.Interior
    71.       .ColorIndex = 15
    72.    End With
    73.    
    74.    ' Highlight T O T A L S  line using the gray color
    75.   lRow = Grid.Rows  '<== Watch out as the excel row is 1 greater than the Grid Row
    76.   If Grid.RowItemData(lRow) = -999999999 Then
    77.     'Make the left cell font color white, also the right cell (it may be 0 wide, but who cares)
    78.     xlApp.Range(xlApp.Cells(lRow + 1, 1), xlApp.Cells(lRow + 1, 1)).Select
    79.     xlApp.Selection.Font.Color = RGB(255, 255, 255)
    80.     xlApp.Range(xlApp.Cells(lRow + 1, Grid.Columns), xlApp.Cells(lRow + 1, Grid.Columns)).Select
    81.     xlApp.Selection.Font.Color = RGB(255, 255, 255)
    82.     'Now cycle along the cells, setting to dark or light backcolor
    83.     For lCol = 1 To Grid.Columns
    84.       If Grid.CellBackColor(lRow, lCol) = Color_TOTAL_CELL_LIGHT Then
    85.         xlApp.Range(xlApp.Cells(lRow + 1, lCol), xlApp.Cells(lRow + 1, lCol)).Select
    86.         xlApp.Selection.Font.Bold = True
    87.         xlApp.Selection.Interior.ColorIndex = 24
    88.       Else
    89.         xlApp.Range(xlApp.Cells(lRow + 1, lCol), xlApp.Cells(lRow + 1, lCol)).Select
    90.         xlApp.Selection.Font.Bold = True
    91.         xlApp.Selection.Interior.ColorIndex = 23           '24
    92.       End If
    93.     Next lCol
    94.   End If
    95.  
    96. 'UNCOMMENT THE NEXT BLOCK TO SEE THE COLORINDEX COLORS
    97. '  ' Highlight a range with various ColorIndex values
    98. '  ' 15 = gray   24 = my light T O T A L S  color   23 or 55 my (very) dark T O T A L S  color
    99. '  Dim i As Integer
    100. '  For i = 1 To 56
    101. '    'xlApp.Range(xlApp.Cells(ROW_START + 1, 1), xlApp.Cells(Grid.Rows, Grid.Columns)).Select
    102. '    xlApp.Range(xlApp.Cells(ROW_START + 1, i), xlApp.Cells(ROW_START + 1, i)).Select
    103. '    xlApp.Selection.Font.Bold = True
    104. '    With xlApp.Selection.Interior
    105. '       .ColorIndex = i
    106. '       '.Color = RGB(220, 220, 220)  'I may have to set one of the 52 colors then use that
    107. '       '.pattern = xlPatternGray50 'xlPatternGray25 'xlSolid
    108. '    End With
    109. '  Next i
    110.    
    111.    'Size columns  and  rows
    112.    For lCol = 1 To Grid.Columns
    113.     If Grid.ColumnVisible(lCol) = True Then
    114.       xlApp.Columns(lCol).ColumnWidth = Grid.ColumnWidth(lCol) / 6
    115.     Else
    116.       xlApp.Columns(lCol).ColumnWidth = 0
    117.     End If
    118.    Next
    119.    
    120.    For lRow = 1 To Grid.Rows + 1
    121.     xlSht.Rows(lRow).RowHeight = 15
    122.    Next
    123.    
    124.    If bPrint Then
    125.       ' Print
    126.       xlApp.ActiveWindow.SelectedSheets.PrintOut
    127.       xlApp.ActiveWindow.Close SaveChanges:=False
    128.    Else
    129.       ' Displaying Excel
    130.       xlApp.Cells(1, 1).Select
    131.       xlApp.Visible = True
    132.    End If
    133.  
    134.     DoEvents
    135.     Set xlSht = Nothing
    136.     Set xlApp = Nothing
    137. End Sub
    138.  
    139. ' 1440 Twips  = 1 logical Inch
    140. '   72 Points = 1 logical Inch
    141. ' Convert my Pixels to Twips then * 72  and  / 1440
    142. Private Function ConvertPixelsToPoints(lIN As Long) As Long
    143.  Dim myLng As Long
    144.   myLng = lIN / 6
    145.   ConvertPixelsToPoints = myLng
    146. End Function
    Rob C

  7. #7

    Thread Starter
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457

    Re: Best way to print reports ??

    Thanks Rob - That is a great starting point for me.

    I would have posted you some points but the forum god says I have to spread a little around first

    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width