Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
785
Frustrate with Generate Report
posted

Hi,

 

I am frustrated with figuring out how to set up the report which have 1 or more gridview to be printout, but need to be printout in the right place.

Plus when I like to see header change after different type of report come in.

 

For example

 

Log of checks received:            

ACCT                   DBA/EMPLOYER NAME               Check Amout              Check Date     

1233                     ABC12                                                   25.00                     9/20/2010

1235                     DCE                                                       15.00                      8/20/2010

 

       page 1

 

MultiCheck breakdown

 

ACCT                   DBA/EMPLOYER NAME               Check Amout              Check Date     

12389                     ABCDF12                                                 125.00                     9/20/2010

12359                    adcDCE                                                     115.00                      8/20/2010

 

       page 2

 

Is that possible

 

My code is here

    Dim otable, otable2 As Data.DataTable
        Dim vstr As String
        Dim a1 As New ArrayList
        Dim aTots(8) As Double
        Dim myDocuments As String = "H:\"
        Dim myDocuments2 As String = HttpContext.Current.Request.PhysicalApplicationPath
        Dim headerstyle As New Infragistics.Documents.Report.Text.Style(New Font("Arial", 14, FontStyle.Bold), Brushes.Black)
        Dim textStyle As New Infragistics.Documents.Report.Text.Style(New Font("Arial", 8, FontStyle.Regular), Brushes.Black)
        Dim headerSmall As New Infragistics.Documents.Report.Text.Style(New Font("Arial", 10, FontStyle.Regular), Brushes.MediumBlue)
        Dim headerTiny As New Infragistics.Documents.Report.Text.Style(New Font("Arial", 8, FontStyle.Regular), Brushes.Black)
        Dim headerBlank As New Infragistics.Documents.Report.Text.Style(New Font("Arial", 4, FontStyle.Regular), Brushes.White)
        Dim gridstyle As New Infragistics.Documents.Report.Text.Style(New Font("Arial", 10, FontStyle.Bold), Brushes.Black)
        Dim theReport As New Infragistics.Documents.Report.Report()
        Dim strCT, strCT1 As String
        Dim theSection As Infragistics.Documents.Report.Section.ISection = theReport.AddSection()
        'Table Pattern (think of this as a kind of "Style Sheet" for ITable
        theSection.PageOrientation = Infragistics.Documents.Report.PageOrientation.Landscape

        theReport.Preferences.Printing.PaperSize = Infragistics.Documents.Report.Preferences.Printing.PaperSize.Auto
        theReport.Preferences.Printing.PaperOrientation = Infragistics.Documents.Report.Preferences.Printing.PaperOrientation.Auto
        theReport.Preferences.Printing.FitToMargins = True
        Dim pn As Infragistics.Documents.Report.Section.PageNumbering = theSection.PageNumbering
        ' Create a style for the page numbering font.
        pn.Style = headerTiny

        ' The Template property is the actual string that
        ' shows the page numbering. Use the [Page #] place-
        ' holder for the current page and the [TotalPages]
        ' place-holder for the total amount of pages in
        ' the entire document.
        pn.Template = "Page [Page #] of [TotalPages]"

        ' Setting SkipFirst to true does not place page
        ' numbering on the first page of the section. This
        ' is useful if the first page is a Title page.
        pn.SkipFirst = False

        ' The page numbering will be aligned with the
        ' right side of the page. Valid values off the
        ' Alignment enum include Left, Center, and Right.
        '  pn.Alignment.Horizontal = Infragistics.Documents.Report.Alignment.Right

        ' The page numbering will be located at the
        ' bottom of the page. Valid values off the
        ' Alignment enum include Top and Bottom.
        '  pn.Alignment.Vertical = Infragistics.Documents.Report.Alignment.Bottom

        ' The page numbering is at the extreme bottom
        ' of the page, so we need to change the Y Offset
        ' in order to bring it in line with the rest of
        ' the page footer text.
        pn.OffsetY = -5

        Dim theTablePattern As New Infragistics.Documents.Report.Table.TablePattern()
        theTablePattern.Header.Repeat = True

        Dim theTablePattern1 As New Infragistics.Documents.Report.Table.TablePattern()
        theTablePattern1.Header.Repeat = True

        theTablePattern.Header.Cell.Background = New Infragistics.Documents.Report.Background(Infragistics.Documents.Graphics.Brushes.LightGray)
        theTablePattern.Row.Cell.Background = New Infragistics.Documents.Report.Background(Infragistics.Documents.Graphics.Brushes.White)
        'for 2nd one
        theTablePattern1.Header.Cell.Background = New Infragistics.Documents.Report.Background(Infragistics.Documents.Graphics.Brushes.LightGray)
        theTablePattern1.Row.Cell.Background = New Infragistics.Documents.Report.Background(Infragistics.Documents.Graphics.Brushes.White)

        Dim tableCellPattern As New Infragistics.Documents.Report.Table.TableCellPattern()
        Dim tableCellPattern1 As New Infragistics.Documents.Report.Table.TableCellPattern()
        Dim theTable As Infragistics.Documents.Report.Table.ITable = theSection.AddTable()
        Dim theTable2 As Infragistics.Documents.Report.Table.ITable = theSection.AddTable()
        theSection.PageMargins = New Infragistics.Documents.Report.Margins(15.0F)
        theTable.ApplyPattern(theTablePattern)
        theTable2.ApplyPattern(theTablePattern1)


        Dim theHeaderCell As Infragistics.Documents.Report.Table.ITableCell = Nothing

        Dim theHeaderText As Infragistics.Documents.Report.Text.IText = Nothing
        Dim theHeaderCell1 As Infragistics.Documents.Report.Table.ITableCell = Nothing

        Dim theHeaderText1 As Infragistics.Documents.Report.Text.IText = Nothing
        'Iterate through the Grid Cols and create corresponding headers in the ITable

        'creates a non repeating header
        Dim sect1Head As Infragistics.Documents.Report.Section.ISectionHeader = theSection.AddHeader()
        sect1Head.Repeat = True
        sect1Head.Height = 20
        'styles used in the header

        'adds a group to the header to help layout contents
        'Dim footer As Infragistics.Documents.Report.Section.ISectionFooter = theSection.AddFooter()
        'footer.Height = -3
        'Dim text As Infragistics.Documents.Report.Text.IText = footer.AddText(0, -10)
        'text.AddContent(String.Format("Print {0}", DateTime.Now.ToString("MM/dd/yyyy hh:mm")), headerTiny)
        'footer.Repeat = True
        Dim sect1HeadGroup As Infragistics.Documents.Report.IGroup = sect1Head.AddGroup(0, 0)
        'using grid to layout first set of elements
        Dim sect1HeadGroupGrid As Infragistics.Documents.Report.Grid.IGrid = sect1HeadGroup.AddGrid()
        'using the gridpattern to style the grid
        'Dim gridPattern As New Infragistics.Documents.Report.Grid.GridPattern()
        'gridPattern.Margins = New Infragistics.Documents.Report.Margins(5)
        'gridPattern.Paddings = New Infragistics.Documents.Report.Paddings(10)
        'sect1HeadGroupGrid.ApplyPattern(gridPattern)
        'adds 5 columns, columns must be added for a grid element
        sect1HeadGroupGrid.AddColumn()
        sect1HeadGroupGrid.AddColumn()
        'frist row of the grid in the header
        Dim headergridrow1 As Infragistics.Documents.Report.Grid.IGridRow = sect1HeadGroupGrid.AddRow()
        Dim r1c2 As Infragistics.Documents.Report.Grid.IGridCell = headergridrow1.AddCell()
        'Dim rlc3 As Infragistics.Documents.Report.Grid.IGridCell = headergridrow1.AddCell
        Dim sect1HeadText As Infragistics.Documents.Report.Text.IText = r1c2.AddText()


        vstr = "SELECT * FROM OPENQUERY(CONTRIBORACLE,'Select ACCT, RECD, APPLIED, CREDIT, CKDATE, NAME1, tcode(''D'' || Disp) D, DISP, ReceiptNum, CLERK, REFER, SPECIAL, COMMENTS, WORKER, BATCH  from TAXDEV.chklog where "
        vstr = vstr & " UNIT =''" & Me.SessionState("Unit") & "'' AND (Recd = ''" & PageFuncts.SQLDtoC(Me.SessionState("aDate")) & "'' "
        vstr = vstr & "or applied = ''" & PageFuncts.SQLDtoC(Me.SessionState("aDate")) & "'') AND (DISP = ''1'' OR DISP = ''3'')  "
        vstr = vstr & "order by DISP, " & SortRB.SelectedValue & " ')"
        otable = PageFuncts.SqlSelect(vstr, strCntrbDbConn)
        ulwbgvdCHKLOGRECV.DataSource = otable
        ulwbgvdCHKLOGRECV.DataBind()

        If ulwbgvdCHKLOGRECV.Rows.Count > 0 Then
            Dim theGrid As Infragistics.WebUI.UltraWebGrid.UltraWebGrid
            theGrid = ulwbgvdCHKLOGRECV

            'sect1HeadText.Alignment = Infragistics.Documents.Report.TextAlignment.Left
            Dim strHeader As String = "Log of checks received:" + Me.SessionState("aDate") + "-" + Me.SessionState("cUnit")
            sect1HeadText.AddContent(strHeader, headerstyle)
            'adds a rule after the grid
            'adds a rule after the grid
            Dim rule2 As Infragistics.Documents.Report.IRule = sect1HeadGroup.AddRule
            rule2 = sect1HeadGroup.AddRule()
            rule2.Pen = New Pen(New Color(255, 255, 255))
            rule2.Pen.Width = 1
            rule2.Pen.Style = DashStyle.Solid
            sect1HeadGroup.AddRule()


            For Each c As Infragistics.WebUI.UltraWebGrid.UltraGridColumn In theGrid.Columns

                theHeaderCell = theTable.Header.AddCell()
                theHeaderText = theHeaderCell.AddText()

                theHeaderText.Style.Font = New Infragistics.Documents.Graphics.Font("Arial", 8)
                theHeaderText.Style.Font.Style = FontStyle.Bold
                ' theHeaderText.Style.Brush = New Infragistics.Documents.Graphics.SolidColorBrush(Infragistics.Documents.Graphics.Colors.WhiteSmoke)

                theHeaderText.AddContent(c.Header.Caption)
            Next

            Dim theRow As Infragistics.Documents.Report.Table.ITableRow = Nothing
            Dim theRowCell As Infragistics.Documents.Report.Table.ITableCell = Nothing

            Dim theRowText As Infragistics.Documents.Report.Text.IText = Nothing
            'Now create your rows:

            For Each r As Infragistics.WebUI.UltraWebGrid.UltraGridRow In theGrid.Rows
                If theGrid.Rows.Count = 0 Then

                ElseIf theGrid.Rows.Count > 0 Then
                    theRow = theTable.AddRow()

                    For Each c As Infragistics.WebUI.UltraWebGrid.UltraGridColumn In Me.ulwbgvdCHKLOGRECV.Columns

                        theRowCell = theRow.AddCell()
                        '  theRowCell.Width = New Infragistics.Documents.Report.RelativeWidth(220)
                        tableCellPattern.Apply(theRowCell)
                        theRowText = theRowCell.AddText()

                        theRowText.Style.Brush = New Infragistics.Documents.Graphics.SolidColorBrush(Infragistics.Documents.Graphics.Colors.Black)
                        theRowText.Style.Font = New Infragistics.Documents.Graphics.Font("Arial", 8)
                        Dim strString, strKey As String
                        Dim strDate As Date

                        strKey = r.Cells.FromKey(c.Key).Key.ToString

                        If strKey = "CK_DATE" Then
                            strString = r.Cells.FromKey(c.Key).Value.ToString()
                            strDate = strString
                            strString = strDate
                        Else
                            If (r.Cells.FromKey(c.Key).Value) = Nothing Then
                                strString = ""
                            Else
                                strString = r.Cells.FromKey(c.Key).Value.ToString()
                            End If

                        End If
                        theRowText.AddContent(strString)

                    Next
                End If

            Next
            otable.Dispose()


        End If

        vstr = "SELECT * FROM OPENQUERY(CONTRIBORACLE,'Select ACCT, RECD, APPLIED, CREDIT, CKDATE, NAME1, tcode(''D'' || Disp) D, DISP, ReceiptNum, CLERK, REFER, SPECIAL, COMMENTS, WORKER, BATCH  from TAXDEV.chklog where "
        vstr = vstr & " UNIT =''" & Me.SessionState("Unit") & "'' AND (Recd = ''" & PageFuncts.SQLDtoC(Me.SessionState("aDate")) & "'' "
        vstr = vstr & "or applied = ''" & PageFuncts.SQLDtoC(Me.SessionState("aDate")) & "'') AND (DISP = ''2'')  "
        vstr = vstr & "order by DISP, " & SortRB.SelectedValue & " ')"
        otable = PageFuncts.SqlSelect(vstr, strCntrbDbConn)
        ulwbgvdCHKREF.DataSource = otable
        ulwbgvdCHKREF.DataBind()
        If ulwbgvdCHKREF.Rows.Count > 0 Then

            Dim theGrid2 As Infragistics.WebUI.UltraWebGrid.UltraWebGrid
            theGrid2 = ulwbgvdCHKREF


            For Each c1 As Infragistics.WebUI.UltraWebGrid.UltraGridColumn In theGrid2.Columns

                theHeaderCell1 = theTable2.Header.AddCell()
                theHeaderText1 = theHeaderCell1.AddText()

                theHeaderText1.Style.Font = New Infragistics.Documents.Graphics.Font("Arial", 8)
                theHeaderText1.Style.Font.Style = FontStyle.Bold
                ' theHeaderText.Style.Brush = New Infragistics.Documents.Graphics.SolidColorBrush(Infragistics.Documents.Graphics.Colors.WhiteSmoke)

                theHeaderText1.AddContent(c1.Header.Caption)
            Next

            Dim theRow1 As Infragistics.Documents.Report.Table.ITableRow = Nothing
            Dim theRowCell1 As Infragistics.Documents.Report.Table.ITableCell = Nothing

            Dim theRowText1 As Infragistics.Documents.Report.Text.IText = Nothing
            'Now create your rows:

            For Each r1 As Infragistics.WebUI.UltraWebGrid.UltraGridRow In theGrid2.Rows
                If theGrid2.Rows.Count = 0 Then

                ElseIf theGrid2.Rows.Count > 0 Then
                    theRow1 = theTable2.AddRow()

                    For Each c1 As Infragistics.WebUI.UltraWebGrid.UltraGridColumn In Me.ulwbgvdCHKREF.Columns

                        theRowCell1 = theRow1.AddCell()
                        '  theRowCell.Width = New Infragistics.Documents.Report.RelativeWidth(220)
                        tableCellPattern1.Apply(theRowCell1)
                        theRowText1 = theRowCell1.AddText()

                        theRowText1.Style.Brush = New Infragistics.Documents.Graphics.SolidColorBrush(Infragistics.Documents.Graphics.Colors.Black)
                        theRowText1.Style.Font = New Infragistics.Documents.Graphics.Font("Arial", 8)
                        Dim strString1, strKey1 As String
                        Dim strDate1 As Date

                        strKey1 = r1.Cells.FromKey(c1.Key).Key.ToString

                        If strKey1 = "CK_DATE" Then
                            strString1 = r1.Cells.FromKey(c1.Key).Value.ToString()
                            strDate1 = strString1
                            strString1 = strDate1
                        Else
                            If (r1.Cells.FromKey(c1.Key).Value) = Nothing Then
                                strString1 = ""
                            Else
                                strString1 = r1.Cells.FromKey(c1.Key).Value.ToString()
                            End If

                        End If
                        theRowText1.AddContent(strString1)

                    Next
                End If
            Next
            otable.Dispose()
        End If

  Dim strfilename, strUnitFile, f_name As String
        strfilename = Me.SessionState("aDate").Replace("/"c, "_"c)
        strUnitFile = Me.SessionState("cUnit").Replace(" "c, "_"c)

        ' f_name = myDocuments + "Reports\TOTAL_WORKORDER_SUBMITTED_" + strNewCalendar + ".pdf"
        f_name = myDocuments2 + "Reports\" + strUnitFile + "_" + strfilename + ".pdf"
        '  f_name = myDocuments + "TOTAL_WORKORDER_SUBMITTED_" + strfilename + ".pdf"

        theReport.Preferences.Printing.PaperOrientation = Infragistics.Documents.Report.Preferences.Printing.PaperOrientation.Landscape

        theReport.Publish(f_name, Infragistics.Documents.Report.FileFormat.PDF)
        Dim strScript As String
        '     ulwbgvdCHKLOGRECV.Visible = False
        strScript = "<script language = javascript>window.open('REPORTS/" + strUnitFile + "_" + strfilename + ".pdf')</script>"
        '    strScript = "<script language = javascript>window.open('file:///h:/Contributions - UI TAX/TOTAL_WORKORDER_SUBMITTED_" + strfilename + ".pdf')</script>"
        ClientScript.RegisterClientScriptBlock(Me.GetType(), "strScript", strScript)
        'Write out to the response.Output Stream and you are done.
        '  ulwbgvdCHKLOGRECV.Visible = False

 

 

So far it is like this

Log of checks received:            

ACCT                   DBA/EMPLOYER NAME               Check Amout              Check Date     

1233                     ABC12                                                   25.00                     9/20/2010

1235                     DCE                                                       15.00                      8/20/2010    

ACCT                   DBA/EMPLOYER NAME               Check Amout              Check Date     

12389                     ABCDF12                                                 125.00                     9/20/2010

12359                    adcDCE                                                     115.00                      8/20/2010

 

 

Page 1

 

Thanks

  

 

Parents
No Data
Reply Children
No Data