Quick Report FAQ [ 4 ]

  • 主题发起人 主题发起人 import
  • 开始时间 开始时间
I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
Q. How can I send control chars to the printer with Quickreport?
A. QuickReport uses the Windows printer driver GDI calls to output data, it does not support sending escape codes directly to the printer. You could use the ASCII text export filter to save the report as text. You would then insert your printer escape sequences into that file and then copy that file to printer port.
------------------
Q. I can't set the printer at runtime, I get an exception if I use the following syntax:
Quickrep1.Printersettings.printerindex := Quickrep1.printer.printers.Indexof('HP LaserJet 4 on LPT1:');
A. QuickReport does not create it's printer until it needs it, you'll need to use a regular printer object that Delphi will initialize for you. the following code will work:
Quickrep1.Printersettings.printerindex :=printer.printers.Indexof('HP LaserJet 4 on LPT1:');
------------------
Q. How can let the users select the printer before running the report?
A. If you call the Report's PrinterSetup method, this will set the printer settings for the report before you run it. You could do it like:
with frmReport do
begin
QuickRep1.PrinterSetup;
QuickRep1.Preview;
end;
------------------
Q. I retrieve the values of the Delphi PrinterSetupDialog and when I use the printerindex returned by it, I get the error: PRINTER INDEX OUT OF RANGE
A. There is a bug in the Delphi printer setup dialog that causes it to create new instances of printers in the printer list. QuickReport 2.0i (and later) includes a fixed printer dialog in the qrprnsu unit. Please use that instead of Delphi's dialog.
------------------
Q. When I change the printerindex, I can't select the right paper size.
A. There is a problem in the printers unit where when the printerindex index is changed, the new printer "inherits" the properties of the previous printer. With the 2.0j release, we now reset the printer driver when the printerindex is changed.
------------------
Q. When I use Printer Settings from within QuickReport, it suggests me to write out all 10000 pages, even though my report contain only 10-15 or so...
A. This is a cosmetic bug (the report will never print out anything past the last page) and this will be fixed in a future release.
------------------
Q. I can't select a tray for HP printers
A. The printer dialog QuickReport uses is a standard print setup dialog. QuickReport defaults to the Default tray defined in Windows. I believe the problem with some printer drivers (LJ5/6) is that they try to redefine the tray order. We will look for a solution to this for a later version.
One work around is to use the LaserJet III driver when printing with QuickReport.
------------------
Q. How do I the printer properties if I use my own printersetup dialog box?
A. Please see the TQuickRep.PrinterSetup method in quickrpt.pas for code showing how to set the printer to what was selected in the setup dialog.
------------------
Q. I get an extra blank page when I print a range of pages.
A. The extra blank page is a known issue and was addressed in the 2.0k release.
------------------
Q. Why do the Properties QRPrinter.Canvas.TextHeight and TextWidth return always zero value when running in 16 bits?
A The QRprinter.Canvas is a standard metafile in Delphi 1 and a standard metafile doesn't support these functions. Enhanced metafiles in Delphi 2/3 does.
------------------
Q. The report prints under Win95 but not under Win 3.1
A. This is probably a printer driver problem even though they use the latest driver. A possible solution might be to try to blank the QRPrinter.OnGenerateToPrinter event to see if that helps.
A workaround is to clear the QuickRep.QRPrinter.OnGenerateToPrinter event, setting it to NIL when the preview is brought up. This will force QR to print the generated metafiles instead of generating the report all over directly to the printer. The down side is that you might experience a slight scaling of the report page and that images might have a lower resolution.
------------------
Q. When I use printer fonts, the preview does not match the print out.
A. A possible solution to this problem is to assign the printer specific font to your report at runtime. If you use the same font for all controls in your report you should be able to say
QuickRep.Font.Name := 'Your font name'
before starting your report. If Windows is able to a reasonably good substitution it should work.
------------------
Q. When I use the QRPrinter object, the scaling is off
A. There are some known problems with using the QRPrinter object in this way. With the 2.0h release, we have added a new class, QRPrintJob, which is a wrapper for the QRPrinter object. This code is in the directory and makes it easier to do code like what you sent in.
------------------
Q. When i use the EPSON LQ-1070+ printer driver the program closed, no error message
A. There is a known problem with using QuickReport with printers that support more than 64 different page sizes. This will be addressed in an upcoming release. At the present time, there is no work around, short of using a generic Epson compatible printer driver.
------------------
Q. When I print my reports under NT 4, the font changes are not working correctly.
A. There is a known printing problem with Windows NT 4.0 when you have multiple font changes on the printer canvas. Installing the Service Pack 3 to NT should solve the problem.
------------------
Q. I get a exception error when running our application on a machine without a default printer.
A. QuickReport requires that a default printer be installed. The report is prepared using information from the printer driver. The following code shows one way to check and see if a default printer has been defined.
procedure TfrmReport.btnReportClick(Sender: TObject);
var
FDevice: PChar;
FDriver: PChar;
FPort: PChar;
FHandle: THandle;
CurrentPrinterName: string;
begin
GetMem (FDevice, 255);
GetMem (FDriver, 255);
GetMem (FPort, 255);
Printer.GetPrinter (FDevice, FDriver, FPort, FHandle);
CurrentPrinterName := FDevice;
if FDevice <> nil then FreeMem (FDevice, 255);
if FDriver <> nil then FreeMem (FDriver, 255);
if FPort <> nil then FreeMem (FPort, 255);
if CurrentPrinterName <> '' then
{ Preview the report }
QuickRep1.Preview
else
MessageDlg('You do not have a default printer defined.' +
#13#13 + 'Please select a printer before running a report.',
mtError,[mbOK],0);
end;
------------------
Q. How do I print to a printer different than the Windows default printer?
A. Set QuickRep.PrinterSettings.PrinterIndex to a value corresponding to the printer you want to print to. This value is the same as for the Delphi TPrinter.PrinterIndex. Set to -1 to print to the default printer again
------------------
Q. I have some easy reports very simple ones (without graphics), but in a matrix printer they are printed very slowly. Is there a way to print them like the DOS programs did in PRINT, and TYPE filename.ext > PRN?
A. QuickReport renders a report to the printer driver's canvas. It doesn't really have a text mode for printing, rendering the pages is left completely up to the printer driver. If the printer driver has a draft mode setting, try making that setting the default. You can also try using the "Generic / Text Only" printer driver that comes with Windows. You may have to modify the fonts and/or control placement with the report to get satisfactory results with this driver.
------------------
Q. I would set to specify a default printer to be used for multiple reports.
A. You have to add the code to determine what the printerindex value is for the printer. Then set the QuickRep1.PrinterSettings.PrinterIndex property to this value for each report before you call the print or preview methods
------------------
Q. My report only prints one page, but the design time preview shows all pages.
A. Check the report's PrinterSettings.FirstPage and PrinterSettings.LastPage properties and make sure that they are set to 0. If you print a range of pages from the design time preview, these two fields may get set to the values that you had selected.
------------------
Q. How can I print multiple copies of a report without having to generate it over and over again?
A. You would set the report's PrinterSettings.Copies property to the value that you want. Not all printer support this property.
Another way to print multiple copies is to use the prepare method instead of calling the print method directly. For example:
Instead of:
with TfrmQR.Create(Application) do
begin
QuickRep1.Print;
free;
end;
Try:
with TfrmQR.Create(Application) do
begin
QuickRep1.Prepare;
QuickRep1.QRPrinter.Print; { print first copy }
QuickRep1.QRPrinter.Print; { print second copy }
QuickRep1.QRPrinter.Free;
QuickRep1.QRPrinter := nil;
free;
end;
This method generates the report to an internal metafile and then rendered report is sent to the printer twice.
------------------
Q. I am getting printer overrun errors with some reports when I print to my laser printer
Q. Some reports are printing dark bands on my laser printer.
A. These problems can happen when you send a full page to a laser printer and that printer does not have enough RAM to print a full page at the specified DPI. Try reducing the DPI or adding more RAM to the printer.
------------------
Q. When I call the printersetup dialog, it always shows the default printer, even if I have preset the printerindex to another printer.
A. This is a bug in Borland's dialog, it always comes up with the default printer no matter what the printerindex is set to.
------------------
[QREditor]
==================
Q. Can I manually edit a QREditor (.qr) file with a text editor?
A. You can convert the .qr file to and from a text file by using the ObjectBinaryToText() and ObjectTextToBinary() methods. The QREditor demos for QuickREport 3 on our download page have example code for this.
------------------
Q. I get an access violation if I set the QREditor's ShowMenu property to true.
A. This a limitation of the current code and will be addressed in a future release. The work around is to set this property to true at runtime.
------------------
Q. How do I master/detail reports in the QREditor?
A. This was added in the 3.0.5 release. You define the master table using the "Report data setup" dialog. The bottom panel of this dialog allows you to define a detail table and link it to the master table.
------------------
Q. I want to be able to execute a report made in "QREditor" (*.qr) without using the QREditor. How can I do this so the user can not edit the report?
A. You can load a qreditor report with the QRLoadREport function (defined in the qrextra unit). Remember to add the qrextra unit to your uses clause. The following code shows how load, preview, and finally free a saved report:
procedure TfrmTest.btnQRLoadReportClick(Sender: TObject);
var
MyReport: TQuickRep;
begin
try
MyReport := QRLoadReport('myreport.qr');
MyReport.Preview;
finally
QRFreeReport(MyReport);
end;
end;
For QuickReport 3.0.5 (or later) you would use a TQREditor object to load the report.
Example:
with TQREditor.Create(self) do begin
OpenReportFile('myreport.qr');
PreviewReport;
Free;
end;
------------------
Q. I'd like to know how to use my QR files made by Delphi 3 with the release of Delphi 1.
A. The .QR files saved by the QREditor are form description files (.DFM) and DFM files are not downward compatible. You will need to either create your .QR files with Delphi 1 or manually edit them to remove the properties that are not supported with Delphi 1.
------------------
Q. How can I send parameters to the QREditor when using a Query?
A. This is not directly supported in the current release. What you can do is to load the saved report and modify the query properties. While you can't pass parameters, you can build an SQL statement with those parameters embedded in the text of the SQL statement. The following example loads a previously saved report and replaces the SQL property if a TQuery was being used or it sets the filter if a TTable is being used:
QuickReport 2:
procedure TfrmMain.Button1Click(Sender: TObject);
var
MyEdit: TfrmQREdit;
begin
MyEdit := TfrmQREdit.Create(Application);
with MyEdit do
begin
show;
qreditor1.OpenReportFile('cust1563.qr');
if qreditor1.Report.DataSet is TQuery then
begin
with TQuery(qreditor1.Report.DataSet) do
begin
SQL.Clear;
SQL.Add('select * from customer where CustNo=6312');
Open;
end;
end
else
begin
with TTable(qreditor1.Report.DataSet) do
begin
Active := False;
{$ifdef win32}
Filter := 'CustNo=6312';
{$endif}
Active := True;
end;
end;
qreditor1.Report.Preview;
Close; { if you want to make the editor go away after the preview }
end;
end;
QuickReport 3.0.5: (from the QREditor demo on our download page)
procedure TEdtDemoFrm.btnSalesPreviewClick(Sender: TObject);
var
EmployeeNumber: integer;
MyReport: TQuickRep;
begin
// Prompt the user for an employee number to report on
if GetEmployeeNumber(EmployeeNumber) then begin
with TEdtFrm.Create(Application) do begin
try
QREditor1.ShowMenu := true;
QREditor1.OpenReportFile('sales.qr');
// Get the report variable
MyReport := TQuickRep(QREditor1.ReportEditor.FormEditor.MainControl);
// Now update the query
if MyReport.DataSet is TQuery then begin
with TQuery(MyReport.DataSet) do begin
if Active then
Close;
// Set the SQL statement. If the user accidently changes the SQL
// statement, this will make sure that the correct one is in place
SQL.Text := 'SELECT OrderNo, CustNo, SaleDate, EmpNo, ItemsTotal, LastName, FirstName '+
'FROM orders JOIN employee ON orders.empno = employee.empno '+
'WHERE employee.empno = :p0 '+
'ORDER BY orders.empno, SaleDate';
// Pass the selected employee number as the parameter to this report
Params[0].AsInteger := EmployeeNumber;
// open the query again
Open;
end;
end;
// Display the report
QREditor1.PreviewReport;
finally
Free;
end;
end;
end;
end;
------------------
Q. After pressing the open button on the QREditor and canceling this action the buttons do not return to the original state and the 'new' button is disabled.
A. The demo editor project shows how to add a menu to the qreditor with ability to re enable the new button.
------------------
Q. The QREditor's NewImage button is commented out. When will this be enabled?
A. This function will be added to a future release.
------------------
Q. Can I use the PAGE function somehow in TQREditor?
A. This will be in the 3.0 release (due out in 98)
------------------
Q. I am interested in the TQREditor component, but I have a question: How can I create a master-detail report through the component?
A. At the current time, the QREditor component is limited to a single dataset. This functionality will part of a future release.
------------------
Q. When working with the QREditor, the Title band does not get previewed nor printed. All the layout options and the band properties appear to be set correctly, but the band will not preview or print.
A. Have you defined a dataset for this QREditor report? If you do not have one, the title band will not be output.
------------------
Q. Is it possible to bypass the login dialog when I want to report data from a database server with the QREditor? (by providing username and password via code)
A. With the BDE, you'll need to use a TDatabase component and set the username and password via the params property. You can't add this to a report created by QREditor, but if you put the component on the same form as the QREditor, this should work. I tested this with a password protected MS Access database and it worked.
------------------
Q. I'm using Quickreport editor and I found a problem. If I want to put in a report a label and its caption is the same name of a dataset field's, I can't put this label caption in the report.
A. This is a known problem and will be addressed in a future release. One work around is to use a SQL statement to rename the columns in the table so that the names do not overlap. Example
SELECT OldName AS NewName FROM SomeTable
------------------
Q. The fields in the QREditor are printing as the field names instead of the values.
A. When you select a dataset with the editor, it names it either TTable1 or TQuery1. If you have datasets with the same name, this can cause a conflict with the QREditor where it tries to use the wrong dataset. Renaming the other datasets removes this conflict. This will be addressed in a future release.
------------------
[QuickReport 3]
==================
Q. In QuickReport 3.0.4, the groupfooter with the AlignToBottom property set true will sometimes print over the bottom of the last detailband.
A. This is an open bug and will be addressed in a future release. If you set the LinkBand property of the detail band to the group footer band, that should force a page break when there is not enough room for both bands on the same page.
------------------
Q. How do I change the language of the package? What files need to be modified in Quick Report 3 and how do I rebuild the packages?
A. Most of the text strings are defined in qr3const.pas. A few of the units have text properties set in their .dfm files.
After you change those units, you will need to rebuild the runtime package (qrpt40 for Delphi 4, qrpt43 for Delphi 3). The qrpt4*.dpk file can be found in the quickrpt directory where the source code was installed. Close all projects and any program using Delphi runtime packages. Load the .dpk file and build it. If you get an error about missing units, just remove those units from the package file. Then load the design time package, dclqrt40.dpk (or dclqrt43.dpk for Delphi 3). Rebuild that unit (removing any units that Delphi can not find).
After you rebuild the packages, you will need exit Delphi. Copy the qrpt40.bpl (or qrpt43.dpl) to your windows system directory. Copy the design time package dclqrt40.bpl (or dclqrt43.dpl for Delphi 3) to the Delphi bin directory. Then copy the .dcu and .dfm files to the Delphi lib directory.
The next time you start Delphi, it should be using the recompiled packages.
------------------
Q. I get an error using QRCreatelist with code that worked in Qr2.
A. With QR3, the report variable must be of type TCustomQuickRep.
------------------
Q. Dropping a TQRlabel or another TQRPrintable on a TQuickReport with the property Units set to another value than PIXEL set the values of Top and Left not to the position of the mouse, but to high dummy values like 7418.
A. This is a known problem if the report is on a form with non-QR visual controls. Placing the report in it's own form is the work around for this problem.
------------------
Q. When I set PrintBand to false, the dataset fields for that line are excluded from the TQRExpr functions. In Quick Report 2, these fields are included in the calculations.
A. This is a feature that had been requested by many users. It had been expressed to us that if a band was suppressed, it's data should be excluded from the accumulator functions like SUM(). To emulate the Quick Report 2 code, instead of setting PrintBand to false, set the height of the band to 0 when you want to suppress it and still use it for functions. Just remember to set the height back to the design time height when you do want to print the band.
------------------
Q. Every time I preview a report with my custom preview, I lose some memory.
A. You will want to check your preview's FormClose event. If you are using code from Quick Report 2, that code may not work correctly. You may want to compare your close event code with the code used by the standard preview.
------------------
Q. I can't find the qrbonus unit.
A. The classes that were the qrbonus unit are now in the qrextra unit.
------------------
Q. I have a report with some controls on a TQRBand and the preview is empty.
A. You must have a detail band, this is required for Quick Report 3. Using reports without detail bands was an undocumented feature of Quick Report 2 and was never supported.
------------------
Q. (Delphi 3) I am getting an error when I compile with runtime packages enabled. With out runtime packages, it works fine.
A. The package list will not get updated automatic when you install QR3 over QR2 and you may have the QR2 runtime package (qrpt30.dpl) on the list instead of the Quick Report 3 runtime package (qrpt43.dpl)
------------------
Q. I have a report that does not print the DetailBand (DetailBand1BeforePrint() sets PrintBand to False). With version 2 of QuickReport, SUM() expressions in groups incremented their values whether or not the detail band printed. In version 3.0.4, it appears that the SUM() expression only increments if the detail band prints. What can I do to change this behavior back to how version to handled this?
A. This was actually a change that had been requested by other users. There is a simple work around that you can use in the BeforePrint event. Instead of setting PrintBand to False, set the band height to 0. If you need to restore the height, set the tag property of the band to the height and restore the height from the tag in the band's AfterPrint event. The report will still think that it printed the band, but the size will be 0 so you will not see the band and your sum will include the data from the hidden records.
------------------
Q. My users can not see the buttons on the preview's toolbar.
A. What version of comctl32.dll is on your system? The preview uses a TToolbar control and that control will not display glyphs from an imagelist when the destination computer has an older version of this dll. It was compiled for version 4.72. You have a couple of options. You can get the free update from MS for the current comctl32.dll, or you can recompile the QR package against the old version of comctl32.dll (not recommended), modify the standard preview in the qrprev unit so that it does not use TToolbar, or you could use a custom preview that does not use a TToolbar control. We have Custom Preview examples on our download page and with QR3, you can change the preview on a global basis. There is an MDI demo example on our download page that shows how to do this.
Delphi 4 requires (and installs version 4.72) You can download the file directly from Microsoft at the URL http://msdn.microsoft.com/developer/downloads/files/40comupd.htm. It has been reported that this link is no longer valid, an alternative would be ftp://ftp.microsoft.com/softlib/mslfiles/40comupd.exe
------------------
Q. With QuickReport 2, I could set OnGenerateToPrinter to nil to keep the report from being regenerated. How do I do this in Quick Report 3?
A. The OnGenerateToPrinter property is a QR2 only property, it doesn't exist in QR3. There are a couple of ways to do this in QR3. You can set the report.qrprinter.master property to nil in the BeforePrint event of the summary band. If you don't need a summary band, you can set PrintBand to false in that event. You could also use a custom preview and change the print button to call the preview's qrprinter.save to a temporary file and then qrprinter.load. You would then call the qrprinter.print method to print the loaded report.
------------------
Q. I think I have installed version QuickReport 3 correctly with Delphi 3, and it prints short reports if I call the PRINT command. If I use preview however, I receive a "Control has no parent window error" when I press the print button. I didn't have this problem with Version 2.0K.
A. The DLL needs a reference to the calling application so that the DLL's forms are children of the application. Please see the Delphi help page for TApplication.Handle.
------------------
Q. I am trying to compile a report from QuickReport 2 and I get the message "Undeclared identifier TQRDetailLink."
A. The TQRDetailLink class was a QuickReport 1 object. QuickReport 2 had partial support for this control and it was treated as an alias to the TQRSubDetail control. QuickReport 3 does not have any support for reports that were ported from QuickReport 1. If you replace the TQRDetailLink controls with TQRSubDetail controls, your report should run like it did under QR2. The TQRDBCalc control from QR1 will also produce the same error. This was replaced with the TQRExpr control.
------------------
Q. I am creating an end user report generator and use the TQRDesigner to enable objects edit and selection functions, but I couldn't find it in the new version.
A. The TQRDesigner is no longer part of the package, we use the Delphi form designer to edit the report.
------------------
Q. I just installed Quickreport 3.03 Pro for Delphi 3 Client/Server and recompiled (Build All) a project that worked fine with QR 2.0j. In order to get it to compile, I had to remove unit QRHTML from all uses clauses because I got a fatal compile error that QRHTML was compiled with under different version
A. The qrhtml unit is a QuickReport 2 only unit, it is not part of the QR3 file set, you can remove all of the references to it. If you may many reports that use the unit, it would save time to create a stub unit named qrhtml that didn't have anything in it. When you get that error message with QuickReport 3, it usually means that the compiler is finding QuickReport 2 files.
------------------
Q. I have some variables defined in the report's functions property and I can't initialize them in the report's BeforePrint event.
A. The report's BeforePrint event is called before the elements in the report's functions property have been initialized. One way to initialize the function variables in code would be to use the BeforePrint event of the TitleBand. If your report does not require a title band, set PrintBand to false in that event.
Example of setting an integer value at the start of the report:
procedure TfrmExpr.TitleBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
var
aQREvElement: TQREvElement;
begin
with QuickRep1.Functions do
begin
aQREvElement := GetConstant('test');
if (aQREvElement <> nil) and (aQREvElement.Value(nil).Kind = resInt) then
begin
SetIntegerConstant(aQREvElement, 10);
end;
end;
end;
------------------
Q. I get the error message "Undeclared identifier; 'TQREvaluator'" when I compile a report that worked with QuickReport 2
A. We moved the expression classes to a new unit, qrexpr. If you add this unit to your uses section, the report will compile again.
------------------
Q. I have a simple project which has a quick report, no bands, just a few labels, memo boxes, and pictures. It worked prior to my upgrade to a purchased version. Now if I do a Preview, the screen is blank, no data, as well as if I do a print, nothing happens.
A. QuickReport was designed to work with bands. Placing controls directly on the band was a non-supported feature of the previous version. Try adding a detail band (set it's height to 1) and then set the report's PrintIfEmpty property to true. Your report should now work as it did with QuickReport 2.
------------------
Q. Delphi4 doesn't find the class "TQREvElementFunction" and my project will not compile.
A. Make sure the qrexpr unit is in the uses clause, that is where the TQREvElement structures are defined.
------------------
Q. The following code does not compile after upgrading: ReportForm.ExportToFilter(TQRHTMLExportFilter.Create(AttachmentFile));
A. The naming was changed. The following code will work: ReportForm.ExportToFilter(TQRHTMLDocumentFilter.Create('c:.htm'));
------------------
Q. Can we use some TQRGroup with a TQuickAbstractRep control ?
A. Not really, the TQuickAbstractRep does not have a DataSet property or OnNeedData event. The mechanism for checking the group expression does not exist and the band would be printed only once.
------------------
Q. Where are the documentation, help files, examples, QREditor, etc?
A. QuickReport 3 is still being finished up and the documentation and help files are still being updated. We will release them, but our efforts are focused on finishing up the package. The QREditor control will be in the release version of QuickReport 3 Pro.
------------------
Q. What is the TQuickAbstractRep control?
A. This is a descendant of the TCustomQuickRep base class that does not use the TDataset. If your application does not use the BDe, this will shrink the code size.
------------------
Q. Why do report event use TCustomQuickRep instead of TQuickRep?
A. This is the base class that TQuickRep is descended from. This change makes it easier to do variations QuickReport objects
------------------
Q. What happened to OnGenerateToPrinter?
A. This feature has not been finished yet and has been disabled until it has been fixed.
------------------
Q. Are there any plans to continue support of QR1 in Delphi 4 like was done in Delphi 3 with QR 1.1b?
A. This fileset is available from our sales department upon request.
------------------
Q. What is the TQRLoopBand control?
A. This is a band that is not connected to any dataset and will print for the number of times that it's PrintCount property is set to.
------------------
Q. What is the TQRStringsBand control?
A. This is a band with a items property that is a built in stringlist. It's name will appear in the expression builder and can be assigned to a TQRExpr control. At runtime, this band will print for each line in the items property.
------------------
Q. How do you use the export filter controls?
A. Just drop them on a form in your project and they will show in the previews.
------------------
Q. What is the new 'LinkBand' property?
A. This works like the LinkBand property in QuickReport 1. The Band components have a LinkBand property which is used to make several bands stick together. The LinkBand property can be set connected to another Band and QuickReport will then make a page break if there is not enough space left on the page for both bands. The second band can in turn be linked to a third band, and so on. It will not keep a series of bands together, like a group of detail bands. We have a demo project for QuickReport 3, QR3LSD4.ZIP, that shows how to "link" a set of bands.
------------------
Q. How can I display a text file with QR3?
A. Qr3 has some new functions to make this an easy task.
#1 Create a report using the TQuickAbstractRep control instead of using the TQuickRep control. The TQuickAbstractRep control does not use any data ware controls and can shrink the size of your executable if you are not using any data ware controls in your application. You can use the TQuickRep control, you just don't need to use it.
#2 Add a TQRStringsBand to the report. This is a band with a items property that is a built in stringlist.
#3 Add a TQRExpr control to the band. Set the following properties
Autosize - False
AutoStretch - True
Expression - to the name of the band (like 'QRStringsBand1')
Width - to the width of the band (can be done at runtime)
#4 Before calling Print or Preview, load the text file into the items property of the TQRStringsBand like this:
QRStringsBand1.Items.LoadFromFile(SomeFileName)
#5 Call the preview or print methods.
------------------
[RichEdit controls]
==================
Q. How can I copy the text from a TRichEdit component to the QuickReport RichText component?
A. You would use the lines property to copy the data. Example: QRRichText1.Lines := frm.RichEdit1.Lines;
------------------
Q. I get an access violation when I have QRDBRichText on a subquery
A. This is a recently discovered problem that happens with TQuery's that do not have persistent fields. Adding persistent fields will fix this. If you can not do this, insert a line into the TQRDBRichText.Print method in qrctrls.pas like the following example using the 2.0k beta code:
procedure TQRDBRichText.Print(OfsX, OfsY : integer);
begin
?Field := FDataSet.FindField(FDataField);?{ Add this line }
?if assigned(Field) then
牋?if (Field is TMemoField) or
牋牋牋 (Field is TBlobField) then
牋牋?Lines.Assign(Field);
?inherited Print(OfsX,OfsY);
end;
------------------
Q. My RTF field will not span more than one page
A. There are some serious bugs in Microsoft's implementation of their RichText common control. We are implementing work arounds to resolve as many of these issues as we can. At this time we are still working on RTF fields that span more than one page.
------------------
Q. My RTF field doesn't consistently print out the last line in the memo.
A. This is known problem with the MS RichText common control. There are two works arounds. One is to add an extra blank line to the text, the other is to set the OnGenerateToPrint event of the report's qrprinter object to nil. This will force the report to not render the report a second time.
Example:
procedure Tfrmqr.QuickRep1BeforePrint(Sender: TQuickRep; var PrintReport: boolean);
begin
QuickRep1.qrprinter.OnGenerateToPrinter := nil;
end;
------------------
Q. Can I print a richtext object that is in a field of a file with ole2 bmp object inserted in it?
Q. My QRRichText control is ignoring the "
" page break command.
A. I'm sorry, but the TRichEdit control that the QRRichText and QRDBRichtext controls link to is limited to text only and it does not appear to support this feature. Our controls are limited to the functionality of Borland's RichEdit control, which is a wrapper for Microsoft's RTF control. The MS RTF common control only supports a subset of the RTF control codes. To see what sequences are supported, load your RTF text into WordPad. WordPad uses the same common control and if it doesn't support an RTF control sequence, then it wont work on Delphi.
------------------
Q. My QRDBRichText control is not resizing correctly.
A. If the design time height of a QRDBRichText control is greater than some of the fields, it may not resize correctly. If you set the height to a small value like 10 and set autostretch to true, it should work.
------------------
Q. My QRRichText/QRDBRichText will not display or print embedded bitmaps.
A. The TRichEdit and TDBRichEdit controls do not support embedded objects and since our RTF controls use the Borland RTF controls, we have the same limitation.
------------------
[Saved Reports (*.QRP)]
==================
Q. I am using the QRPrinter object and I can't get it to save to a text file.
A. Saving as text uses the ASCII export filter and the export filters only work with reports. When you use the qrprinter object directly, the only save option is the default .QRP save.
------------------
Q. If I save a report with the Report's Options.Compression property set to true, I can't load the saved the report back into the preview.
A. This is a bug in the TMetaFile component introduced with Delphi 3.02. This should be addressed in the next Delphi release.
------------------
Q. How do I load a previously saved report via code?
A. We have a class, TQRPHandler, that is defined and documented in the QRBonus unit in QR2 and in the QRExtra unit for QR3. This class is designed to easily allow you load a saved report using the following syntax:
Delphi:
with TQRPHandler.Create do
try
Filename := 'somefile.QRP';
Preview; {or}
print;
finally
Free;
end;
 
C++:
fQRPHandler = new TQRPHandler;
// Set it's filename property to one selected by the user
fQRPHandler->Filename = OpenQRPDialog->FileName;
fQRPHandler->Print();
// or
fQRPHandler->Preview();
 
fQRPHandler->Free();
fQRPHandler = NULL;
There is a bug in current release that will prevent this from printing with Delphi 1.
(QR3) In Quick Report 3, the classes that were in qrbonus were moved to the qrextra unit.
------------------
Q. What is the format of a report saved to disk by clicking the save button in the previewer?
A. The saved report format is a proprietary metafile format that is only readable by QuickReport.
------------------
Q. Why can't I load reports saved from the preview into the Editor and vice versa?
A. The .QRP files saved by the preview are a rendered copy of the report saved as a metafile (not WMF format). You can only preview or print a .QRP file. The .QR file saved by the Editor is a Delphi resource file like a .DFM file and is basically a report form. It contains the information required to run a report, but it does not have any data from the report in it,
------------------
Q. I am trying to do is distribute .qrp files to our sales force.?On their end I will associate .qrp with a viewer we create.?If I create the .qrp file here where my default printer is a laserjet and distribute the report to someone who has a canon?
A. You can, but if the page sizes are different the page will be stretched (or compressed) to fit the page and there may some loss in resolution. An alternative way of doing this would be to use Adobe Acrobat and print the files as PDF files. The files would be more compact and Adobe makes the Acrobat Reader program freely available for multiple platforms. Please not: Quick Report does not come with the Adobe Acrobat PDFWriter printer driver used to make PDF files.
------------------
[Text controls]
==================
Q. I wish to print mailing labels. But sometimes I have only one label to print. But print starts every time with the top left label. How can I say, that print starts with the second label or in the second column with the 4th label
A. There are a few ways of dong this. You could use the OnNeedData event to drive the report and code it to print X blank detail records until it reaches the label that you want start with. You could also use a temporary table and write X number of blank records to the start of the file. You could also add child bands to the title band and increase their size to eat up the space required to fit the columns.
------------------
Q. When I increase a component's font size, the component's height increases. When I set the font size to a smaller value, the component does not shrink the height. Why does it do that and how can I make the component shrink in height?
A, We trap the CM_FONTCHANGED message for TQRCustomLabel components. When you change the font property, that message calls the CMFontChanged procedure. This procedure tells the component to reformat the text and resize the height of the control of needed. When you go from a larger font size to a smaller size, the height will not change. To force the component to match the font size, you would need to set the height to 0 before changing the font size.
------------------
Q. Why doesn't the OnPrint event work for memo fields with the TQRDBText component?
A. Memo fields do not use the OnPrint event. The reason behind the OnPrint event was to be able to override short text fields, like to expand an abbreviation. If you really want to override a memo field, you could use a calculated field and handle that type of code in the OnCalcField event.
------------------
Q. How do I force the text components to clip by letter instead of by word?
A. The current code clips on word boundaries. If you have a single line of text and you want to control the clipping by the letter, you can use the OnPrint event of the text component to manually clip the text. The following example event can be used as a generic handler for multiple text components on a report:
procedure TfrmReport.QRLabel4Print(sender: TObject; var Value: String);
begin
with TQRCustomLabel(Sender) do
while (ParentReport.TextWidth(Font, Value) > Width) and (Value <> '') do
Delete(Value, length(Value), 1);
end;
------------------
Q. The OnPrint event for the TQRDBText component does not get called when the data is null.
A. This is a limitation of the TQRDBText component. The work around is to use a TQRExpr component and in it's OnPrint event, check the IsNull property of the dataset field.
------------------
Q. My multi line text control only prints as a single line and it goes right off the right margin.
A. Make sure that you have autosize set to false and AutoStretch set to true and WordWrap set to true.
------------------
Q. The OnPrint event of my TQRLabel control is never being called.
A. Is the caption of the label blank? The code checks the caption and if it's blank, it doesn't call the OnPrint event to save time. If you want to use OnPrint with a TQRLabel, you must set the Caption to a non empty string.
------------------
Q. I have controls on the page footer that use the detail table. On the each page of a report (except for the last page) the first record's data appears everywhere except in the page footer where the second record's data appears.
A. When the page footer band is printed, the report is already working on the first detail record for the next page. One way around this would be to use the AfterPrint event of the detail band to store the data for the page footer band in some variables. In the BeforePrint event of the footerband, you would use TQRLabels and set the their captions to the string representations of the variables.
------------------
Q. On a band, I have some QRDBText fields and a QRMemo field (set to autostretch=true). When the memo field is going to go beyond the current page - QR prints the memo first (instead of the text fields) and then rolls on to the new page, finishes the memo, and then prints the text fields on top of the next page. How can I force the QRDBText fields to print first?.
A. The memo control is being printed first, which causes the page break and the rest of the controls are printed afterwards. If you change the creation order of the controls on the band so that the memo is last, the other controls will print first. Select each control (except for the Memo) and right-click on each one and select "Send to Back". That will create other controls before memo.
------------------
Q. I can't get my text to word wrap if it doesn't have any carriage returns in the text?
A. Check to make sure that your text has spaces in it. If the text is unbroken, it will not be word wrapped.
------------------
Q. My RTF text does not have the same formatting as it appears in MS Word.
A. QuickReport's RichText control uses Delphi's RichEdit control, which in turn is a wrapper for Microsoft's RichEdit common control. And that control may not be able to handle your file. Almost all of our RTF problems have been traced to bugs in that common control, and it ripples down to our control. If you load your rtf file into WordPad and it looses the formatting, then you can trace it to the common control.
------------------
Q. I can't get the mask property work with my phone number field (it's a string field)
A. The mask property only applies to numeric fields and will be ignored on string data. Use the OnPrint event to format the field like the following:
procedure TfrmReport.QRDBTextPhonePrint(sender: TObject; var Value: string);
begin
Value := '(' + copy(Value,1,3) + ') ' + copy(Value,4,3)
+ '-' + copy(Value,7,4);
end;
------------------
Q. If the report contains nulls or blanks these are not included, this destroys the alignment of the columns. Is there any way to include all nulls?
A. Use a QRExpr control for fields that could have nulls and for the expression use the IF() function to insert a space for null fields like the following:
IF(tbSample.Extra<>'', tbSample.Extra, ' ')
------------------
Q. My multiple line QRDBText controls are having the words cutoff at the right margin even when autosize is set to false.
A. If you have autostretch turned on, please make sure that the WordWrap is also turned on.
------------------
Q. I can't get the mask property to work on my numbers.
A. Please make sure that you are using a number field, the mask property will be ignored for string fields.
------------------
Q. I read the FAQ to use TQRDBText because there is no TQRDBMemo, but when my memo contains embedded carriage returns they show up as a square symbol, not as a new line.
A. This was a known bug and it was fixed in the 2.0j release.
------------------
Q. Is there a property for QRDBText to tell it *not* to split itself across pages? (i.e. widow/orphan protection.)
A. We do not have support for a Window/orphan feature, but you can do this with some minor code.
There is a function in the report called AvailableSpace that returns the amount of space left on the page. You can compare that value to the band's Size.Length property and call NewPage when There is not enough space for the band. AvailableSpace is a protected function so you can not call it directly. If you subclass the report, you can access the function by casting the report to the subclass.
First, add the following declaration in the type section of your report form declaration:
TMyQuickRep = class(TQuickRep)
end;
To use this function to keep a band from being split over a page:
procedure Tfrm.DetailBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
begin
if TMyQuickRep(QuickRep1).AvailableSpace >= round(Sender.Size.Length) then
Sender.ParentReport.NewColumn;
end;
------------------
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.
------------------
Q. How do I control interline spacing within a QRMemo? Sometimes I need greater control over the line spacing.
A. We do not support this. This is being considered for a future release, but it has not been scheduled yet.
------------------
Q. When a TQRDBText field is added to a pageheader band the field is not refreshed (it remains the last field printed).
A. This is not a bug, the report is designed to retrieve rows from the dataset when it handles the detail band, it's not designed to refresh the dataset at the first call for the PageHeader. There is a simple way to get the correct for what you want to do. In the BeforePrint event of the report, add a line that goes to the first row of the dataset. If you are using a TTable named "Table1" it would look like this:
procedure TfrmSample.QuickRep1BeforePrint(Sender: TQuickRep;
var PrintReport: Boolean);
begin
Table1.First;
end;
------------------
Q. I put a mask 9999999999 for a phone number. And it still printing 5144559400 instead of 514-455-9400. Why?
A. That is the format of the editmask used by the TMaskedEdit control. The QRExpr control's mask is the format string used by FormatFloat() and FormatDateTime functions. Please refer to their documentation for allowable values. In this case, the format mask for the USA phone number would '(000) 000-000'
Documented on page 2-32 in the manual.
------------------
Q. I have two autostretched text controls on one band and it doesn't work right.
A. Multiple stretching controls on one band is not supported. This is documented on the manual page for the AutoStretch property. This limitation was removed in the 3.0 release.
------------------
Q. I have a calculated table field and it has line breaks in the text and those line breaks don't print.
A. Delphi defines calculated table text fields as TStringfield and QR handles that type of field differently than
it handles actual memo fields. To output a calculated text field, use a QRMemo component and set QRMemo.Lines.Text to the
value of the calculated field at runtime.
------------------
Q. I am setting QuickRep1.QRPrinter.OnGenerateToPrinter:=nil爐o expedite the printing of a large report from the preview form. When I use the printersetup to select a subset of the pages for printing, I still get all of the pages printed. When I don't set OnGenerateToPrinter:=nil, the settings take effect and I get the subset of pages printed. How can I print a subset of the pages and still use OnGenerateToPrinter:=nil to expedite printing?
A. This is a known limitation (also applies to saved reports) and will be addressed in a future release. The only work around would be to only set the OnGenerateToPrinter to nil when you know that the printer setup button has not been pressed. Starting with the 2.0j release, if you use a custom preview, you can check the result of calling printersetup and then you could set the OnGenerateToPrinter to nil if the user did not use printersetup.
------------------
Q. Is there a simple way to use a single QRLabel and create a label with the letters stacked on top of each other.?An example is shown below.
P
A
T
I
E
N
T
A. With QR 2.0J you can insert carriage returns and line feeds between each letter and set the Stretch property of the control to true.
Example:
qrlabel1.Caption := 'V' + #13#10 + 'E' + #13#10 + 'R' + #13#10 + 'T' + #13#10 + 'I' + #13#10 + 'C' + #13#10 + 'A' + #13#10 + 'L';
------------------
Q. I need to change the DataField properties on the QRDBText component under run-time so that it uses one field on page 1 and another the rest of the pages.
A. You can not change the DataField property after the report starts. You could use a TQRLabel control and set it's value at runtime in (either in it's OnPrint event or it's parent band's BeforePrint event) based on the current value of the report's PageNumber property.
------------------
Q. If I use tabs (ctrl-tab in the editor) in my TQrMemo fields the report prints []. Is that a general problem in TQrMemo fields?
A. Tab characters are not supported in the TQRMemo, TQRLabel, TQRExpr, TQRDBtext controls. The only control that will correctly display a tab character are the RichText controls.
------------------
Q. Is it possible to change the Autosize property of the QRImage and the Autostretch property of the QRRichtext at runtime ?
A. Yes, you can change most of the properties at runtime in the BeforePrint and AfterPrint events of the report and of the band that the controls are on.
------------------
Q. Can you advise me how to suppress the printing of blank fields in mailing label report?
A. Use a TQRMemo control and fill it with only the information that is not blank.
Example:
procedure TReportForm.AddIfNotBlank(memo: TQRMemo; s: string);
begin
{ simple function to only add non blank fields }
if Trim(s) <> '' then memo.Lines.Add(s);
end;
procedure TReportForm.DetailBand1BeforePrint(Sender: TQRCustomBand; var PrintBand: Boolean);
begin
QRMemo1.Lines.Clear;
QRMemo1.Lines.Add(Table1Company.AsString);
AddIfNotBlank(QRMemo1, Table1Addr1.AsString);
AddIfNotBlank(QRMemo1, Table1Addr2.AsString);
AddIfNotBlank(QRMemo1, Table1City.AsString + ', ' + Table1State.AsString + ' ' + Table1Zip.AsString);
end;
------------------
 

Similar threads

A
回复
0
查看
932
Andreas Hausladen
A
A
回复
0
查看
981
Andreas Hausladen
A
A
回复
0
查看
399
Andreas Hausladen
A
A
回复
0
查看
607
Andreas Hausladen
A
A
回复
0
查看
805
Andreas Hausladen
A
后退
顶部