Autor Beitrag
José Fonseca
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Mi 04.09.02 13:06 
Hi,

I need to have a text document parameterized with some fields from a database. I'm trying to use QuickReport, but I would like the report to be identical to a Word document I have as the model. I have no problems getting the values to QRDBText boxes, but I would like the values to fit nicely along the text, instead of appearing on a fixed position.

Here's an example:

Zitat:

Report ABC

Your name is [name], you are [age] years old, and you live in [country]. You have registered on [day]-[month]-[year].

Regards,
[companyname]



The tags in brackets would be replaced by the database values, and the text would be justified.

I would really appreciate if someone could give me some hints on how to accomplish this. Is QuickReport suited for this task, or should I use the Word document and link it directly with Delphi? Thanks in advance.

Regards...

_________________
José
MrSpock
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 262



BeitragVerfasst: Mi 04.09.02 13:22 
Hi Jose,

one way would be to not use QRDBText, but to take only one QRText instead. You could use the OnNeedData event to manually create the desired string and assign it to your QRText component.

_________________
Live long and prosper
MrSpock \\//
José Fonseca Threadstarter
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Mi 04.09.02 14:22 
Hi MrSpock,
Thank you very much for the hint. I've tested the OnNeedData event and it works. I've placed a QRRichText and filled it with text. There is one problem though... I think there are only 3 types of text alignment: Left, Center and Right, and I would need Justify, so the text aligns to both sides... Is it possible to do?
Regards...

_________________
José
MrSpock
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 262



BeitragVerfasst: Mi 04.09.02 17:01 
Hallo Jose,

unfortuntely there is no other alignment than the three options you had quoted. Whether it is possible to send a message to that control to justify the text as a block, I do not know. May be somebody else has an idea for that, since principally RTF supports block formation.

_________________
Live long and prosper
MrSpock \\//
José Fonseca Threadstarter
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Mi 04.09.02 20:25 
I've tried to find some more information and found this, on the QuickReport FAQ:
Zitat:

Q. What about adding real "LeftAndRightJustify" (newspaper style) (aka Full Justification) in an upcoming release?
A. This will not be part of QuickReport. A future release will make the FormatLines procedure virtual so this can be done in a descending component by someone else.


So, I think I'm forced to use another method... :(
How about using the Word template and filling in the fields? Or could I output the equivalent document in HTML?
I would like to be able to format the text (bold, italic, underlined, etc.), so perhaps QuickReport also wouldn't support this...

_________________
José
MrSpock
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 262



BeitragVerfasst: Do 05.09.02 07:28 
Hallo Jose,

if you use a QRRichText component, you can use the font property to create e.g. bold or italic formatted text.

It is also possible to create a database and merge it to a word text file, but this would require the user to have word installed. (I would not have it installed and could not use it :cry: ). But principally it is not very difficult to control word via Delphi interfaces.

_________________
Live long and prosper
MrSpock \\//
José Fonseca Threadstarter
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Do 05.09.02 13:21 
Hallo,
With QRRichText, can the text have some parts in bold, some in italic, etc? Are there control tags like HTML ones (<b></b>, <i></i>, ...)?
Do you know good documentation/tutorial on controlling Word and Excel documents with Delphi? I would really like to try this method...
Danke!

_________________
José
MrSpock
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 262



BeitragVerfasst: Fr 06.09.02 07:50 
Hallo Jose,

yes, you can format parts of text in different styles. Internally RichTextFormat uses "plain language" Format Information. If you save a text with any wordprocessor as ".RTF" file and then open this file in e.g. notepad, you can see these "tags".

For documentation: I bought the book "Mastering Delphi" from MarcoCantu, it explains how to use Interfaces to control other applications, e.g. Word and Excel. It is a book with more than 1000 pages and covers a lot of complex topics. If German language is no problem for you, see the tutorial Word & Excel Automation.

_________________
Live long and prosper
MrSpock \\//
José Fonseca Threadstarter
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Mo 09.09.02 15:46 
Hi MrSpock,

Thanks, I tried a RTF file and the format is something like this:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
{\rtf1\ansi\ansicpg1252\deff0\deflang2070{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}}
\viewkind4\uc1\pard\f0\fs20 lksdfjla sd jfds \b fakljd\b0  flkajs \i dflkaj\i0  dflkja \ul dflkj \ulnone adlf \par
asdfj alsdjf lasdj f\par
alsdfj lasjd flkadj fkla dsfj\par
lasdfj a djflakf\par
}


I guess the bold and italic tags are \bTEXT\b0 and \iTEXT\i0... I tried this with a Memo box, and it works well at design time, but at runtime the text doesn't appear formated... I'll have to make some more tests...

As for books I've also bought Mastering Delphi 6 and am reading it...
And just ordered Borland Delphi 6 Developer's Guide by Xavier Pacheco and Steve Teixeira, and I should receive it the next week... From reviews I read they say it's more technical than MD6...

Thanks for the tutorial... I hadn't seen that and it will certainly be useful... and no, I just know a few words in german... but I'll use altavista to translate it... :)

Thanks again...

_________________
José