1. PRASHANT NIRGUN
  2. PowerBuilder
  3. Monday, 12 September 2022 10:31 AM UTC

I am trying to create jpg files and send them as whatsapp chat. let say user gives print order of pages 1,3-5,7. In that case I generate a print pages list 1,3,4,5,7 but at same time I have to read mobile_no and party name of particular pages. I displayed the Invoice Report in preview mode.

Now the worried part is I have to parse pages and fetch column values and create a csv has following structure(file_name, party_name, mobile_no, page_no).

//Go To first page
dw_report.ScrollToRow(1)
li_pos = Pos(ls_pages_list, ',')
//loop begin
//check page no is matching
ls_mobile_no = dw_report.Object.mobile_no[?]
dw_report.Object.DataWindow.Print.Page.Range = ls_page
dw_report.print()
//loop end

one possible solution I am thinking is to use filter(). Is there any way I can read or scroll to row for the page ?

Accepted Answer
John Fauss Accepted Answer Pending Moderation
  1. Monday, 12 September 2022 14:23 PM UTC
  2. PowerBuilder
  3. # Permalink

You can obtain the first/last row numbers on each page programatically, but it requires you have a computed field (it can be hidden) in the detail row. For example, create a computed field in the detail row named "c_page" and for the expression, use "page()" without the quotes, of course.

The following script illustrates one way to obtain the first & last row numbers on each page using this computed field:

Long ll_page, ll_rows, ll_row_first, ll_row_last
String ls_find

ll_row_first = 1
ll_rows = dw_report.RowCount()

ll_page = 1

Do While True
   ll_page ++
   ls_find = "c_page = "+String(ll_page)
   ll_row_last = dw_report.Find(ls_find,ll_row_first,ll_rows)
   
   If ll_row_last < 1 Then
      ll_row_last = ll_rows
   End If
   
   MessageBox("Page "+String(ll_page - 1),"First Row = "+String(ll_row_first)+&
      "~r~nLast Row = "+String(ll_row_last - 1))
   
   If ll_row_last >= ll_rows Then Exit
   
   ll_row_first = ll_row_last
Loop

Be aware the first & last row numbers on each page can change depending if print preview is enabled or disabled, filtering, size of the DW control, etc.

Regards, John

Comment
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Monday, 12 September 2022 13:46 PM UTC
  2. PowerBuilder
  3. # 1

perhaps scroll to the page, then get the row ranges.

dw_control.Object.DataWindow.FirstRowOnPage 

dw_control.Object.DataWindow.LastRowOnPage

 

 

 

Comment
  1. PRASHANT NIRGUN
  2. Monday, 12 September 2022 15:01 PM UTC
This works !!! I am using PB 12.5 Classical is it possible to scroll to the page directly ? If I have a invoices report where in 50 Invoices in a day and user give print order of page no 50. In that case I have to skip dw_report.scrollNextPage() till I moved to last page. Looking for go to page no 'n'
  1. Helpful 1
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Monday, 12 September 2022 16:32 PM UTC
  2. PowerBuilder
  3. # 2

>>> Looking for go to page no 'n'  

Like John said, the page numbers can change depending on a variety of factors,which make any page number a non-static value.

One way to to this is to use John's suggestion of a hidden DETAIL BAND computed field called cp_page, with the expression set to "Page()".

Now in your script, you can use FIND:   ll_row = dw_1.FIND ("cp_page = " + string (<n>))
Once you have the row, then:            ll_rc    = dw_1.ScrollToRow (ll_row)

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.