1 (edited by krokodil_sk 2016-11-25 09:47:40)

Topic: Report by script open in Excel

Hi anybody,

can you please help me :

procedure FmReport_BtTest_OnClick (Sender: string; var Cancel: boolean);
var
    frxDBDataset1, : TfrxDBDataset;
    report : TDataSet;
begin
   SQLQuery('SELECT xy from xy where xy');
    frxDBDataset1 := TfrxDBDataset.Create(Form1);
    frxDBDataset1.UserName        := 'report';
    frxDBDataset1.CloseDataSource := True;
    frxDBDataset1.OpenDataSource  := True;
    frxDBDataset1.DataSet         := report;

    Form1.frxReport.Clear;
    Form1.frxReport.DataSets.Clear;
    Form1.frxReport.DataSets.Add(frxDBDataset1);

  //    DESIGN MODE - WORKING OK
 //  Form1.frxReport.LoadFromFile(ExtractFilePath(Application.ExeName)+'Report\test.fr3');
 //  Form1.frxReport.DesignReport;

   // OPEN REPORT IN Excel  NOT WORKING
    Form1.frxReport.LoadFromFile(ExtractFilePath(Application.ExeName)+'Report\test.fr3');
    Form1.frxReport.PrepareReport();
    Form1.frxRTFExport1.FileName := ChangeFileExt(GetTempFileName,'.xlsx');
    Form1.frxRTFExport1.ShowDialog := False;
    Form1.frxReport.Export(Form1.frxRTFexport1);

    // PREVIEW MODE  - WORKING OK
 //     frxDBDataset1.DataSet.Close;
 //    Form1.frxReport.LoadFromFile(ExtractFilePath(Application.ExeName)+'Report\test.fr3');
 //    Form1.frxReport.ShowReport;

    frxDBDataset1.Free;

end;

1.OPEN REPORT IN Excel  NOT WORKING i dont know why error message is:
"Excel cant open the file xy.xlsx becouse file format or its extension is invalid"

Please where is the problem ?
In the forum a find only open in PDF..

2.And the another question:
When the SQLQuery is too long. How can i write him on more rows ?


Thx,
Krokodil

Re: Report by script open in Excel

1. Please attach your project.


2. SQL is just text, you can write multi line text, example:

s := 'SELECT fieldname FROM tablename ' + 
     'WHERE id=1'; 
Dmitry.

Re: Report by script open in Excel

1. Attached example project
2. Working , THX

Bgrd,

Krokodil

Post's attachments

Attachment icon Report to excel.rar 296.89 kb, 630 downloads since 2016-11-25 

Re: Report by script open in Excel

krokodil_sk wrote:

1. Attached example project

Krokodil


I changed frxRTFExport1 to frxXLSExport1 in your script and made small change in the test.fr3

Post's attachments

Attachment icon Report to excel_fixed.zip 8.59 kb, 865 downloads since 2016-11-27 

Dmitry.

Re: Report by script open in Excel

Great Dimitry,

working.

Thx,

Krokodil

Re: Report by script open in Excel

frxXLSExport1

working for excel but for JPEG what i mension there