delphi 10.3 FastReport 多设备跨平台 打印之解决方法

时间:2024-03-23 07:57:05

以下能WINDOWS10 +DELPHI 10.3 FastReport6.0上顺利通过

基础知识点:需掌握   https://blog.csdn.net/qq_25439957/article/details/87110559 

FastReport6.2对Multi-Device Application应用的支持不够友好,如下图;在palette    FastReport6.0才出现几个制件。非Multi-Device Application应用时是一大堆;

delphi 10.3 FastReport 多设备跨平台 打印之解决方法

非Multi-Device Application应用时是一大堆;如下图

delphi 10.3 FastReport 多设备跨平台 打印之解决方法

所以在 Multi-Device Application应用时,需要一些技巧;

1、依照  https://blog.csdn.net/qq_25439957/article/details/87110559   制作好 salse.fr3文件;

2、制作如下图

delphi 10.3 FastReport 多设备跨平台 打印之解决方法

直接代码如下:

object Form2: TForm2
  Left = 0
  Top = 0
  Caption = 'Form2'
  ClientHeight = 371
  ClientWidth = 509
  FormFactor.Width = 320
  FormFactor.Height = 480
  FormFactor.Devices = [Desktop]
  DesignerMasterStyle = 0
  object Button1: TButton
    Position.X = 288.000000000000000000
    Position.Y = 136.000000000000000000
    TabOrder = 2
    Text = #39044#35272
    OnClick = Button1Click
  end
  object SqlserversalesdbConnection: TFDConnection
    Params.Strings = (
      'ConnectionDef=sql server salesdb')
    Connected = True
    LoginPrompt = False
    Left = 135
    Top = 67
  end
  object SalesTable: TFDQuery
    Active = True
    Connection = SqlserversalesdbConnection
    SQL.Strings = (
      'SELECT top 100* FROM SalesDB.dbo.Sales')
    Left = 135
    Top = 131
  end
  object FDGUIxWaitCursor1: TFDGUIxWaitCursor
    Provider = 'FMX'
    Left = 144
    Top = 208
  end
end

 

unit Unit2;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,frxClass,
  frxDBSet,
FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error,
  FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool,
  FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.MSSQL, FireDAC.Phys.MSSQLDef,
  FireDAC.FMXUI.Wait, FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf,
  FireDAC.DApt, FMX.Controls.Presentation, FMX.StdCtrls, Data.DB,
  FireDAC.Comp.DataSet, FireDAC.Comp.Client, FireDAC.Comp.UI;

type
  TForm2 = class(TForm)
    SqlserversalesdbConnection: TFDConnection;
    SalesTable: TFDQuery;
    Button1: TButton;
    FDGUIxWaitCursor1: TFDGUIxWaitCursor;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.fmx}

procedure TForm2.Button1Click(Sender: TObject);
var
frxReport1: TfrxReport;
frxDBDataset1: TfrxDBDataset;
begin
    frxDBDataset1:=TfrxDBDataset.Create(self) ;
    frxDBDataset1.UserName:='frxDBDataset1';
    frxDBDataset1.DataSet:=SalesTable;

    frxReport1:=TfrxReport.Create(self);
    frxReport1.DataSet:=frxDBDataset1;
    frxReport1.LoadFromFile('C:\oz\test.fr3') ;
    frxReport1.showReport;
end;

end.