Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Print To File ?

edited March 2008 in General
I have a report which uses a DBPipeLine (with a simple SQL Select Statement)

I am trying to use the report to do an export (Create a file of data)

My report Detail band looks like the following below

100 ID Name Address
200 AccntNo TransDate Comment
300 StatudID Status War

where the 100, 200, & 300 are text labels
the rest are DBText (fields)

For every record in my dataset (Select statement return), i want to print
three lines.

How canI do this?

Here is what I tried

I go into Print To File Setup

I set my File Type = Fixed Length

I choose from the detail banner all my controls i want to print to file -
and i set each of their lengths

However, now, when I print, I get the following

100200300....ect

I need three lines - not 1

Can someone explain to me how I can accomplish this?

Thanks

Shane
ValuTech, Inc.

Comments

  • edited March 2008
    One other comment....

    I tried using the Report Emulation Text File.....however, the justification
    on everything is way out of wack.

    What am i doin wrong?

    Thanks

    Shane


  • edited March 2008
    Hi Shane,

    The TextFile Device will separate each line based on each detail band
    printed (i.e. each traversal of a new record in your dataset will start a
    new line). You can also customize the text file device using its various
    events. For instance, the Report.OnSaveText gives you complete control over
    the text being saved. At the proper time, you could add a CRLF forcing a
    line break. If you would like the text file to appear more like the report
    design, try using the Report Emulation Textfile device. This device however
    tries to map your text objects to a standard text grid (similar to Notepad).
    You will need to be sure you use standard font sizes and spacing for the
    file to export correctly.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2008
    I have tried both ways. Neither seem to work.

    You can't use #10#13, cause then it wont compile.

    so i tried

    Text := Chr(10) + Chr(13);

    and that doesn't work either.

    I have tried 100 different formatting ways with the Report Emulation
    TextFile device and ican't ever seem to get it to work either.

    Can you direct me on how to use the Report.OnSaveText properly?

    Create a simple report, add three labels 100, 200, 300 in the Detail band
    and then have them print as

    100
    200
    300

    for each record

    THanks

    Shane





  • edited March 2008
    Hi Shane,


    The Text parameter contains the text being exported. If you trace into this
    event you can see what the value is. Something like the following is what I
    had in mind...

    if (Pos(, Text) > 0 then
    Text := Text + #13#10;


    Please take a look at demos 106 and 107 located in the \RBuilder\Demos\1.
    Reports\... directory. These demos extensively show how to use each text
    file device and how you can format your report(s) so they export correctly
    in this each format.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2008
    Thanks - and i understand everything you have suggested, howeever, no matter
    what i do, my file shows the CRLFs as little squares in my file.

    100[][]200[][]300[]
    100[][]200[][]300[]
    100[][]200[][]300[]

    I have used brackets here to represent the squares

    I never actually get this

    100
    200
    300

    100
    200
    300

    100
    200
    300

    I only use the OnSaveText event of the form - and nothing else

    Shane



  • edited March 2008
    ahhhhhh, disregard my last

    I was sending #10#13 instead of #13#10

    Shane


  • edited March 2008
    I need to do this within the design, using RAP. Is it possible? If so, which
    event is the most appropriate place?

    I tried and keep getting all the same issues i had early on.

    SHane

  • edited March 2008
    In Rap you need to use the Chr() routine.

    Text := Text + Chr(13) + Chr(10);

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2008
    Have you tried this?

    I have tried your code and a large number of variations of it.

    Nothing seems to work. Nothing is consistent.

    using the OnGetText event

    somtimes tacking to the front of one and or maybe the end of another

    Anyway, if you would try this for me

    place three Text labels in a detail band

    100
    200
    300

    and then add some DBText fields to the right of each of those.

    100
    200
    300

    then have the records print to file

    so it maintains

    100
    200
    300

    and not

    100 200 300


    for each record


    again, i have to do this at design using RAP.


    Thanks

    Shane





  • edited March 2008
    As I mentioned before, you need to use the OnSaveText event of the report to
    alter the output to a text file. If you are unable to determine which
    DBText is the last on in the line, you may need to add another "marker"
    label to mark the spot when you should perform a CRLF. You can set these
    labels' Visible property to False when not printing to file. Below is my
    code and detail design.

    Detail band...

    100 [field] [field] [field]
    200 [field] [field] [field]
    300 [field] [field] [field]

    ReportOnSaveText(var Text: String);
    begin

    if (Pos('', Text) > 0) then
    Text := ' ' + Chr(13) + Chr(10);

    end;


    Yes I have tried it and it works perfectly :).

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2008
    Sorry it took me so long to get back to this, other things became priority
    on our agenda.

    Anyway, yes, you mentioned it before, however, i also mentioned - I have to
    be able to do this from RAP (in the designer).

    We provide in our application, the ability for our customers to create/
    design their own reports.

    Thanks

    shane


  • edited April 2008
    Hi Shane,

    Everything done in my previous post was done in RAP. This is probably the
    closest the built-in text file device can get to your specifications.

    Another option would be to create and register your own text file device
    that is similar to the current one however includes your line break
    requirements. If you take a look at the TppTextFileDevice class located in
    the ppFilDev.pas file, you will see that it is a fairly simple device.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2008
    I added a label (text = 'TTT') after each of my items in the details section

    100 TTT
    200 TTT
    300 TTT
    and then in the reports OnSaveText event (in rap), i added the following

    if (Pos('TTT', Text) > 0 then
    Text := Text + Chr(13) + chr(10);

    here is what i get

    100TTT
    200TTT
    300TTT

    100TTT
    200TTT
    300TTT

    100TTT
    200TTT
    300TTT
    etc.,
    etc

    Of course, I can't have the extra line.How do i get rid of the extra line?

    and I can't have the TTT displayed. If i set the visibility of the label to
    false, then the line

    if (Pos('TTT', Text) > 0 then

    is never true

    thanks

    shane


  • edited April 2008
    Disregard the question:


    100TTT
    200TTT
    300
    100TTT
    200TTT
    300
    100TTT
    200TTT
    300
    etc
    etc

    However, I still need to get rid of 'TTT' label. I will be having DBText
    labels across each line. I will not know there text values.
    How can i still accomplish this.

    Thanks

    shane




  • edited April 2008
    Solved this question as well

    shane


This discussion has been closed.