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

Print to File Multiple Rows Per Record

edited July 2005 in General
I need to create an import file for Quickbooks from a summary file and I was
thinking of using ReportBuilder instead of hard coding it. The problem is
that I need a tab delimited file which has multiple rows per record. Is
there an easy way to get the Print To File option to create about six rows
per record from the database?

David Miller

Comments

  • edited July 2005
    Hi David,

    You can use the DetailBand.BandsPerRecord property to print multiple rows
    for each record in your database. This is a published property so it can be
    accessed from the Object Inspector in Delphi or at run time in code.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2005
    The BandsPerRecord property appears to repeat the entire report and is not
    giving me what I need. Here is a simple example of what I want to do.

    Let's say I have three fields on a record called Amt1, Amt2, and Amt3. I
    want to create a label for each of these and output them on separate lines.

    For example, the report might have:

    ACCNT DATE AMOUNT
    INCOME 7/25/2005 $1,295.00
    EXPENSE 7/25/2005 $316.21
    SAVINGS 7/25/2005 $200.00

    I want to print to file so that this is output as a tab delimited file with
    four rows, with each field separated by tabs. Right now it creates one row
    with all these fields in one line. I played with the BandsPerRecord
    property, but it just repeats the long line by the value of this property.
    Obviously I can do this in code, but if the Report can do it, it will give
    my end users an easy way to modify the export file. So, is there an easy
    way to do this in Report Builder?

    David Miller


  • edited July 2005
    Hi David,

    Sorry, I missed the part where you explained you were exporting to a text
    file :). The TextFile Device in ReportBuilder is not designed to show any
    report formatting, only export the data in a delimited form. If you wish to
    format your text file into four rows, you might try exporting your report to
    a Report Emulation text file rather than a delimited text file.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2005
    I'm importing the file into Quickbooks, so I need a tab delimited file. I'm
    not sure Report Emulation will do this well. The Print To File Tab
    Delimited setup works well except for one thing... all the fields are put on
    the same row. I have tried inserting a carriage return where I need them
    using a calc variable, and this gets it close. The only problem is that a
    tab is inserted after the carriage return calc field so that each row after
    the first one has a tab character in column 1, which I suspect will throw
    off Quickbooks.

    Unless you or someone else has any ideas, I may have to abandon the idea of
    using ReportBuilder to output the file. Too bad, because it is really close
    to being able to do it. I'm sure others have needs to import into
    Quickbooks, so perhaps an update request could be made to have an option to
    have Print to File do a null delimited file. :-) I know that sounds
    strange, but if it could, then I could insert my own delimiters (tabs and
    carriage returns) using calc fields and have full control.

    The primary reason I am interested in using ReportBuilder is so end users
    would be able to modify the format of the output file easily.

    Regards,

    David Miller.

  • edited July 2005
    Concerning the Print To File method:
    Is there an event that fires between the time a line is constructed for
    writing to file and the time it is written to file that I could tap into and
    strip away any leading tabs from the line that it is about to write?

    David Miller.
  • edited July 2005
    Hi David,

    Thanks for the suggestions. If you take a look at the TppTextFileDevice
    located in the ppFilDev.pas file, you will see that this class is relatively
    simple. Creating a simple descendent to this class or new text file device
    would not be that dificult if you are in need of such a feature immediately.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2005
    Hi David,

    ReportBuilder defines a "line" as an entire detail band. RB has no concept
    of individual "lines" of text inside the detail band. If you would like to
    strip away any leading tabs per detail band information, you can use the
    DetailBand.BeforePrint or AfterPrint events. Otherwise you can use the
    OnPrint or OnGetText of the text object at the end of the line inside the
    detail band.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2005
    Thanks for all the info, Nico.

    I was able to accomplish what I needed by adding a line of code to the
    OnGetText event of the field that starts the new row. I saw in searching
    the newsgroup that this solution had been sought before but without answers.
    In case anybody else is trying to export a tab delimited file for importing
    into Quickbooks or some other application, the line of code I put in the
    OnGetText event was:

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

    Now the exported detail band separates into a separate line wheneever I put
    this code in the OnGetText event of the field that should start the new
    line. Usually this is on a label, declared as something like: Procedure
    Label8OnGetText(var Text: String);

    David Miller
This discussion has been closed.